Skip to contentSkip to conversation

wifi: mt76: mt7996: replace direct WTBL access with MCU for station statistics

PATCH Superseded Joshua Klinesmith 2 participants 3 messages Apr 7

Subsystems (2)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 wifi: mt76: mt7996: replace direct WTBL access with MCU for station statistics

Direct MMIO access to WTBL entries for airtime and RSSI statistics in mt7996_mac_sta_poll() races with firmware, causing warnings at mt7996_mac_wtbl_lmac_addr, MCU message timeouts, and firmware communication breakdown. The function was called from mt7996_mac_tx_free() on every TX-Free-Done event, compounding the issue with heavy CPU overhead.

Replace the direct WTBL polling with firmware MCU queries:
- Airtime: UNI_ALL_STA_TXRX_AIR_TIME via the existing all_sta_info MCU command, with a new handler in mt7996_mcu_rx_all_sta_info_event()
- RSSI: UNI_PER_STA_RSSI via new mt7996_mcu_get_per_sta_info() using MCU_WM_UNI_CMD(PER_STA_INFO)

Both queries run from mt7996_mac_work() every 5th tick under dev mutex, matching the pattern already used for TX rate, admission stats, and MSDU count reporting.

Remove mt7996_mac_sta_poll() and its airtime_ac tracking array entirely.

The per-sta-info response handler validates the firmware-returned entry count against what was requested and against the skb payload length before walking the response array, and uses bounds-checked mt76_wcid_ptr() for WLAN ID lookup. RSSI polling is batched in groups of PER_STA_INFO_MAX_NUM to cover the full WTBL capacity.

Vendor driver analysis (mt_wifi.ko from Xiaomi AX3000T MT7981 firmware) confirms the RCPI-to-RSSI conversion formula (rcpi - 220) / 2 and that the vendor never performs direct WTBL reads for statistics.

Fixes 98686cd21624 ("wifi: mt76: mt7996: add driver for MediaTek Wi-Fi 7 (802.11be) devices")
---
 .../wireless/mediatek/mt76/mt76_connac_mcu.h  |   7 +
 .../net/wireless/mediatek/mt76/mt7996/mac.c   | 117 +--------------
 .../net/wireless/mediatek/mt76/mt7996/mcu.c   | 135 ++++++++++++++++++
 .../net/wireless/mediatek/mt76/mt7996/mcu.h   |  25 ++++
 .../wireless/mediatek/mt76/mt7996/mt7996.h    |   2 +-
 5 files changed, 170 insertions(+), 116 deletions(-)
drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h +7 -0
index 8d59cf43f0e2..14d3ee7defa1 100644
@@ -1392,6 +1392,13 @@ enum {
 	UNI_OFFLOAD_OFFLOAD_BMC_RPY_DETECT,
 };
 
+#define PER_STA_INFO_MAX_NUM	90
+
+enum UNI_PER_STA_INFO_TAG {
+	UNI_PER_STA_RSSI,
+	UNI_PER_STA_MAX_NUM
+};
+
 enum UNI_ALL_STA_INFO_TAG {
 	UNI_ALL_STA_TXRX_RATE,
 	UNI_ALL_STA_TX_STAT,
drivers/net/wireless/mediatek/mt76/mt7996/mac.c +2 -115

135 lines not on this page · raw message

drivers/net/wireless/mediatek/mt76/mt7996/mcu.c +135 -0

147 lines not on this page · raw message

drivers/net/wireless/mediatek/mt76/mt7996/mcu.h +25 -0
index e0b83ac9f5e2..b5bad9a76c49 100644
@@ -220,6 +220,31 @@ struct mt7996_mcu_all_sta_info_event {
 			__le32 tx_msdu_cnt;
 			__le32 rx_msdu_cnt;
 		} __packed, msdu_cnt);
