2022-10-22 03:28:21

by Deren Wu

[permalink] [raw]
Subject: [PATCH] wifi: mt76: fix bandwidth 80MHz link fail in 6GHz band

From: Ming Yen Hsieh <[email protected]>

Due to information missing, the firmware may be fail on bandwidth
related settings in mt7921/mt7922. Add new cmd STA_REC_HE_V2 to apply
additional capabilities in 6GHz band.

Tested-by: Ben Greear <[email protected]>
Co-developed-by: Deren Wu <[email protected]>
Signed-off-by: Deren Wu <[email protected]>
Signed-off-by: Ming Yen Hsieh <[email protected]>
---
.../wireless/mediatek/mt76/mt76_connac_mcu.c | 38 +++++++++++++++++++
.../wireless/mediatek/mt76/mt76_connac_mcu.h | 11 ++++++
2 files changed, 49 insertions(+)

diff --git a/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c b/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c
index 011fc9729b38..cdfc0b0da823 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c
@@ -744,6 +744,43 @@ mt76_connac_mcu_sta_he_tlv(struct sk_buff *skb, struct ieee80211_sta *sta)
he->pkt_ext = 2;
}

+static void
+mt76_connac_mcu_sta_he_tlv_v2(struct sk_buff *skb, struct ieee80211_sta *sta)
+{
+ struct ieee80211_sta_he_cap *he_cap = &sta->deflink.he_cap;
+ struct ieee80211_he_cap_elem *elem = &he_cap->he_cap_elem;
+ struct sta_rec_he_v2 *he;
+ struct tlv *tlv;
+ int i;
+
+ tlv = mt76_connac_mcu_add_tlv(skb, STA_REC_HE_V2, sizeof(*he));
+
+ he = (struct sta_rec_he_v2 *)tlv;
+ for (i = 0; i < ARRAY_SIZE(he->he_phy_cap); i++)
+ he->he_phy_cap[i] = cpu_to_le16(elem->phy_cap_info[i]);
+
+ for (i = 0; i < ARRAY_SIZE(he->he_mac_cap); i++)
+ he->he_mac_cap[i] = cpu_to_le16(elem->mac_cap_info[i]);
+
+ switch (sta->deflink.bandwidth) {
+ case IEEE80211_STA_RX_BW_160:
+ if (elem->phy_cap_info[0] &
+ IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_80PLUS80_MHZ_IN_5G)
+ he->max_nss_mcs[CMD_HE_MCS_BW8080] =
+ he_cap->he_mcs_nss_supp.rx_mcs_80p80;
+
+ he->max_nss_mcs[CMD_HE_MCS_BW160] =
+ he_cap->he_mcs_nss_supp.rx_mcs_160;
+ fallthrough;
+ default:
+ he->max_nss_mcs[CMD_HE_MCS_BW80] =
+ he_cap->he_mcs_nss_supp.rx_mcs_80;
+ break;
+ }
+
+ he->pkt_ext = IEEE80211_HE_PHY_CAP9_NOMINAL_PKT_PADDING_16US;
+}
+
static u8
mt76_connac_get_phy_mode_v2(struct mt76_phy *mphy, struct ieee80211_vif *vif,
enum nl80211_band band, struct ieee80211_sta *sta)
@@ -838,6 +875,7 @@ void mt76_connac_mcu_sta_tlv(struct mt76_phy *mphy, struct sk_buff *skb,
/* starec he */
if (sta->deflink.he_cap.has_he) {
mt76_connac_mcu_sta_he_tlv(skb, sta);
+ mt76_connac_mcu_sta_he_tlv_v2(skb, sta);
if (band == NL80211_BAND_6GHZ &&
sta_state == MT76_STA_INFO_STATE_ASSOC) {
struct sta_rec_he_6g_capa *he_6g_capa;
diff --git a/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h b/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h
index cf4ce3b1fc21..8166722d4717 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h
+++ b/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h
@@ -354,6 +354,16 @@ struct sta_rec_he {
u8 rsv2[2];
} __packed;

+struct sta_rec_he_v2 {
+ __le16 tag;
+ __le16 len;
+ u8 he_mac_cap[6];
+ u8 he_phy_cap[11];
+ u8 pkt_ext;
+ /* 0: BW80, 1: BW160, 2: BW8080 */
+ __le16 max_nss_mcs[CMD_HE_MCS_BW_NUM];
+} __packed;
+
struct sta_rec_amsdu {
__le16 tag;
__le16 len;
@@ -779,6 +789,7 @@ enum {
STA_REC_BFEE,
STA_REC_PHY = 0x15,
STA_REC_HE_6G = 0x17,
+ STA_REC_HE_V2 = 0x19,
STA_REC_MAX_NUM
};

--
2.18.0


2022-10-22 14:50:19

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH] wifi: mt76: fix bandwidth 80MHz link fail in 6GHz band

Hi Deren,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on wireless-next/main]
[also build test WARNING on wireless/main linus/master v6.1-rc1 next-20221021]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url: https://github.com/intel-lab-lkp/linux/commits/Deren-Wu/wifi-mt76-fix-bandwidth-80MHz-link-fail-in-6GHz-band/20221022-112302
base: https://git.kernel.org/pub/scm/linux/kernel/git/wireless/wireless-next.git main
patch link: https://lore.kernel.org/r/7f10cced1976b40f0aeafc281ead0652a54ec718.1666408187.git.deren.wu%40mediatek.com
patch subject: [PATCH] wifi: mt76: fix bandwidth 80MHz link fail in 6GHz band
config: sparc-randconfig-s031-20221019
compiler: sparc64-linux-gcc (GCC) 12.1.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# apt-get install sparse
# sparse version: v0.6.4-39-gce1a6720-dirty
# https://github.com/intel-lab-lkp/linux/commit/72d3c2dd27bdfef058a5e5ce5e19d951ae91c1f7
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Deren-Wu/wifi-mt76-fix-bandwidth-80MHz-link-fail-in-6GHz-band/20221022-112302
git checkout 72d3c2dd27bdfef058a5e5ce5e19d951ae91c1f7
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=sparc SHELL=/bin/bash drivers/net/wireless/mediatek/mt76/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <[email protected]>

sparse warnings: (new ones prefixed by >>)
>> drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c:760:35: sparse: sparse: incorrect type in assignment (different base types) @@ expected unsigned char @@ got restricted __le16 [usertype] @@
drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c:760:35: sparse: expected unsigned char
drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c:760:35: sparse: got restricted __le16 [usertype]
drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c:763:35: sparse: sparse: incorrect type in assignment (different base types) @@ expected unsigned char @@ got restricted __le16 [usertype] @@
drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c:763:35: sparse: expected unsigned char
drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c:763:35: sparse: got restricted __le16 [usertype]

vim +760 drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c

746
747 static void
748 mt76_connac_mcu_sta_he_tlv_v2(struct sk_buff *skb, struct ieee80211_sta *sta)
749 {
750 struct ieee80211_sta_he_cap *he_cap = &sta->deflink.he_cap;
751 struct ieee80211_he_cap_elem *elem = &he_cap->he_cap_elem;
752 struct sta_rec_he_v2 *he;
753 struct tlv *tlv;
754 int i;
755
756 tlv = mt76_connac_mcu_add_tlv(skb, STA_REC_HE_V2, sizeof(*he));
757
758 he = (struct sta_rec_he_v2 *)tlv;
759 for (i = 0; i < ARRAY_SIZE(he->he_phy_cap); i++)
> 760 he->he_phy_cap[i] = cpu_to_le16(elem->phy_cap_info[i]);
761
762 for (i = 0; i < ARRAY_SIZE(he->he_mac_cap); i++)
763 he->he_mac_cap[i] = cpu_to_le16(elem->mac_cap_info[i]);
764
765 switch (sta->deflink.bandwidth) {
766 case IEEE80211_STA_RX_BW_160:
767 if (elem->phy_cap_info[0] &
768 IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_80PLUS80_MHZ_IN_5G)
769 he->max_nss_mcs[CMD_HE_MCS_BW8080] =
770 he_cap->he_mcs_nss_supp.rx_mcs_80p80;
771
772 he->max_nss_mcs[CMD_HE_MCS_BW160] =
773 he_cap->he_mcs_nss_supp.rx_mcs_160;
774 fallthrough;
775 default:
776 he->max_nss_mcs[CMD_HE_MCS_BW80] =
777 he_cap->he_mcs_nss_supp.rx_mcs_80;
778 break;
779 }
780
781 he->pkt_ext = IEEE80211_HE_PHY_CAP9_NOMINAL_PKT_PADDING_16US;
782 }
783

--
0-DAY CI Kernel Test Service
https://01.org/lkp


Attachments:
(No filename) (4.21 kB)
config (173.26 kB)
Download all attachments