diff mbox series

ath10k: enable VHT160 and VHT80+80 modes

Message ID 1585148169-2320-1-git-send-email-ssreeela@codeaurora.org (mailing list archive)
State New, archived
Headers show
Series ath10k: enable VHT160 and VHT80+80 modes | expand

Commit Message

Sowmiya Sree Elavalagan March 25, 2020, 2:56 p.m. UTC
From: Lei Wang <leiwa@codeaurora.org>

Set right channel frequencies in VHT160 mode according to the VHT160
interoperability workaround added as part of IEEE Std 802.11™-2016 in
"Table 9-252—VHT Operation Information subfields", band_center_freq2
corresponds to CCFS1 in Table 9-253. Previous implementation
(band_center_freq2 = 0 for VHT160) is only deprecated.

Enable VHT80+80 mode and set the proper peer RX nss value for VHT160 and
VHT80+80 mode.

Based on patches by Sebastian Gottschall:

https://lkml.kernel.org/r/20180704095444.662-1-s.gottschall@dd-wrt.com

https://lkml.kernel.org/r/20180704120519.6479-1-s.gottschall@dd-wrt.com

Tested: qca9984 with firmware ver 10.4-3.10-00047

Co-developed-by: Sebastian Gottschall <s.gottschall@dd-wrt.com>
Signed-off-by: Sebastian Gottschall <s.gottschall@dd-wrt.com>
Co-developed-by: Rick Wu <rwu@codeaurora.org>
Signed-off-by: Rick Wu <rwu@codeaurora.org>
Signed-off-by: Lei Wang <leiwa@codeaurora.org>
Signed-off-by: Sowmiya Sree Elavalagan <ssreeela@codeaurora.org>
---
 drivers/net/wireless/ath/ath10k/mac.c | 84 +++++++++++++++++++++++++----------
 drivers/net/wireless/ath/ath10k/wmi.c | 23 ++++++----
 drivers/net/wireless/ath/ath10k/wmi.h |  5 ++-
 3 files changed, 80 insertions(+), 32 deletions(-)

Comments

Kalle Valo March 26, 2020, 9:59 a.m. UTC | #1
Sowmiya Sree Elavalagan <ssreeela@codeaurora.org> wrote:

> From: Lei Wang <leiwa@codeaurora.org>
> 
> Set right channel frequencies in VHT160 mode according to the VHT160
> interoperability workaround added as part of IEEE Std 802.11™-2016 in
> "Table 9-252—VHT Operation Information subfields", band_center_freq2
> corresponds to CCFS1 in Table 9-253. Previous implementation
> (band_center_freq2 = 0 for VHT160) is only deprecated.
> 
> Enable VHT80+80 mode and set the proper peer RX nss value for VHT160 and
> VHT80+80 mode.
> 
> Based on patches by Sebastian Gottschall:
> 
> https://lkml.kernel.org/r/20180704095444.662-1-s.gottschall@dd-wrt.com
> 
> https://lkml.kernel.org/r/20180704120519.6479-1-s.gottschall@dd-wrt.com
> 
> Tested: qca9984 with firmware ver 10.4-3.10-00047
> 
> Co-developed-by: Sebastian Gottschall <s.gottschall@dd-wrt.com>
> Signed-off-by: Sebastian Gottschall <s.gottschall@dd-wrt.com>
> Co-developed-by: Rick Wu <rwu@codeaurora.org>
> Signed-off-by: Rick Wu <rwu@codeaurora.org>
> Signed-off-by: Lei Wang <leiwa@codeaurora.org>
> Signed-off-by: Sowmiya Sree Elavalagan <ssreeela@codeaurora.org>

Fails to build on GCC 8.1. Did you test this?

In file included from ./include/asm-generic/bug.h:5,
                 from ./arch/x86/include/asm/bug.h:83,
                 from ./include/linux/bug.h:5,
                 from ./include/net/mac80211.h:16,
                 from drivers/net/wireless/ath/ath10k/mac.h:10,
                 from drivers/net/wireless/ath/ath10k/mac.c:8:
In function 'ath10k_peer_assoc_h_vht',
    inlined from 'ath10k_peer_assoc_prepare' at drivers/net/wireless/ath/ath10k/mac.c:2790:2:
