1 From: Sebastian Gottschall <s.gottschall@dd-wrt.com>
3 current handling of peer_bw_rxnss_override parameter is based on guessing the VHT160/8080 capability by rx rate. this is wrong and may lead
4 to a non initialized peer_bw_rxnss_override parameter which is required since VHT160 operation mode only supports 2x2 chainmasks in addition the original code
5 initialized the parameter with wrong masked values.
6 This patch uses the peer phymode and peer nss information for correct initialisation of the peer_bw_rxnss_override parameter.
7 if this peer information is not available, we initialize the parameter by minimum nss which is suggested by QCA as temporary workaround according
8 to the QCA sourcecodes.
10 Signed-off-by: Sebastian Gottschall <s.gottschall@dd-wrt.com>
12 v2: remove debug messages
13 v3: apply some cosmetics, update documentation
14 v4: fix compile warning and truncate nss to maximum of 2x2 since current chipsets only support 2x2 at vht160
15 v5: handle maximum nss for chipsets supportig vht160 with 1x1 only
16 v7: use more simple code variant and take care about hw/sw chainmask configuration
17 v8: fix some code style issues
18 v9: use SM/MS macros from code.h to simplify shift/mask handling
20 drivers/net/wireless/ath/ath10k/mac.c | 54 +++++++++++++++++++--------
21 drivers/net/wireless/ath/ath10k/wmi.c | 7 +---
22 drivers/net/wireless/ath/ath10k/wmi.h | 14 ++++++-
23 3 files changed, 52 insertions(+), 23 deletions(-)
24 --- a/drivers/net/wireless/ath/ath10k/mac.c
25 +++ b/drivers/net/wireless/ath/ath10k/mac.c
26 @@ -2473,7 +2473,7 @@ static void ath10k_peer_assoc_h_vht(stru
27 const u16 *vht_mcs_mask;
33 if (WARN_ON(ath10k_mac_vif_chan(vif, &def)))
35 @@ -2533,23 +2533,45 @@ static void ath10k_peer_assoc_h_vht(stru
36 __le16_to_cpu(vht_cap->vht_mcs.tx_highest);
37 arg->peer_vht_rates.tx_mcs_set = ath10k_peer_assoc_h_vht_limit(
38 __le16_to_cpu(vht_cap->vht_mcs.tx_mcs_map), vht_mcs_mask);
39 + arg->peer_bw_rxnss_override = 0;
40 + nss160 = 1; /* 1x1 default config for VHT160 */
42 - ath10k_dbg(ar, ATH10K_DBG_MAC, "mac vht peer %pM max_mpdu %d flags 0x%x\n",
43 - sta->addr, arg->peer_max_mpdu, arg->peer_flags);
44 + /* only local 4x4 configuration do support 2x2 for VHT160,
45 + * everything else must use 1x1
48 - if (arg->peer_vht_rates.rx_max_rate &&
49 - (sta->vht_cap.cap & IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_MASK)) {
50 - switch (arg->peer_vht_rates.rx_max_rate) {
52 - /* Must be 2x2 at 160Mhz is all it can do. */
53 - arg->peer_bw_rxnss_override = 2;
56 - /* Can only do 1x1 at 160Mhz (Long Guard Interval) */
57 - arg->peer_bw_rxnss_override = 1;
60 + if (ar->cfg_rx_chainmask == 15)
61 + nss160 = arg->peer_num_spatial_streams <= 2 ? 1 : 2;
63 + /* if peer provides 1x1 nss160 information using max rate
64 + * vht information, we reduce local nss160 to 1x1.
65 + * consider that it has been observed that some client
66 + * devices provide zero here, no matter which transmission
67 + * rate is possible. in that case the local nss configuration
68 + * will be used at maxmimum configuration possible. (see above)
71 + if (arg->peer_vht_rates.rx_max_rate == 780)
74 + /* in case if peer is connected with vht160 or vht80+80,
75 + * we need to properly adjust rxnss parameters otherwise
76 + * firmware will raise a assert
78 + switch (arg->peer_phymode) {
79 + case MODE_11AC_VHT80_80:
80 + arg->peer_bw_rxnss_override = BW_NSS_FWCONF_80_80(nss160);
82 + case MODE_11AC_VHT160:
83 + arg->peer_bw_rxnss_override |= BW_NSS_FWCONF_160(nss160);
89 + ath10k_dbg(ar, ATH10K_DBG_MAC, "mac vht peer %pM max_mpdu %d flags 0x%x peer_bw_rxnss_override 0x%x\n",
90 + sta->addr, arg->peer_max_mpdu, arg->peer_flags,
91 + arg->peer_bw_rxnss_override);
94 static void ath10k_peer_assoc_h_qos(struct ath10k *ar,
95 @@ -2701,9 +2723,9 @@ static int ath10k_peer_assoc_prepare(str
96 ath10k_peer_assoc_h_crypto(ar, vif, sta, arg);
97 ath10k_peer_assoc_h_rates(ar, vif, sta, arg);
98 ath10k_peer_assoc_h_ht(ar, vif, sta, arg);
99 + ath10k_peer_assoc_h_phymode(ar, vif, sta, arg);
100 ath10k_peer_assoc_h_vht(ar, vif, sta, arg);
101 ath10k_peer_assoc_h_qos(ar, vif, sta, arg);
102 - ath10k_peer_assoc_h_phymode(ar, vif, sta, arg);
106 --- a/drivers/net/wireless/ath/ath10k/wmi.c
107 +++ b/drivers/net/wireless/ath/ath10k/wmi.c
108 @@ -7357,12 +7357,7 @@ ath10k_wmi_peer_assoc_fill_10_4(struct a
109 struct wmi_10_4_peer_assoc_complete_cmd *cmd = buf;
111 ath10k_wmi_peer_assoc_fill_10_2(ar, buf, arg);
112 - if (arg->peer_bw_rxnss_override)
113 - cmd->peer_bw_rxnss_override =
114 - __cpu_to_le32((arg->peer_bw_rxnss_override - 1) |
115 - BIT(PEER_BW_RXNSS_OVERRIDE_OFFSET));
117 - cmd->peer_bw_rxnss_override = 0;
118 + cmd->peer_bw_rxnss_override = __cpu_to_le32(arg->peer_bw_rxnss_override);
122 --- a/drivers/net/wireless/ath/ath10k/wmi.h
123 +++ b/drivers/net/wireless/ath/ath10k/wmi.h
124 @@ -6357,7 +6357,19 @@ struct wmi_10_2_peer_assoc_complete_cmd
125 __le32 info0; /* WMI_PEER_ASSOC_INFO0_ */
128 -#define PEER_BW_RXNSS_OVERRIDE_OFFSET 31
129 +#define BW_NSS_FWCONF_MAP_ENABLE BIT(31)
130 +#define BW_NSS_FWCONF_MAP_160MHZ_LSB (0)
131 +#define BW_NSS_FWCONF_MAP_160MHZ_MASK (0x00000007)
132 +#define BW_NSS_FWCONF_MAP_80_80MHZ_LSB (3)
133 +#define BW_NSS_FWCONF_MAP_80_80MHZ_MASK (0x00000038)
134 +#define BW_NSS_FWCONF_MAP_MASK (0x0000003F)
136 +#define GET_BW_NSS_FWCONF_160(x) (MS(x, BW_NSS_FWCONF_MAP_160MHZ) + 1)
137 +#define GET_BW_NSS_FWCONF_80_80(x) (MS(x, BW_NSS_FWCONF_MAP_80_80MHZ) + 1)
139 +/* Values defined to set 160 MHz Bandwidth NSS Mapping into FW*/
140 +#define BW_NSS_FWCONF_160(x) (BW_NSS_FWCONF_MAP_ENABLE | SM(x - 1, BW_NSS_FWCONF_MAP_160MHZ))
141 +#define BW_NSS_FWCONF_80_80(x) (BW_NSS_FWCONF_MAP_ENABLE | SM(x - 1, BW_NSS_FWCONF_MAP_80_80MHZ))
143 struct wmi_10_4_peer_assoc_complete_cmd {
144 struct wmi_10_2_peer_assoc_complete_cmd cmd;