+
+		DECLARE_FLEX_ARRAY(struct {
+			__le16 wlan_idx;
+			u8 rsv[2];
+			__le32 tx[IEEE80211_NUM_ACS];
+			__le32 rx[IEEE80211_NUM_ACS];
+		} __packed, airtime);
+	} __packed;
+} __packed;
+
+struct mt7996_mcu_per_sta_info_event {
+	u8 rsv[4];
+	__le16 tag;
+	__le16 len;
+	u8 more;
+	u8 rsv2;
+	__le16 sta_num;
+	u8 rsv3[4];
+
+	union {
+		DECLARE_FLEX_ARRAY(struct {
+			__le16 wlan_idx;
+			u8 rsv[2];
+			u8 rcpi[4];
+		} __packed, rssi);
 	} __packed;
 } __packed;
 
drivers/net/wireless/mediatek/mt76/mt7996/mt7996.h +1 -1
index 7a884311800e..b523e971f78c 100644
@@ -222,7 +222,6 @@ struct mt7996_sta_link {
 	struct mt7996_sta *sta;
 
 	struct list_head rc_list;
-	u32 airtime_ac[8];
 
 	int ack_signal;
 	struct ewma_avg_signal avg_ack_signal;
@@ -741,6 +740,7 @@ int mt7996_mcu_trigger_assert(struct mt7996_dev *dev);
 void mt7996_mcu_rx_event(struct mt7996_dev *dev, struct sk_buff *skb);
 void mt7996_mcu_exit(struct mt7996_dev *dev);
 int mt7996_mcu_get_all_sta_info(struct mt7996_phy *phy, u16 tag);
+int mt7996_mcu_get_per_sta_info(struct mt7996_phy *phy, u16 tag);
 int mt7996_mcu_wed_rro_reset_sessions(struct mt7996_dev *dev, u16 id);
 int mt7996_mcu_set_sniffer_mode(struct mt7996_phy *phy, bool enabled);
 
Signature · 1 line
2.43.0
#1 lore raw
kernel test robot noticed the following build errors:

Hi Joshua,

kernel test robot noticed the following build errors:

[auto build test ERROR on wireless/main]
[also build test ERROR on linus/master v7.0-rc7 next-20260406] [cannot apply to wireless-next/main]
[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/Joshua-Klinesmith/wifi-mt76-mt7996-replace-direct-WTBL-access-with-MCU-for-station-statistics/20260407-151612
base:   https://git.kernel.org/pub/scm/linux/kernel/git/wireless/wireless.git main
patch link:    https://lore.kernel.org/r/20260407053855.75828-1-joshuaklinesmith%40gmail.com
patch subject: [PATCH wireless v2] wifi: mt76: mt7996: replace direct WTBL access with MCU for station statistics
config: riscv-allmodconfig (https://download.01.org/0day-ci/archive/20260407/[email protected]/config)
compiler: clang version 23.0.0git (https://github.com/llvm/llvm-project c80443cd37b2e2788cba67ffa180a6331e5f0791)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260407/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>):

>> drivers/net/wireless/mediatek/mt76/mt7996/mcu.c:4870:10: error: incompatible pointer types assigning to 'struct mt76_vif_link *' from 'struct mt76_vif_data *' [-Wincompatible-pointer-types]
    4870 |                                 mvif = &msta_link->sta->vif->mt76;
         |                                      ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~

drivers/net/wireless/mediatek/mt76/mt7996/mcu.c:4871:35: error: no member named 'link' in 'struct mt76_vif_link'
4871 | mlink = rcu_dereference(mvif->link[wcid->link_id]);
| ~~~~ ^
drivers/net/wireless/mediatek/mt76/mt7996/mcu.c:4871:35: error: no member named 'link' in 'struct mt76_vif_link'
4871 | mlink = rcu_dereference(mvif->link[wcid->link_id]);
| ~~~~ ^
drivers/net/wireless/mediatek/mt76/mt7996/mcu.c:4871:35: error: no member named 'link' in 'struct mt76_vif_link'
4871 | mlink = rcu_dereference(mvif->link[wcid->link_id]);
| ~~~~ ^
drivers/net/wireless/mediatek/mt76/mt7996/mcu.c:4871:35: error: no member named 'link' in 'struct mt76_vif_link'
4871 | mlink = rcu_dereference(mvif->link[wcid->link_id]);
| ~~~~ ^
drivers/net/wireless/mediatek/mt76/mt7996/mcu.c:4871:35: error: no member named 'link' in 'struct mt76_vif_link'
4871 | mlink = rcu_dereference(mvif->link[wcid->link_id]);
| ~~~~ ^
drivers/net/wireless/mediatek/mt76/mt7996/mcu.c:4871:35: error: no member named 'link' in 'struct mt76_vif_link'
4871 | mlink = rcu_dereference(mvif->link[wcid->link_id]);
| ~~~~ ^
drivers/net/wireless/mediatek/mt76/mt7996/mcu.c:4871:35: error: no member named 'link' in 'struct mt76_vif_link'
4871 | mlink = rcu_dereference(mvif->link[wcid->link_id]);
| ~~~~ ^
drivers/net/wireless/mediatek/mt76/mt7996/mcu.c:4871:35: error: no member named 'link' in 'struct mt76_vif_link'
4871 | mlink = rcu_dereference(mvif->link[wcid->link_id]);
| ~~~~ ^
drivers/net/wireless/mediatek/mt76/mt7996/mcu.c:4871:35: error: no member named 'link' in 'struct mt76_vif_link'
4871 | mlink = rcu_dereference(mvif->link[wcid->link_id]);
| ~~~~ ^
drivers/net/wireless/mediatek/mt76/mt7996/mcu.c:4871:35: error: no member named 'link' in 'struct mt76_vif_link'
4871 | mlink = rcu_dereference(mvif->link[wcid->link_id]);
| ~~~~ ^
11 errors generated.

vim +4870 drivers/net/wireless/mediatek/mt76/mt7996/mcu.c

4786
4787 int mt7996_mcu_get_per_sta_info(struct mt7996_phy *phy, u16 tag)
4788 {
4789 struct mt7996_dev *dev = phy->dev;
4790 struct mt7996_mcu_per_sta_info_event *res;
4791 struct mt76_wcid *wcid;
4792 struct sk_buff *skb;
4793 int i, ret, sta_num, resp_sta_num;
4794 int wcid_idx = 0;
4795 struct {
4796 u8 _rsv1;
4797 u8 unsolicit;
4798 u8 _rsv2[2];
4799
4800 __le16 tag;
4801 __le16 len;
4802 __le16 sta_num;
4803 u8 _rsv3[2];
4804 __le16 wlan_idx[PER_STA_INFO_MAX_NUM];
4805 } __packed req = {
4806 .tag = cpu_to_le16(tag),
4807 .len = cpu_to_le16(sizeof(req) - 4),
4808 };
4809
4810 while (wcid_idx < mt7996_wtbl_size(dev)) {
4811 sta_num = 0;
4812
4813 rcu_read_lock();
4814 for (i = wcid_idx;
4815 i < mt7996_wtbl_size(dev) && sta_num < PER_STA_INFO_MAX_NUM;
4816 i++) {
4817 wcid = rcu_dereference(dev->mt76.wcid[i]);
4818 if (!wcid || !wcid->sta)
4819 continue;
4820 req.wlan_idx[sta_num++] = cpu_to_le16(i);
4821 }
4822 rcu_read_unlock();
4823 wcid_idx = i;
4824
4825 if (!sta_num)
4826 continue;
4827
4828 req.sta_num = cpu_to_le16(sta_num);
4829
4830 ret = mt76_mcu_send_and_get_msg(&dev->mt76,
4831 MCU_WM_UNI_CMD(PER_STA_INFO),
4832 &req, sizeof(req), true, &skb);
4833 if (ret)
4834 return ret;
4835
4836 res = (struct mt7996_mcu_per_sta_info_event *)skb->data;
4837
4838 resp_sta_num = le16_to_cpu(res->sta_num);
4839 if (resp_sta_num > sta_num ||
4840 skb->len < struct_size(res, rssi, resp_sta_num)) {
4841 dev_kfree_skb(skb);
4842 return -EINVAL;
4843 }
4844
4845 rcu_read_lock();
4846 for (i = 0; i < resp_sta_num; i++) {
4847 struct mt7996_sta_link *msta_link;
4848 struct mt76_vif_link *mvif;
4849 struct mt76_vif_link *mlink;
4850 struct mt76_phy *mphy;
4851 u16 wlan_idx;
4852 s8 rssi[4];
4853
4854 switch (tag) {
4855 case UNI_PER_STA_RSSI:
4856 wlan_idx = le16_to_cpu(res->rssi[i].wlan_idx);
4857 wcid = mt76_wcid_ptr(dev, wlan_idx);
4858 if (!wcid || !wcid->sta)
4859 break;
4860
4861 msta_link = container_of(wcid,
4862 struct mt7996_sta_link,
4863 wcid);
4864
4865 rssi[0] = (res->rssi[i].rcpi[0] - 220) / 2;
4866 rssi[1] = (res->rssi[i].rcpi[1] - 220) / 2;
4867 rssi[2] = (res->rssi[i].rcpi[2] - 220) / 2;
4868 rssi[3] = (res->rssi[i].rcpi[3] - 220) / 2;
4869

> 4870					mvif = &msta_link->sta->vif->mt76;

4871 mlink = rcu_dereference(mvif->link[wcid->link_id]);
4872 if (mlink) {
4873 mphy = mt76_vif_link_phy(mlink);
4874 if (mphy)
4875 msta_link->ack_signal =
4876 mt76_rx_signal(mphy->antenna_mask,
4877 rssi);
4878 }
4879
4880 ewma_avg_signal_add(&msta_link->avg_ack_signal,
4881 -msta_link->ack_signal);
4882 break;
4883 }
4884 }
4885 rcu_read_unlock();
4886
4887 dev_kfree_skb(skb);
4888 }
4889
4890 return 0;
4891 }
4892

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
#2 lore raw
In reply to Joshua Klinesmith
kernel test robot noticed the following build errors:

Hi Joshua,

kernel test robot noticed the following build errors:

[auto build test ERROR on wireless/main]
[also build test ERROR on linus/master v7.0-rc7 next-20260406] [cannot apply to wireless-next/main]
[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/Joshua-Klinesmith/wifi-mt76-mt7996-replace-direct-WTBL-access-with-MCU-for-station-statistics/20260407-151612
base:   https://git.kernel.org/pub/scm/linux/kernel/git/wireless/wireless.git main
patch link:    https://lore.kernel.org/r/20260407053855.75828-1-joshuaklinesmith%40gmail.com
patch subject: [PATCH wireless v2] wifi: mt76: mt7996: replace direct WTBL access with MCU for station statistics
config: loongarch-allmodconfig (https://download.01.org/0day-ci/archive/20260407/[email protected]/config)
compiler: clang version 19.1.7 (https://github.com/llvm/llvm-project cd708029e0b2869e80abe31ddb175f7c35361f90)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260407/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>):

>> drivers/net/wireless/mediatek/mt76/mt7996/mcu.c:4870:10: error: incompatible pointer types assigning to 'struct mt76_vif_link *' from 'struct mt76_vif_data *' [-Werror,-Wincompatible-pointer-types]
    4870 |                                 mvif = &msta_link->sta->vif->mt76;
         |                                      ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~
>> drivers/net/wireless/mediatek/mt76/mt7996/mcu.c:4871:35: error: no member named 'link' in 'struct mt76_vif_link'
    4871 |                                 mlink = rcu_dereference(mvif->link[wcid->link_id]);
         |                                                         ~~~~  ^
   include/linux/rcupdate.h:752:50: note: expanded from macro 'rcu_dereference'
     752 | #define rcu_dereference(p) rcu_dereference_check(p, 0)
         |                                                  ^
   include/linux/rcupdate.h:662:27: note: expanded from macro 'rcu_dereference_check'
     662 |         __rcu_dereference_check((p), __UNIQUE_ID(rcu), \
         |                                  ^
   include/linux/rcupdate.h:514:10: note: expanded from macro '__rcu_dereference_check'
     514 |         typeof(*p) *local = (typeof(*p) *__force)READ_ONCE(p); \
         |                 ^
>> drivers/net/wireless/mediatek/mt76/mt7996/mcu.c:4871:35: error: no member named 'link' in 'struct mt76_vif_link'
    4871 |                                 mlink = rcu_dereference(mvif->link[wcid->link_id]);
         |                                                         ~~~~  ^
   include/linux/rcupdate.h:752:50: note: expanded from macro 'rcu_dereference'
     752 | #define rcu_dereference(p) rcu_dereference_check(p, 0)
         |                                                  ^
   include/linux/rcupdate.h:662:27: note: expanded from macro 'rcu_dereference_check'
     662 |         __rcu_dereference_check((p), __UNIQUE_ID(rcu), \
         |                                  ^
   include/linux/rcupdate.h:514:31: note: expanded from macro '__rcu_dereference_check'
     514 |         typeof(*p) *local = (typeof(*p) *__force)READ_ONCE(p); \
         |                                      ^
>> drivers/net/wireless/mediatek/mt76/mt7996/mcu.c:4871:35: error: no member named 'link' in 'struct mt76_vif_link'
    4871 |                                 mlink = rcu_dereference(mvif->link[wcid->link_id]);
         |                                                         ~~~~  ^
   include/linux/rcupdate.h:752:50: note: expanded from macro 'rcu_dereference'
     752 | #define rcu_dereference(p) rcu_dereference_check(p, 0)
         |                                                  ^
   include/linux/rcupdate.h:662:27: note: expanded from macro 'rcu_dereference_check'
     662 |         __rcu_dereference_check((p), __UNIQUE_ID(rcu), \
         |                                  ^
   include/linux/rcupdate.h:514:53: note: expanded from macro '__rcu_dereference_check'
     514 |         typeof(*p) *local = (typeof(*p) *__force)READ_ONCE(p); \
         |                                                            ^
   note: (skipping 3 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
   include/linux/compiler_types.h:706:22: note: expanded from macro 'compiletime_assert'
     706 |         _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
         |                             ^~~~~~~~~
   include/linux/compiler_types.h:694:23: note: expanded from macro '_compiletime_assert'
     694 |         __compiletime_assert(condition, msg, prefix, suffix)
         |                              ^~~~~~~~~
   include/linux/compiler_types.h:686:9: note: expanded from macro '__compiletime_assert'
     686 |                 if (!(condition))                                       \
         |                       ^~~~~~~~~
>> drivers/net/wireless/mediatek/mt76/mt7996/mcu.c:4871:35: error: no member named 'link' in 'struct mt76_vif_link'
    4871 |                                 mlink = rcu_dereference(mvif->link[wcid->link_id]);
         |                                                         ~~~~  ^
   include/linux/rcupdate.h:752:50: note: expanded from macro 'rcu_dereference'
     752 | #define rcu_dereference(p) rcu_dereference_check(p, 0)
         |                                                  ^
   include/linux/rcupdate.h:662:27: note: expanded from macro 'rcu_dereference_check'
     662 |         __rcu_dereference_check((p), __UNIQUE_ID(rcu), \
         |                                  ^
   include/linux/rcupdate.h:514:53: note: expanded from macro '__rcu_dereference_check'
     514 |         typeof(*p) *local = (typeof(*p) *__force)READ_ONCE(p); \
         |                                                            ^
   note: (skipping 3 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
   include/linux/compiler_types.h:706:22: note: expanded from macro 'compiletime_assert'
     706 |         _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
         |                             ^~~~~~~~~
   include/linux/compiler_types.h:694:23: note: expanded from macro '_compiletime_assert'
     694 |         __compiletime_assert(condition, msg, prefix, suffix)
         |                              ^~~~~~~~~
   include/linux/compiler_types.h:686:9: note: expanded from macro '__compiletime_assert'
     686 |                 if (!(condition))                                       \
         |                       ^~~~~~~~~
>> drivers/net/wireless/mediatek/mt76/mt7996/mcu.c:4871:35: error: no member named 'link' in 'struct mt76_vif_link'
    4871 |                                 mlink = rcu_dereference(mvif->link[wcid->link_id]);
         |                                                         ~~~~  ^
   include/linux/rcupdate.h:752:50: note: expanded from macro 'rcu_dereference'
     752 | #define rcu_dereference(p) rcu_dereference_check(p, 0)
         |                                                  ^
   include/linux/rcupdate.h:662:27: note: expanded from macro 'rcu_dereference_check'
     662 |         __rcu_dereference_check((p), __UNIQUE_ID(rcu), \
         |                                  ^
   include/linux/rcupdate.h:514:53: note: expanded from macro '__rcu_dereference_check'
     514 |         typeof(*p) *local = (typeof(*p) *__force)READ_ONCE(p); \
         |                                                            ^
   note: (skipping 3 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
   include/linux/compiler_types.h:706:22: note: expanded from macro 'compiletime_assert'
     706 |         _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
         |                             ^~~~~~~~~
   include/linux/compiler_types.h:694:23: note: expanded from macro '_compiletime_assert'
     694 |         __compiletime_assert(condition, msg, prefix, suffix)
         |                              ^~~~~~~~~
   include/linux/compiler_types.h:686:9: note: expanded from macro '__compiletime_assert'
     686 |                 if (!(condition))                                       \
         |                       ^~~~~~~~~
>> drivers/net/wireless/mediatek/mt76/mt7996/mcu.c:4871:35: error: no member named 'link' in 'struct mt76_vif_link'
    4871 |                                 mlink = rcu_dereference(mvif->link[wcid->link_id]);
         |                                                         ~~~~  ^
   include/linux/rcupdate.h:752:50: note: expanded from macro 'rcu_dereference'
     752 | #define rcu_dereference(p) rcu_dereference_check(p, 0)
         |                                                  ^
   include/linux/rcupdate.h:662:27: note: expanded from macro 'rcu_dereference_check'
     662 |         __rcu_dereference_check((p), __UNIQUE_ID(rcu), \
         |                                  ^
   include/linux/rcupdate.h:514:53: note: expanded from macro '__rcu_dereference_check'
     514 |         typeof(*p) *local = (typeof(*p) *__force)READ_ONCE(p); \
         |                                                            ^
   note: (skipping 3 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
   include/linux/compiler_types.h:706:22: note: expanded from macro 'compiletime_assert'
     706 |         _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
         |                             ^~~~~~~~~
   include/linux/compiler_types.h:694:23: note: expanded from macro '_compiletime_assert'
     694 |         __compiletime_assert(condition, msg, prefix, suffix)
         |                              ^~~~~~~~~
   include/linux/compiler_types.h:686:9: note: expanded from macro '__compiletime_assert'
     686 |                 if (!(condition))                                       \
         |                       ^~~~~~~~~
>> drivers/net/wireless/mediatek/mt76/mt7996/mcu.c:4871:35: error: no member named 'link' in 'struct mt76_vif_link'
    4871 |                                 mlink = rcu_dereference(mvif->link[wcid->link_id]);
         |                                                         ~~~~  ^
   include/linux/rcupdate.h:752:50: note: expanded from macro 'rcu_dereference'
     752 | #define rcu_dereference(p) rcu_dereference_check(p, 0)
         |                                                  ^
   include/linux/rcupdate.h:662:27: note: expanded from macro 'rcu_dereference_check'
     662 |         __rcu_dereference_check((p), __UNIQUE_ID(rcu), \
         |                                  ^
   include/linux/rcupdate.h:514:53: note: expanded from macro '__rcu_dereference_check'
     514 |         typeof(*p) *local = (typeof(*p) *__force)READ_ONCE(p); \
         |                                                            ^
   note: (skipping 2 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
   include/linux/compiler_types.h:706:22: note: expanded from macro 'compiletime_assert'
     706 |         _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
         |                             ^~~~~~~~~
   include/linux/compiler_types.h:694:23: note: expanded from macro '_compiletime_assert'
     694 |         __compiletime_assert(condition, msg, prefix, suffix)
         |                              ^~~~~~~~~
   include/linux/compiler_types.h:686:9: note: expanded from macro '__compiletime_assert'
     686 |                 if (!(condition))                                       \
         |                       ^~~~~~~~~
>> drivers/net/wireless/mediatek/mt76/mt7996/mcu.c:4871:35: error: no member named 'link' in 'struct mt76_vif_link'
    4871 |                                 mlink = rcu_dereference(mvif->link[wcid->link_id]);
         |                                                         ~~~~  ^
   include/linux/rcupdate.h:752:50: note: expanded from macro 'rcu_dereference'
     752 | #define rcu_dereference(p) rcu_dereference_check(p, 0)
         |                                                  ^
   include/linux/rcupdate.h:662:27: note: expanded from macro 'rcu_dereference_check'
     662 |         __rcu_dereference_check((p), __UNIQUE_ID(rcu), \
         |                                  ^
   include/linux/rcupdate.h:514:53: note: expanded from macro '__rcu_dereference_check'
     514 |         typeof(*p) *local = (typeof(*p) *__force)READ_ONCE(p); \
         |                                                            ^
   include/asm-generic/rwonce.h:50:14: note: expanded from macro 'READ_ONCE'
      50 |         __READ_ONCE(x);                                                 \
         |                     ^
   include/asm-generic/rwonce.h:44:65: note: expanded from macro '__READ_ONCE'
      44 | #define __READ_ONCE(x)  (*(const volatile __unqual_scalar_typeof(x) *)&(x))
         |                                                                  ^
   include/linux/compiler_types.h:642:53: note: expanded from macro '__unqual_scalar_typeof'
     642 | #define __unqual_scalar_typeof(x) __typeof_unqual__(x)
         |                                                     ^
>> drivers/net/wireless/mediatek/mt76/mt7996/mcu.c:4871:35: error: no member named 'link' in 'struct mt76_vif_link'
    4871 |                                 mlink = rcu_dereference(mvif->link[wcid->link_id]);
         |                                                         ~~~~  ^
   include/linux/rcupdate.h:752:50: note: expanded from macro 'rcu_dereference'
     752 | #define rcu_dereference(p) rcu_dereference_check(p, 0)
         |                                                  ^
   include/linux/rcupdate.h:662:27: note: expanded from macro 'rcu_dereference_check'
     662 |         __rcu_dereference_check((p), __UNIQUE_ID(rcu), \
         |                                  ^
   include/linux/rcupdate.h:514:53: note: expanded from macro '__rcu_dereference_check'
     514 |         typeof(*p) *local = (typeof(*p) *__force)READ_ONCE(p); \
         |                                                            ^
   include/asm-generic/rwonce.h:50:14: note: expanded from macro 'READ_ONCE'
      50 |         __READ_ONCE(x);                                                 \
         |                     ^
   include/asm-generic/rwonce.h:44:72: note: expanded from macro '__READ_ONCE'
      44 | #define __READ_ONCE(x)  (*(const volatile __unqual_scalar_typeof(x) *)&(x))
         |                                                                         ^
>> drivers/net/wireless/mediatek/mt76/mt7996/mcu.c:4871:35: error: no member named 'link' in 'struct mt76_vif_link'
    4871 |                                 mlink = rcu_dereference(mvif->link[wcid->link_id]);
         |                                                         ~~~~  ^
   include/linux/rcupdate.h:752:50: note: expanded from macro 'rcu_dereference'
     752 | #define rcu_dereference(p) rcu_dereference_check(p, 0)
         |                                                  ^
   include/linux/rcupdate.h:662:27: note: expanded from macro 'rcu_dereference_check'
     662 |         __rcu_dereference_check((p), __UNIQUE_ID(rcu), \
         |                                  ^
   include/linux/rcupdate.h:517:12: note: expanded from macro '__rcu_dereference_check'
     517 |         ((typeof(*p) __force __kernel *)(local)); \
         |                   ^
>> drivers/net/wireless/mediatek/mt76/mt7996/mcu.c:4871:11: error: assigning to 'struct mt76_vif_link *' from incompatible type 'void'
    4871 |                                 mlink = rcu_dereference(mvif->link[wcid->link_id]);
         |                                       ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

12 errors generated.

vim +4870 drivers/net/wireless/mediatek/mt76/mt7996/mcu.c

4786
4787 int mt7996_mcu_get_per_sta_info(struct mt7996_phy *phy, u16 tag)
4788 {
4789 struct mt7996_dev *dev = phy->dev;
4790 struct mt7996_mcu_per_sta_info_event *res;
4791 struct mt76_wcid *wcid;
4792 struct sk_buff *skb;
4793 int i, ret, sta_num, resp_sta_num;
4794 int wcid_idx = 0;
4795 struct {
4796 u8 _rsv1;
4797 u8 unsolicit;
4798 u8 _rsv2[2];
4799
4800 __le16 tag;
4801 __le16 len;
4802 __le16 sta_num;
4803 u8 _rsv3[2];
4804 __le16 wlan_idx[PER_STA_INFO_MAX_NUM];
4805 } __packed req = {
4806 .tag = cpu_to_le16(tag),
4807 .len = cpu_to_le16(sizeof(req) - 4),
4808 };
4809
4810 while (wcid_idx < mt7996_wtbl_size(dev)) {
4811 sta_num = 0;
4812
4813 rcu_read_lock();
4814 for (i = wcid_idx;
4815 i < mt7996_wtbl_size(dev) && sta_num < PER_STA_INFO_MAX_NUM;
4816 i++) {
4817 wcid = rcu_dereference(dev->mt76.wcid[i]);
4818 if (!wcid || !wcid->sta)
4819 continue;
4820 req.wlan_idx[sta_num++] = cpu_to_le16(i);
4821 }
4822 rcu_read_unlock();
4823 wcid_idx = i;
4824
4825 if (!sta_num)
4826 continue;
4827
4828 req.sta_num = cpu_to_le16(sta_num);
4829
4830 ret = mt76_mcu_send_and_get_msg(&dev->mt76,
4831 MCU_WM_UNI_CMD(PER_STA_INFO),
4832 &req, sizeof(req), true, &skb);
4833 if (ret)
4834 return ret;
4835
4836 res = (struct mt7996_mcu_per_sta_info_event *)skb->data;
4837
4838 resp_sta_num = le16_to_cpu(res->sta_num);
4839 if (resp_sta_num > sta_num ||
4840 skb->len < struct_size(res, rssi, resp_sta_num)) {
4841 dev_kfree_skb(skb);
4842 return -EINVAL;
4843 }
4844
4845 rcu_read_lock();
4846 for (i = 0; i < resp_sta_num; i++) {
4847 struct mt7996_sta_link *msta_link;
4848 struct mt76_vif_link *mvif;
4849 struct mt76_vif_link *mlink;
4850 struct mt76_phy *mphy;
4851 u16 wlan_idx;
4852 s8 rssi[4];
4853
4854 switch (tag) {
4855 case UNI_PER_STA_RSSI:
4856 wlan_idx = le16_to_cpu(res->rssi[i].wlan_idx);
4857 wcid = mt76_wcid_ptr(dev, wlan_idx);
4858 if (!wcid || !wcid->sta)
4859 break;
4860
4861 msta_link = container_of(wcid,
4862 struct mt7996_sta_link,
4863 wcid);
4864
4865 rssi[0] = (res->rssi[i].rcpi[0] - 220) / 2;
4866 rssi[1] = (res->rssi[i].rcpi[1] - 220) / 2;
4867 rssi[2] = (res->rssi[i].rcpi[2] - 220) / 2;
4868 rssi[3] = (res->rssi[i].rcpi[3] - 220) / 2;
4869

> 4870					mvif = &msta_link->sta->vif->mt76;
> 4871					mlink = rcu_dereference(mvif->link[wcid->link_id]);

4872 if (mlink) {
4873 mphy = mt76_vif_link_phy(mlink);
4874 if (mphy)
4875 msta_link->ack_signal =
4876 mt76_rx_signal(mphy->antenna_mask,
4877 rssi);
4878 }
4879
4880 ewma_avg_signal_add(&msta_link->avg_ack_signal,
4881 -msta_link->ack_signal);
4882 break;
4883 }
4884 }
4885 rcu_read_unlock();
4886
4887 dev_kfree_skb(skb);
4888 }
4889
4890 return 0;
4891 }
4892

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki