From db072fdc9e1a93eacfc5402fed6ab796fdf205ed Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Mon, 24 May 2021 11:52:40 +0200 Subject: [PATCH] mac80211: add 6 GHz support to mac80211_hwsim Signed-off-by: Felix Fietkau --- ...320-mac80211_hwsim-add-6GHz-channels.patch | 123 ++++++++++++++++++ ...211_hwsim-make-6-GHz-channels-usable.patch | 74 +++++++++++ 2 files changed, 197 insertions(+) create mode 100644 package/kernel/mac80211/patches/subsys/320-mac80211_hwsim-add-6GHz-channels.patch create mode 100644 package/kernel/mac80211/patches/subsys/321-mac80211_hwsim-make-6-GHz-channels-usable.patch diff --git a/package/kernel/mac80211/patches/subsys/320-mac80211_hwsim-add-6GHz-channels.patch b/package/kernel/mac80211/patches/subsys/320-mac80211_hwsim-add-6GHz-channels.patch new file mode 100644 index 0000000000..a7c09f00bc --- /dev/null +++ b/package/kernel/mac80211/patches/subsys/320-mac80211_hwsim-add-6GHz-channels.patch @@ -0,0 +1,123 @@ +From: Ramon Fontes +Date: Sun, 27 Dec 2020 00:11:55 -0300 +Subject: [PATCH] mac80211_hwsim: add 6GHz channels + +Advertise 6GHz channels to mac80211. + +Signed-off-by: Ramon Fontes +Link: https://lore.kernel.org/r/20201227031155.81161-1-ramonreisfontes@gmail.com +[reword commit message] +Signed-off-by: Johannes Berg +--- + +--- a/drivers/net/wireless/mac80211_hwsim.c ++++ b/drivers/net/wireless/mac80211_hwsim.c +@@ -311,6 +311,12 @@ static struct net_device *hwsim_mon; /* + .hw_value = (_freq), \ + } + ++#define CHAN6G(_freq) { \ ++ .band = NL80211_BAND_6GHZ, \ ++ .center_freq = (_freq), \ ++ .hw_value = (_freq), \ ++} ++ + static const struct ieee80211_channel hwsim_channels_2ghz[] = { + CHAN2G(2412), /* Channel 1 */ + CHAN2G(2417), /* Channel 2 */ +@@ -377,6 +383,68 @@ static const struct ieee80211_channel hw + CHAN5G(5925), /* Channel 185 */ + }; + ++static const struct ieee80211_channel hwsim_channels_6ghz[] = { ++ CHAN6G(5955), /* Channel 1 */ ++ CHAN6G(5975), /* Channel 5 */ ++ CHAN6G(5995), /* Channel 9 */ ++ CHAN6G(6015), /* Channel 13 */ ++ CHAN6G(6035), /* Channel 17 */ ++ CHAN6G(6055), /* Channel 21 */ ++ CHAN6G(6075), /* Channel 25 */ ++ CHAN6G(6095), /* Channel 29 */ ++ CHAN6G(6115), /* Channel 33 */ ++ CHAN6G(6135), /* Channel 37 */ ++ CHAN6G(6155), /* Channel 41 */ ++ CHAN6G(6175), /* Channel 45 */ ++ CHAN6G(6195), /* Channel 49 */ ++ CHAN6G(6215), /* Channel 53 */ ++ CHAN6G(6235), /* Channel 57 */ ++ CHAN6G(6255), /* Channel 61 */ ++ CHAN6G(6275), /* Channel 65 */ ++ CHAN6G(6295), /* Channel 69 */ ++ CHAN6G(6315), /* Channel 73 */ ++ CHAN6G(6335), /* Channel 77 */ ++ CHAN6G(6355), /* Channel 81 */ ++ CHAN6G(6375), /* Channel 85 */ ++ CHAN6G(6395), /* Channel 89 */ ++ CHAN6G(6415), /* Channel 93 */ ++ CHAN6G(6435), /* Channel 97 */ ++ CHAN6G(6455), /* Channel 181 */ ++ CHAN6G(6475), /* Channel 105 */ ++ CHAN6G(6495), /* Channel 109 */ ++ CHAN6G(6515), /* Channel 113 */ ++ CHAN6G(6535), /* Channel 117 */ ++ CHAN6G(6555), /* Channel 121 */ ++ CHAN6G(6575), /* Channel 125 */ ++ CHAN6G(6595), /* Channel 129 */ ++ CHAN6G(6615), /* Channel 133 */ ++ CHAN6G(6635), /* Channel 137 */ ++ CHAN6G(6655), /* Channel 141 */ ++ CHAN6G(6675), /* Channel 145 */ ++ CHAN6G(6695), /* Channel 149 */ ++ CHAN6G(6715), /* Channel 153 */ ++ CHAN6G(6735), /* Channel 157 */ ++ CHAN6G(6755), /* Channel 161 */ ++ CHAN6G(6775), /* Channel 165 */ ++ CHAN6G(6795), /* Channel 169 */ ++ CHAN6G(6815), /* Channel 173 */ ++ CHAN6G(6835), /* Channel 177 */ ++ CHAN6G(6855), /* Channel 181 */ ++ CHAN6G(6875), /* Channel 185 */ ++ CHAN6G(6895), /* Channel 189 */ ++ CHAN6G(6915), /* Channel 193 */ ++ CHAN6G(6935), /* Channel 197 */ ++ CHAN6G(6955), /* Channel 201 */ ++ CHAN6G(6975), /* Channel 205 */ ++ CHAN6G(6995), /* Channel 209 */ ++ CHAN6G(7015), /* Channel 213 */ ++ CHAN6G(7035), /* Channel 217 */ ++ CHAN6G(7055), /* Channel 221 */ ++ CHAN6G(7075), /* Channel 225 */ ++ CHAN6G(7095), /* Channel 229 */ ++ CHAN6G(7115), /* Channel 233 */ ++}; ++ + #define NUM_S1G_CHANS_US 51 + static struct ieee80211_channel hwsim_channels_s1g[NUM_S1G_CHANS_US]; + +@@ -548,6 +616,7 @@ struct mac80211_hwsim_data { + struct ieee80211_supported_band bands[NUM_NL80211_BANDS]; + struct ieee80211_channel channels_2ghz[ARRAY_SIZE(hwsim_channels_2ghz)]; + struct ieee80211_channel channels_5ghz[ARRAY_SIZE(hwsim_channels_5ghz)]; ++ struct ieee80211_channel channels_6ghz[ARRAY_SIZE(hwsim_channels_6ghz)]; + struct ieee80211_channel channels_s1g[ARRAY_SIZE(hwsim_channels_s1g)]; + struct ieee80211_rate rates[ARRAY_SIZE(hwsim_rates)]; + struct ieee80211_iface_combination if_combination; +@@ -578,7 +647,8 @@ struct mac80211_hwsim_data { + struct ieee80211_channel *channel; + unsigned long next_start, start, end; + } survey_data[ARRAY_SIZE(hwsim_channels_2ghz) + +- ARRAY_SIZE(hwsim_channels_5ghz)]; ++ ARRAY_SIZE(hwsim_channels_5ghz) + ++ ARRAY_SIZE(hwsim_channels_6ghz)]; + + struct ieee80211_channel *channel; + u64 beacon_int /* beacon interval in us */; +@@ -3149,6 +3219,8 @@ static int mac80211_hwsim_new_radio(stru + sizeof(hwsim_channels_2ghz)); + memcpy(data->channels_5ghz, hwsim_channels_5ghz, + sizeof(hwsim_channels_5ghz)); ++ memcpy(data->channels_6ghz, hwsim_channels_6ghz, ++ sizeof(hwsim_channels_6ghz)); + memcpy(data->channels_s1g, hwsim_channels_s1g, + sizeof(hwsim_channels_s1g)); + memcpy(data->rates, hwsim_rates, sizeof(hwsim_rates)); diff --git a/package/kernel/mac80211/patches/subsys/321-mac80211_hwsim-make-6-GHz-channels-usable.patch b/package/kernel/mac80211/patches/subsys/321-mac80211_hwsim-make-6-GHz-channels-usable.patch new file mode 100644 index 0000000000..4bac10eefe --- /dev/null +++ b/package/kernel/mac80211/patches/subsys/321-mac80211_hwsim-make-6-GHz-channels-usable.patch @@ -0,0 +1,74 @@ +From: Felix Fietkau +Date: Mon, 24 May 2021 11:46:09 +0200 +Subject: [PATCH] mac80211_hwsim: make 6 GHz channels usable + +The previous commit that claimed to add 6 GHz channels didn't actually make +them usable, since the 6 GHz band was not registered with mac80211. + +Fixes: 28881922abd7 ("mac80211_hwsim: add 6GHz channels") +Signed-off-by: Felix Fietkau +--- + +--- a/drivers/net/wireless/mac80211_hwsim.c ++++ b/drivers/net/wireless/mac80211_hwsim.c +@@ -2968,15 +2968,19 @@ static void mac80211_hwsim_he_capab(stru + { + u16 n_iftype_data; + +- if (sband->band == NL80211_BAND_2GHZ) { ++ switch (sband->band) { ++ case NL80211_BAND_2GHZ: + n_iftype_data = ARRAY_SIZE(he_capa_2ghz); + sband->iftype_data = + (struct ieee80211_sband_iftype_data *)he_capa_2ghz; +- } else if (sband->band == NL80211_BAND_5GHZ) { ++ break; ++ case NL80211_BAND_5GHZ: ++ case NL80211_BAND_6GHZ: + n_iftype_data = ARRAY_SIZE(he_capa_5ghz); + sband->iftype_data = + (struct ieee80211_sband_iftype_data *)he_capa_5ghz; +- } else { ++ break; ++ default: + return; + } + +@@ -3265,6 +3269,12 @@ static int mac80211_hwsim_new_radio(stru + sband->vht_cap.vht_mcs.tx_mcs_map = + sband->vht_cap.vht_mcs.rx_mcs_map; + break; ++ case NL80211_BAND_6GHZ: ++ sband->channels = data->channels_6ghz; ++ sband->n_channels = ARRAY_SIZE(hwsim_channels_6ghz); ++ sband->bitrates = data->rates + 4; ++ sband->n_bitrates = ARRAY_SIZE(hwsim_rates) - 4; ++ break; + case NL80211_BAND_S1GHZ: + memcpy(&sband->s1g_cap, &hwsim_s1g_cap, + sizeof(sband->s1g_cap)); +@@ -3275,6 +3285,13 @@ static int mac80211_hwsim_new_radio(stru + continue; + } + ++ mac80211_hwsim_he_capab(sband); ++ ++ hw->wiphy->bands[band] = sband; ++ ++ if (band == NL80211_BAND_6GHZ) ++ continue; ++ + sband->ht_cap.ht_supported = true; + sband->ht_cap.cap = IEEE80211_HT_CAP_SUP_WIDTH_20_40 | + IEEE80211_HT_CAP_GRN_FLD | +@@ -3288,10 +3305,6 @@ static int mac80211_hwsim_new_radio(stru + sband->ht_cap.mcs.rx_mask[0] = 0xff; + sband->ht_cap.mcs.rx_mask[1] = 0xff; + sband->ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED; +- +- mac80211_hwsim_he_capab(sband); +- +- hw->wiphy->bands[band] = sband; + } + + /* By default all radios belong to the first group */ -- 2.30.2