ath6kl registers the same static band and channel structures for every device. ath6kl_cfg80211_init() already changes the HT capabilities of these shared structures to match the firmware of the device being probed, so a second device inherits them. A per-board channel limit from the device tree would have the same problem. Copy the band and channel templates into struct ath6kl and register the copies. The HT adjustments and the one reader of the 2.4 GHz HT support now use the copies. The bitrate tables stay shared. Signed-off-by: Josef Schlehofer --- This touches every ath6kl chip. Only an AR6006 hw1.1 on USB was available for testing. It ran there with the rest of the series, but two ath6kl devices side by side did not run. drivers/net/wireless/ath/ath6kl/cfg80211.c | 50 ++++++++++++++-------- drivers/net/wireless/ath/ath6kl/core.h | 9 ++++ 2 files changed, 40 insertions(+), 19 deletions(-) diff --git a/drivers/net/wireless/ath/ath6kl/cfg80211.c b/drivers/net/wireless/ath/ath6kl/cfg80211.c index c91560d55..6b03627e2 100644 --- a/drivers/net/wireless/ath/ath6kl/cfg80211.c +++ b/drivers/net/wireless/ath/ath6kl/cfg80211.c @@ -85,7 +85,7 @@ static struct ieee80211_rate ath6kl_rates[] = { IEEE80211_HT_CAP_SGI_20 | \ IEEE80211_HT_CAP_SGI_40) -static struct ieee80211_channel ath6kl_2ghz_channels[] = { +static const struct ieee80211_channel ath6kl_2ghz_channels[] = { CHAN2G(1, 2412, 0), CHAN2G(2, 2417, 0), CHAN2G(3, 2422, 0), @@ -102,7 +102,7 @@ static struct ieee80211_channel ath6kl_2ghz_channels[] = { CHAN2G(14, 2484, 0), }; -static struct ieee80211_channel ath6kl_5ghz_a_channels[] = { +static const struct ieee80211_channel ath6kl_5ghz_a_channels[] = { CHAN5G(36, 0), CHAN5G(40, 0), CHAN5G(44, 0), CHAN5G(48, 0), CHAN5G(52, 0), CHAN5G(56, 0), @@ -122,18 +122,16 @@ static struct ieee80211_channel ath6kl_5ghz_a_channels[] = { CHAN5G(216, 0), }; -static struct ieee80211_supported_band ath6kl_band_2ghz = { +static const struct ieee80211_supported_band ath6kl_band_2ghz = { .n_channels = ARRAY_SIZE(ath6kl_2ghz_channels), - .channels = ath6kl_2ghz_channels, .n_bitrates = ath6kl_g_rates_size, .bitrates = ath6kl_g_rates, .ht_cap.cap = ath6kl_g_htcap, .ht_cap.ht_supported = true, }; -static struct ieee80211_supported_band ath6kl_band_5ghz = { +static const struct ieee80211_supported_band ath6kl_band_5ghz = { .n_channels = ARRAY_SIZE(ath6kl_5ghz_a_channels), - .channels = ath6kl_5ghz_a_channels, .n_bitrates = ath6kl_a_rates_size, .bitrates = ath6kl_a_rates, .ht_cap.cap = ath6kl_a_htcap, @@ -1121,7 +1119,7 @@ void ath6kl_cfg80211_ch_switch_notify(struct ath6kl_vif *vif, int freq, cfg80211_chandef_create(&chandef, ieee80211_get_channel(vif->ar->wiphy, freq), (mode == WMI_11G_HT20 && - ath6kl_band_2ghz.ht_cap.ht_supported) ? + vif->ar->band_2ghz.ht_cap.ht_supported) ? NL80211_CHAN_HT20 : NL80211_CHAN_NO_HT); wiphy_lock(vif->ar->wiphy); @@ -3931,6 +3929,20 @@ int ath6kl_cfg80211_init(struct ath6kl *ar) return -EINVAL; } + BUILD_BUG_ON(ARRAY_SIZE(ath6kl_2ghz_channels) != + ATH6KL_NUM_2GHZ_CHANNELS); + BUILD_BUG_ON(ARRAY_SIZE(ath6kl_5ghz_a_channels) != + ATH6KL_NUM_5GHZ_CHANNELS); + + memcpy(ar->channels_2ghz, ath6kl_2ghz_channels, + sizeof(ar->channels_2ghz)); + memcpy(ar->channels_5ghz, ath6kl_5ghz_a_channels, + sizeof(ar->channels_5ghz)); + ar->band_2ghz = ath6kl_band_2ghz; + ar->band_2ghz.channels = ar->channels_2ghz; + ar->band_5ghz = ath6kl_band_5ghz; + ar->band_5ghz.channels = ar->channels_5ghz; + /* * Even if the fw has HT support, advertise HT cap only when * the firmware has support to override RSN capability, otherwise @@ -3939,10 +3951,10 @@ int ath6kl_cfg80211_init(struct ath6kl *ar) if (!(ht && test_bit(ATH6KL_FW_CAPABILITY_RSN_CAP_OVERRIDE, ar->fw_capabilities))) { - ath6kl_band_2ghz.ht_cap.cap = 0; - ath6kl_band_2ghz.ht_cap.ht_supported = false; - ath6kl_band_5ghz.ht_cap.cap = 0; - ath6kl_band_5ghz.ht_cap.ht_supported = false; + ar->band_2ghz.ht_cap.cap = 0; + ar->band_2ghz.ht_cap.ht_supported = false; + ar->band_5ghz.ht_cap.cap = 0; + ar->band_5ghz.ht_cap.ht_supported = false; if (ht) ath6kl_err("Firmware lacks RSN-CAP-OVERRIDE, so HT (802.11n) is disabled."); @@ -3950,15 +3962,15 @@ int ath6kl_cfg80211_init(struct ath6kl *ar) if (test_bit(ATH6KL_FW_CAPABILITY_64BIT_RATES, ar->fw_capabilities)) { - ath6kl_band_2ghz.ht_cap.mcs.rx_mask[0] = 0xff; - ath6kl_band_5ghz.ht_cap.mcs.rx_mask[0] = 0xff; - ath6kl_band_2ghz.ht_cap.mcs.rx_mask[1] = 0xff; - ath6kl_band_5ghz.ht_cap.mcs.rx_mask[1] = 0xff; + ar->band_2ghz.ht_cap.mcs.rx_mask[0] = 0xff; + ar->band_5ghz.ht_cap.mcs.rx_mask[0] = 0xff; + ar->band_2ghz.ht_cap.mcs.rx_mask[1] = 0xff; + ar->band_5ghz.ht_cap.mcs.rx_mask[1] = 0xff; ar->hw.tx_ant = 0x3; /* mask, 2 antenna */ ar->hw.rx_ant = 0x3; } else { - ath6kl_band_2ghz.ht_cap.mcs.rx_mask[0] = 0xff; - ath6kl_band_5ghz.ht_cap.mcs.rx_mask[0] = 0xff; + ar->band_2ghz.ht_cap.mcs.rx_mask[0] = 0xff; + ar->band_5ghz.ht_cap.mcs.rx_mask[0] = 0xff; ar->hw.tx_ant = 1; ar->hw.rx_ant = 1; } @@ -3967,9 +3979,9 @@ int ath6kl_cfg80211_init(struct ath6kl *ar) wiphy->available_antennas_rx = ar->hw.rx_ant; if (band_2gig) - wiphy->bands[NL80211_BAND_2GHZ] = &ath6kl_band_2ghz; + wiphy->bands[NL80211_BAND_2GHZ] = &ar->band_2ghz; if (band_5gig) - wiphy->bands[NL80211_BAND_5GHZ] = &ath6kl_band_5ghz; + wiphy->bands[NL80211_BAND_5GHZ] = &ar->band_5ghz; wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM; diff --git a/drivers/net/wireless/ath/ath6kl/core.h b/drivers/net/wireless/ath/ath6kl/core.h index 31cd88d83..da85c8dfb 100644 --- a/drivers/net/wireless/ath/ath6kl/core.h +++ b/drivers/net/wireless/ath/ath6kl/core.h @@ -703,10 +703,19 @@ enum ath6kl_fw_err { ATH6KL_FW_EP_FULL, }; +#define ATH6KL_NUM_2GHZ_CHANNELS 14 +#define ATH6KL_NUM_5GHZ_CHANNELS 33 + struct ath6kl { struct device *dev; struct wiphy *wiphy; + /* per device copies, a board may disable channels or change HT caps */ + struct ieee80211_supported_band band_2ghz; + struct ieee80211_supported_band band_5ghz; + struct ieee80211_channel channels_2ghz[ATH6KL_NUM_2GHZ_CHANNELS]; + struct ieee80211_channel channels_5ghz[ATH6KL_NUM_5GHZ_CHANNELS]; + enum ath6kl_state state; unsigned int testmode; -- 2.54.0 (Apple Git-157)