]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
wifi: mac80211_hwsim: modernise S1G channel list
authorLachlan Hodges <lachlan.hodges@morsemicro.com>
Wed, 27 May 2026 03:38:28 +0000 (13:38 +1000)
committerJohannes Berg <johannes.berg@intel.com>
Thu, 28 May 2026 07:48:15 +0000 (09:48 +0200)
The current S1G channel list in mac80211_hwsim does not represent
what S1G drivers would advertise that being 1MHz primaries. Also,
include the NO_PRIMARY flag on the edgeband 1MHz primaries to emulate
US operation such that it can also be tested.

Signed-off-by: Lachlan Hodges <lachlan.hodges@morsemicro.com>
Link: https://patch.msgid.link/20260527033828.183821-3-lachlan.hodges@morsemicro.com
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
drivers/net/wireless/virtual/mac80211_hwsim_main.c

index 0241b38beddc50689e342b972ba1a9c815cce2d0..1512e160e41a0047db6fef7c99aea5b5f0dd85d4 100644 (file)
@@ -356,6 +356,14 @@ static struct net_device *hwsim_mon; /* global monitor netdev */
        .hw_value = (_freq), \
 }
 
+#define CHANS1G(_freq, _offset, _flags) { \
+       .band = NL80211_BAND_S1GHZ, \
+       .center_freq = (_freq), \
+       .freq_offset = (_offset), \
+       .hw_value = (_freq), \
+       .flags = (_flags), \
+}
+
 static const struct ieee80211_channel hwsim_channels_2ghz[] = {
        CHAN2G(2412), /* Channel 1 */
        CHAN2G(2417), /* Channel 2 */
@@ -490,7 +498,38 @@ static const struct ieee80211_channel hwsim_channels_6ghz[] = {
 static_assert(HWSIM_NUM_CHANNELS_6GHZ == ARRAY_SIZE(hwsim_channels_6ghz),
              "Inconsistent 6 GHz channel count");
 
-static struct ieee80211_channel hwsim_channels_s1g[HWSIM_NUM_S1G_CHANNELS_US];
+/*
+ * US 2024 channels (op class 1). Additionally to emulate real world
+ * US operation, the edgeband 1MHz channels (1, 51) are marked as NO_PRIMARY.
+ */
+static const struct ieee80211_channel hwsim_channels_s1g[] = {
+       CHANS1G(902, 500, IEEE80211_CHAN_S1G_NO_PRIMARY), /* Channel 1 */
+       CHANS1G(903, 500, 0), /* Channel 3 */
+       CHANS1G(904, 500, 0), /* Channel 5 */
+       CHANS1G(905, 500, 0), /* Channel 7 */
+       CHANS1G(906, 500, 0), /* Channel 9 */
+       CHANS1G(907, 500, 0), /* Channel 11 */
+       CHANS1G(908, 500, 0), /* Channel 13 */
+       CHANS1G(909, 500, 0), /* Channel 15 */
+       CHANS1G(910, 500, 0), /* Channel 17 */
+       CHANS1G(911, 500, 0), /* Channel 19 */
+       CHANS1G(912, 500, 0), /* Channel 21 */
+       CHANS1G(913, 500, 0), /* Channel 23 */
+       CHANS1G(914, 500, 0), /* Channel 25 */
+       CHANS1G(915, 500, 0), /* Channel 27 */
+       CHANS1G(916, 500, 0), /* Channel 29 */
+       CHANS1G(917, 500, 0), /* Channel 31 */
+       CHANS1G(918, 500, 0), /* Channel 33 */
+       CHANS1G(919, 500, 0), /* Channel 35 */
+       CHANS1G(920, 500, 0), /* Channel 37 */
+       CHANS1G(921, 500, 0), /* Channel 39 */
+       CHANS1G(922, 500, 0), /* Channel 41 */
+       CHANS1G(923, 500, 0), /* Channel 43 */
+       CHANS1G(924, 500, 0), /* Channel 45 */
+       CHANS1G(925, 500, 0), /* Channel 47 */
+       CHANS1G(926, 500, 0), /* Channel 49 */
+       CHANS1G(927, 500, IEEE80211_CHAN_S1G_NO_PRIMARY), /* Channel 51 */
+};
 
 static const struct ieee80211_sta_s1g_cap hwsim_s1g_cap = {
        .s1g = true,
@@ -519,19 +558,6 @@ static const struct ieee80211_sta_s1g_cap hwsim_s1g_cap = {
                     0 },
 };
 
-static void hwsim_init_s1g_channels(struct ieee80211_channel *chans)
-{
-       int ch, freq;
-
-       for (ch = 0; ch < ARRAY_SIZE(hwsim_channels_s1g); ch++) {
-               freq = 902000 + (ch + 1) * 500;
-               chans[ch].band = NL80211_BAND_S1GHZ;
-               chans[ch].center_freq = KHZ_TO_MHZ(freq);
-               chans[ch].freq_offset = freq % 1000;
-               chans[ch].hw_value = ch + 1;
-       }
-}
-
 static const struct ieee80211_rate hwsim_rates[] = {
        { .bitrate = 10 },
        { .bitrate = 20, .flags = IEEE80211_RATE_SHORT_PREAMBLE },
@@ -7443,8 +7469,6 @@ static int __init init_mac80211_hwsim(void)
        if (err)
                goto out_exit_virtio;
 
-       hwsim_init_s1g_channels(hwsim_channels_s1g);
-
        for (i = 0; i < radios; i++) {
                struct hwsim_new_radio_params param = { 0 };