./include/linux/compiler.h:350:38: error: call to '__compiletime_assert_2631' declared with attribute error: BUILD_BUG_ON failed: ((((((~(((0UL)))) - ((((1UL))) << (3)) + 1) & (~(((0UL))) >> (64 - 1 - (5))))) + (1ULL << (__builtin_ffsll((((~(((0UL)))) - ((((1UL))) << (3)) + 1) & (~(((0UL))) >> (64 - 1 - (5))))) - 1))) & ((((((~(((0UL)))) - ((((1UL))) << (3)) + 1) & (~(((0UL))) >> (64 - 1 - (5))))) + (1ULL << (__builtin_ffsll((((~(((0UL)))) - ((((1UL))) << (3)) + 1) & (~(((0UL))) >> (64 - 1 - (5))))) - 1))) - 1)) != 0
  _compiletime_assert(condition, msg, __compiletime_assert_, __LINE__)
                                      ^
./include/linux/compiler.h:331:4: note: in definition of macro '__compiletime_assert'
    prefix ## suffix();    \
    ^~~~~~
./include/linux/compiler.h:350:2: note: in expansion of macro '_compiletime_assert'
  _compiletime_assert(condition, msg, __compiletime_assert_, __LINE__)
  ^~~~~~~~~~~~~~~~~~~
./include/linux/build_bug.h:39:37: note: in expansion of macro 'compiletime_assert'
 #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
                                     ^~~~~~~~~~~~~~~~~~
./include/linux/bitfield.h:49:3: note: in expansion of macro 'BUILD_BUG_ON_MSG'
   BUILD_BUG_ON_MSG(__builtin_constant_p(_val) ?  \
   ^~~~~~~~~~~~~~~~
./include/linux/bitfield.h:81:3: note: in expansion of macro '__BF_FIELD_CHECK'
   __BF_FIELD_CHECK(_mask, 0ULL, _val, "FIELD_PREP: "); \
   ^~~~~~~~~~~~~~~~
drivers/net/wireless/ath/ath10k/mac.c:2631:4: note: in expansion of macro 'FIELD_PREP'
    FIELD_PREP(WMI_PEER_NSS_80_80MHZ_MASK, (rx_nss - 1));
    ^~~~~~~~~~
./include/linux/compiler.h:350:38: error: call to '__compiletime_assert_2627' declared with attribute error: BUILD_BUG_ON failed: ((((((~(((0UL)))) - ((((1UL))) << (0)) + 1) & (~(((0UL))) >> (64 - 1 - (2))))) + (1ULL << (__builtin_ffsll((((~(((0UL)))) - ((((1UL))) << (0)) + 1) & (~(((0UL))) >> (64 - 1 - (2))))) - 1))) & ((((((~(((0UL)))) - ((((1UL))) << (0)) + 1) & (~(((0UL))) >> (64 - 1 - (2))))) + (1ULL << (__builtin_ffsll((((~(((0UL)))) - ((((1UL))) << (0)) + 1) & (~(((0UL))) >> (64 - 1 - (2))))) - 1))) - 1)) != 0
  _compiletime_assert(condition, msg, __compiletime_assert_, __LINE__)
                                      ^
./include/linux/compiler.h:331:4: note: in definition of macro '__compiletime_assert'
    prefix ## suffix();    \
    ^~~~~~
./include/linux/compiler.h:350:2: note: in expansion of macro '_compiletime_assert'
  _compiletime_assert(condition, msg, __compiletime_assert_, __LINE__)
  ^~~~~~~~~~~~~~~~~~~
./include/linux/build_bug.h:39:37: note: in expansion of macro 'compiletime_assert'
 #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
                                     ^~~~~~~~~~~~~~~~~~
./include/linux/bitfield.h:49:3: note: in expansion of macro 'BUILD_BUG_ON_MSG'
   BUILD_BUG_ON_MSG(__builtin_constant_p(_val) ?  \
   ^~~~~~~~~~~~~~~~
./include/linux/bitfield.h:81:3: note: in expansion of macro '__BF_FIELD_CHECK'
   __BF_FIELD_CHECK(_mask, 0ULL, _val, "FIELD_PREP: "); \
   ^~~~~~~~~~~~~~~~
drivers/net/wireless/ath/ath10k/mac.c:2627:4: note: in expansion of macro 'FIELD_PREP'
    FIELD_PREP(WMI_PEER_NSS_160MHZ_MASK, (rx_nss - 1));
    ^~~~~~~~~~
make[5]: *** [drivers/net/wireless/ath/ath10k/mac.o] Error 1
make[5]: *** Waiting for unfinished jobs....
make[4]: *** [drivers/net/wireless/ath/ath10k] Error 2
make[3]: *** [drivers/net/wireless/ath] Error 2
make[2]: *** [drivers/net/wireless] Error 2
make[1]: *** [drivers/net] Error 2
make: *** [drivers] Error 2

Patch set to Changes Requested.
Sowmiya Sree Elavalagan March 26, 2020, 1:15 p.m. UTC | #2
On 2020-03-26 15:29, Kalle Valo wrote:
> Sowmiya Sree Elavalagan <ssreeela@codeaurora.org> wrote:
> 
>> From: Lei Wang <leiwa@codeaurora.org>
>> 
>> Set right channel frequencies in VHT160 mode according to the VHT160
>> interoperability workaround added as part of IEEE Std 802.11™-2016 in
>> "Table 9-252—VHT Operation Information subfields", band_center_freq2
>> corresponds to CCFS1 in Table 9-253. Previous implementation
>> (band_center_freq2 = 0 for VHT160) is only deprecated.
>> 
>> Enable VHT80+80 mode and set the proper peer RX nss value for VHT160 
>> and
>> VHT80+80 mode.
>> 
>> Based on patches by Sebastian Gottschall:
>> 
>> https://lkml.kernel.org/r/20180704095444.662-1-s.gottschall@dd-wrt.com
>> 
>> https://lkml.kernel.org/r/20180704120519.6479-1-s.gottschall@dd-wrt.com
>> 
>> Tested: qca9984 with firmware ver 10.4-3.10-00047
>> 
>> Co-developed-by: Sebastian Gottschall <s.gottschall@dd-wrt.com>
>> Signed-off-by: Sebastian Gottschall <s.gottschall@dd-wrt.com>
>> Co-developed-by: Rick Wu <rwu@codeaurora.org>
>> Signed-off-by: Rick Wu <rwu@codeaurora.org>
>> Signed-off-by: Lei Wang <leiwa@codeaurora.org>
>> Signed-off-by: Sowmiya Sree Elavalagan <ssreeela@codeaurora.org>
> 
> Fails to build on GCC 8.1. Did you test this?
> 
> In file included from ./include/asm-generic/bug.h:5,
>                  from ./arch/x86/include/asm/bug.h:83,
>                  from ./include/linux/bug.h:5,
>                  from ./include/net/mac80211.h:16,
>                  from drivers/net/wireless/ath/ath10k/mac.h:10,
>                  from drivers/net/wireless/ath/ath10k/mac.c:8:
> In function 'ath10k_peer_assoc_h_vht',
>     inlined from 'ath10k_peer_assoc_prepare' at
> drivers/net/wireless/ath/ath10k/mac.c:2790:2:
> ./include/linux/compiler.h:350:38: error: call to
> '__compiletime_assert_2631' declared with attribute error:
> BUILD_BUG_ON failed: ((((((~(((0UL)))) - ((((1UL))) << (3)) + 1) &
> (~(((0UL))) >> (64 - 1 - (5))))) + (1ULL <<
> (__builtin_ffsll((((~(((0UL)))) - ((((1UL))) << (3)) + 1) &
> (~(((0UL))) >> (64 - 1 - (5))))) - 1))) & ((((((~(((0UL)))) -
> ((((1UL))) << (3)) + 1) & (~(((0UL))) >> (64 - 1 - (5))))) + (1ULL <<
> (__builtin_ffsll((((~(((0UL)))) - ((((1UL))) << (3)) + 1) &
> (~(((0UL))) >> (64 - 1 - (5))))) - 1))) - 1)) != 0
>   _compiletime_assert(condition, msg, __compiletime_assert_, __LINE__)
>                                       ^
> ./include/linux/compiler.h:331:4: note: in definition of macro
> '__compiletime_assert'
>     prefix ## suffix();    \
>     ^~~~~~
> ./include/linux/compiler.h:350:2: note: in expansion of macro
> '_compiletime_assert'
>   _compiletime_assert(condition, msg, __compiletime_assert_, __LINE__)
>   ^~~~~~~~~~~~~~~~~~~
> ./include/linux/build_bug.h:39:37: note: in expansion of macro
> 'compiletime_assert'
>  #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
>                                      ^~~~~~~~~~~~~~~~~~
> ./include/linux/bitfield.h:49:3: note: in expansion of macro 
> 'BUILD_BUG_ON_MSG'
>    BUILD_BUG_ON_MSG(__builtin_constant_p(_val) ?  \
>    ^~~~~~~~~~~~~~~~
> ./include/linux/bitfield.h:81:3: note: in expansion of macro 
> '__BF_FIELD_CHECK'
>    __BF_FIELD_CHECK(_mask, 0ULL, _val, "FIELD_PREP: "); \
>    ^~~~~~~~~~~~~~~~
> drivers/net/wireless/ath/ath10k/mac.c:2631:4: note: in expansion of
> macro 'FIELD_PREP'
>     FIELD_PREP(WMI_PEER_NSS_80_80MHZ_MASK, (rx_nss - 1));
>     ^~~~~~~~~~
> ./include/linux/compiler.h:350:38: error: call to
> '__compiletime_assert_2627' declared with attribute error:
> BUILD_BUG_ON failed: ((((((~(((0UL)))) - ((((1UL))) << (0)) + 1) &
> (~(((0UL))) >> (64 - 1 - (2))))) + (1ULL <<
> (__builtin_ffsll((((~(((0UL)))) - ((((1UL))) << (0)) + 1) &
> (~(((0UL))) >> (64 - 1 - (2))))) - 1))) & ((((((~(((0UL)))) -
> ((((1UL))) << (0)) + 1) & (~(((0UL))) >> (64 - 1 - (2))))) + (1ULL <<
> (__builtin_ffsll((((~(((0UL)))) - ((((1UL))) << (0)) + 1) &
> (~(((0UL))) >> (64 - 1 - (2))))) - 1))) - 1)) != 0
>   _compiletime_assert(condition, msg, __compiletime_assert_, __LINE__)
>                                       ^
> ./include/linux/compiler.h:331:4: note: in definition of macro
> '__compiletime_assert'
>     prefix ## suffix();    \
>     ^~~~~~
> ./include/linux/compiler.h:350:2: note: in expansion of macro
> '_compiletime_assert'
>   _compiletime_assert(condition, msg, __compiletime_assert_, __LINE__)
>   ^~~~~~~~~~~~~~~~~~~
> ./include/linux/build_bug.h:39:37: note: in expansion of macro
> 'compiletime_assert'
>  #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
>                                      ^~~~~~~~~~~~~~~~~~
> ./include/linux/bitfield.h:49:3: note: in expansion of macro 
> 'BUILD_BUG_ON_MSG'
>    BUILD_BUG_ON_MSG(__builtin_constant_p(_val) ?  \
>    ^~~~~~~~~~~~~~~~
> ./include/linux/bitfield.h:81:3: note: in expansion of macro 
> '__BF_FIELD_CHECK'
>    __BF_FIELD_CHECK(_mask, 0ULL, _val, "FIELD_PREP: "); \
>    ^~~~~~~~~~~~~~~~
> drivers/net/wireless/ath/ath10k/mac.c:2627:4: note: in expansion of
> macro 'FIELD_PREP'
>     FIELD_PREP(WMI_PEER_NSS_160MHZ_MASK, (rx_nss - 1));
>     ^~~~~~~~~~
> make[5]: *** [drivers/net/wireless/ath/ath10k/mac.o] Error 1
> make[5]: *** Waiting for unfinished jobs....
> make[4]: *** [drivers/net/wireless/ath/ath10k] Error 2
> make[3]: *** [drivers/net/wireless/ath] Error 2
> make[2]: *** [drivers/net/wireless] Error 2
> make[1]: *** [drivers/net] Error 2
> make: *** [drivers] Error 2
> 
> Patch set to Changes Requested.

Hi Kalle,

I checked the build. Build was successful with GCC version 4.8.
Will fix the error and update the patch.

Thanks,
Sowmiya Sree
Kalle Valo March 27, 2020, 11:25 a.m. UTC | #3
ssreeela@codeaurora.org writes:

> On 2020-03-26 15:29, Kalle Valo wrote:
>> Sowmiya Sree Elavalagan <ssreeela@codeaurora.org> wrote:
>>
>>> From: Lei Wang <leiwa@codeaurora.org>
>>>
>>> Set right channel frequencies in VHT160 mode according to the VHT160
>>> interoperability workaround added as part of IEEE Std 802.11™-2016 in
>>> "Table 9-252—VHT Operation Information subfields", band_center_freq2
>>> corresponds to CCFS1 in Table 9-253. Previous implementation
>>> (band_center_freq2 = 0 for VHT160) is only deprecated.
>>>
>>> Enable VHT80+80 mode and set the proper peer RX nss value for
>>> VHT160 and
>>> VHT80+80 mode.
>>>
>>> Based on patches by Sebastian Gottschall:
>>>
>>> https://lkml.kernel.org/r/20180704095444.662-1-s.gottschall@dd-wrt.com
>>>
>>> https://lkml.kernel.org/r/20180704120519.6479-1-s.gottschall@dd-wrt.com
>>>
>>> Tested: qca9984 with firmware ver 10.4-3.10-00047
>>>
>>> Co-developed-by: Sebastian Gottschall <s.gottschall@dd-wrt.com>
>>> Signed-off-by: Sebastian Gottschall <s.gottschall@dd-wrt.com>
>>> Co-developed-by: Rick Wu <rwu@codeaurora.org>
>>> Signed-off-by: Rick Wu <rwu@codeaurora.org>
>>> Signed-off-by: Lei Wang <leiwa@codeaurora.org>
>>> Signed-off-by: Sowmiya Sree Elavalagan <ssreeela@codeaurora.org>
>>
>> Fails to build on GCC 8.1. Did you test this?
>>
>> In file included from ./include/asm-generic/bug.h:5,
>>                  from ./arch/x86/include/asm/bug.h:83,
>>                  from ./include/linux/bug.h:5,
>>                  from ./include/net/mac80211.h:16,
>>                  from drivers/net/wireless/ath/ath10k/mac.h:10,
>>                  from drivers/net/wireless/ath/ath10k/mac.c:8:
>> In function 'ath10k_peer_assoc_h_vht',
>>     inlined from 'ath10k_peer_assoc_prepare' at
>> drivers/net/wireless/ath/ath10k/mac.c:2790:2:
>> ./include/linux/compiler.h:350:38: error: call to
>> '__compiletime_assert_2631' declared with attribute error:

[...]

> I checked the build. Build was successful with GCC version 4.8.
> Will fix the error and update the patch.

Great, thanks. Here's how I installed GCC 8.1 from crosstool:

listings: https://www.kernel.org/pub/tools/crosstool/

wget https://www.kernel.org/pub/tools/crosstool/files/bin/x86_64/8.1.0/x86_64-gcc-8.1.0-nolibc-x86_64-linux.tar.xz
pushd /opt/cross/
tar -xf ~/tmp/crosstool/x86_64-gcc-8.1.0-nolibc-x86_64-linux.tar.xz

In top level create GNUMakefile:

CROSS_COMPILE=/opt/cross/gcc-8.1.0-nolibc/x86_64-linux/bin/x86_64-linux-
include Makefile
Sowmiya Sree Elavalagan March 30, 2020, 9:22 a.m. UTC | #4
On 2020-03-27 16:55, Kalle Valo wrote:
> ssreeela@codeaurora.org writes:
> 
>> On 2020-03-26 15:29, Kalle Valo wrote:
>>> Sowmiya Sree Elavalagan <ssreeela@codeaurora.org> wrote:
>>> 
>>>> From: Lei Wang <leiwa@codeaurora.org>
>>>> 
>>>> Set right channel frequencies in VHT160 mode according to the VHT160
>>>> interoperability workaround added as part of IEEE Std 802.11™-2016 
>>>> in
>>>> "Table 9-252—VHT Operation Information subfields", band_center_freq2
>>>> corresponds to CCFS1 in Table 9-253. Previous implementation
>>>> (band_center_freq2 = 0 for VHT160) is only deprecated.
>>>> 
>>>> Enable VHT80+80 mode and set the proper peer RX nss value for
>>>> VHT160 and
>>>> VHT80+80 mode.
>>>> 
>>>> Based on patches by Sebastian Gottschall:
>>>> 
>>>> https://lkml.kernel.org/r/20180704095444.662-1-s.gottschall@dd-wrt.com
>>>> 
>>>> https://lkml.kernel.org/r/20180704120519.6479-1-s.gottschall@dd-wrt.com
>>>> 
>>>> Tested: qca9984 with firmware ver 10.4-3.10-00047
>>>> 
>>>> Co-developed-by: Sebastian Gottschall <s.gottschall@dd-wrt.com>
>>>> Signed-off-by: Sebastian Gottschall <s.gottschall@dd-wrt.com>
>>>> Co-developed-by: Rick Wu <rwu@codeaurora.org>
>>>> Signed-off-by: Rick Wu <rwu@codeaurora.org>
>>>> Signed-off-by: Lei Wang <leiwa@codeaurora.org>
>>>> Signed-off-by: Sowmiya Sree Elavalagan <ssreeela@codeaurora.org>
>>> 
>>> Fails to build on GCC 8.1. Did you test this?
>>> 
>>> In file included from ./include/asm-generic/bug.h:5,
>>>                  from ./arch/x86/include/asm/bug.h:83,
>>>                  from ./include/linux/bug.h:5,
>>>                  from ./include/net/mac80211.h:16,
>>>                  from drivers/net/wireless/ath/ath10k/mac.h:10,
>>>                  from drivers/net/wireless/ath/ath10k/mac.c:8:
>>> In function 'ath10k_peer_assoc_h_vht',
>>>     inlined from 'ath10k_peer_assoc_prepare' at
>>> drivers/net/wireless/ath/ath10k/mac.c:2790:2:
>>> ./include/linux/compiler.h:350:38: error: call to
>>> '__compiletime_assert_2631' declared with attribute error:
> 
> [...]
> 
>> I checked the build. Build was successful with GCC version 4.8.
>> Will fix the error and update the patch.
> 
> Great, thanks. Here's how I installed GCC 8.1 from crosstool:
> 
> listings: https://www.kernel.org/pub/tools/crosstool/
> 
> wget
> https://www.kernel.org/pub/tools/crosstool/files/bin/x86_64/8.1.0/x86_64-gcc-8.1.0-nolibc-x86_64-linux.tar.xz
> pushd /opt/cross/
> tar -xf ~/tmp/crosstool/x86_64-gcc-8.1.0-nolibc-x86_64-linux.tar.xz
> 
> In top level create GNUMakefile:
> 
> CROSS_COMPILE=/opt/cross/gcc-8.1.0-nolibc/x86_64-linux/bin/x86_64-linux-
> include Makefile

Thanks for the info. Will check the build with GCC 8.1 and resend.

Regards,
Sowmiya Sree
diff mbox series

Patch

diff --git a/drivers/net/wireless/ath/ath10k/mac.c b/drivers/net/wireless/ath/ath10k/mac.c
index 81e148e..7c2e396 100644
--- a/drivers/net/wireless/ath/ath10k/mac.c
+++ b/drivers/net/wireless/ath/ath10k/mac.c
@@ -2505,6 +2505,30 @@  static int ath10k_peer_assoc_qos_ap(struct ath10k *ar,
 	return tx_mcs_set;
 }
 
+static u32 get_160mhz_nss_from_maxrate(int rate)
+{
+	u32 nss;
+
+	switch (rate) {
+	case 780:
+		nss = 1;
+		break;
+	case 1560:
+		nss = 2;
+		break;
+	case 2106:
+		nss = 3; /* not support MCS9 from spec*/
+		break;
+	case 3120:
+		nss = 4;
+		break;
+	default:
+		 nss = 0;
+	}
+
+	return nss;
+}
+
 static void ath10k_peer_assoc_h_vht(struct ath10k *ar,
 				    struct ieee80211_vif *vif,
 				    struct ieee80211_sta *sta,
@@ -2512,6 +2536,7 @@  static void ath10k_peer_assoc_h_vht(struct ath10k *ar,
 {
 	const struct ieee80211_sta_vht_cap *vht_cap = &sta->vht_cap;
 	struct ath10k_vif *arvif = (void *)vif->drv_priv;
+	struct ath10k_hw_params *hw = &ar->hw_params;
 	struct cfg80211_chan_def def;
 	enum nl80211_band band;
 	const u16 *vht_mcs_mask;
@@ -2578,22 +2603,38 @@  static void ath10k_peer_assoc_h_vht(struct ath10k *ar,
 	arg->peer_vht_rates.tx_mcs_set = ath10k_peer_assoc_h_vht_limit(
 		__le16_to_cpu(vht_cap->vht_mcs.tx_mcs_map), vht_mcs_mask);
 
-	ath10k_dbg(ar, ATH10K_DBG_MAC, "mac vht peer %pM max_mpdu %d flags 0x%x\n",
-		   sta->addr, arg->peer_max_mpdu, arg->peer_flags);
+	/* Configure bandwidth-NSS mapping to FW
+	 * for the chip's tx chains setting on 160Mhz bw
+	 */
+	if (arg->peer_phymode == MODE_11AC_VHT160 ||
+	    arg->peer_phymode == MODE_11AC_VHT80_80) {
+		u32 rx_nss;
+		u32 max_rate;
 
-	if (arg->peer_vht_rates.rx_max_rate &&
-	    (sta->vht_cap.cap & IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_MASK)) {
-		switch (arg->peer_vht_rates.rx_max_rate) {
-		case 1560:
-			/* Must be 2x2 at 160Mhz is all it can do. */
-			arg->peer_bw_rxnss_override = 2;
-			break;
-		case 780:
-			/* Can only do 1x1 at 160Mhz (Long Guard Interval) */
-			arg->peer_bw_rxnss_override = 1;
-			break;
+		max_rate = arg->peer_vht_rates.rx_max_rate;
+		rx_nss = get_160mhz_nss_from_maxrate(max_rate);
+
+		if (rx_nss == 0)
+			rx_nss = arg->peer_num_spatial_streams;
+		else
+			rx_nss = min(arg->peer_num_spatial_streams, rx_nss);
+
+		max_rate = hw->vht160_mcs_tx_highest;
+		rx_nss = min(rx_nss, get_160mhz_nss_from_maxrate(max_rate));
+
+		arg->peer_bw_rxnss_override =
+			FIELD_PREP(WMI_PEER_NSS_MAP_ENABLE, 1) |
+			FIELD_PREP(WMI_PEER_NSS_160MHZ_MASK, (rx_nss - 1));
+
+		if (arg->peer_phymode == MODE_11AC_VHT80_80) {
+			arg->peer_bw_rxnss_override |=
+			FIELD_PREP(WMI_PEER_NSS_80_80MHZ_MASK, (rx_nss - 1));
 		}
 	}
+	ath10k_dbg(ar, ATH10K_DBG_MAC,
+		   "mac vht peer %pM max_mpdu %d flags 0x%x peer_rx_nss_override 0x%x\n",
+		   sta->addr, arg->peer_max_mpdu,
+		   arg->peer_flags, arg->peer_bw_rxnss_override);
 }
 
 static void ath10k_peer_assoc_h_qos(struct ath10k *ar,
@@ -2745,9 +2786,9 @@  static int ath10k_peer_assoc_prepare(struct ath10k *ar,
 	ath10k_peer_assoc_h_crypto(ar, vif, sta, arg);
 	ath10k_peer_assoc_h_rates(ar, vif, sta, arg);
 	ath10k_peer_assoc_h_ht(ar, vif, sta, arg);
+	ath10k_peer_assoc_h_phymode(ar, vif, sta, arg);
 	ath10k_peer_assoc_h_vht(ar, vif, sta, arg);
 	ath10k_peer_assoc_h_qos(ar, vif, sta, arg);
-	ath10k_peer_assoc_h_phymode(ar, vif, sta, arg);
 
 	return 0;
 }
@@ -4561,13 +4602,6 @@  static struct ieee80211_sta_vht_cap ath10k_create_vht_cap(struct ath10k *ar)
 		vht_cap.cap |= val;
 	}
 
-	/* Currently the firmware seems to be buggy, don't enable 80+80
-	 * mode until that's resolved.
-	 */
-	if ((ar->vht_cap_info & IEEE80211_VHT_CAP_SHORT_GI_160) &&
-	    (ar->vht_cap_info & IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_MASK) == 0)
-		vht_cap.cap |= IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160MHZ;
-
 	mcs_map = 0;
 	for (i = 0; i < 8; i++) {
 		if ((i < ar->num_rf_chains) && (ar->cfg_tx_chainmask & BIT(i)))
@@ -8623,7 +8657,9 @@  void ath10k_mac_destroy(struct ath10k *ar)
 		.radar_detect_widths =	BIT(NL80211_CHAN_WIDTH_20_NOHT) |
 					BIT(NL80211_CHAN_WIDTH_20) |
 					BIT(NL80211_CHAN_WIDTH_40) |
-					BIT(NL80211_CHAN_WIDTH_80),
+					BIT(NL80211_CHAN_WIDTH_80) |
+					BIT(NL80211_CHAN_WIDTH_80P80) |
+					BIT(NL80211_CHAN_WIDTH_160),
 #endif
 	},
 };
@@ -8641,7 +8677,9 @@  void ath10k_mac_destroy(struct ath10k *ar)
 		.radar_detect_widths =  BIT(NL80211_CHAN_WIDTH_20_NOHT) |
 					BIT(NL80211_CHAN_WIDTH_20) |
 					BIT(NL80211_CHAN_WIDTH_40) |
-					BIT(NL80211_CHAN_WIDTH_80),
+					BIT(NL80211_CHAN_WIDTH_80) |
+					BIT(NL80211_CHAN_WIDTH_80P80) |
+					BIT(NL80211_CHAN_WIDTH_160),
 #endif
 	},
 };
diff --git a/drivers/net/wireless/ath/ath10k/wmi.c b/drivers/net/wireless/ath/ath10k/wmi.c
index 2ea77bb..db6f4c7 100644
--- a/drivers/net/wireless/ath/ath10k/wmi.c
+++ b/drivers/net/wireless/ath/ath10k/wmi.c
@@ -1714,12 +1714,23 @@  void ath10k_wmi_put_wmi_channel(struct wmi_channel *ch,
 	if (arg->chan_radar)
 		flags |= WMI_CHAN_FLAG_DFS;
 
+	ch->band_center_freq2 = 0;
 	ch->mhz = __cpu_to_le32(arg->freq);
 	ch->band_center_freq1 = __cpu_to_le32(arg->band_center_freq1);
 	if (arg->mode == MODE_11AC_VHT80_80)
 		ch->band_center_freq2 = __cpu_to_le32(arg->band_center_freq2);
-	else
-		ch->band_center_freq2 = 0;
+
+	if (arg->mode == MODE_11AC_VHT160) {
+		if (arg->freq > arg->band_center_freq1)
+			ch->band_center_freq1 =
+				__cpu_to_le32(arg->band_center_freq1 + 40);
+		else
+			ch->band_center_freq1 =
+				__cpu_to_le32(arg->band_center_freq1 - 40);
+
+		ch->band_center_freq2 = __cpu_to_le32(arg->band_center_freq1);
+	}
+
 	ch->min_power = arg->min_power;
 	ch->max_power = arg->max_power;
 	ch->reg_power = arg->max_reg_power;
@@ -7628,12 +7639,8 @@  void ath10k_wmi_start_scan_init(struct ath10k *ar,
 	struct wmi_10_4_peer_assoc_complete_cmd *cmd = buf;
 
 	ath10k_wmi_peer_assoc_fill_10_2(ar, buf, arg);
-	if (arg->peer_bw_rxnss_override)
-		cmd->peer_bw_rxnss_override =
-			__cpu_to_le32((arg->peer_bw_rxnss_override - 1) |
-				      BIT(PEER_BW_RXNSS_OVERRIDE_OFFSET));
-	else
-		cmd->peer_bw_rxnss_override = 0;
+	cmd->peer_bw_rxnss_override =
+		__cpu_to_le32(arg->peer_bw_rxnss_override);
 }
 
 static int
diff --git a/drivers/net/wireless/ath/ath10k/wmi.h b/drivers/net/wireless/ath/ath10k/wmi.h
index 972d53d..f722eef3 100644
--- a/drivers/net/wireless/ath/ath10k/wmi.h
+++ b/drivers/net/wireless/ath/ath10k/wmi.h
@@ -6501,7 +6501,10 @@  struct wmi_10_2_peer_assoc_complete_cmd {
 	__le32 info0; /* WMI_PEER_ASSOC_INFO0_ */
 } __packed;
 
-#define PEER_BW_RXNSS_OVERRIDE_OFFSET  31
+/* NSS Mapping to FW */
+#define WMI_PEER_NSS_MAP_ENABLE	BIT(31)
+#define WMI_PEER_NSS_160MHZ_MASK	GENMASK(2, 0)
+#define WMI_PEER_NSS_80_80MHZ_MASK	GENMASK(5, 3)
 
 struct wmi_10_4_peer_assoc_complete_cmd {
 	struct wmi_10_2_peer_assoc_complete_cmd cmd;