9dceea8f41e01c13db14c1c6967f2ee87946a7ba
[openwrt/staging/neocturne.git] /
1 From: Sebastian Gottschall <s.gottsch...@dd-wrt.com>
2
3 current handling of peer_bw_rxnss_override parameter is based on guessing the
4 VHT160/8080 capability by rx rate. this is wrong and may lead
5 to a non initialized peer_bw_rxnss_override parameter which is required since
6 VHT160 operation mode only supports 2x2 chainmasks in addition the original code
7 initialized the parameter with wrong masked values.
8 This patch uses the peer phymode and peer nss information for correct
9 initialisation of the peer_bw_rxnss_override parameter.
10 if this peer information is not available, we initialize the parameter by
11 minimum nss which is suggested by QCA as temporary workaround according
12 to the QCA sourcecodes.
13
14 Signed-off-by: Sebastian Gottschall <s.gottsch...@dd-wrt.com>
15
16 v2: remove debug messages
17 v3: apply some cosmetics, update documentation
18 v4: fix compile warning and truncate nss to maximum of 2x2 since current
19 chipsets only support 2x2 at vht160
20 v5: handle maximum nss for chipsets supportig vht160 with 1x1 only
21 v7: use more simple code variant and take care about hw/sw chainmask
22 configuration
23 ---
24 drivers/net/wireless/ath/ath10k/mac.c | 40 +++++++++++++++------------
25 drivers/net/wireless/ath/ath10k/wmi.c | 7 +----
26 drivers/net/wireless/ath/ath10k/wmi.h | 14 +++++++++-
27 3 files changed, 36 insertions(+), 25 deletions(-)
28
29 --- a/drivers/net/wireless/ath/ath10k/mac.c
30 +++ b/drivers/net/wireless/ath/ath10k/mac.c
31 @@ -2466,7 +2466,7 @@ static void ath10k_peer_assoc_h_vht(stru
32 const u16 *vht_mcs_mask;
33 u8 ampdu_factor;
34 u8 max_nss, vht_mcs;
35 - int i;
36 + int i, nss160;
37
38 if (WARN_ON(ath10k_mac_vif_chan(vif, &def)))
39 return;
40 @@ -2526,23 +2526,27 @@ static void ath10k_peer_assoc_h_vht(stru
41 __le16_to_cpu(vht_cap->vht_mcs.tx_highest);
42 arg->peer_vht_rates.tx_mcs_set = ath10k_peer_assoc_h_vht_limit(
43 __le16_to_cpu(vht_cap->vht_mcs.tx_mcs_map), vht_mcs_mask);
44 + arg->peer_bw_rxnss_override = 0;
45 + nss160 = 1; /* 1x1 default config for VHT160 */
46
47 - ath10k_dbg(ar, ATH10K_DBG_MAC, "mac vht peer %pM max_mpdu %d flags 0x%x\n",
48 - sta->addr, arg->peer_max_mpdu, arg->peer_flags);
49 -
50 - if (arg->peer_vht_rates.rx_max_rate &&
51 - (sta->vht_cap.cap & IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_MASK)) {
52 - switch (arg->peer_vht_rates.rx_max_rate) {
53 - case 1560:
54 - /* Must be 2x2 at 160Mhz is all it can do. */
55 - arg->peer_bw_rxnss_override = 2;
56 - break;
57 - case 780:
58 - /* Can only do 1x1 at 160Mhz (Long Guard Interval) */
59 - arg->peer_bw_rxnss_override = 1;
60 - break;
61 - }
62 + /* only 4x4 configuration do support 2x2 for VHT160, everything else must use 1x1 */
63 + if (ar->cfg_rx_chainmask == 15)
64 + nss160 = arg->peer_num_spatial_streams <= 2 ? arg->peer_num_spatial_streams : 2;
65 +
66 + /* in case if peer is connected with vht160 or vht80+80, we need to properly adjust rxnss parameters otherwise firmware will raise a assert */
67 + switch(arg->peer_phymode) {
68 + case MODE_11AC_VHT80_80:
69 + arg->peer_bw_rxnss_override = BW_NSS_FWCONF_80_80(nss160);
70 + /* fall through */
71 + case MODE_11AC_VHT160:
72 + arg->peer_bw_rxnss_override |= BW_NSS_FWCONF_160(nss160);
73 + break;
74 + default:
75 + break;
76 }
77 +
78 + ath10k_dbg(ar, ATH10K_DBG_MAC, "mac vht peer %pM max_mpdu %d flags 0x%x peer_bw_rxnss_override 0x%x\n",
79 + sta->addr, arg->peer_max_mpdu, arg->peer_flags, arg->peer_bw_rxnss_override);
80 }
81
82 static void ath10k_peer_assoc_h_qos(struct ath10k *ar,
83 @@ -2694,9 +2698,9 @@ static int ath10k_peer_assoc_prepare(str
84 ath10k_peer_assoc_h_crypto(ar, vif, sta, arg);
85 ath10k_peer_assoc_h_rates(ar, vif, sta, arg);
86 ath10k_peer_assoc_h_ht(ar, vif, sta, arg);
87 + ath10k_peer_assoc_h_phymode(ar, vif, sta, arg);
88 ath10k_peer_assoc_h_vht(ar, vif, sta, arg);
89 ath10k_peer_assoc_h_qos(ar, vif, sta, arg);
90 - ath10k_peer_assoc_h_phymode(ar, vif, sta, arg);
91
92 return 0;
93 }
94 --- a/drivers/net/wireless/ath/ath10k/wmi.c
95 +++ b/drivers/net/wireless/ath/ath10k/wmi.c
96 @@ -6760,12 +6760,7 @@ ath10k_wmi_peer_assoc_fill_10_4(struct a
97 struct wmi_10_4_peer_assoc_complete_cmd *cmd = buf;
98
99 ath10k_wmi_peer_assoc_fill_10_2(ar, buf, arg);
100 - if (arg->peer_bw_rxnss_override)
101 - cmd->peer_bw_rxnss_override =
102 - __cpu_to_le32((arg->peer_bw_rxnss_override - 1) |
103 - BIT(PEER_BW_RXNSS_OVERRIDE_OFFSET));
104 - else
105 - cmd->peer_bw_rxnss_override = 0;
106 + cmd->peer_bw_rxnss_override = __cpu_to_le32(arg->peer_bw_rxnss_override);
107 }
108
109 static int
110 --- a/drivers/net/wireless/ath/ath10k/wmi.h
111 +++ b/drivers/net/wireless/ath/ath10k/wmi.h
112 @@ -6209,7 +6209,19 @@ struct wmi_10_2_peer_assoc_complete_cmd
113 __le32 info0; /* WMI_PEER_ASSOC_INFO0_ */
114 } __packed;
115
116 -#define PEER_BW_RXNSS_OVERRIDE_OFFSET 31
117 +#define BW_NSS_FWCONF_MAP_ENABLE (1 << 31)
118 +#define BW_NSS_FWCONF_MAP_160MHZ_S (0)
119 +#define BW_NSS_FWCONF_MAP_160MHZ_M (0x00000007)
120 +#define BW_NSS_FWCONF_MAP_80_80MHZ_S (3)
121 +#define BW_NSS_FWCONF_MAP_80_80MHZ_M (0x00000038)
122 +#define BW_NSS_FWCONF_MAP_M (0x0000003F)
123 +
124 +#define GET_BW_NSS_FWCONF_160(x) ((((x) & BW_NSS_FWCONF_MAP_160MHZ_M) >> BW_NSS_FWCONF_MAP_160MHZ_S) + 1)
125 +#define GET_BW_NSS_FWCONF_80_80(x) ((((x) & BW_NSS_FWCONF_MAP_80_80MHZ_M) >> BW_NSS_FWCONF_MAP_80_80MHZ_S) + 1)
126 +
127 +/* Values defined to set 160 MHz Bandwidth NSS Mapping into FW*/
128 +#define BW_NSS_FWCONF_160(x) (BW_NSS_FWCONF_MAP_ENABLE | (((x - 1) << BW_NSS_FWCONF_MAP_160MHZ_S) & BW_NSS_FWCONF_MAP_160MHZ_M))
129 +#define BW_NSS_FWCONF_80_80(x) (BW_NSS_FWCONF_MAP_ENABLE | (((x - 1) << BW_NSS_FWCONF_MAP_80_80MHZ_S) & BW_NSS_FWCONF_MAP_80_80MHZ_M))
130
131 struct wmi_10_4_peer_assoc_complete_cmd {
132 struct wmi_10_2_peer_assoc_complete_cmd cmd;