Skip to contentSkip to conversation

wifi: mt76: mt7928: Add debugfs for stats to provide debug purpose

PATCH Superseded Eason Lai 5 participants 18 messages Aug 24 – Nov 17

Subsystems (2)
lore
Share & tools
lore

Eason Lai

author
#0 lore raw

PATCH 1/1 wifi: mt76: mt7928: Add debugfs for stats to provide debug purpose

From: Michael Shih <[email protected]>

Usage:
(1) Connect STA to AP (You can use dhclient CMD to ask for DHCP IP, to use ping to AP)

    DHCP IP CMD:  dhclient ${WLAN_IF} -v

Example: dhclient wlan0 -v

## (To simulate traffic) Ping 10 packets for every second to AP ping 192.168.0.XXX -i0.1

(2) (Get stats) Use command, phyX is your WiFi interface:

     cat /sys/kernel/debug/ieee80211/phyX/mt76/stats

(3) You will see below stats info:
(STA) connected AP MAC Address = a8:42:a1:46:c4:6b
BssIdx = [0]
StaRecIdx = [1],
RSSI = -25
Link_Speed = 2402000 (kbit/s)
temperature = 40
Tx success = 716
Tx fail to Rcv ACK after retry = 0
Rx Mpdu = 23
Rx Fcs Error = 1 (MPDU)
Rx FIFO full = 0 (MPDU)
TRX_AGG_RANGE[0] = 0 (PPDU) TRX_AGG_RANGE[1] = 0 (PPDU) TRX_AGG_RANGE[2] = 0 (PPDU) TRX_AGG_RANGE[3] = 0 (PPDU) TRX_AGG_RANGE[4] = 0 (PPDU) TRX_AGG_RANGE[5] = 0 (PPDU) TRX_AGG_RANGE[6] = 0 (PPDU) TRX_AGG_RANGE[7] = 0 (PPDU)
MPDUs in AMPDUs transmitted = 0 (MPDU) MPDUs in AMPDUs transmitted with ACK reply = 0 (MPDU) rate1_tx_cnt = 714
rate1_fail_cnt = 223
train_up = 2310
train_down = 3080
is_force_tx_stream = 0
is_force_se_off = 0
max_ampdu_factor = 9
tx_rate_up_penalty = 0
low_traffic_mode = 2
low_traffic_count = 0 low_traffic_dashboard = 3 dynamic_sgi_state = 0
dynamic_sgi_score = 2
dynamic_bw_state = 0 dynamic_gband_256qam_state = 3 vht_non_sp_rate_state = 0
Last TX Rate = 24M, BW20, OFDM, BCC, SPE24 Chip Out TX Power = +16.5 dBm
Cur Rate Index = 0
Rate index[0] --> NSS2_MCS11, BW160/BW8080, SGI, HE_SU, LDPC

Rate index[1]        NSS2_MCS9, BW160/BW8080, SGI, HE_SU, LDPC
Rate index[2]        NSS2_MCS7, BW160/BW8080, SGI, HE_SU, LDPC
Rate index[3]        NSS2_MCS4, BW160/BW8080, SGI, HE_SU, LDPC
Rate index[4]        NSS2_MCS3, BW160/BW8080, SGI, HE_SU, LDPC
Rate index[5]        NSS1_MCS2, BW160/BW8080, SGI, HE_SU, LDPC
Rate index[6]        NSS1_MCS1, BW80, SGI, HE_SU, LDPC
Rate index[7]        NSS1_MCS0, BW80, SGI, HE_SU, LDPC

mib state:
=== Rx Related Counters ===
Rx with CRC = 24020 (MPDU)
Rx drop due to out of resource = 0 (MPDU) Rx Mpdu = 93223 (MPDU)
Rx AMpdu = 668 (PPDU)
Rx PF Drop = 0 (MPDU)
Rx Len Mismatch = 5853 (PPDU)

=== Phy/Timing Related Counters ===

                        ChannelIdleCnt = 1040434
                        CCA_NAV_Tx_Time = 18510036
                        Rx_MDRDY_CNT = 166580 (PPDU)
                        CCK_MDRDY = 7782
                        OFDM_MDRDY = 11912731
                        OFDM_GREEN_MDRDY = 0
                        Prim CCA Time = 17917650
                        Sec CCA Time = 14922034
                        Prim ED Time = 5677528

=== Tx Related Counters(Generic) ===

                        BeaconTxCnt = 0
                        Tx 40MHz Cnt = 279  (MPDU)
                        Tx 80MHz Cnt = 44  (MPDU)
                        Tx 160MHz Cnt = 712  (MPDU)

=== BSSID[0] Related Counters ===
BA Miss Cnt = 210 (PPDU) RTS Tx Cnt = 1003 (MPDU) Frame Retry Cnt = 239 (MPDU) Frame Retry 2 Cnt = 71 (MPDU) RTS Retry Cnt = 152 (MPDU) Ack Failed Cnt = 319 (PPDU)

=== AMPDU Related Counters ===

                        Tx AMPDU_Pkt_Cnt = 705  (PPDU)
                        Tx AMPDU_MPDU_Pkt_Cnt = 713  (MPDU)
                        AMPDU Tx success = 503 (MPDU)
                        AMPDU Tx fail count   = 210  (MPDU), PER=29.4%
---
 .../wireless/mediatek/mt76/mt76_connac_mcu.h  |  177 +++
 .../wireless/mediatek/mt76/mt7925/Makefile    |    2 +-
 .../wireless/mediatek/mt76/mt7925/debugfs.c   | 1054 +++++++++++++++++
 .../net/wireless/mediatek/mt76/mt7925/stats.c |  585 +++++++++
 .../net/wireless/mediatek/mt76/mt7925/stats.h |  305 +++++
 5 files changed, 2122 insertions(+), 1 deletion(-)
 create mode 100644 drivers/net/wireless/mediatek/mt76/mt7925/stats.c
 create mode 100644 drivers/net/wireless/mediatek/mt76/mt7925/stats.h
drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h +177 -0
index 0ededa569e9a..72cc69750f47 100644
@@ -1483,6 +1483,183 @@ enum {
 	MT_NIC_CAP_EML_CAP = 0x22,
 };
 
+enum {
+	UNI_CMD_ID_STATISTICS_BASIC = 0,
+	UNI_CMD_ID_STATISTICS_LINK_QUALITY = 1,
+	UNI_CMD_ID_STATISTICS_STA = 2,
+	UNI_CMD_ID_STATISTICS_BUG_REPORT = 3,
+	UNI_CMD_ID_STATISTICS_TX_STATS = 4,
+	UNI_CMD_ID_STATISTICS_ALL_STATS = 5,
+	UNI_CMD_ID_STATISTICS_EML_STATS = 6,
+	UNI_CMD_ID_STATISTICS_REGULAR_STATS = 7,
+	UNI_CMD_ID_STATISTICS_BSS_LINK_QUALITY = 8,
+	UNI_CMD_ID_STATISTICS_ML_CHNL_COND = 9,
+	UNI_CMD_ID_STATISTICS_WTBL = 10,
+	UNI_CMD_ID_STATISTICS_LINK_LAYER_STATS = 128,
+	UNI_CMD_ID_STATISTICS_PPDU_LATENCY = 129,
+	UNI_CMD_ID_STATISTICS_CURRENT_TX_RATE = 130,
+	UNI_CMD_ID_STATISTICS_SET_TX_BITRATE_MONITOR = 131,
+	UNI_CMD_ID_STATISTICS_GET_PREDICT_TX_BITRATE = 132,
+	UNI_CMD_ID_STATISTICS_SET_ATPS_TYPE_RATE_MODE = 133,
+	UNI_CMD_ID_STATISTICS_SET_BEACON_REPORT = 134,
+	UNI_CMD_ID_STATISTICS_BSS_CURRENT_TX_RATE = 135,
+	UNI_CMD_ID_STATISTICS_GET_BSS_PREDICT_TX_BITRATE = 136,
+	UNI_CMD_ID_STATISTICS_MAX_NUM
+};
+
+enum {
+	UNI_CMD_MIB_DATA,
+};
+
+enum mt7925_mib_counter {
+	UNI_CMD_MIB_CNT_RX_FCS_ERR = 0,
+	UNI_CMD_MIB_CNT_RX_FIFO_OVERFLOW = 1,
+	UNI_CMD_MIB_CNT_RX_MPDU = 2,
+	UNI_CMD_MIB_CNT_AMPDU_RX_COUNT = 3,
+	UNI_CMD_MIB_CNT_RX_TOTAL_BYTE = 4,
+	UNI_CMD_MIB_CNT_RX_VALID_AMPDU_SF = 5,
+	UNI_CMD_MIB_CNT_RX_VALID_BYTE = 6,
+	UNI_CMD_MIB_CNT_CHANNEL_IDLE = 7,
+	UNI_CMD_MIB_CNT_VEC_DROP = 8,
+	UNI_CMD_MIB_CNT_DELIMITER_FAIL = 9,
+	UNI_CMD_MIB_CNT_VEC_MISMATCH = 10,
+	UNI_CMD_MIB_CNT_MDRDY = 11,
+	UNI_CMD_MIB_CNT_RX_CCK_MDRDY_TIME = 12,
+	UNI_CMD_MIB_CNT_RX_OFDM_LG_MIXED_MDRDY_TIME = 13,
+	UNI_CMD_MIB_CNT_RX_OFDM_GREEN_MDRDY_TIME = 14,
+	UNI_CMD_MIB_CNT_PF_DROP = 15,
+	UNI_CMD_MIB_CNT_LEN_MISMATCH = 16,
+	UNI_CMD_MIB_CNT_P_CCA_TIME = 17,
+	UNI_CMD_MIB_CNT_S_CCA_TIME = 18,
+	UNI_CMD_MIB_CNT_CCA_NAV_TX_TIME = 19,
+	UNI_CMD_MIB_CNT_P_ED_TIME = 20,
+	UNI_CMD_MIB_CNT_BCN_TX = 21,
+	UNI_CMD_MIB_CNT_TX_BW_20MHZ = 22,
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MIB_CNT_BSS3_FRAME_RETRY_2 = 80,
+	UNI_CMD_MIB_CNT_RX_A1_SEARCH = 81,
+	UNI_CMD_MIB_CNT_RX_DROP_MPDU = 82,
+	UNI_CMD_MIB_CNT_RX_UNWANTED = 83,
+	UNI_CMD_MIB_CNT_RX_FCS_OK = 84,
+	UNI_CMD_MIB_CNT_SU_TX_OK = 85,
+	UNI_CMD_MIB_CNT_TX_FULL_BW = 86,
+	UNI_CMD_MIB_CNT_TX_AUTO_BW = 87,
+	UNI_CMD_MIB_CNT_CCA_SAMPLE_IDLE = 88,
+	UNI_CMD_MIB_CNT_CCA_SAMPLE_ACTIVE = 89,
+	UNI_CMD_MIB_CNT_CCA_TIME = 90,
+	UNI_CMD_MIB_CNT_S_20BW_CCA_TIME = 91,
+	UNI_CMD_MIB_CNT_S_40BW_CCA_TIME = 92,
+	UNI_CMD_MIB_CNT_S_80BW_CCA_TIME = 93,
+	UNI_CMD_MIB_CNT_S_160BW_CCA_TIME = 94,
+	UNI_CMD_MIB_CNT_S_P20BW_0_ED_TIME = 95,
+	UNI_CMD_MIB_CNT_S_P20BW_1_ED_TIME = 96,
+	UNI_CMD_MIB_CNT_S_P20BW_2_ED_TIME = 97,
+	UNI_CMD_MIB_CNT_S_P20BW_3_ED_TIME = 98,
+	UNI_CMD_MIB_CNT_S_P20BW_4_ED_TIME = 99,
+	UNI_CMD_MIB_CNT_S_P20BW_5_ED_TIME = 100,
+	UNI_CMD_MIB_CNT_S_P20BW_6_ED_TIME = 101,
+	UNI_CMD_MIB_CNT_S_P20BW_7_ED_TIME = 102,
+	UNI_CMD_MIB_CNT_S_P20BW_8_ED_TIME = 103,
+	UNI_CMD_MIB_CNT_S_P20BW_9_ED_TIME = 104,
+	UNI_CMD_MIB_CNT_S_P20BW_10_ED_TIME = 105,
+	UNI_CMD_MIB_CNT_S_P20BW_11_ED_TIME = 106,
+	UNI_CMD_MIB_CNT_S_P20BW_12_ED_TIME = 107,
+	UNI_CMD_MIB_CNT_S_P20BW_13_ED_TIME = 108,
+	UNI_CMD_MIB_CNT_S_P20BW_14_ED_TIME = 109,
+	UNI_CMD_MIB_CNT_S_P20BW_15_ED_TIME = 110,
+	UNI_CMD_MIB_CNT_TX_BW_320MHZ = 111,
+	UNI_CMD_MIB_CNT_TX_DDLMT_RNG0 = 112, /* Rng0~Rng4 112~116 */
+	UNI_CMD_MIB_CNT_BSS0_FRAME_RETRY_3 = 117, /* 117~120 */
+	UNI_CMD_MIB_CNT_BSS0_TX = 121, /* 121~124 */
+	UNI_CMD_MIB_CNT_BSS0_TX_DATA = 125, /* 125~128 */
+	UNI_CMD_MIB_CNT_BSS0_TX_BYTE = 129, /* 129~132 */
+	UNI_CMD_MIB_CNT_RX_OK_BSS0 = 133, /* 133~136 */
+	UNI_CMD_MIB_CNT_RX_BYTE_BSS0 = 137, /* 137~140 */
+	UNI_CMD_MIB_CNT_RX_DATA_BSS0 = 141, /* 141~144 */
+	UNI_CMD_MIB_CNT_MBSS0_TX_OK = 145, /* 145~160 */
+	UNI_CMD_MIB_CNT_MBSS0_TX_BYTE = 161, /* 161~176 */
+	UNI_CMD_MIB_CNT_RX_OK_MBSS0 = 177, /* 177~192 */
+	UNI_CMD_MIB_CNT_RX_BYTE_MBSS0 = 193, /* 193~208 */
+	UNI_CMD_MIB_CNT_AMPDU = 209,
+	UNI_CMD_MIB_CNT_AMPDU_MPDU = 210,
+	UNI_CMD_MIB_CNT_AMPDU_ACKED = 211,
+	UNI_CMD_MIB_CNT_MAX_NUM
+};
+
+enum ENUM_UNI_CMD_GET_STATISTICS_TAG {
+	UNI_CMD_GET_STATISTICS_TAG_BASIC = 0,
+	UNI_CMD_GET_STATISTICS_TAG_LINK_QUALITY = 1,
+	UNI_CMD_GET_STATISTICS_TAG_STA = 2,
+	UNI_CMD_GET_STATISTICS_TAG_BUG_REPORT = 3,
+	UNI_CMD_GET_STATISTICS_TAG_EML_STATS = 6,
+	UNI_CMD_GET_STATISTICS_TAG_REGULAR_STATS = 7,
+	UNI_CMD_GET_STATISTICS_TAG_BSS_LINK_QUALITY = 8,
+	UNI_CMD_GET_STATISTICS_TAG_GET_ML_CHNL_COND = 9,
+	UNI_CMD_GET_STATISTICS_TAG_STAT_WTBL = 10,
+	UNI_CMD_GET_STATISTICS_TAG_LINK_LAYER_STATS = 0x80,
+	UNI_CMD_GET_STATISTICS_TAG_PPDU_LATENCY,
+	UNI_CMD_GET_STATISTICS_TAG_CURRENT_TX_RATE,
+	UNI_CMD_GET_STATISTICS_TAG_BEACON_REPORT = 0x86,
+	UNI_CMD_GET_STATISTICS_TAG_BSS_CURRENT_TX_RATE = 0x87,
+	UNI_CMD_GET_STATISTICS_TAG_BSS_PRED_TX_BITRATE = 0x88,
+};
+
 #define UNI_WOW_DETECT_TYPE_MAGIC		BIT(0)
 #define UNI_WOW_DETECT_TYPE_ANY			BIT(1)
 #define UNI_WOW_DETECT_TYPE_DISCONNECT		BIT(2)
drivers/net/wireless/mediatek/mt76/mt7925/Makefile +1 -1
index f9dcc0bba393..3863a89b8974 100644
@@ -4,7 +4,7 @@ obj-$(CONFIG_MT7925_COMMON) += mt7925-common.o
 obj-$(CONFIG_MT7925E) += mt7925e.o
 obj-$(CONFIG_MT7925U) += mt7925u.o
 
-mt7925-common-y := mac.o mcu.o regd.o main.o init.o debugfs.o nan.o
+mt7925-common-y := mac.o mcu.o regd.o main.o init.o debugfs.o nan.o stats.o
 mt7925-common-$(CONFIG_NL80211_TESTMODE) += testmode.o
 mt7925e-y := pci.o pci_mac.o pci_mcu.o
 mt7925u-y := usb.o
drivers/net/wireless/mediatek/mt76/mt7925/debugfs.c +1054 -0

1,071 lines not on this page · raw message

drivers/net/wireless/mediatek/mt76/mt7925/stats.c new file +585 -0

585 lines not on this page · raw message

drivers/net/wireless/mediatek/mt76/mt7925/stats.h new file +305 -0

305 lines not on this page · raw message

Signature · 1 line
2.45.2
#1 lore raw
kernel test robot noticed the following build errors:

Hi Eason,

kernel test robot noticed the following build errors:

[auto build test ERROR on wireless-next/main]
[also build test ERROR on linus/master next-20260821] [cannot apply to wireless/main v7.2]
[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/Eason-Lai/wifi-mt76-mt7928-Add-debugfs-for-stats-to-provide-debug-purpose/20260824-110746
base:   https://git.kernel.org/pub/scm/linux/kernel/git/wireless/wireless-next.git main
patch link:    https://lore.kernel.org/r/20260824030746.60706-1-eason.lai%40mediatek.com
patch subject: [PATCH v1] wifi: mt76: mt7928: Add debugfs for stats to provide debug purpose
config: nios2-allmodconfig (https://download.01.org/0day-ci/archive/20260825/[email protected]/config)
compiler: nios2-linux-gcc (GCC) 11.5.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260825/[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 error/warnings (new ones prefixed by >>):

drivers/net/wireless/mediatek/mt76/mt7925/debugfs.c: In function 'mt7925_fixedrate_set':

>> drivers/net/wireless/mediatek/mt76/mt7925/debugfs.c:312:16: error: variable 'rate' has initializer but incomplete type
     312 |         struct mt7925_ra_fixed_rate_v1 rate = {};
         |                ^~~~~~~~~~~~~~~~~~~~~~~
>> drivers/net/wireless/mediatek/mt76/mt7925/debugfs.c:312:40: error: storage size of 'rate' isn't known
     312 |         struct mt7925_ra_fixed_rate_v1 rate = {};
         |                                        ^~~~
>> drivers/net/wireless/mediatek/mt76/mt7925/debugfs.c:314:12: error: 'struct mt792x_dev' has no member named 'fixed_rate'
     314 |         dev->fixed_rate = val;
         |            ^~
>> drivers/net/wireless/mediatek/mt76/mt7925/debugfs.c:329:9: error: implicit declaration of function 'mt7925_mcu_set_fixed_rate'; did you mean 'mt7925_mcu_get_rx_rate'? [-Werror=implicit-function-declaration]
     329 |         mt7925_mcu_set_fixed_rate(dev, &rate);
         |         ^~~~~~~~~~~~~~~~~~~~~~~~~
         |         mt7925_mcu_get_rx_rate
>> drivers/net/wireless/mediatek/mt76/mt7925/debugfs.c:312:40: warning: unused variable 'rate' [-Wunused-variable]
     312 |         struct mt7925_ra_fixed_rate_v1 rate = {};
         |                                        ^~~~
   drivers/net/wireless/mediatek/mt76/mt7925/debugfs.c: In function 'mt7925_fixedrate_get':
   drivers/net/wireless/mediatek/mt76/mt7925/debugfs.c:340:19: error: 'struct mt792x_dev' has no member named 'fixed_rate'
     340 |         *val = dev->fixed_rate;
         |                   ^~
   drivers/net/wireless/mediatek/mt76/mt7925/debugfs.c: In function 'mt7925_autorate_set':
>> drivers/net/wireless/mediatek/mt76/mt7925/debugfs.c:364:12: error: 'struct mt792x_dev' has no member named 'auto_rate'
     364 |         dev->auto_rate = val;
         |            ^~
>> drivers/net/wireless/mediatek/mt76/mt7925/debugfs.c:367:9: error: implicit declaration of function 'mt7925_mcu_set_auto_rate'; did you mean 'mt7925_mcu_get_rx_rate'? [-Werror=implicit-function-declaration]
     367 |         mt7925_mcu_set_auto_rate(dev, wlan_idx, enable, mode);
         |         ^~~~~~~~~~~~~~~~~~~~~~~~
         |         mt7925_mcu_get_rx_rate
   drivers/net/wireless/mediatek/mt76/mt7925/debugfs.c: In function 'mt7925_autorate_get':
   drivers/net/wireless/mediatek/mt76/mt7925/debugfs.c:378:19: error: 'struct mt792x_dev' has no member named 'auto_rate'
     378 |         *val = dev->auto_rate;
         |                   ^~
   drivers/net/wireless/mediatek/mt76/mt7925/debugfs.c: In function 'mt7925_wtbl_idx_set':
>> drivers/net/wireless/mediatek/mt76/mt7925/debugfs.c:400:12: error: 'struct mt792x_dev' has no member named 'wtbl_dump_idx'
     400 |         dev->wtbl_dump_idx = (u32)val;
         |            ^~
   drivers/net/wireless/mediatek/mt76/mt7925/debugfs.c: In function 'mt7925_wtbl_idx_get':
   drivers/net/wireless/mediatek/mt76/mt7925/debugfs.c:410:19: error: 'struct mt792x_dev' has no member named 'wtbl_dump_idx'
     410 |         *val = dev->wtbl_dump_idx;
         |                   ^~
   drivers/net/wireless/mediatek/mt76/mt7925/debugfs.c: In function 'mt7925_wtbl_read':
   drivers/net/wireless/mediatek/mt76/mt7925/debugfs.c:422:22: error: 'struct mt792x_dev' has no member named 'wtbl_dump_idx'
     422 |         u32 idx = dev->wtbl_dump_idx;
         |                      ^~
>> drivers/net/wireless/mediatek/mt76/mt7925/debugfs.c:443:16: error: implicit declaration of function 'mt7925_mac_wtbl_lmac_addr'; did you mean 'mt7925_mac_wtbl_update'? [-Werror=implicit-function-declaration]
     443 |         base = mt7925_mac_wtbl_lmac_addr(dev, idx, 0);
         |                ^~~~~~~~~~~~~~~~~~~~~~~~~
         |                mt7925_mac_wtbl_update
   drivers/net/wireless/mediatek/mt76/mt7925/debugfs.c: In function 'mt7925_vefuse_read':
>> drivers/net/wireless/mediatek/mt76/mt7925/debugfs.c:474:23: error: 'struct mt792x_dev' has no member named 'vefuse_cap'
     474 |         u16 size = dev->vefuse_cap.size;
         |                       ^~
   drivers/net/wireless/mediatek/mt76/mt7925/debugfs.c:479:17: error: 'struct mt792x_dev' has no member named 'vefuse_cap'
     479 |         if (!dev->vefuse_cap.present || !size) {
         |                 ^~
>> drivers/net/wireless/mediatek/mt76/mt7925/debugfs.c:492:23: error: implicit declaration of function 'mt7925_mcu_read_vefuse'; did you mean 'mt7925_mcu_del_dev'? [-Werror=implicit-function-declaration]
     492 |                 ret = mt7925_mcu_read_vefuse(dev, off, chunk, buf + off);
         |                       ^~~~~~~~~~~~~~~~~~~~~~
         |                       mt7925_mcu_del_dev
   drivers/net/wireless/mediatek/mt76/mt7925/debugfs.c: In function 'mt7925_perf_ind_set':
>> drivers/net/wireless/mediatek/mt76/mt7925/debugfs.c:520:16: error: implicit declaration of function 'mt792x_perf_ind_trigger'; did you mean 'mt7925_perf_ind_set'? [-Werror=implicit-function-declaration]
     520 |         return mt792x_perf_ind_trigger(dev, val);
         |                ^~~~~~~~~~~~~~~~~~~~~~~
         |                mt7925_perf_ind_set
   drivers/net/wireless/mediatek/mt76/mt7925/debugfs.c: In function 'mt7925_perf_ind_enable_get':
>> drivers/net/wireless/mediatek/mt76/mt7925/debugfs.c:529:19: error: 'struct mt792x_dev' has no member named 'perf'
     529 |         *val = dev->perf.enabled;
         |                   ^~
   drivers/net/wireless/mediatek/mt76/mt7925/debugfs.c: In function 'mt7925_perf_ind_enable_set':
   drivers/net/wireless/mediatek/mt76/mt7925/debugfs.c:538:12: error: 'struct mt792x_dev' has no member named 'perf'
     538 |         dev->perf.enabled = !!val;
         |            ^~
   drivers/net/wireless/mediatek/mt76/mt7925/debugfs.c: In function 'mt7925_coex_info':
>> drivers/net/wireless/mediatek/mt76/mt7925/debugfs.c:555:15: error: implicit declaration of function 'mt7925_mcu_chip_config_query'; did you mean 'mt7925_mcu_chip_config'? [-Werror=implicit-function-declaration]
     555 |         ret = mt7925_mcu_chip_config_query(dev, "coexBwcGetModeInfo 0",
         |               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
         |               mt7925_mcu_chip_config
>> drivers/net/wireless/mediatek/mt76/mt7925/debugfs.c:564:31: error: 'CHIP_CONFIG_TYPE_ASCII' undeclared (first use in this function)
     564 |         else if (resp_type == CHIP_CONFIG_TYPE_ASCII)
         |                               ^~~~~~~~~~~~~~~~~~~~~~
   drivers/net/wireless/mediatek/mt76/mt7925/debugfs.c:564:31: note: each undeclared identifier is reported only once for each function it appears in
   drivers/net/wireless/mediatek/mt76/mt7925/debugfs.c: In function 'mt7925_dmashdl_read':
>> drivers/net/wireless/mediatek/mt76/mt7925/debugfs.c:603:45: warning: format '%x' expects argument of type 'unsigned int', but argument 3 has type 'long unsigned int' [-Wformat=]
     603 |         seq_printf(s, "\t\tPLE pkt max=0x%03x, PSE pkt max=0x%03x\n",
         |                                          ~~~^
         |                                             |
         |                                             unsigned int
         |                                          %03lx
   drivers/net/wireless/mediatek/mt76/mt7925/debugfs.c:603:65: warning: format '%x' expects argument of type 'unsigned int', but argument 4 has type 'long unsigned int' [-Wformat=]
     603 |         seq_printf(s, "\t\tPLE pkt max=0x%03x, PSE pkt max=0x%03x\n",
         |                                                              ~~~^
         |                                                                 |
         |                                                                 unsigned int
         |                                                              %03lx
   In file included from drivers/net/wireless/mediatek/mt76/mt7925/../mt76_connac.h:7,
                    from drivers/net/wireless/mediatek/mt76/mt7925/../mt76_connac_mcu.h:7,
                    from drivers/net/wireless/mediatek/mt76/mt7925/../mt792x.h:10,
                    from drivers/net/wireless/mediatek/mt76/mt7925/mt7925.h:7,
                    from drivers/net/wireless/mediatek/mt76/mt7925/debugfs.c:4:
>> drivers/net/wireless/mediatek/mt76/mt7925/debugfs.c:607:28: error: 'MT_DMASHDL_ERROR_FLAG_CTRL' undeclared (first use in this function)
     607 |         val = mt76_rr(dev, MT_DMASHDL_ERROR_FLAG_CTRL);
         |                            ^~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/net/wireless/mediatek/mt76/mt7925/../mt76.h:1196:69: note: in definition of macro 'mt76_rr'
    1196 | #define mt76_rr(dev, ...)       (dev)->mt76.bus->rr(&((dev)->mt76), __VA_ARGS__)
         |                                                                     ^~~~~~~~~~~
>> drivers/net/wireless/mediatek/mt76/mt7925/debugfs.c:613:43: error: implicit declaration of function 'MT_DMASHDL_STATUS_RD_GP' [-Werror=implicit-function-declaration]
     613 |                 u32 status = mt76_rr(dev, MT_DMASHDL_STATUS_RD_GP(i));
         |                                           ^~~~~~~~~~~~~~~~~~~~~~~
   drivers/net/wireless/mediatek/mt76/mt7925/../mt76.h:1196:69: note: in definition of macro 'mt76_rr'
    1196 | #define mt76_rr(dev, ...)       (dev)->mt76.bus->rr(&((dev)->mt76), __VA_ARGS__)
         |                                                                     ^~~~~~~~~~~
   In file included from <command-line>:
>> drivers/net/wireless/mediatek/mt76/mt7925/debugfs.c:614:37: error: 'MT_DMASHDL_STATUS_RD_GP_RSV' undeclared (first use in this function)
     614 |                 u32 rsv = FIELD_GET(MT_DMASHDL_STATUS_RD_GP_RSV, status);
         |                                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/compiler_types.h:682:23: note: in definition of macro '__compiletime_assert'
     682 |                 if (!(condition))                                       \
         |                       ^~~~~~~~~
   include/linux/compiler_types.h:702:9: note: in expansion of macro '_compiletime_assert'
     702 |         _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
         |         ^~~~~~~~~~~~~~~~~~~
   include/linux/build_bug.h:40:37: note: in expansion of macro 'compiletime_assert'
      40 | #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
         |                                     ^~~~~~~~~~~~~~~~~~
   include/linux/bitfield.h:79:9: note: in expansion of macro 'BUILD_BUG_ON_MSG'
      79 |         BUILD_BUG_ON_MSG(__bf_cast_unsigned(mask, mask) >               \
         |         ^~~~~~~~~~~~~~~~
   include/linux/bitfield.h:63:43: note: in expansion of macro '__unsigned_scalar_typeof'
      63 | #define __bf_cast_unsigned(type, x)     ((__unsigned_scalar_typeof(type))(x))
         |                                           ^~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/bitfield.h:79:26: note: in expansion of macro '__bf_cast_unsigned'
      79 |         BUILD_BUG_ON_MSG(__bf_cast_unsigned(mask, mask) >               \
         |                          ^~~~~~~~~~~~~~~~~~
   include/linux/bitfield.h:177:17: note: in expansion of macro '__BF_FIELD_CHECK_REG'
     177 |                 __BF_FIELD_CHECK_REG(_mask, _reg, "FIELD_GET: ");       \
         |                 ^~~~~~~~~~~~~~~~~~~~
   drivers/net/wireless/mediatek/mt76/mt7925/debugfs.c:614:27: note: in expansion of macro 'FIELD_GET'
     614 |                 u32 rsv = FIELD_GET(MT_DMASHDL_STATUS_RD_GP_RSV, status);
         |                           ^~~~~~~~~
>> drivers/net/wireless/mediatek/mt76/mt7925/debugfs.c:615:37: error: 'MT_DMASHDL_STATUS_RD_GP_SRC' undeclared (first use in this function)
     615 |                 u32 src = FIELD_GET(MT_DMASHDL_STATUS_RD_GP_SRC, status);
         |                                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/compiler_types.h:682:23: note: in definition of macro '__compiletime_assert'
     682 |                 if (!(condition))                                       \
         |                       ^~~~~~~~~
   include/linux/compiler_types.h:702:9: note: in expansion of macro '_compiletime_assert'
     702 |         _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
         |         ^~~~~~~~~~~~~~~~~~~
   include/linux/build_bug.h:40:37: note: in expansion of macro 'compiletime_assert'
      40 | #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
         |                                     ^~~~~~~~~~~~~~~~~~
   include/linux/bitfield.h:79:9: note: in expansion of macro 'BUILD_BUG_ON_MSG'
      79 |         BUILD_BUG_ON_MSG(__bf_cast_unsigned(mask, mask) >               \
         |         ^~~~~~~~~~~~~~~~
   include/linux/bitfield.h:63:43: note: in expansion of macro '__unsigned_scalar_typeof'
      63 | #define __bf_cast_unsigned(type, x)     ((__unsigned_scalar_typeof(type))(x))
         |                                           ^~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/bitfield.h:79:26: note: in expansion of macro '__bf_cast_unsigned'
      79 |         BUILD_BUG_ON_MSG(__bf_cast_unsigned(mask, mask) >               \
         |                          ^~~~~~~~~~~~~~~~~~
   include/linux/bitfield.h:177:17: note: in expansion of macro '__BF_FIELD_CHECK_REG'
     177 |                 __BF_FIELD_CHECK_REG(_mask, _reg, "FIELD_GET: ");       \
         |                 ^~~~~~~~~~~~~~~~~~~~
   drivers/net/wireless/mediatek/mt76/mt7925/debugfs.c:615:27: note: in expansion of macro 'FIELD_GET'
     615 |                 u32 src = FIELD_GET(MT_DMASHDL_STATUS_RD_GP_SRC, status);
         |                           ^~~~~~~~~
   drivers/net/wireless/mediatek/mt76/mt7925/debugfs.c:617:65: warning: format '%x' expects argument of type 'unsigned int', but argument 4 has type 'long unsigned int' [-Wformat=]
     617 |                 seq_printf(s, "\tGroup %2d: quota(min/max)=0x%03x/0x%03x, used/rsv=0x%03x/0x%03x\n",
         |                                                              ~~~^
         |                                                                 |
         |                                                                 unsigned int
         |                                                              %03lx
   drivers/net/wireless/mediatek/mt76/mt7925/debugfs.c:617:72: warning: format '%x' expects argument of type 'unsigned int', but argument 5 has type 'long unsigned int' [-Wformat=]
     617 |                 seq_printf(s, "\tGroup %2d: quota(min/max)=0x%03x/0x%03x, used/rsv=0x%03x/0x%03x\n",
         |                                                                     ~~~^
         |                                                                        |
         |                                                                        unsigned int
         |                                                                     %03lx
   In file included from drivers/net/wireless/mediatek/mt76/mt7925/../mt76_connac.h:7,
                    from drivers/net/wireless/mediatek/mt76/mt7925/../mt76_connac_mcu.h:7,
                    from drivers/net/wireless/mediatek/mt76/mt7925/../mt792x.h:10,
                    from drivers/net/wireless/mediatek/mt76/mt7925/mt7925.h:7,
                    from drivers/net/wireless/mediatek/mt76/mt7925/debugfs.c:4:
   drivers/net/wireless/mediatek/mt76/mt7925/debugfs.c:626:28: error: 'MT_DMASHDL_STATUS_RD' undeclared (first use in this function)
     626 |         val = mt76_rr(dev, MT_DMASHDL_STATUS_RD);
         |                            ^~~~~~~~~~~~~~~~~~~~
   drivers/net/wireless/mediatek/mt76/mt7925/../mt76.h:1196:69: note: in definition of macro 'mt76_rr'
    1196 | #define mt76_rr(dev, ...)       (dev)->mt76.bus->rr(&((dev)->mt76), __VA_ARGS__)
         |                                                                     ^~~~~~~~~~~
   In file included from <command-line>:
   drivers/net/wireless/mediatek/mt76/mt7925/debugfs.c:627:33: error: 'MT_DMASHDL_STATUS_RD_FREE_PG' undeclared (first use in this function)
     627 |         free_pg_cnt = FIELD_GET(MT_DMASHDL_STATUS_RD_FREE_PG, val);
         |                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/compiler_types.h:682:23: note: in definition of macro '__compiletime_assert'
     682 |                 if (!(condition))                                       \
         |                       ^~~~~~~~~
   include/linux/compiler_types.h:702:9: note: in expansion of macro '_compiletime_assert'
     702 |         _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
         |         ^~~~~~~~~~~~~~~~~~~
   include/linux/build_bug.h:40:37: note: in expansion of macro 'compiletime_assert'
      40 | #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
         |                                     ^~~~~~~~~~~~~~~~~~
   include/linux/bitfield.h:79:9: note: in expansion of macro 'BUILD_BUG_ON_MSG'
      79 |         BUILD_BUG_ON_MSG(__bf_cast_unsigned(mask, mask) >               \
         |         ^~~~~~~~~~~~~~~~
   include/linux/bitfield.h:63:43: note: in expansion of macro '__unsigned_scalar_typeof'
      63 | #define __bf_cast_unsigned(type, x)     ((__unsigned_scalar_typeof(type))(x))
         |                                           ^~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/bitfield.h:79:26: note: in expansion of macro '__bf_cast_unsigned'
      79 |         BUILD_BUG_ON_MSG(__bf_cast_unsigned(mask, mask) >               \
         |                          ^~~~~~~~~~~~~~~~~~
   include/linux/bitfield.h:177:17: note: in expansion of macro '__BF_FIELD_CHECK_REG'
     177 |                 __BF_FIELD_CHECK_REG(_mask, _reg, "FIELD_GET: ");       \
         |                 ^~~~~~~~~~~~~~~~~~~~
   drivers/net/wireless/mediatek/mt76/mt7925/debugfs.c:627:23: note: in expansion of macro 'FIELD_GET'
     627 |         free_pg_cnt = FIELD_GET(MT_DMASHDL_STATUS_RD_FREE_PG, val);
         |                       ^~~~~~~~~
   drivers/net/wireless/mediatek/mt76/mt7925/debugfs.c:628:29: error: 'MT_DMASHDL_STATUS_RD_FFA' undeclared (first use in this function)
     628 |         ffa_cnt = FIELD_GET(MT_DMASHDL_STATUS_RD_FFA, val);
         |                             ^~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/compiler_types.h:682:23: note: in definition of macro '__compiletime_assert'
     682 |                 if (!(condition))                                       \
         |                       ^~~~~~~~~
   include/linux/compiler_types.h:702:9: note: in expansion of macro '_compiletime_assert'
     702 |         _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
         |         ^~~~~~~~~~~~~~~~~~~
   include/linux/build_bug.h:40:37: note: in expansion of macro 'compiletime_assert'
      40 | #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
         |                                     ^~~~~~~~~~~~~~~~~~
   include/linux/bitfield.h:79:9: note: in expansion of macro 'BUILD_BUG_ON_MSG'
      79 |         BUILD_BUG_ON_MSG(__bf_cast_unsigned(mask, mask) >               \
         |         ^~~~~~~~~~~~~~~~
   include/linux/bitfield.h:63:43: note: in expansion of macro '__unsigned_scalar_typeof'
      63 | #define __bf_cast_unsigned(type, x)     ((__unsigned_scalar_typeof(type))(x))
         |                                           ^~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/bitfield.h:79:26: note: in expansion of macro '__bf_cast_unsigned'
      79 |         BUILD_BUG_ON_MSG(__bf_cast_unsigned(mask, mask) >               \
         |                          ^~~~~~~~~~~~~~~~~~
   include/linux/bitfield.h:177:17: note: in expansion of macro '__BF_FIELD_CHECK_REG'
     177 |                 __BF_FIELD_CHECK_REG(_mask, _reg, "FIELD_GET: ");       \

vim +/rate +312 drivers/net/wireless/mediatek/mt76/mt7925/debugfs.c

289
290 /* fixedrate input format (12 hex digits):
291 * 0x[WCID(2)][Mode][BW][MCS][Nss][SGI][Preamble][STBC][LDPC][SPE_EN][HeLtf]
292 * The RA tag is fixed to SET_FIXED_RATE internally.
293 * WCID is 2 nibbles, all others are 1 nibble.
294 *

   295	 * [WCID]    Wireless Client ID
   296	 * [Mode]    CCK=0, OFDM=1, HT=2, GF=3, VHT=4, PLR=5, HE_SU=8, HE_ER_SU=9,
   297	 *           HE_TRIG=10, HE_MU=11, EHT_ER=13, EHT_TB=14, EHT_SU and EHT_MU=15
   298	 * [BW]      BW20=0, BW40=1, BW80=2, BW160=3, BW320=4
   299	 * [MCS]     CCK=0~3, OFDM=0~7, HT=0~32, VHT=0~9, HE=0~11, EHT=0~13, EHT_ER=14~15
   300	 * [Nss]     1~8
   301	 * [GI]      HT/VHT: 0=Long, 1=Short; HE/EHT: 0=0.8us, 1=1.6us, 2=3.2us
   302	 * [Preamble] Long=0, Short=other
   303	 * [STBC]    Enable=1, Disable=0
   304	 * [LDPC]    BCC=0, LDPC=1 (driver sends the FW's "on" value 7)
   305	 * [SPE_EN]  spatial extension index
   306	 * [HeLtf]   1X=0, 2X=1, 4X=2 (NOTE: EHT modes require HeLtf=1)
   307	 */
   308	static int
   309	mt7925_fixedrate_set(void *data, u64 val)
   310	{
   311		struct mt792x_dev *dev = data;
 > 312		struct mt7925_ra_fixed_rate_v1 rate = {};
   313	
 > 314		dev->fixed_rate = val;
   315	
   316		rate.wlan_idx       = cpu_to_le16((val >> 40) & 0xff);
   317		rate.phy_mode       = (val >> 36) & 0xf;
   318		rate.bw             = (val >> 32) & 0xf;
   319		rate.mcs            = (val >> 28) & 0xf;
   320		rate.nss            = (val >> 24) & 0xf;
   321		rate.short_gi       = cpu_to_le16((val >> 20) & 0xf);
   322		rate.short_preamble = (val >> 16) & 0xf;
   323		rate.stbc           = (val >> 12) & 0xf;
   324		rate.ecc            = ((val >> 8) & 0xf) ? 7 : 0;
   325		rate.spe            = (val >> 4) & 0xf;
   326		rate.he_ltf         = cpu_to_le16((val >> 0) & 0xf);
   327	
   328		mt792x_mutex_acquire(dev);
 > 329		mt7925_mcu_set_fixed_rate(dev, &rate);
   330		mt792x_mutex_release(dev);
   331	
   332		return 0;
   333	}
   334	
   335	static int
   336	mt7925_fixedrate_get(void *data, u64 *val)
   337	{
   338		struct mt792x_dev *dev = data;
   339	
   340		*val = dev->fixed_rate;
   341	
   342		return 0;
   343	}
 > 344	DEFINE_DEBUGFS_ATTRIBUTE(fops_fixedrate, mt7925_fixedrate_get,
   345				 mt7925_fixedrate_set, "0x%llx\n");
   346	
   347	/* autorate input format (6 hex digits):
   348	 * 0x[Tag(2)][WCID(2)][En][Mode]
   349	 * The RA tag is fixed to SET_AUTO_RATE internally.
   350	 * WCID is 2 nibbles, En and Mode are 1 nibble each.
   351	 *
   352	 * [WCID] Wireless Client ID
   353	 * [En]   Auto rate: Enable=1, Disable=0
   354	 * [Mode] don't care (RA picks the rate)
   355	 */
   356	static int
   357	mt7925_autorate_set(void *data, u64 val)
   358	{
   359		struct mt792x_dev *dev = data;
   360		u16 wlan_idx = (val >> 8) & 0xff;
   361		bool enable = (val >> 4) & 0xf;
   362		u8 mode = val & 0xf;
   363	
 > 364		dev->auto_rate = val;
   365	
   366		mt792x_mutex_acquire(dev);
 > 367		mt7925_mcu_set_auto_rate(dev, wlan_idx, enable, mode);
   368		mt792x_mutex_release(dev);
   369	
   370		return 0;
   371	}
   372	
   373	static int
   374	mt7925_autorate_get(void *data, u64 *val)
   375	{
   376		struct mt792x_dev *dev = data;
   377	
   378		*val = dev->auto_rate;
   379	
   380		return 0;
   381	}
 > 382	DEFINE_DEBUGFS_ATTRIBUTE(fops_autorate, mt7925_autorate_get,
   383				 mt7925_autorate_set, "0x%llx\n");
   384	
   385	/* WTBL dump
   386	 *
   387	 * Usage:
   388	 *   echo <idx> > /sys/kernel/debug/ieee80211/phy1/mt76/wtbl_idx
   389	 *   cat  /sys/kernel/debug/ieee80211/phy1/mt76/get_wtbl
   390	 *
   391	 * LMAC WTBL has 36 dwords per entry (connac3x).
   392	 */
   393	#define MT792x_WTBL_LMAC_DWORDS	36
   394	
   395	static int
   396	mt7925_wtbl_idx_set(void *data, u64 val)
   397	{
   398		struct mt792x_dev *dev = data;
   399	
 > 400		dev->wtbl_dump_idx = (u32)val;
   401	
   402		return 0;
   403	}
   404	
   405	static int
   406	mt7925_wtbl_idx_get(void *data, u64 *val)
   407	{
   408		struct mt792x_dev *dev = data;
   409	
   410		*val = dev->wtbl_dump_idx;
   411	
   412		return 0;
   413	}
   414	
 > 415	DEFINE_DEBUGFS_ATTRIBUTE(fops_wtbl_idx, mt7925_wtbl_idx_get,
   416				 mt7925_wtbl_idx_set, "%llu\n");
   417	
   418	static int
 > 419	mt7925_wtbl_read(struct seq_file *s, void *data)
   420	{
   421		struct mt792x_dev *dev = dev_get_drvdata(s->private);
   422		u32 idx = dev->wtbl_dump_idx;
   423		u32 wdu_cr, wducr_val, base;
   424		u32 dw0, dw1;
   425		int i;
   426	
   427		if (!mt76_is_mmio(&dev->mt76)) {
   428			seq_puts(s, "WTBL direct dump not supported on this interface\n");
   429			return 0;
   430		}
   431	
   432		if (idx >= MT792x_WTBL_SIZE) {
   433			seq_printf(s, "Invalid WTBL idx %u (max %u)\n",
   434				   idx, MT792x_WTBL_SIZE - 1);
   435			return 0;
   436		}
   437	
   438		mt792x_mutex_acquire(dev);
   439	
   440		/* mt7925_mac_wtbl_lmac_addr() writes WDUCR group selection and
   441		 * returns the mapped register address for DW 0 of this WCID.
   442		 */
 > 443		base = mt7925_mac_wtbl_lmac_addr(dev, idx, 0);
   444		wdu_cr = is_mt7928(&dev->mt76) ? MT7928_WTBLON_TOP_WDUCR :
   445						  MT7925_WTBLON_TOP_WDUCR;
   446		wducr_val = mt76_rr(dev, wdu_cr);
   447	
   448		/* DW0[15:0] + DW1[31:0] encode the link address */
   449		dw0 = mt76_rr(dev, base);
   450		dw1 = mt76_rr(dev, base + 4);
   451	
   452		seq_printf(s, "Dump WTBL info of WLAN_IDX: %u\n", idx);
   453		seq_printf(s, "LMAC WTBL Addr: group:0x%08x=0x%08x addr: 0x%08x\n",
   454			   wdu_cr, wducr_val, base);
   455		seq_printf(s, "LinkAddr: %02x:%02x:%02x:%02x:%02x:%02x\n",
   456			   dw1 & 0xff, (dw1 >> 8) & 0xff,
   457			   (dw1 >> 16) & 0xff, (dw1 >> 24) & 0xff,
   458			   dw0 & 0xff, (dw0 >> 8) & 0xff);
   459	
   460		seq_puts(s, "\nLMAC WTBL raw data:\n");
   461		for (i = 0; i < MT792x_WTBL_LMAC_DWORDS; i++)
   462			seq_printf(s, "DW%02d: 0x%08x\n", i,
   463				   mt76_rr(dev, base + i * 4));
   464	
   465		mt792x_mutex_release(dev);
   466	
   467		return 0;
   468	}
   469	
   470	static int
 > 471	mt7925_vefuse_read(struct seq_file *s, void *data)
   472	{
   473		struct mt792x_dev *dev = dev_get_drvdata(s->private);
 > 474		u16 size = dev->vefuse_cap.size;
   475		int off = 0;
   476		u8 *buf;
   477		int ret = 0;
   478	
   479		if (!dev->vefuse_cap.present || !size) {
   480			seq_puts(s, "vefuse: no region in FW image\n");
   481			return 0;
   482		}
   483	
   484		buf = kzalloc(size, GFP_KERNEL);
   485		if (!buf)
   486			return -ENOMEM;
   487	
   488		mt792x_mutex_acquire(dev);
   489		while (off < (int)size) {
   490			u16 chunk = min_t(u16, 512, size - off);
   491	
 > 492			ret = mt7925_mcu_read_vefuse(dev, off, chunk, buf + off);

493 if (ret)
494 break;
495 off += chunk;
496 }
497 mt792x_mutex_release(dev);
498
499 if (ret) {
500 seq_printf(s, "vefuse: read failed at 0x%04x (%d)\n", off, ret);
501 kfree(buf);
502 return 0;
503 }
504
505 seq_printf(s, "vefuse content: %u bytes\n", size);
506 for (off = 0; off < (int)size; off += 16)
507 seq_printf(s, "%04x: %*ph\n", off,
508 (int)min_t(u16, 16, size - off), buf + off);
509
510 kfree(buf);
511
512 return 0;
513 }
514

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

#2 lore raw
In reply to Eason Lai
kernel test robot noticed the following build errors:

Hi Eason,

kernel test robot noticed the following build errors:

[auto build test ERROR on wireless-next/main]
[also build test ERROR on linus/master next-20260821] [cannot apply to wireless/main v7.2]
[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/Eason-Lai/wifi-mt76-mt7928-Add-debugfs-for-stats-to-provide-debug-purpose/20260824-110746
base:   https://git.kernel.org/pub/scm/linux/kernel/git/wireless/wireless-next.git main
patch link:    https://lore.kernel.org/r/20260824030746.60706-1-eason.lai%40mediatek.com
patch subject: [PATCH v1] wifi: mt76: mt7928: Add debugfs for stats to provide debug purpose
config: parisc-allyesconfig (https://download.01.org/0day-ci/archive/20260825/[email protected]/config)
compiler: hppa-linux-gcc (GCC) 16.1.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260825/[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 >>):

In file included from drivers/net/wireless/mediatek/mt76/mt7996/init.c:13:

>> drivers/net/wireless/mediatek/mt76/mt7996/mcu.h:1000:9: error: redeclaration of enumerator 'UNI_CMD_MIB_DATA'
    1000 |         UNI_CMD_MIB_DATA,
         |         ^~~~~~~~~~~~~~~~
   In file included from drivers/net/wireless/mediatek/mt76/mt7996/mcu.h:9:
   drivers/net/wireless/mediatek/mt76/mt7996/../mt76_connac_mcu.h:1511:9: note: previous definition of 'UNI_CMD_MIB_DATA' with type 'enum <anonymous>'
    1511 |         UNI_CMD_MIB_DATA,
         |         ^~~~~~~~~~~~~~~~

vim +/UNI_CMD_MIB_DATA +1000 drivers/net/wireless/mediatek/mt76/mt7996/mcu.h

98686cd21624c7 Shayne Chen 2022-11-22 998

98686cd21624c7 Shayne Chen 2022-11-22   999  enum {
98686cd21624c7 Shayne Chen 2022-11-22 @1000  	UNI_CMD_MIB_DATA,
98686cd21624c7 Shayne Chen 2022-11-22  1001  };

98686cd21624c7 Shayne Chen 2022-11-22 1002

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

author
#3 lore raw

PATCH v2 1/1 wifi: mt76: mt7928: Add debugfs for stats to provide debug purpose

In reply to Eason Lai

From: Michael Shih <[email protected]>

Usage:
(1) Connect STA to AP (You may use dhclient CMD to ask for DHCP IP, to use ping to AP)

    DHCP IP CMD:  dhclient ${WLAN_IF} -v

Example: dhclient wlan0 -v

## (To simulate traffic) Ping 10 packets for every second to AP ping 192.168.0.XXX -i0.1

(2) (Get stats) Use command, phyX is your WiFi interface:

     cat /sys/kernel/debug/ieee80211/phyX/mt76/stats

(3) You will see below stats info:
(STA) connected AP MAC Address = a8:42:a1:46:c4:6b
BssIdx = [0]
StaRecIdx = [1],
RSSI = -25
Link_Speed = 2402000 (kbit/s)
temperature = 40
Tx success = 716
Tx fail to Rcv ACK after retry = 0
Rx Mpdu = 23
Rx Fcs Error = 1 (MPDU)
Rx FIFO full = 0 (MPDU)
TRX_AGG_RANGE[0] = 0 (PPDU) TRX_AGG_RANGE[1] = 0 (PPDU) TRX_AGG_RANGE[2] = 0 (PPDU) TRX_AGG_RANGE[3] = 0 (PPDU) TRX_AGG_RANGE[4] = 0 (PPDU) TRX_AGG_RANGE[5] = 0 (PPDU) TRX_AGG_RANGE[6] = 0 (PPDU) TRX_AGG_RANGE[7] = 0 (PPDU)
MPDUs in AMPDUs transmitted = 0 (MPDU) MPDUs in AMPDUs transmitted with ACK reply = 0 (MPDU) rate1_tx_cnt = 714
rate1_fail_cnt = 223
train_up = 2310
train_down = 3080
is_force_tx_stream = 0
is_force_se_off = 0
max_ampdu_factor = 9
tx_rate_up_penalty = 0
low_traffic_mode = 2
low_traffic_count = 0 low_traffic_dashboard = 3 dynamic_sgi_state = 0
dynamic_sgi_score = 2
dynamic_bw_state = 0 dynamic_gband_256qam_state = 3 vht_non_sp_rate_state = 0
Last TX Rate = 24M, BW20, OFDM, BCC, SPE24 Chip Out TX Power = +16.5 dBm
Cur Rate Index = 0
Rate index[0] --> NSS2_MCS11, BW160/BW8080, SGI, HE_SU, LDPC

Rate index[1]        NSS2_MCS9, BW160/BW8080, SGI, HE_SU, LDPC
Rate index[2]        NSS2_MCS7, BW160/BW8080, SGI, HE_SU, LDPC
Rate index[3]        NSS2_MCS4, BW160/BW8080, SGI, HE_SU, LDPC
Rate index[4]        NSS2_MCS3, BW160/BW8080, SGI, HE_SU, LDPC
Rate index[5]        NSS1_MCS2, BW160/BW8080, SGI, HE_SU, LDPC
Rate index[6]        NSS1_MCS1, BW80, SGI, HE_SU, LDPC
Rate index[7]        NSS1_MCS0, BW80, SGI, HE_SU, LDPC

mib state:
=== Rx Related Counters ===
Rx with CRC = 24020 (MPDU)
Rx drop due to out of resource = 0 (MPDU) Rx Mpdu = 93223 (MPDU)
Rx AMpdu = 668 (PPDU)
Rx PF Drop = 0 (MPDU)
Rx Len Mismatch = 5853 (PPDU)

=== Phy/Timing Related Counters ===

                        ChannelIdleCnt = 1040434
                        CCA_NAV_Tx_Time = 18510036
                        Rx_MDRDY_CNT = 166580 (PPDU)
                        CCK_MDRDY = 7782
                        OFDM_MDRDY = 11912731
                        OFDM_GREEN_MDRDY = 0
                        Prim CCA Time = 17917650
                        Sec CCA Time = 14922034
                        Prim ED Time = 5677528

=== Tx Related Counters(Generic) ===

                        BeaconTxCnt = 0
                        Tx 40MHz Cnt = 279  (MPDU)
                        Tx 80MHz Cnt = 44  (MPDU)
                        Tx 160MHz Cnt = 712  (MPDU)

=== BSSID[0] Related Counters ===
BA Miss Cnt = 210 (PPDU) RTS Tx Cnt = 1003 (MPDU) Frame Retry Cnt = 239 (MPDU) Frame Retry 2 Cnt = 71 (MPDU) RTS Retry Cnt = 152 (MPDU) Ack Failed Cnt = 319 (PPDU)

=== AMPDU Related Counters ===

                        Tx AMPDU_Pkt_Cnt = 705  (PPDU)
                        Tx AMPDU_MPDU_Pkt_Cnt = 713  (MPDU)
                        AMPDU Tx success = 503 (MPDU)
                        AMPDU Tx fail count   = 210  (MPDU), PER=29.4%

---
v2: (1) Remove redundant code to fix build errors.
(2) Move UNI_CMD_MIB_DATA enum definition from 'mt76/mt76_connac_mcu.h' to 'mt7925/stats.h' to avoid redeclartion with 'mt76/mt7996/mcu.h'

---
 .../wireless/mediatek/mt76/mt76_connac_mcu.h  | 173 ++++++
 .../wireless/mediatek/mt76/mt7925/Makefile    |   2 +-
 .../wireless/mediatek/mt76/mt7925/debugfs.c   | 343 ++++++++++
 .../net/wireless/mediatek/mt76/mt7925/stats.c | 585 ++++++++++++++++++
 .../net/wireless/mediatek/mt76/mt7925/stats.h | 309 +++++++++
 5 files changed, 1411 insertions(+), 1 deletion(-)
 create mode 100644 drivers/net/wireless/mediatek/mt76/mt7925/stats.c
 create mode 100644 drivers/net/wireless/mediatek/mt76/mt7925/stats.h
drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h +173 -0
index 0ededa569e9a..bf0f105c786e 100644
@@ -1483,6 +1483,179 @@ enum {
 	MT_NIC_CAP_EML_CAP = 0x22,
 };
 
+enum {
+	UNI_CMD_ID_STATISTICS_BASIC = 0,
+	UNI_CMD_ID_STATISTICS_LINK_QUALITY = 1,
+	UNI_CMD_ID_STATISTICS_STA = 2,
+	UNI_CMD_ID_STATISTICS_BUG_REPORT = 3,
+	UNI_CMD_ID_STATISTICS_TX_STATS = 4,
+	UNI_CMD_ID_STATISTICS_ALL_STATS = 5,
+	UNI_CMD_ID_STATISTICS_EML_STATS = 6,
+	UNI_CMD_ID_STATISTICS_REGULAR_STATS = 7,
+	UNI_CMD_ID_STATISTICS_BSS_LINK_QUALITY = 8,
+	UNI_CMD_ID_STATISTICS_ML_CHNL_COND = 9,
+	UNI_CMD_ID_STATISTICS_WTBL = 10,
+	UNI_CMD_ID_STATISTICS_LINK_LAYER_STATS = 128,
+	UNI_CMD_ID_STATISTICS_PPDU_LATENCY = 129,
+	UNI_CMD_ID_STATISTICS_CURRENT_TX_RATE = 130,
+	UNI_CMD_ID_STATISTICS_SET_TX_BITRATE_MONITOR = 131,
+	UNI_CMD_ID_STATISTICS_GET_PREDICT_TX_BITRATE = 132,
+	UNI_CMD_ID_STATISTICS_SET_ATPS_TYPE_RATE_MODE = 133,
+	UNI_CMD_ID_STATISTICS_SET_BEACON_REPORT = 134,
+	UNI_CMD_ID_STATISTICS_BSS_CURRENT_TX_RATE = 135,
+	UNI_CMD_ID_STATISTICS_GET_BSS_PREDICT_TX_BITRATE = 136,
+	UNI_CMD_ID_STATISTICS_MAX_NUM
+};
+
+enum mt7925_mib_counter {
+	UNI_CMD_MIB_CNT_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O_BW = 87,
+	UNI_CMD_MIB_CNT_CCA_SAMPLE_IDLE = 88,
+	UNI_CMD_MIB_CNT_CCA_SAMPLE_ACTIVE = 89,
+	UNI_CMD_MIB_CNT_CCA_TIME = 90,
+	UNI_CMD_MIB_CNT_S_20BW_CCA_TIME = 91,
+	UNI_CMD_MIB_CNT_S_40BW_CCA_TIME = 92,
+	UNI_CMD_MIB_CNT_S_80BW_CCA_TIME = 93,
+	UNI_CMD_MIB_CNT_S_160BW_CCA_TIME = 94,
+	UNI_CMD_MIB_CNT_S_P20BW_0_ED_TIME = 95,
+	UNI_CMD_MIB_CNT_S_P20BW_1_ED_TIME = 96,
+	UNI_CMD_MIB_CNT_S_P20BW_2_ED_TIME = 97,
+	UNI_CMD_MIB_CNT_S_P20BW_3_ED_TIME = 98,
+	UNI_CMD_MIB_CNT_S_P20BW_4_ED_TIME = 99,
+	UNI_CMD_MIB_CNT_S_P20BW_5_ED_TIME = 100,
+	UNI_CMD_MIB_CNT_S_P20BW_6_ED_TIME = 101,
+	UNI_CMD_MIB_CNT_S_P20BW_7_ED_TIME = 102,
+	UNI_CMD_MIB_CNT_S_P20BW_8_ED_TIME = 103,
+	UNI_CMD_MIB_CNT_S_P20BW_9_ED_TIME = 104,
+	UNI_CMD_MIB_CNT_S_P20BW_10_ED_TIME = 105,
+	UNI_CMD_MIB_CNT_S_P20BW_11_ED_TIME = 106,
+	UNI_CMD_MIB_CNT_S_P20BW_12_ED_TIME = 107,
+	UNI_CMD_MIB_CNT_S_P20BW_13_ED_TIME = 108,
+	UNI_CMD_MIB_CNT_S_P20BW_14_ED_TIME = 109,
+	UNI_CMD_MIB_CNT_S_P20BW_15_ED_TIME = 110,
+	UNI_CMD_MIB_CNT_TX_BW_320MHZ = 111,
+	UNI_CMD_MIB_CNT_TX_DDLMT_RNG0 = 112, /* Rng0~Rng4 112~116 */
+	UNI_CMD_MIB_CNT_BSS0_FRAME_RETRY_3 = 117, /* 117~120 */
+	UNI_CMD_MIB_CNT_BSS0_TX = 121, /* 121~124 */
+	UNI_CMD_MIB_CNT_BSS0_TX_DATA = 125, /* 125~128 */
+	UNI_CMD_MIB_CNT_BSS0_TX_BYTE = 129, /* 129~132 */
+	UNI_CMD_MIB_CNT_RX_OK_BSS0 = 133, /* 133~136 */
+	UNI_CMD_MIB_CNT_RX_BYTE_BSS0 = 137, /* 137~140 */
+	UNI_CMD_MIB_CNT_RX_DATA_BSS0 = 141, /* 141~144 */
+	UNI_CMD_MIB_CNT_MBSS0_TX_OK = 145, /* 145~160 */
+	UNI_CMD_MIB_CNT_MBSS0_TX_BYTE = 161, /* 161~176 */
+	UNI_CMD_MIB_CNT_RX_OK_MBSS0 = 177, /* 177~192 */
+	UNI_CMD_MIB_CNT_RX_BYTE_MBSS0 = 193, /* 193~208 */
+	UNI_CMD_MIB_CNT_AMPDU = 209,
+	UNI_CMD_MIB_CNT_AMPDU_MPDU = 210,
+	UNI_CMD_MIB_CNT_AMPDU_ACKED = 211,
+	UNI_CMD_MIB_CNT_MAX_NUM
+};
+
+enum ENUM_UNI_CMD_GET_STATISTICS_TAG {
+	UNI_CMD_GET_STATISTICS_TAG_BASIC = 0,
+	UNI_CMD_GET_STATISTICS_TAG_LINK_QUALITY = 1,
+	UNI_CMD_GET_STATISTICS_TAG_STA = 2,
+	UNI_CMD_GET_STATISTICS_TAG_BUG_REPORT = 3,
+	UNI_CMD_GET_STATISTICS_TAG_EML_STATS = 6,
+	UNI_CMD_GET_STATISTICS_TAG_REGULAR_STATS = 7,
+	UNI_CMD_GET_STATISTICS_TAG_BSS_LINK_QUALITY = 8,
+	UNI_CMD_GET_STATISTICS_TAG_GET_ML_CHNL_COND = 9,
+	UNI_CMD_GET_STATISTICS_TAG_STAT_WTBL = 10,
+	UNI_CMD_GET_STATISTICS_TAG_LINK_LAYER_STATS = 0x80,
+	UNI_CMD_GET_STATISTICS_TAG_PPDU_LATENCY,
+	UNI_CMD_GET_STATISTICS_TAG_CURRENT_TX_RATE,
+	UNI_CMD_GET_STATISTICS_TAG_BEACON_REPORT = 0x86,
+	UNI_CMD_GET_STATISTICS_TAG_BSS_CURRENT_TX_RATE = 0x87,
+	UNI_CMD_GET_STATISTICS_TAG_BSS_PRED_TX_BITRATE = 0x88,
+};
+
 #define UNI_WOW_DETECT_TYPE_MAGIC		BIT(0)
 #define UNI_WOW_DETECT_TYPE_ANY			BIT(1)
 #define UNI_WOW_DETECT_TYPE_DISCONNECT		BIT(2)
drivers/net/wireless/mediatek/mt76/mt7925/Makefile +1 -1
index f9dcc0bba393..3863a89b8974 100644
@@ -4,7 +4,7 @@ obj-$(CONFIG_MT7925_COMMON) += mt7925-common.o
 obj-$(CONFIG_MT7925E) += mt7925e.o
 obj-$(CONFIG_MT7925U) += mt7925u.o
 
-mt7925-common-y := mac.o mcu.o regd.o main.o init.o debugfs.o nan.o
+mt7925-common-y := mac.o mcu.o regd.o main.o init.o debugfs.o nan.o stats.o
 mt7925-common-$(CONFIG_NL80211_TESTMODE) += testmode.o
 mt7925e-y := pci.o pci_mac.o pci_mcu.o
 mt7925u-y := usb.o
drivers/net/wireless/mediatek/mt76/mt7925/debugfs.c +343 -0

360 lines not on this page · raw message

drivers/net/wireless/mediatek/mt76/mt7925/stats.c new file +585 -0

585 lines not on this page · raw message

drivers/net/wireless/mediatek/mt76/mt7925/stats.h new file +309 -0

309 lines not on this page · raw message

Signature · 1 line
2.45.2
author
#4 lore raw

PATCH v3 1/1 wifi: mt76: mt7928: Add debugfs for stats to provide debug purpose

From: Michael Shih <[email protected]>

Usage:
(1) Connect STA to AP (You may use dhclient CMD to ask for DHCP IP, to use ping to AP)

    DHCP IP CMD:  dhclient ${WLAN_IF} -v

Example: dhclient wlan0 -v

## (To simulate traffic) Ping 10 packets for every second to AP ping 192.168.0.XXX -i0.1

(2) (Get stats) Use command, phyX is your WiFi interface:

     cat /sys/kernel/debug/ieee80211/phyX/mt76/stats

(3) You will see below stats info:
(STA) connected AP MAC Address = a8:42:a1:46:c4:6b
BssIdx = [0]
StaRecIdx = [1],
RSSI = -25
Link_Speed = 2402000 (kbit/s)
temperature = 40
Tx success = 716
Tx fail to Rcv ACK after retry = 0
Rx Mpdu = 23
Rx Fcs Error = 1 (MPDU)
Rx FIFO full = 0 (MPDU)
TRX_AGG_RANGE[0] = 0 (PPDU) TRX_AGG_RANGE[1] = 0 (PPDU) TRX_AGG_RANGE[2] = 0 (PPDU) TRX_AGG_RANGE[3] = 0 (PPDU) TRX_AGG_RANGE[4] = 0 (PPDU) TRX_AGG_RANGE[5] = 0 (PPDU) TRX_AGG_RANGE[6] = 0 (PPDU) TRX_AGG_RANGE[7] = 0 (PPDU)
MPDUs in AMPDUs transmitted = 0 (MPDU) MPDUs in AMPDUs transmitted with ACK reply = 0 (MPDU) rate1_tx_cnt = 714
rate1_fail_cnt = 223
train_up = 2310
train_down = 3080
is_force_tx_stream = 0
is_force_se_off = 0
max_ampdu_factor = 9
tx_rate_up_penalty = 0
low_traffic_mode = 2
low_traffic_count = 0 low_traffic_dashboard = 3 dynamic_sgi_state = 0
dynamic_sgi_score = 2
dynamic_bw_state = 0 dynamic_gband_256qam_state = 3 vht_non_sp_rate_state = 0
Last TX Rate = 24M, BW20, OFDM, BCC, SPE24 Chip Out TX Power = +16.5 dBm
Cur Rate Index = 0
Rate index[0] --> NSS2_MCS11, BW160/BW8080, SGI, HE_SU, LDPC

Rate index[1]        NSS2_MCS9, BW160/BW8080, SGI, HE_SU, LDPC
Rate index[2]        NSS2_MCS7, BW160/BW8080, SGI, HE_SU, LDPC
Rate index[3]        NSS2_MCS4, BW160/BW8080, SGI, HE_SU, LDPC
Rate index[4]        NSS2_MCS3, BW160/BW8080, SGI, HE_SU, LDPC
Rate index[5]        NSS1_MCS2, BW160/BW8080, SGI, HE_SU, LDPC
Rate index[6]        NSS1_MCS1, BW80, SGI, HE_SU, LDPC
Rate index[7]        NSS1_MCS0, BW80, SGI, HE_SU, LDPC

mib state:
=== Rx Related Counters ===
Rx with CRC = 24020 (MPDU)
Rx drop due to out of resource = 0 (MPDU) Rx Mpdu = 93223 (MPDU)
Rx AMpdu = 668 (PPDU)
Rx PF Drop = 0 (MPDU)
Rx Len Mismatch = 5853 (PPDU)

=== Phy/Timing Related Counters ===

                        ChannelIdleCnt = 1040434
                        CCA_NAV_Tx_Time = 18510036
                        Rx_MDRDY_CNT = 166580 (PPDU)
                        CCK_MDRDY = 7782
                        OFDM_MDRDY = 11912731
                        OFDM_GREEN_MDRDY = 0
                        Prim CCA Time = 17917650
                        Sec CCA Time = 14922034
                        Prim ED Time = 5677528

=== Tx Related Counters(Generic) ===

                        BeaconTxCnt = 0
                        Tx 40MHz Cnt = 279  (MPDU)
                        Tx 80MHz Cnt = 44  (MPDU)
                        Tx 160MHz Cnt = 712  (MPDU)

=== BSSID[0] Related Counters ===
BA Miss Cnt = 210 (PPDU) RTS Tx Cnt = 1003 (MPDU) Frame Retry Cnt = 239 (MPDU) Frame Retry 2 Cnt = 71 (MPDU) RTS Retry Cnt = 152 (MPDU) Ack Failed Cnt = 319 (PPDU)

=== AMPDU Related Counters ===

                        Tx AMPDU_Pkt_Cnt = 705  (PPDU)
                        Tx AMPDU_MPDU_Pkt_Cnt = 713  (MPDU)
                        AMPDU Tx success = 503 (MPDU)
                        AMPDU Tx fail count   = 210  (MPDU), PER=29.4%

---
v2: (1) Remove redundant code to fix build errors.
(2) Move UNI_CMD_MIB_DATA enum definition from 'mt76/mt76_connac_mcu.h' to 'mt7925/stats.h' to avoid redeclartion with 'mt76/mt7996/mcu.h'
v3: Fixed build errors due to __udivdi3

---
 .../wireless/mediatek/mt76/mt76_connac_mcu.h  | 173 ++++++
 .../wireless/mediatek/mt76/mt7925/Makefile    |   2 +-
 .../wireless/mediatek/mt76/mt7925/debugfs.c   | 346 +++++++++++
 .../net/wireless/mediatek/mt76/mt7925/stats.c | 585 ++++++++++++++++++
 .../net/wireless/mediatek/mt76/mt7925/stats.h | 309 +++++++++
 5 files changed, 1414 insertions(+), 1 deletion(-)
 create mode 100644 drivers/net/wireless/mediatek/mt76/mt7925/stats.c
 create mode 100644 drivers/net/wireless/mediatek/mt76/mt7925/stats.h
drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h +173 -0
index 0ededa569e9a..bf0f105c786e 100644
@@ -1483,6 +1483,179 @@ enum {
 	MT_NIC_CAP_EML_CAP = 0x22,
 };
 
+enum {
+	UNI_CMD_ID_STATISTICS_BASIC = 0,
+	UNI_CMD_ID_STATISTICS_LINK_QUALITY = 1,
+	UNI_CMD_ID_STATISTICS_STA = 2,
+	UNI_CMD_ID_STATISTICS_BUG_REPORT = 3,
+	UNI_CMD_ID_STATISTICS_TX_STATS = 4,
+	UNI_CMD_ID_STATISTICS_ALL_STATS = 5,
+	UNI_CMD_ID_STATISTICS_EML_STATS = 6,
+	UNI_CMD_ID_STATISTICS_REGULAR_STATS = 7,
+	UNI_CMD_ID_STATISTICS_BSS_LINK_QUALITY = 8,
+	UNI_CMD_ID_STATISTICS_ML_CHNL_COND = 9,
+	UNI_CMD_ID_STATISTICS_WTBL = 10,
+	UNI_CMD_ID_STATISTICS_LINK_LAYER_STATS = 128,
+	UNI_CMD_ID_STATISTICS_PPDU_LATENCY = 129,
+	UNI_CMD_ID_STATISTICS_CURRENT_TX_RATE = 130,
+	UNI_CMD_ID_STATISTICS_SET_TX_BITRATE_MONITOR = 131,
+	UNI_CMD_ID_STATISTICS_GET_PREDICT_TX_BITRATE = 132,
+	UNI_CMD_ID_STATISTICS_SET_ATPS_TYPE_RATE_MODE = 133,
+	UNI_CMD_ID_STATISTICS_SET_BEACON_REPORT = 134,
+	UNI_CMD_ID_STATISTICS_BSS_CURRENT_TX_RATE = 135,
+	UNI_CMD_ID_STATISTICS_GET_BSS_PREDICT_TX_BITRATE = 136,
+	UNI_CMD_ID_STATISTICS_MAX_NUM
+};
+
+enum mt7925_mib_counter {
+	UNI_CMD_MIB_CNT_RX_FCS_ERR = 0,
+	UNI_CMD_MIB_CNT_RX_FIFO_OVERFLOW = 1,
+	UNI_CMD_MIB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CA_SAMPLE_ACTIVE = 89,
+	UNI_CMD_MIB_CNT_CCA_TIME = 90,
+	UNI_CMD_MIB_CNT_S_20BW_CCA_TIME = 91,
+	UNI_CMD_MIB_CNT_S_40BW_CCA_TIME = 92,
+	UNI_CMD_MIB_CNT_S_80BW_CCA_TIME = 93,
+	UNI_CMD_MIB_CNT_S_160BW_CCA_TIME = 94,
+	UNI_CMD_MIB_CNT_S_P20BW_0_ED_TIME = 95,
+	UNI_CMD_MIB_CNT_S_P20BW_1_ED_TIME = 96,
+	UNI_CMD_MIB_CNT_S_P20BW_2_ED_TIME = 97,
+	UNI_CMD_MIB_CNT_S_P20BW_3_ED_TIME = 98,
+	UNI_CMD_MIB_CNT_S_P20BW_4_ED_TIME = 99,
+	UNI_CMD_MIB_CNT_S_P20BW_5_ED_TIME = 100,
+	UNI_CMD_MIB_CNT_S_P20BW_6_ED_TIME = 101,
+	UNI_CMD_MIB_CNT_S_P20BW_7_ED_TIME = 102,
+	UNI_CMD_MIB_CNT_S_P20BW_8_ED_TIME = 103,
+	UNI_CMD_MIB_CNT_S_P20BW_9_ED_TIME = 104,
+	UNI_CMD_MIB_CNT_S_P20BW_10_ED_TIME = 105,
+	UNI_CMD_MIB_CNT_S_P20BW_11_ED_TIME = 106,
+	UNI_CMD_MIB_CNT_S_P20BW_12_ED_TIME = 107,
+	UNI_CMD_MIB_CNT_S_P20BW_13_ED_TIME = 108,
+	UNI_CMD_MIB_CNT_S_P20BW_14_ED_TIME = 109,
+	UNI_CMD_MIB_CNT_S_P20BW_15_ED_TIME = 110,
+	UNI_CMD_MIB_CNT_TX_BW_320MHZ = 111,
+	UNI_CMD_MIB_CNT_TX_DDLMT_RNG0 = 112, /* Rng0~Rng4 112~116 */
+	UNI_CMD_MIB_CNT_BSS0_FRAME_RETRY_3 = 117, /* 117~120 */
+	UNI_CMD_MIB_CNT_BSS0_TX = 121, /* 121~124 */
+	UNI_CMD_MIB_CNT_BSS0_TX_DATA = 125, /* 125~128 */
+	UNI_CMD_MIB_CNT_BSS0_TX_BYTE = 129, /* 129~132 */
+	UNI_CMD_MIB_CNT_RX_OK_BSS0 = 133, /* 133~136 */
+	UNI_CMD_MIB_CNT_RX_BYTE_BSS0 = 137, /* 137~140 */
+	UNI_CMD_MIB_CNT_RX_DATA_BSS0 = 141, /* 141~144 */
+	UNI_CMD_MIB_CNT_MBSS0_TX_OK = 145, /* 145~160 */
+	UNI_CMD_MIB_CNT_MBSS0_TX_BYTE = 161, /* 161~176 */
+	UNI_CMD_MIB_CNT_RX_OK_MBSS0 = 177, /* 177~192 */
+	UNI_CMD_MIB_CNT_RX_BYTE_MBSS0 = 193, /* 193~208 */
+	UNI_CMD_MIB_CNT_AMPDU = 209,
+	UNI_CMD_MIB_CNT_AMPDU_MPDU = 210,
+	UNI_CMD_MIB_CNT_AMPDU_ACKED = 211,
+	UNI_CMD_MIB_CNT_MAX_NUM
+};
+
+enum ENUM_UNI_CMD_GET_STATISTICS_TAG {
+	UNI_CMD_GET_STATISTICS_TAG_BASIC = 0,
+	UNI_CMD_GET_STATISTICS_TAG_LINK_QUALITY = 1,
+	UNI_CMD_GET_STATISTICS_TAG_STA = 2,
+	UNI_CMD_GET_STATISTICS_TAG_BUG_REPORT = 3,
+	UNI_CMD_GET_STATISTICS_TAG_EML_STATS = 6,
+	UNI_CMD_GET_STATISTICS_TAG_REGULAR_STATS = 7,
+	UNI_CMD_GET_STATISTICS_TAG_BSS_LINK_QUALITY = 8,
+	UNI_CMD_GET_STATISTICS_TAG_GET_ML_CHNL_COND = 9,
+	UNI_CMD_GET_STATISTICS_TAG_STAT_WTBL = 10,
+	UNI_CMD_GET_STATISTICS_TAG_LINK_LAYER_STATS = 0x80,
+	UNI_CMD_GET_STATISTICS_TAG_PPDU_LATENCY,
+	UNI_CMD_GET_STATISTICS_TAG_CURRENT_TX_RATE,
+	UNI_CMD_GET_STATISTICS_TAG_BEACON_REPORT = 0x86,
+	UNI_CMD_GET_STATISTICS_TAG_BSS_CURRENT_TX_RATE = 0x87,
+	UNI_CMD_GET_STATISTICS_TAG_BSS_PRED_TX_BITRATE = 0x88,
+};
+
 #define UNI_WOW_DETECT_TYPE_MAGIC		BIT(0)
 #define UNI_WOW_DETECT_TYPE_ANY			BIT(1)
 #define UNI_WOW_DETECT_TYPE_DISCONNECT		BIT(2)
drivers/net/wireless/mediatek/mt76/mt7925/Makefile +1 -1
index f9dcc0bba393..3863a89b8974 100644
@@ -4,7 +4,7 @@ obj-$(CONFIG_MT7925_COMMON) += mt7925-common.o
 obj-$(CONFIG_MT7925E) += mt7925e.o
 obj-$(CONFIG_MT7925U) += mt7925u.o
 
-mt7925-common-y := mac.o mcu.o regd.o main.o init.o debugfs.o nan.o
+mt7925-common-y := mac.o mcu.o regd.o main.o init.o debugfs.o nan.o stats.o
 mt7925-common-$(CONFIG_NL80211_TESTMODE) += testmode.o
 mt7925e-y := pci.o pci_mac.o pci_mcu.o
 mt7925u-y := usb.o
drivers/net/wireless/mediatek/mt76/mt7925/debugfs.c +346 -0

365 lines not on this page · raw message

drivers/net/wireless/mediatek/mt76/mt7925/stats.c new file +585 -0

585 lines not on this page · raw message

drivers/net/wireless/mediatek/mt76/mt7925/stats.h new file +309 -0

309 lines not on this page · raw message

Signature · 1 line
2.45.2
#5 lore raw
kernel test robot noticed the following build warnings:

Hi Eason,

kernel test robot noticed the following build warnings:

[auto build test WARNING on wireless-next/main]
[also build test WARNING on linus/master next-20260826] [cannot apply to wireless/main v7.2]
[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/Eason-Lai/wifi-mt76-mt7928-Add-debugfs-for-stats-to-provide-debug-purpose/20260827-164427
base:   https://git.kernel.org/pub/scm/linux/kernel/git/wireless/wireless-next.git main
patch link:    https://lore.kernel.org/r/20260827084427.1624598-1-eason.lai%40mediatek.com
patch subject: [PATCH v3] wifi: mt76: mt7928: Add debugfs for stats to provide debug purpose
config: sparc-randconfig-r073-20260828 (https://download.01.org/0day-ci/archive/20260828/[email protected]/config)
compiler: sparc-linux-gcc (GCC) 14.3.0
smatch: v0.5.0-9187-g5189e3fb

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]/

smatch warnings:
drivers/net/wireless/mediatek/mt76/mt7925/debugfs.c:437 mt792x_stats() warn: inconsistent indenting drivers/net/wireless/mediatek/mt76/mt7925/debugfs.c:540 mt792x_stats() error: testing array offset 'band_idx' after use.

vim +437 drivers/net/wireless/mediatek/mt76/mt7925/debugfs.c

415
416 static int mt792x_stats(struct seq_file *s, void *data)
417 {
418 s8 rssi = 0;
419 u8 band_idx = 0;
420 bool wtbl_rate_valid = false;
421 int ret = 0;
422 int i = 0;
423 u32 stats_value = 0;
424 u32 tx_link_speed_kbps = 0;
425 u64 tx_total = 0;
426 u64 tx_fail = 0;
427 u64 tx_per = 0;
428 u32 tx_per_rem = 0;
429 /* UNI_CMD_MIB_DATA */
430 u64 mib_values[ARRAY_SIZE(stats_query_mib_counters)];
431 struct mt792x_dev *dev = dev_get_drvdata(s->private);
432 struct mt7925_wtbl_rate wtbl_rate;
433 struct mt7925_sta_stats *stats = NULL;
434
435 band_idx = dev->mphy.band_idx;
436

 > 437		 stats = kzalloc(sizeof(*stats), GFP_KERNEL);
   438		if (!stats)
   439			return -ENOMEM;
   440	
   441		/* Get STA_STATS */
   442		mt792x_mutex_acquire(dev);
   443		ret = mt792x_mcu_get_stat(dev, stats);
   444		mt792x_mutex_release(dev);
   445		if (ret)
   446			goto out;
   447	
   448		/* Get MIB_STATS */
   449		mt792x_mutex_acquire(dev);
   450		ret = mt7925_mcu_get_mib_info(dev, band_idx, stats_query_mib_counters,
   451					      ARRAY_SIZE(stats_query_mib_counters), mib_values);
   452		mt792x_mutex_release(dev);
   453		if (ret)
   454			goto out;
   455	
   456		/* Get Link_Speed and RSSI */
   457		mt792x_mutex_acquire(dev);
   458		ret = mt7925_mcu_get_link_quality(dev, stats->bss_idx, &rssi, &tx_link_speed_kbps);
   459		mt792x_mutex_release(dev);
   460		if (ret)
   461			goto out;
   462	
   463		/* Get the firmware auto-rate table (best effort; do not abort the
   464		 * whole stats dump if the WTBL query is not available).
   465		 */
   466		mt792x_mutex_acquire(dev);
   467		if (!mt792x_mcu_get_wtbl_rate(dev, stats->wtbl_idx, &wtbl_rate))
   468			wtbl_rate_valid = true;
   469		mt792x_mutex_release(dev);
   470	
   471		/* Print STA_STATS info */
   472		seq_printf(s, "(STA) connected AP MAC Address = %pM\n", stats->mac_addr);
   473		seq_printf(s, "%-22s  BssIdx = [%u]\n", " ", stats->bss_idx);
   474		seq_printf(s, "%-22s  StaRecIdx = [%u]\n",
   475			   " ", stats->sta_idx);
   476		seq_printf(s, "%-22s  RSSI = %d\n", " ", rssi);
   477		seq_printf(s, "%-22s  Link_Speed = %u (kbit/s)\n", " ", tx_link_speed_kbps);
   478	
   479		seq_printf(s, "%-22s  temperature = %u\n",
   480			   " ", stats->temperature);
   481	
   482		stats_value = le32_to_cpu(stats->transmit_count) - le32_to_cpu(stats->transmit_fail_count);
   483		seq_printf(s, "%-22s  Tx success = %u\n",
   484			   " ", stats_value);
   485	
   486		stats_value = le32_to_cpu(stats->tx_fail_count) - le32_to_cpu(stats->tx_life_timeout_count);
   487		seq_printf(s, "%-22s  Tx fail to Rcv ACK after retry = %u\n",
   488			   " ", stats_value);
   489	
   490		seq_printf(s, "%-22s  Rx Mpdu = %u\n",
   491			   " ", le32_to_cpu(stats->mib[band_idx].rx_mpdu_cnt));
   492	
   493		seq_printf(s, "%-22s  Rx Fcs Error = %u (MPDU)\n",
   494			   " ", le32_to_cpu(stats->mib[band_idx].fcs_error));
   495		seq_printf(s, "%-22s  Rx FIFO full = %u (MPDU)\n",
   496			   " ", le32_to_cpu(stats->mib[band_idx].rx_fifo_full));
   497	
   498		for (i = 0; i < STAT_MIB_CNT_TRX_AGG_RANGE_MAX_NUM; i++)
   499			seq_printf(s, "%-22s  TRX_AGG_RANGE[%d] = %u (PPDU)\n",
   500				   " ", i, le32_to_cpu(stats->mib[band_idx].tx_range_ampdu_cnt[i]));
   501	
   502		seq_printf(s, "%-22s  MPDUs in AMPDUs transmitted = %u (MPDU)\n",
   503			   " ", le32_to_cpu(stats->mib[band_idx].ampdu_tx_sf_cnt));
   504		seq_printf(s, "%-22s  MPDUs in AMPDUs transmitted with ACK reply = %u (MPDU)\n",
   505			   " ", le32_to_cpu(stats->mib[band_idx].ampdu_tx_ack_sf_cnt));
   506		seq_printf(s, "%-22s  rate1_tx_cnt = %u\n",
   507			   " ", le32_to_cpu(stats->rate1_tx_cnt));
   508		seq_printf(s, "%-22s  rate1_fail_cnt = %u\n",
   509			   " ", le32_to_cpu(stats->rate1_fail_cnt));
   510		seq_printf(s, "%-22s  train_up = %u\n",
   511			   " ", le16_to_cpu(stats->train_up));
   512		seq_printf(s, "%-22s  train_down = %u\n",
   513			   " ", le16_to_cpu(stats->train_down));
   514		seq_printf(s, "%-22s  is_force_tx_stream = %u\n",
   515			   " ", stats->is_force_tx_stream);
   516		seq_printf(s, "%-22s  is_force_se_off = %u\n",
   517			   " ", stats->is_force_se_off);
   518		seq_printf(s, "%-22s  max_ampdu_factor = %u\n",
   519			   " ", stats->max_ampdu_factor);
   520		seq_printf(s, "%-22s  tx_rate_up_penalty = %u\n",
   521			   " ", stats->tx_rate_up_penalty);
   522		seq_printf(s, "%-22s  low_traffic_mode = %u\n",
   523			   " ", stats->low_traffic_mode);
   524		seq_printf(s, "%-22s  low_traffic_count = %u\n",
   525			   " ", stats->low_traffic_count);
   526		seq_printf(s, "%-22s  low_traffic_dashboard = %u\n",
   527			   " ", stats->low_traffic_dashboard);
   528		seq_printf(s, "%-22s  dynamic_sgi_state = %u\n",
   529			   " ", stats->dynamic_sgi_state);
   530		seq_printf(s, "%-22s  dynamic_sgi_score = %u\n",
   531			   " ", stats->dynamic_sgi_score);
   532		seq_printf(s, "%-22s  dynamic_bw_state = %u\n",
   533			   " ", stats->dynamic_bw_state);
   534		seq_printf(s, "%-22s  dynamic_gband_256qam_state = %u\n",
   535			   " ", stats->dynamic_gband_256qam_state);
   536		seq_printf(s, "%-22s  vht_non_sp_rate_state = %u\n",
   537			   " ", stats->vht_non_sp_rate_state);
   538	
   539		/* Decode the TX Vector BBP latch to show the current TX MCS rate */
 > 540		if (band_idx < MT7925_STA_STATS_BAND_NUM)
   541			mt7925_print_last_tx_rate(s, stats->tx_vector[band_idx].txv);
   542	
   543		/* Dump the whole firmware auto-rate table and mark the entry currently */
   544		if (wtbl_rate_valid)
   545			mt7925_dump_auto_rate_table(s, &wtbl_rate);
   546	
   547		seq_puts(s, "\nmib state:\n");
   548		/* ===Rx Related Counters=== */
   549		seq_puts(s, "=== Rx Related Counters ===\n");
   550		seq_printf(s, "%-22s  Rx with CRC = %llu (MPDU)\n",
   551			   " ", mib_values[QUERY_MIB_CNT_RX_FCS_ERR]);
   552		seq_printf(s, "%-22s  Rx drop due to out of resource = %llu (MPDU)\n",
   553			   " ", mib_values[QUERY_MIB_CNT_RX_FIFO_OVERFLOW]);
   554		seq_printf(s, "%-22s  Rx Mpdu = %llu (MPDU)\n",
   555			   " ", mib_values[QUERY_MIB_CNT_RX_MPDU]);
   556		seq_printf(s, "%-22s  Rx AMpdu = %llu (PPDU)\n",
   557			   " ", mib_values[QUERY_MIB_CNT_AMPDU_RX_COUNT]);
   558		seq_printf(s, "%-22s  Rx PF Drop = %llu (MPDU)\n",
   559			   " ", mib_values[QUERY_MIB_CNT_PF_DROP]);
   560		seq_printf(s, "%-22s  Rx Len Mismatch = %llu (PPDU)\n",
   561			   " ", mib_values[QUERY_MIB_CNT_LEN_MISMATCH]);
   562	
   563		/* ===Phy/Timing Related Counters=== */
   564		seq_puts(s, "\n=== Phy/Timing Related Counters ===\n");
   565		seq_printf(s, "%-22s  ChannelIdleCnt = %llu\n",
   566			   " ", mib_values[QUERY_MIB_CNT_CHANNEL_IDLE]);
   567		seq_printf(s, "%-22s  CCA_NAV_Tx_Time = %llu\n",
   568			   " ", mib_values[QUERY_MIB_CNT_CCA_NAV_TX_TIME]);
   569		seq_printf(s, "%-22s  Rx_MDRDY_CNT = %llu (PPDU)\n",
   570			   " ", mib_values[QUERY_MIB_CNT_MDRDY]);
   571		seq_printf(s, "%-22s  CCK_MDRDY = %llu\n",
   572			   " ", mib_values[QUERY_MIB_CNT_RX_CCK_MDRDY_TIME]);
   573		seq_printf(s, "%-22s  OFDM_MDRDY = %llu\n",
   574			   " ", mib_values[QUERY_MIB_CNT_RX_OFDM_LG_MIXED_MDRDY_TIME]);
   575		seq_printf(s, "%-22s  OFDM_GREEN_MDRDY = %llu\n",
   576			   " ", mib_values[QUERY_MIB_CNT_RX_OFDM_GREEN_MDRDY_TIME]);
   577		seq_printf(s, "%-22s  Prim CCA Time = %llu\n",
   578			   " ", mib_values[QUERY_MIB_CNT_P_CCA_TIME]);
   579		seq_printf(s, "%-22s  Sec CCA Time = %llu\n",
   580			   " ", mib_values[QUERY_MIB_CNT_S_CCA_TIME]);
   581		seq_printf(s, "%-22s  Prim ED Time = %llu\n",
   582			   " ", mib_values[QUERY_MIB_CNT_P_ED_TIME]);
   583	
   584		/* ===Tx Related Counters(Generic)=== */
   585		seq_puts(s, "\n=== Tx Related Counters(Generic) ===\n");
   586		seq_printf(s, "%-22s  BeaconTxCnt = %llu\n",
   587			   " ", mib_values[QUERY_MIB_CNT_BCN_TX]);
   588		seq_printf(s, "%-22s  Tx 40MHz Cnt = %llu  (MPDU)\n",
   589			   " ", mib_values[QUERY_MIB_CNT_TX_BW_40MHZ]);
   590		seq_printf(s, "%-22s  Tx 80MHz Cnt = %llu  (MPDU)\n",
   591			   " ", mib_values[QUERY_MIB_CNT_TX_BW_80MHZ]);
   592		seq_printf(s, "%-22s  Tx 160MHz Cnt = %llu  (MPDU)\n",
   593			   " ", mib_values[QUERY_MIB_CNT_TX_BW_160MHZ]);
   594	
   595		/* ===BSSID[0] Related Counters=== */
   596		seq_puts(s, "\n=== BSSID[0] Related Counters ===\n");
   597		seq_printf(s, "%-22s  BA Miss Cnt = %llu  (PPDU)\n",
   598			   " ", mib_values[QUERY_MIB_CNT_BSS0_BA_MISS]);
   599		seq_printf(s, "%-22s  RTS Tx Cnt = %llu  (MPDU)\n",
   600			   " ", mib_values[QUERY_MIB_CNT_BSS0_RTS_TX_CNT]);
   601		seq_printf(s, "%-22s  Frame Retry Cnt = %llu (MPDU)\n",
   602			   " ", mib_values[QUERY_MIB_CNT_BSS0_FRAME_RETRY]);
   603		seq_printf(s, "%-22s  Frame Retry 2 Cnt = %llu (MPDU)\n",
   604			   " ", mib_values[QUERY_MIB_CNT_BSS0_FRAME_RETRY_2]);
   605		seq_printf(s, "%-22s  RTS Retry Cnt = %llu (MPDU)\n",
   606			   " ", mib_values[QUERY_MIB_CNT_BSS0_RTS_RETRY]);
   607		seq_printf(s, "%-22s  Ack Failed Cnt = %llu (PPDU)\n",
   608			   " ", mib_values[QUERY_MIB_CNT_BSS0_ACK_FAIL]);
   609	
   610		/* ===AMPDU Related Counters=== */
   611		seq_puts(s, "\n=== AMPDU Related Counters ===\n");
   612		seq_printf(s, "%-22s  Tx AMPDU_Pkt_Cnt = %llu  (PPDU)\n",
   613			   " ", mib_values[QUERY_MIB_CNT_AMPDU]);
   614		seq_printf(s, "%-22s  Tx AMPDU_MPDU_Pkt_Cnt = %llu  (MPDU)\n",
   615			   " ", mib_values[QUERY_MIB_CNT_AMPDU_MPDU]);
   616		seq_printf(s, "%-22s  AMPDU Tx success = %llu (MPDU)\n",
   617			   " ", mib_values[QUERY_MIB_CNT_AMPDU_ACKED]);
   618	
   619		tx_total = mib_values[QUERY_MIB_CNT_AMPDU_MPDU];
   620		tx_fail =  mib_values[QUERY_MIB_CNT_AMPDU_MPDU] - mib_values[QUERY_MIB_CNT_AMPDU_ACKED];
   621		tx_per = tx_total == 0 ? 0 : div64_u64(1000 * tx_fail, tx_total);
   622		seq_printf(s, "%-22s  AMPDU Tx fail count   = %llu  (MPDU), PER=%llu.%1llu%%\n",
   623			   " ",
   624			   tx_fail,
   625			   div_u64_rem(tx_per, 10, &tx_per_rem), (u64)tx_per_rem);

626
627 out:
628 kfree(stats);
629 return ret;
630 }
631

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

author
#6 lore raw

PATCH v4 1/1 wifi: mt76: mt7928: Add debugfs for stats to provide debug purpose

In reply to Eason Lai

From: Michael Shih <[email protected]>

Usage:
(1) Connect STA to AP
(You may use dhclient CMD to ask for DHCP IP, to use ping to AP) DHCP IP CMD: dhclient ${WLAN_IF} -v

Example: dhclient wlan0 -v

## (To simulate traffic) Ping 10 packets for every second to AP ping 192.168.0.XXX -i0.1

(2) (Get stats) Use command, phyX is your WiFi interface:

     cat /sys/kernel/debug/ieee80211/phyX/mt76/stats

(3) You will see below stats info:
(STA) connected AP MAC Address = a8:42:a1:46:c4:6b
BssIdx = [0]
StaRecIdx = [1],
RSSI = -25
Link_Speed = 2402000 (kbit/s)
temperature = 40
Tx success = 716
Tx fail to Rcv ACK after retry = 0
Rx Mpdu = 23
Rx Fcs Error = 1 (MPDU)
Rx FIFO full = 0 (MPDU)
TRX_AGG_RANGE[0] = 0 (PPDU) TRX_AGG_RANGE[1] = 0 (PPDU) TRX_AGG_RANGE[2] = 0 (PPDU) TRX_AGG_RANGE[3] = 0 (PPDU) TRX_AGG_RANGE[4] = 0 (PPDU) TRX_AGG_RANGE[5] = 0 (PPDU) TRX_AGG_RANGE[6] = 0 (PPDU) TRX_AGG_RANGE[7] = 0 (PPDU)
MPDUs in AMPDUs transmitted = 0 (MPDU) MPDUs in AMPDUs transmitted with ACK reply = 0 (MPDU) rate1_tx_cnt = 714
rate1_fail_cnt = 223
train_up = 2310
train_down = 3080
is_force_tx_stream = 0
is_force_se_off = 0
max_ampdu_factor = 9
tx_rate_up_penalty = 0
low_traffic_mode = 2
low_traffic_count = 0 low_traffic_dashboard = 3 dynamic_sgi_state = 0
dynamic_sgi_score = 2
dynamic_bw_state = 0 dynamic_gband_256qam_state = 3 vht_non_sp_rate_state = 0
Last TX Rate = 24M, BW20, OFDM, BCC, SPE24 Chip Out TX Power = +16.5 dBm
Cur Rate Index = 0
Rate index[0] --> NSS2_MCS11, BW160/BW8080, SGI, HE_SU, LDPC

Rate index[1]        NSS2_MCS9, BW160/BW8080, SGI, HE_SU, LDPC
Rate index[2]        NSS2_MCS7, BW160/BW8080, SGI, HE_SU, LDPC
Rate index[3]        NSS2_MCS4, BW160/BW8080, SGI, HE_SU, LDPC
Rate index[4]        NSS2_MCS3, BW160/BW8080, SGI, HE_SU, LDPC
Rate index[5]        NSS1_MCS2, BW160/BW8080, SGI, HE_SU, LDPC
Rate index[6]        NSS1_MCS1, BW80, SGI, HE_SU, LDPC
Rate index[7]        NSS1_MCS0, BW80, SGI, HE_SU, LDPC

mib state:
=== Rx Related Counters ===
Rx with CRC = 24020 (MPDU)
Rx drop due to out of resource = 0 (MPDU) Rx Mpdu = 93223 (MPDU)
Rx AMpdu = 668 (PPDU)
Rx PF Drop = 0 (MPDU)
Rx Len Mismatch = 5853 (PPDU)

=== Phy/Timing Related Counters ===

                        ChannelIdleCnt = 1040434
                        CCA_NAV_Tx_Time = 18510036
                        Rx_MDRDY_CNT = 166580 (PPDU)
                        CCK_MDRDY = 7782
                        OFDM_MDRDY = 11912731
                        OFDM_GREEN_MDRDY = 0
                        Prim CCA Time = 17917650
                        Sec CCA Time = 14922034
                        Prim ED Time = 5677528

=== Tx Related Counters(Generic) ===

                        BeaconTxCnt = 0
                        Tx 40MHz Cnt = 279  (MPDU)
                        Tx 80MHz Cnt = 44  (MPDU)
                        Tx 160MHz Cnt = 712  (MPDU)

=== BSSID[0] Related Counters ===
BA Miss Cnt = 210 (PPDU) RTS Tx Cnt = 1003 (MPDU) Frame Retry Cnt = 239 (MPDU) Frame Retry 2 Cnt = 71 (MPDU) RTS Retry Cnt = 152 (MPDU) Ack Failed Cnt = 319 (PPDU)

=== AMPDU Related Counters ===

                        Tx AMPDU_Pkt_Cnt = 705  (PPDU)
                        Tx AMPDU_MPDU_Pkt_Cnt = 713  (MPDU)
                        AMPDU Tx success = 503 (MPDU)
                        AMPDU Tx fail count   = 210  (MPDU), PER=29.4%

---
v2: (1) Remove redundant code to fix build errors.
(2) Move UNI_CMD_MIB_DATA enum definition from 'mt76/mt76_connac_mcu.h' to 'mt7925/stats.h' to avoid redeclartion with 'mt76/mt7996/mcu.h'
v3: (1) Remove redundant code to fix build errors.
(2) Move UNI_CMD_MIB_DATA enum definition from 'mt76/mt76_connac_mcu.h' to 'mt7925/stats.h' to avoid redeclartion with 'mt76/mt7996/mcu.h'
v4: (1) Fix inconsistent indenting.
(2) Fix array offset 'band_idx' as to before use, not after use.

---
 .../wireless/mediatek/mt76/mt76_connac_mcu.h  | 173 ++++++
 .../wireless/mediatek/mt76/mt7925/Makefile    |   2 +-
 .../wireless/mediatek/mt76/mt7925/debugfs.c   | 366 +++++++++++
 .../net/wireless/mediatek/mt76/mt7925/stats.c | 587 ++++++++++++++++++
 .../net/wireless/mediatek/mt76/mt7925/stats.h | 309 +++++++++
 5 files changed, 1436 insertions(+), 1 deletion(-)
 create mode 100644 drivers/net/wireless/mediatek/mt76/mt7925/stats.c
 create mode 100644 drivers/net/wireless/mediatek/mt76/mt7925/stats.h
drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h +173 -0
index 0ededa569e9a..bf0f105c786e 100644
@@ -1483,6 +1483,179 @@ enum {
 	MT_NIC_CAP_EML_CAP = 0x22,
 };
 
+enum {
+	UNI_CMD_ID_STATISTICS_BASIC = 0,
+	UNI_CMD_ID_STATISTICS_LINK_QUALITY = 1,
+	UNI_CMD_ID_STATISTICS_STA = 2,
+	UNI_CMD_ID_STATISTICS_BUG_REPORT = 3,
+	UNI_CMD_ID_STATISTICS_TX_STATS = 4,
+	UNI_CMD_ID_STATISTICS_ALL_STATS = 5,
+	UNI_CMD_ID_STATISTICS_EML_STATS = 6,
+	UNI_CMD_ID_STATISTICS_REGULAR_STATS = 7,
+	UNI_CMD_ID_STATISTICS_BSS_LINK_QUALITY = 8,
+	UNI_CMD_ID_STATISTICS_ML_CHNL_COND = 9,
+	UNI_CMD_ID_STATISTICS_WTBL = 10,
+	UNI_CMD_ID_STATISTICS_LINK_LAYER_STATS = 128,
+	UNI_CMD_ID_STATISTICS_PPDU_LATENCY = 129,
+	UNI_CMD_ID_STATISTICS_CURRENT_TX_RATE = 130,
+	UNI_CMD_ID_STATISTICS_SET_TX_BITRATE_MONITOR = 131,
+	UNI_CMD_ID_STATISTICS_GET_PREDICT_TX_BITRATE = 132,
+	UNI_CMD_ID_STATISTICS_SET_ATPS_TYPE_RATE_MODE = 133,
+	UNI_CMD_ID_STATISTICS_SET_BEACON_REPORT = 134,
+	UNI_CMD_ID_STATISTICS_BSS_CURRENT_TX_RATE = 135,
+	UNI_CMD_ID_STATISTICS_GET_BSS_PREDICT_TX_BITRATE = 136,
+	UNI_CMD_ID_STATISTICS_MAX_NUM
+};
+
+enum mt7925_mib_counter {
+	UNI_CMD_MIB_CNT_RX_FCS_ERR = 0,
+	UNI_CMD_MIB_CNT_RX_FIFO_OVERFLOW = 1,
+	UNI_CMD_MIB_CNT_RX_MPDU = 2,
+	UNI_CMD_MIB_CNT_AMPDU_RX_COUNT = 3,
+	UNI_CMD_MIB_CNT_RX_TOTAL_BYTE = 4,
+	UNI_CMD_MIB_CNT_RX_VALID_AMPDU_SF = 5,
+	UNI_CMD_MIB_CNT_RX_VALID_BYTE = 6,
+	UNI_CMD_MIB_CNT_CHANNEL_IDLE = 7,
+	UNI_CMD_MIB_CNT_VEC_DROP = 8,
+	UNI_CMD_MIB_CNT_DELIMITER_FAIL = 9,
+	UNI_CMD_MIB_CNT_VEC_MISMATCH = 10,
+	UNI_CMD_MIB_CNT_MDRDY = 11,
+	UNI_CMD_MIB_CNT_RX_CCK_MDRDY_TIME = 12,
+	UNI_CMD_M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W_4_ED_TIME = 99,
+	UNI_CMD_MIB_CNT_S_P20BW_5_ED_TIME = 100,
+	UNI_CMD_MIB_CNT_S_P20BW_6_ED_TIME = 101,
+	UNI_CMD_MIB_CNT_S_P20BW_7_ED_TIME = 102,
+	UNI_CMD_MIB_CNT_S_P20BW_8_ED_TIME = 103,
+	UNI_CMD_MIB_CNT_S_P20BW_9_ED_TIME = 104,
+	UNI_CMD_MIB_CNT_S_P20BW_10_ED_TIME = 105,
+	UNI_CMD_MIB_CNT_S_P20BW_11_ED_TIME = 106,
+	UNI_CMD_MIB_CNT_S_P20BW_12_ED_TIME = 107,
+	UNI_CMD_MIB_CNT_S_P20BW_13_ED_TIME = 108,
+	UNI_CMD_MIB_CNT_S_P20BW_14_ED_TIME = 109,
+	UNI_CMD_MIB_CNT_S_P20BW_15_ED_TIME = 110,
+	UNI_CMD_MIB_CNT_TX_BW_320MHZ = 111,
+	UNI_CMD_MIB_CNT_TX_DDLMT_RNG0 = 112, /* Rng0~Rng4 112~116 */
+	UNI_CMD_MIB_CNT_BSS0_FRAME_RETRY_3 = 117, /* 117~120 */
+	UNI_CMD_MIB_CNT_BSS0_TX = 121, /* 121~124 */
+	UNI_CMD_MIB_CNT_BSS0_TX_DATA = 125, /* 125~128 */
+	UNI_CMD_MIB_CNT_BSS0_TX_BYTE = 129, /* 129~132 */
+	UNI_CMD_MIB_CNT_RX_OK_BSS0 = 133, /* 133~136 */
+	UNI_CMD_MIB_CNT_RX_BYTE_BSS0 = 137, /* 137~140 */
+	UNI_CMD_MIB_CNT_RX_DATA_BSS0 = 141, /* 141~144 */
+	UNI_CMD_MIB_CNT_MBSS0_TX_OK = 145, /* 145~160 */
+	UNI_CMD_MIB_CNT_MBSS0_TX_BYTE = 161, /* 161~176 */
+	UNI_CMD_MIB_CNT_RX_OK_MBSS0 = 177, /* 177~192 */
+	UNI_CMD_MIB_CNT_RX_BYTE_MBSS0 = 193, /* 193~208 */
+	UNI_CMD_MIB_CNT_AMPDU = 209,
+	UNI_CMD_MIB_CNT_AMPDU_MPDU = 210,
+	UNI_CMD_MIB_CNT_AMPDU_ACKED = 211,
+	UNI_CMD_MIB_CNT_MAX_NUM
+};
+
+enum ENUM_UNI_CMD_GET_STATISTICS_TAG {
+	UNI_CMD_GET_STATISTICS_TAG_BASIC = 0,
+	UNI_CMD_GET_STATISTICS_TAG_LINK_QUALITY = 1,
+	UNI_CMD_GET_STATISTICS_TAG_STA = 2,
+	UNI_CMD_GET_STATISTICS_TAG_BUG_REPORT = 3,
+	UNI_CMD_GET_STATISTICS_TAG_EML_STATS = 6,
+	UNI_CMD_GET_STATISTICS_TAG_REGULAR_STATS = 7,
+	UNI_CMD_GET_STATISTICS_TAG_BSS_LINK_QUALITY = 8,
+	UNI_CMD_GET_STATISTICS_TAG_GET_ML_CHNL_COND = 9,
+	UNI_CMD_GET_STATISTICS_TAG_STAT_WTBL = 10,
+	UNI_CMD_GET_STATISTICS_TAG_LINK_LAYER_STATS = 0x80,
+	UNI_CMD_GET_STATISTICS_TAG_PPDU_LATENCY,
+	UNI_CMD_GET_STATISTICS_TAG_CURRENT_TX_RATE,
+	UNI_CMD_GET_STATISTICS_TAG_BEACON_REPORT = 0x86,
+	UNI_CMD_GET_STATISTICS_TAG_BSS_CURRENT_TX_RATE = 0x87,
+	UNI_CMD_GET_STATISTICS_TAG_BSS_PRED_TX_BITRATE = 0x88,
+};
+
 #define UNI_WOW_DETECT_TYPE_MAGIC		BIT(0)
 #define UNI_WOW_DETECT_TYPE_ANY			BIT(1)
 #define UNI_WOW_DETECT_TYPE_DISCONNECT		BIT(2)
drivers/net/wireless/mediatek/mt76/mt7925/Makefile +1 -1
index f9dcc0bba393..3863a89b8974 100644
@@ -4,7 +4,7 @@ obj-$(CONFIG_MT7925_COMMON) += mt7925-common.o
 obj-$(CONFIG_MT7925E) += mt7925e.o
 obj-$(CONFIG_MT7925U) += mt7925u.o
 
-mt7925-common-y := mac.o mcu.o regd.o main.o init.o debugfs.o nan.o
+mt7925-common-y := mac.o mcu.o regd.o main.o init.o debugfs.o nan.o stats.o
 mt7925-common-$(CONFIG_NL80211_TESTMODE) += testmode.o
 mt7925e-y := pci.o pci_mac.o pci_mcu.o
 mt7925u-y := usb.o
drivers/net/wireless/mediatek/mt76/mt7925/debugfs.c +366 -0

385 lines not on this page · raw message

drivers/net/wireless/mediatek/mt76/mt7925/stats.c new file +587 -0

587 lines not on this page · raw message

drivers/net/wireless/mediatek/mt76/mt7925/stats.h new file +309 -0

309 lines not on this page · raw message

Signature · 1 line
2.45.2
#7 lore raw

v5 cover wifi: mt76: mt7925: per-channel survey dump during scan

This series improves channel survey reporting for mt7925 so that "iw <dev> survey dump" shows meaningful per-channel airtime.

Patch 1 adds a stats debugfs infrastructure (shared stats.c/stats.h and the firmware MIB plumbing) that patch 2 builds on.

Patch 2 wires up two channel survey accounting paths on top of it:
- the home/operating channel, settled from assign_vif_chanctx() since mt7925 is firmware/chanctx managed and never goes through __mt76_set_channel(); and
- the scanned channels, folded in from the per-channel airtime carried by the firmware scan-done CHNLINFO event.

After the series, both the connected channel and every channel visited during a firmware-offloaded scan report non-zero active/busy/rx/tx time.

Changes since v4:
---
v2: (1) Remove redundant code to fix build errors.
(2) Move UNI_CMD_MIB_DATA enum definition from 'mt76/mt76_connac_mcu.h' to 'mt7925/stats.h' to avoid redeclartion with 'mt76/mt7996/mcu.h'
v3: (1) Remove redundant code to fix build errors.
(2) Move UNI_CMD_MIB_DATA enum definition from 'mt76/mt76_connac_mcu.h' to 'mt7925/stats.h' to avoid redeclartion with 'mt76/mt7996/mcu.h'
v4: (1) Fix inconsistent indenting.
(2) Fix array offset 'band_idx' as to before use, not after use.
v5: Adding the second patch for supporting channel survey command: "iw <dev> survey dump"
---
Michael Shih (2):
wifi: mt76: mt7928: Add debugfs for stats to provide debug purpose
wifi: mt76: mt7925: support per-channel survey dump during scan

 drivers/net/wireless/mediatek/mt76/mac80211.c |   3 +-
 drivers/net/wireless/mediatek/mt76/mt76.h     |   2 +
 .../wireless/mediatek/mt76/mt76_connac_mcu.h  | 173 ++++
 .../wireless/mediatek/mt76/mt7925/Makefile    |   2 +-
 .../wireless/mediatek/mt76/mt7925/debugfs.c   | 344 +++++++
 .../net/wireless/mediatek/mt76/mt7925/main.c  |  12 +
 .../net/wireless/mediatek/mt76/mt7925/mcu.h   |  30 +
 .../wireless/mediatek/mt76/mt7925/mt7925.h    |   7 +
 .../net/wireless/mediatek/mt76/mt7925/pci.c   |   2 +-
 .../net/wireless/mediatek/mt76/mt7925/stats.c | 884 ++++++++++++++++++
 .../net/wireless/mediatek/mt76/mt7925/stats.h | 315 +++++++
 .../net/wireless/mediatek/mt76/mt7925/usb.c   |   2 +-
 drivers/net/wireless/mediatek/mt76/mt792x.h   |   6 +
 13 files changed, 1778 insertions(+), 4 deletions(-)
 create mode 100644 drivers/net/wireless/mediatek/mt76/mt7925/stats.c
 create mode 100644 drivers/net/wireless/mediatek/mt76/mt7925/stats.h
Signature · 1 line
2.45.2
#8 lore raw

PATCH v5 1/2 wifi: mt76: mt7928: Add debugfs for stats to provide debug purpose

Usage:
(1) Connect STA to AP (You can use dhclient CMD to ask for DHCP IP, to use ping to AP)

    DHCP IP CMD:  dhclient ${WLAN_IF} -v

Example: dhclient wlan0 -v

## (To simulate traffic) Ping 10 packets for every second to AP ping 192.168.0.XXX -i0.1

(2) (Get stats) Use command, phyX is your WiFi interface:

     cat /sys/kernel/debug/ieee80211/phyX/mt76/stats

(3) You will see below stats info:
(STA) connected AP MAC Address = a8:42:a1:46:c4:6b
BssIdx = [0]
StaRecIdx = [1],
RSSI = -25
Link_Speed = 2402000 (kbit/s)
temperature = 40
Tx success = 716
Tx fail to Rcv ACK after retry = 0
Rx Mpdu = 23
Rx Fcs Error = 1 (MPDU)
Rx FIFO full = 0 (MPDU)
TRX_AGG_RANGE[0] = 0 (PPDU) TRX_AGG_RANGE[1] = 0 (PPDU) TRX_AGG_RANGE[2] = 0 (PPDU) TRX_AGG_RANGE[3] = 0 (PPDU) TRX_AGG_RANGE[4] = 0 (PPDU) TRX_AGG_RANGE[5] = 0 (PPDU) TRX_AGG_RANGE[6] = 0 (PPDU) TRX_AGG_RANGE[7] = 0 (PPDU)
MPDUs in AMPDUs transmitted = 0 (MPDU) MPDUs in AMPDUs transmitted with ACK reply = 0 (MPDU) rate1_tx_cnt = 714
rate1_fail_cnt = 223
train_up = 2310
train_down = 3080
is_force_tx_stream = 0
is_force_se_off = 0
max_ampdu_factor = 9
tx_rate_up_penalty = 0
low_traffic_mode = 2
low_traffic_count = 0 low_traffic_dashboard = 3 dynamic_sgi_state = 0
dynamic_sgi_score = 2
dynamic_bw_state = 0 dynamic_gband_256qam_state = 3 vht_non_sp_rate_state = 0
Last TX Rate = 24M, BW20, OFDM, BCC, SPE24 Chip Out TX Power = +16.5 dBm
Cur Rate Index = 0
Rate index[0] --> NSS2_MCS11, BW160/BW8080, SGI, HE_SU, LDPC

Rate index[1]        NSS2_MCS9, BW160/BW8080, SGI, HE_SU, LDPC
Rate index[2]        NSS2_MCS7, BW160/BW8080, SGI, HE_SU, LDPC
Rate index[3]        NSS2_MCS4, BW160/BW8080, SGI, HE_SU, LDPC
Rate index[4]        NSS2_MCS3, BW160/BW8080, SGI, HE_SU, LDPC
Rate index[5]        NSS1_MCS2, BW160/BW8080, SGI, HE_SU, LDPC
Rate index[6]        NSS1_MCS1, BW80, SGI, HE_SU, LDPC
Rate index[7]        NSS1_MCS0, BW80, SGI, HE_SU, LDPC

mib state:
=== Rx Related Counters ===
Rx with CRC = 24020 (MPDU)
Rx drop due to out of resource = 0 (MPDU) Rx Mpdu = 93223 (MPDU)
Rx AMpdu = 668 (PPDU)
Rx PF Drop = 0 (MPDU)
Rx Len Mismatch = 5853 (PPDU)

=== Phy/Timing Related Counters ===

                        ChannelIdleCnt = 1040434
                        CCA_NAV_Tx_Time = 18510036
                        Rx_MDRDY_CNT = 166580 (PPDU)
                        CCK_MDRDY = 7782
                        OFDM_MDRDY = 11912731
                        OFDM_GREEN_MDRDY = 0
                        Prim CCA Time = 17917650
                        Sec CCA Time = 14922034
                        Prim ED Time = 5677528

=== Tx Related Counters(Generic) ===

                        BeaconTxCnt = 0
                        Tx 40MHz Cnt = 279  (MPDU)
                        Tx 80MHz Cnt = 44  (MPDU)
                        Tx 160MHz Cnt = 712  (MPDU)

=== BSSID[0] Related Counters ===
BA Miss Cnt = 210 (PPDU) RTS Tx Cnt = 1003 (MPDU) Frame Retry Cnt = 239 (MPDU) Frame Retry 2 Cnt = 71 (MPDU) RTS Retry Cnt = 152 (MPDU) Ack Failed Cnt = 319 (PPDU)

=== AMPDU Related Counters ===

                        Tx AMPDU_Pkt_Cnt = 705  (PPDU)
                        Tx AMPDU_MPDU_Pkt_Cnt = 713  (MPDU)
                        AMPDU Tx success = 503 (MPDU)
                        AMPDU Tx fail count   = 210  (MPDU), PER=29.4%
---
 .../wireless/mediatek/mt76/mt76_connac_mcu.h  | 173 ++++++
 .../wireless/mediatek/mt76/mt7925/Makefile    |   2 +-
 .../wireless/mediatek/mt76/mt7925/debugfs.c   | 344 ++++++++++
 .../net/wireless/mediatek/mt76/mt7925/stats.c | 585 ++++++++++++++++++
 .../net/wireless/mediatek/mt76/mt7925/stats.h | 309 +++++++++
 5 files changed, 1412 insertions(+), 1 deletion(-)
 create mode 100644 drivers/net/wireless/mediatek/mt76/mt7925/stats.c
 create mode 100644 drivers/net/wireless/mediatek/mt76/mt7925/stats.h
drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h +173 -0
index bb98a6eacac4..937790676edc 100644
@@ -1489,6 +1489,179 @@ enum {
 	MT_NIC_CAP_EML_CAP = 0x22,
 };
 
+enum {
+	UNI_CMD_ID_STATISTICS_BASIC = 0,
+	UNI_CMD_ID_STATISTICS_LINK_QUALITY = 1,
+	UNI_CMD_ID_STATISTICS_STA = 2,
+	UNI_CMD_ID_STATISTICS_BUG_REPORT = 3,
+	UNI_CMD_ID_STATISTICS_TX_STATS = 4,
+	UNI_CMD_ID_STATISTICS_ALL_STATS = 5,
+	UNI_CMD_ID_STATISTICS_EML_STATS = 6,
+	UNI_CMD_ID_STATISTICS_REGULAR_STATS = 7,
+	UNI_CMD_ID_STATISTICS_BSS_LINK_QUALITY = 8,
+	UNI_CMD_ID_STATISTICS_ML_CHNL_COND = 9,
+	UNI_CMD_ID_STATISTICS_WTBL = 10,
+	UNI_CMD_ID_STATISTICS_LINK_LAYER_STATS = 128,
+	UNI_CMD_ID_STATISTICS_PPDU_LATENCY = 129,
+	UNI_CMD_ID_STATISTICS_CURRENT_TX_RATE = 130,
+	UNI_CMD_ID_STATISTICS_SET_TX_BITRATE_MONITOR = 131,
+	UNI_CMD_ID_STATISTICS_GET_PREDICT_TX_BITRATE = 132,
+	UNI_CMD_ID_STATISTICS_SET_ATPS_TYPE_RATE_MODE = 133,
+	UNI_CMD_ID_STATISTICS_SET_BEACON_REPORT = 134,
+	UNI_CMD_ID_STATISTICS_BSS_CURRENT_TX_RATE = 135,
+	UNI_CMD_ID_STATISTICS_GET_BSS_PREDICT_TX_BITRATE = 136,
+	UNI_CMD_ID_STATISTICS_MAX_NUM
+};
+
+enum mt7925_mib_counter {
+	UNI_CMD_MIB_CNT_RX_FCS_ERR = 0,
+	UNI_CMD_MIB_CNT_RX_FIFO_OVERFLOW = 1,
+	UNI_CMD_MIB_CNT_RX_MPDU = 2,
+	UNI_CMD_MIB_CNT_AMPDU_RX_COUNT = 3,
+	UNI_CMD_MIB_CNT_RX_TOTAL_BYTE = 4,
+	UNI_CMD_MIB_CNT_RX_VALID_AMPDU_SF = 5,
+	UNI_CMD_MIB_CNT_RX_VALID_BYTE = 6,
+	UNI_CMD_MIB_CNT_CHANNEL_IDLE = 7,
+	UNI_CMD_MIB_CNT_VEC_DROP = 8,
+	UNI_CMD_MIB_CNT_DELIMITER_FAIL = 9,
+	UNI_CMD_MIB_CNT_VEC_MISMATCH = 10,
+	UNI_CMD_MIB_CNT_MDRDY = 11,
+	UNI_CMD_MIB_CNT_RX_CCK_MDRDY_TIME = 12,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IB_CNT_S_P20BW_4_ED_TIME = 99,
+	UNI_CMD_MIB_CNT_S_P20BW_5_ED_TIME = 100,
+	UNI_CMD_MIB_CNT_S_P20BW_6_ED_TIME = 101,
+	UNI_CMD_MIB_CNT_S_P20BW_7_ED_TIME = 102,
+	UNI_CMD_MIB_CNT_S_P20BW_8_ED_TIME = 103,
+	UNI_CMD_MIB_CNT_S_P20BW_9_ED_TIME = 104,
+	UNI_CMD_MIB_CNT_S_P20BW_10_ED_TIME = 105,
+	UNI_CMD_MIB_CNT_S_P20BW_11_ED_TIME = 106,
+	UNI_CMD_MIB_CNT_S_P20BW_12_ED_TIME = 107,
+	UNI_CMD_MIB_CNT_S_P20BW_13_ED_TIME = 108,
+	UNI_CMD_MIB_CNT_S_P20BW_14_ED_TIME = 109,
+	UNI_CMD_MIB_CNT_S_P20BW_15_ED_TIME = 110,
+	UNI_CMD_MIB_CNT_TX_BW_320MHZ = 111,
+	UNI_CMD_MIB_CNT_TX_DDLMT_RNG0 = 112, /* Rng0~Rng4 112~116 */
+	UNI_CMD_MIB_CNT_BSS0_FRAME_RETRY_3 = 117, /* 117~120 */
+	UNI_CMD_MIB_CNT_BSS0_TX = 121, /* 121~124 */
+	UNI_CMD_MIB_CNT_BSS0_TX_DATA = 125, /* 125~128 */
+	UNI_CMD_MIB_CNT_BSS0_TX_BYTE = 129, /* 129~132 */
+	UNI_CMD_MIB_CNT_RX_OK_BSS0 = 133, /* 133~136 */
+	UNI_CMD_MIB_CNT_RX_BYTE_BSS0 = 137, /* 137~140 */
+	UNI_CMD_MIB_CNT_RX_DATA_BSS0 = 141, /* 141~144 */
+	UNI_CMD_MIB_CNT_MBSS0_TX_OK = 145, /* 145~160 */
+	UNI_CMD_MIB_CNT_MBSS0_TX_BYTE = 161, /* 161~176 */
+	UNI_CMD_MIB_CNT_RX_OK_MBSS0 = 177, /* 177~192 */
+	UNI_CMD_MIB_CNT_RX_BYTE_MBSS0 = 193, /* 193~208 */
+	UNI_CMD_MIB_CNT_AMPDU = 209,
+	UNI_CMD_MIB_CNT_AMPDU_MPDU = 210,
+	UNI_CMD_MIB_CNT_AMPDU_ACKED = 211,
+	UNI_CMD_MIB_CNT_MAX_NUM
+};
+
+enum ENUM_UNI_CMD_GET_STATISTICS_TAG {
+	UNI_CMD_GET_STATISTICS_TAG_BASIC = 0,
+	UNI_CMD_GET_STATISTICS_TAG_LINK_QUALITY = 1,
+	UNI_CMD_GET_STATISTICS_TAG_STA = 2,
+	UNI_CMD_GET_STATISTICS_TAG_BUG_REPORT = 3,
+	UNI_CMD_GET_STATISTICS_TAG_EML_STATS = 6,
+	UNI_CMD_GET_STATISTICS_TAG_REGULAR_STATS = 7,
+	UNI_CMD_GET_STATISTICS_TAG_BSS_LINK_QUALITY = 8,
+	UNI_CMD_GET_STATISTICS_TAG_GET_ML_CHNL_COND = 9,
+	UNI_CMD_GET_STATISTICS_TAG_STAT_WTBL = 10,
+	UNI_CMD_GET_STATISTICS_TAG_LINK_LAYER_STATS = 0x80,
+	UNI_CMD_GET_STATISTICS_TAG_PPDU_LATENCY,
+	UNI_CMD_GET_STATISTICS_TAG_CURRENT_TX_RATE,
+	UNI_CMD_GET_STATISTICS_TAG_BEACON_REPORT = 0x86,
+	UNI_CMD_GET_STATISTICS_TAG_BSS_CURRENT_TX_RATE = 0x87,
+	UNI_CMD_GET_STATISTICS_TAG_BSS_PRED_TX_BITRATE = 0x88,
+};
+
 #define UNI_WOW_DETECT_TYPE_MAGIC		BIT(0)
 #define UNI_WOW_DETECT_TYPE_ANY			BIT(1)
 #define UNI_WOW_DETECT_TYPE_DISCONNECT		BIT(2)
drivers/net/wireless/mediatek/mt76/mt7925/Makefile +1 -1
index 33539121a15c..dc596b93c7cc 100644
@@ -4,7 +4,7 @@ obj-$(CONFIG_MT7925_COMMON) += mt7925-common.o
 obj-$(CONFIG_MT7925E) += mt7925e.o
 obj-$(CONFIG_MT7925U) += mt7925u.o
 
-mt7925-common-y := mac.o mcu.o regd.o main.o init.o debugfs.o nan.o
+mt7925-common-y := mac.o mcu.o regd.o main.o init.o debugfs.o nan.o stats.o
 mt7925-common-$(CONFIG_NL80211_TESTMODE) += testmode.o
 mt7925e-y := pci.o pci_mac.o pci_mcu.o cached_cal.o
 mt7925u-y := usb.o
drivers/net/wireless/mediatek/mt76/mt7925/debugfs.c +344 -0

362 lines not on this page · raw message

drivers/net/wireless/mediatek/mt76/mt7925/stats.c new file +585 -0

585 lines not on this page · raw message

drivers/net/wireless/mediatek/mt76/mt7925/stats.h new file +309 -0

309 lines not on this page · raw message

Signature · 1 line
2.45.2
#9 lore raw
kernel test robot noticed the following build errors:

Hi Michael,

kernel test robot noticed the following build errors:

[auto build test ERROR on wireless-next/main]
[also build test ERROR on wireless/main linus/master v7.4-rc2 next-20261111] [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/Michael-Shih/wifi-mt76-mt7928-Add-debugfs-for-stats-to-provide-debug-purpose/20261112-155556
base:   https://git.kernel.org/pub/scm/linux/kernel/git/wireless/wireless-next.git main
patch link:    https://lore.kernel.org/r/20261112075558.1813785-2-michael.shih%40mediatek.com
patch subject: [PATCH v5 1/2] wifi: mt76: mt7928: Add debugfs for stats to provide debug purpose
config: nios2-allmodconfig (https://download.01.org/0day-ci/archive/20261113/[email protected]/config)
compiler: nios2-linux-gcc (GCC) 11.5.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20261113/[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 >>, old ones prefixed by <<):

>> ERROR: modpost: drivers/net/wireless/mediatek/mt76/mt7925/mt7925-common.ko: symbol '__udivdi3' undefined!

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

#10 lore raw
In reply to Michael Shih
kernel test robot noticed the following build errors:

Hi Michael,

kernel test robot noticed the following build errors:

[auto build test ERROR on wireless-next/main]
[also build test ERROR on wireless/main linus/master v7.4-rc2] [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/Michael-Shih/wifi-mt76-mt7928-Add-debugfs-for-stats-to-provide-debug-purpose/20261112-155556
base:   https://git.kernel.org/pub/scm/linux/kernel/git/wireless/wireless-next.git main
patch link:    https://lore.kernel.org/r/20261112075558.1813785-2-michael.shih%40mediatek.com
patch subject: [PATCH v5 1/2] wifi: mt76: mt7928: Add debugfs for stats to provide debug purpose
config: openrisc-allmodconfig (https://download.01.org/0day-ci/archive/20261113/[email protected]/config)
compiler: or1k-linux-gcc (GCC) 16.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20261113/[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 >>, old ones prefixed by <<):

WARNING: modpost: drivers/net/ethernet/intel/ice/ice.ko: section mismatch in reference: ice_adv_lnk_speed_maps+0x14 (section: .data) -> ice_adv_lnk_speed_100 (section: .init.rodata)
WARNING: modpost: drivers/net/ethernet/intel/ice/ice.ko: section mismatch in reference: ice_adv_lnk_speed_maps+0x30 (section: .data) -> ice_adv_lnk_speed_1000 (section: .init.rodata)
WARNING: modpost: drivers/net/ethernet/intel/ice/ice.ko: section mismatch in reference: ice_adv_lnk_speed_maps+0x4c (section: .data) -> ice_adv_lnk_speed_2500 (section: .init.rodata)
WARNING: modpost: drivers/net/ethernet/intel/ice/ice.ko: section mismatch in reference: ice_adv_lnk_speed_maps+0x68 (section: .data) -> ice_adv_lnk_speed_5000 (section: .init.rodata)
WARNING: modpost: drivers/net/ethernet/intel/ice/ice.ko: section mismatch in reference: ice_adv_lnk_speed_maps+0x84 (section: .data) -> ice_adv_lnk_speed_10000 (section: .init.rodata)
WARNING: modpost: drivers/net/ethernet/intel/ice/ice.ko: section mismatch in reference: ice_adv_lnk_speed_maps+0xa0 (section: .data) -> ice_adv_lnk_speed_25000 (section: .init.rodata)
WARNING: modpost: drivers/net/ethernet/intel/ice/ice.ko: section mismatch in reference: ice_adv_lnk_speed_maps+0xbc (section: .data) -> ice_adv_lnk_speed_40000 (section: .init.rodata)
WARNING: modpost: drivers/net/ethernet/intel/ice/ice.ko: section mismatch in reference: ice_adv_lnk_speed_maps+0xd8 (section: .data) -> ice_adv_lnk_speed_50000 (section: .init.rodata)
WARNING: modpost: drivers/net/ethernet/intel/ice/ice.ko: section mismatch in reference: ice_adv_lnk_speed_maps+0xf4 (section: .data) -> ice_adv_lnk_speed_100000 (section: .init.rodata)
WARNING: modpost: drivers/net/ethernet/intel/ice/ice.ko: section mismatch in reference: ice_adv_lnk_speed_maps+0x110 (section: .data) -> ice_adv_lnk_speed_200000 (section: .init.rodata)
WARNING: modpost: drivers/net/ethernet/qlogic/qed/qed.ko: section mismatch in reference: qed_mfw_ext_maps+0x14 (section: .data) -> qed_mfw_ext_1g (section: .init.rodata)
WARNING: modpost: drivers/net/ethernet/qlogic/qed/qed.ko: section mismatch in reference: qed_mfw_ext_maps+0x30 (section: .data) -> qed_mfw_ext_10g (section: .init.rodata)
WARNING: modpost: drivers/net/ethernet/qlogic/qed/qed.ko: section mismatch in reference: qed_mfw_ext_maps+0x4c (section: .data) -> qed_mfw_ext_25g (section: .init.rodata)
WARNING: modpost: drivers/net/ethernet/qlogic/qed/qed.ko: section mismatch in reference: qed_mfw_ext_maps+0x68 (section: .data) -> qed_mfw_ext_40g (section: .init.rodata)
WARNING: modpost: drivers/net/ethernet/qlogic/qed/qed.ko: section mismatch in reference: qed_mfw_ext_maps+0x84 (section: .data) -> qed_mfw_ext_50g_base_r (section: .init.rodata)
WARNING: modpost: drivers/net/ethernet/qlogic/qed/qed.ko: section mismatch in reference: qed_mfw_ext_maps+0xa0 (section: .data) -> qed_mfw_ext_50g_base_r2 (section: .init.rodata)
WARNING: modpost: drivers/net/ethernet/qlogic/qed/qed.ko: section mismatch in reference: qed_mfw_ext_maps+0xbc (section: .data) -> qed_mfw_ext_100g_base_r2 (section: .init.rodata)
WARNING: modpost: drivers/net/ethernet/qlogic/qed/qed.ko: section mismatch in reference: qed_mfw_ext_maps+0xd8 (section: .data) -> qed_mfw_ext_100g_base_r4 (section: .init.rodata)
WARNING: modpost: drivers/net/ethernet/qlogic/qed/qed.ko: section mismatch in reference: qed_mfw_legacy_maps+0x14 (section: .data) -> qed_mfw_legacy_1g (section: .init.rodata)
WARNING: modpost: drivers/net/ethernet/qlogic/qed/qed.ko: section mismatch in reference: qed_mfw_legacy_maps+0x30 (section: .data) -> qed_mfw_legacy_10g (section: .init.rodata)
WARNING: modpost: drivers/net/ethernet/qlogic/qed/qed.ko: section mismatch in reference: qed_mfw_legacy_maps+0x4c (section: .data) -> qed_mfw_legacy_20g (section: .init.rodata)
WARNING: modpost: drivers/net/ethernet/qlogic/qed/qed.ko: section mismatch in reference: qed_mfw_legacy_maps+0x68 (section: .data) -> qed_mfw_legacy_25g (section: .init.rodata)
WARNING: modpost: drivers/net/ethernet/qlogic/qed/qed.ko: section mismatch in reference: qed_mfw_legacy_maps+0x84 (section: .data) -> qed_mfw_legacy_40g (section: .init.rodata)
WARNING: modpost: drivers/net/ethernet/qlogic/qed/qed.ko: section mismatch in reference: qed_mfw_legacy_maps+0xa0 (section: .data) -> qed_mfw_legacy_50g (section: .init.rodata)
WARNING: modpost: drivers/net/ethernet/qlogic/qed/qed.ko: section mismatch in reference: qed_mfw_legacy_maps+0xbc (section: .data) -> qed_mfw_legacy_bb_100g (section: .init.rodata)
WARNING: modpost: drivers/net/ethernet/qlogic/qede/qede.ko: section mismatch in reference: qede_forced_speed_maps+0x14 (section: .data) -> qede_forced_speed_1000 (section: .init.rodata)
WARNING: modpost: drivers/net/ethernet/qlogic/qede/qede.ko: section mismatch in reference: qede_forced_speed_maps+0x30 (section: .data) -> qede_forced_speed_10000 (section: .init.rodata)
WARNING: modpost: drivers/net/ethernet/qlogic/qede/qede.ko: section mismatch in reference: qede_forced_speed_maps+0x4c (section: .data) -> qede_forced_speed_20000 (section: .init.rodata)
WARNING: modpost: drivers/net/ethernet/qlogic/qede/qede.ko: section mismatch in reference: qede_forced_speed_maps+0x68 (section: .data) -> qede_forced_speed_25000 (section: .init.rodata)
WARNING: modpost: drivers/net/ethernet/qlogic/qede/qede.ko: section mismatch in reference: qede_forced_speed_maps+0x84 (section: .data) -> qede_forced_speed_40000 (section: .init.rodata)
WARNING: modpost: drivers/net/ethernet/qlogic/qede/qede.ko: section mismatch in reference: qede_forced_speed_maps+0xa0 (section: .data) -> qede_forced_speed_50000 (section: .init.rodata)
WARNING: modpost: drivers/net/ethernet/qlogic/qede/qede.ko: section mismatch in reference: qede_forced_speed_maps+0xbc (section: .data) -> qede_forced_speed_100000 (section: .init.rodata)

>> ERROR: modpost: drivers/net/wireless/mediatek/mt76/mt7925/mt7925-common.ko: symbol '__umoddi3' undefined!

ERROR: modpost: drivers/net/wireless/mediatek/mt76/mt7925/mt7925-common.ko: symbol '__udivdi3' undefined!

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

#11 lore raw

v6 cover wifi: mt76: mt7925/mt7928: per-channel survey dump during scan

In reply to Michael Shih

This series improves channel survey reporting for mt7925/mt7928 so that "iw <dev> survey dump" shows meaningful per-channel airtime.

Patch 1 adds a stats debugfs infrastructure (shared stats.c/stats.h and the firmware MIB plumbing) that patch 2 builds on.

Patch 2 wires up two survey accounting paths on top of it:
- the home/operating channel, settled from assign_vif_chanctx() since mt7925 is firmware/chanctx managed and never goes through __mt76_set_channel(); and
- the scanned channels, folded in from the per-channel airtime carried by the firmware scan-done CHNLINFO event.

After the series, both the connected channel and every channel visited during a firmware-offloaded scan report non-zero active/busy/rx/tx time.

Changes since v5:
- <fill in what changed vs v5 before sending>

Michael Shih (2):
wifi: mt76: mt7928: Add debugfs for stats to provide debug purpose
wifi: mt76: mt7925: support per-channel survey dump during scan

 drivers/net/wireless/mediatek/mt76/mac80211.c |   3 +-
 drivers/net/wireless/mediatek/mt76/mt76.h     |   2 +
 .../wireless/mediatek/mt76/mt76_connac_mcu.h  | 173 ++++
 .../wireless/mediatek/mt76/mt7925/Makefile    |   2 +-
 .../wireless/mediatek/mt76/mt7925/debugfs.c   | 345 +++++++
 .../net/wireless/mediatek/mt76/mt7925/main.c  |  12 +
 .../net/wireless/mediatek/mt76/mt7925/mcu.h   |  30 +
 .../wireless/mediatek/mt76/mt7925/mt7925.h    |   7 +
 .../net/wireless/mediatek/mt76/mt7925/pci.c   |   2 +-
 .../net/wireless/mediatek/mt76/mt7925/stats.c | 884 ++++++++++++++++++
 .../net/wireless/mediatek/mt76/mt7925/stats.h | 315 +++++++
 .../net/wireless/mediatek/mt76/mt7925/usb.c   |   2 +-
 drivers/net/wireless/mediatek/mt76/mt792x.h   |   6 +
 13 files changed, 1779 insertions(+), 4 deletions(-)
 create mode 100644 drivers/net/wireless/mediatek/mt76/mt7925/stats.c
 create mode 100644 drivers/net/wireless/mediatek/mt76/mt7925/stats.h
Signature · 1 line
2.45.2
#12 lore raw

PATCH v6 1/2 wifi: mt76: mt7928: Add debugfs for stats to provide debug purpose

Usage:
(1) Connect STA to AP (You can use dhclient CMD to ask for DHCP IP, to use ping to AP)

    DHCP IP CMD:  dhclient ${WLAN_IF} -v

Example: dhclient wlan0 -v

## (To simulate traffic) Ping 10 packets for every second to AP ping 192.168.0.XXX -i0.1

(2) (Get stats) Use command, phyX is your WiFi interface:

     cat /sys/kernel/debug/ieee80211/phyX/mt76/stats

(3) You will see below stats info:
(STA) connected AP MAC Address = a8:42:a1:46:c4:6b
BssIdx = [0]
StaRecIdx = [1],
RSSI = -25
Link_Speed = 2402000 (kbit/s)
temperature = 40
Tx success = 716
Tx fail to Rcv ACK after retry = 0
Rx Mpdu = 23
Rx Fcs Error = 1 (MPDU)
Rx FIFO full = 0 (MPDU)
TRX_AGG_RANGE[0] = 0 (PPDU) TRX_AGG_RANGE[1] = 0 (PPDU) TRX_AGG_RANGE[2] = 0 (PPDU) TRX_AGG_RANGE[3] = 0 (PPDU) TRX_AGG_RANGE[4] = 0 (PPDU) TRX_AGG_RANGE[5] = 0 (PPDU) TRX_AGG_RANGE[6] = 0 (PPDU) TRX_AGG_RANGE[7] = 0 (PPDU)
MPDUs in AMPDUs transmitted = 0 (MPDU) MPDUs in AMPDUs transmitted with ACK reply = 0 (MPDU) rate1_tx_cnt = 714
rate1_fail_cnt = 223
train_up = 2310
train_down = 3080
is_force_tx_stream = 0
is_force_se_off = 0
max_ampdu_factor = 9
tx_rate_up_penalty = 0
low_traffic_mode = 2
low_traffic_count = 0 low_traffic_dashboard = 3 dynamic_sgi_state = 0
dynamic_sgi_score = 2
dynamic_bw_state = 0 dynamic_gband_256qam_state = 3 vht_non_sp_rate_state = 0
Last TX Rate = 24M, BW20, OFDM, BCC, SPE24 Chip Out TX Power = +16.5 dBm
Cur Rate Index = 0
Rate index[0] --> NSS2_MCS11, BW160/BW8080, SGI, HE_SU, LDPC

Rate index[1]        NSS2_MCS9, BW160/BW8080, SGI, HE_SU, LDPC
Rate index[2]        NSS2_MCS7, BW160/BW8080, SGI, HE_SU, LDPC
Rate index[3]        NSS2_MCS4, BW160/BW8080, SGI, HE_SU, LDPC
Rate index[4]        NSS2_MCS3, BW160/BW8080, SGI, HE_SU, LDPC
Rate index[5]        NSS1_MCS2, BW160/BW8080, SGI, HE_SU, LDPC
Rate index[6]        NSS1_MCS1, BW80, SGI, HE_SU, LDPC
Rate index[7]        NSS1_MCS0, BW80, SGI, HE_SU, LDPC

mib state:
=== Rx Related Counters ===
Rx with CRC = 24020 (MPDU)
Rx drop due to out of resource = 0 (MPDU) Rx Mpdu = 93223 (MPDU)
Rx AMpdu = 668 (PPDU)
Rx PF Drop = 0 (MPDU)
Rx Len Mismatch = 5853 (PPDU)

=== Phy/Timing Related Counters ===

                        ChannelIdleCnt = 1040434
                        CCA_NAV_Tx_Time = 18510036
                        Rx_MDRDY_CNT = 166580 (PPDU)
                        CCK_MDRDY = 7782
                        OFDM_MDRDY = 11912731
                        OFDM_GREEN_MDRDY = 0
                        Prim CCA Time = 17917650
                        Sec CCA Time = 14922034
                        Prim ED Time = 5677528

=== Tx Related Counters(Generic) ===

                        BeaconTxCnt = 0
                        Tx 40MHz Cnt = 279  (MPDU)
                        Tx 80MHz Cnt = 44  (MPDU)
                        Tx 160MHz Cnt = 712  (MPDU)

=== BSSID[0] Related Counters ===
BA Miss Cnt = 210 (PPDU) RTS Tx Cnt = 1003 (MPDU) Frame Retry Cnt = 239 (MPDU) Frame Retry 2 Cnt = 71 (MPDU) RTS Retry Cnt = 152 (MPDU) Ack Failed Cnt = 319 (PPDU)

=== AMPDU Related Counters ===

                        Tx AMPDU_Pkt_Cnt = 705  (PPDU)
                        Tx AMPDU_MPDU_Pkt_Cnt = 713  (MPDU)
                        AMPDU Tx success = 503 (MPDU)
                        AMPDU Tx fail count   = 210  (MPDU), PER=29.4%

---
v2: (1) Remove redundant code to fix build errors.
(2) Move UNI_CMD_MIB_DATA enum definition from 'mt76/mt76_connac_mcu.h' to 'mt7925/stats.h' to avoid redeclartion with 'mt76/mt7996/mcu.h'
v3: (1) Remove redundant code to fix build errors.
(2) Move UNI_CMD_MIB_DATA enum definition from 'mt76/mt76_connac_mcu.h' to 'mt7925/stats.h' to avoid redeclartion with 'mt76/mt7996/mcu.h'
v4: (1) Fix inconsistent indenting.
(2) Fix array offset 'band_idx' as to before use, not after use.
v5: No change.
v6: Fix "symbol '__udivdi3' undefined!" build error

---
 .../wireless/mediatek/mt76/mt76_connac_mcu.h  | 173 ++++++
 .../wireless/mediatek/mt76/mt7925/Makefile    |   2 +-
 .../wireless/mediatek/mt76/mt7925/debugfs.c   | 345 +++++++++++
 .../net/wireless/mediatek/mt76/mt7925/stats.c | 585 ++++++++++++++++++
 .../net/wireless/mediatek/mt76/mt7925/stats.h | 309 +++++++++
 5 files changed, 1413 insertions(+), 1 deletion(-)
 create mode 100644 drivers/net/wireless/mediatek/mt76/mt7925/stats.c
 create mode 100644 drivers/net/wireless/mediatek/mt76/mt7925/stats.h
drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h +173 -0
index 2acaae9830fb..7993e20449c2 100644
@@ -1491,6 +1491,179 @@ enum {
 	MT_NIC_CAP_EML_CAP = 0x22,
 };
 
+enum {
+	UNI_CMD_ID_STATISTICS_BASIC = 0,
+	UNI_CMD_ID_STATISTICS_LINK_QUALITY = 1,
+	UNI_CMD_ID_STATISTICS_STA = 2,
+	UNI_CMD_ID_STATISTICS_BUG_REPORT = 3,
+	UNI_CMD_ID_STATISTICS_TX_STATS = 4,
+	UNI_CMD_ID_STATISTICS_ALL_STATS = 5,
+	UNI_CMD_ID_STATISTICS_EML_STATS = 6,
+	UNI_CMD_ID_STATISTICS_REGULAR_STATS = 7,
+	UNI_CMD_ID_STATISTICS_BSS_LINK_QUALITY = 8,
+	UNI_CMD_ID_STATISTICS_ML_CHNL_COND = 9,
+	UNI_CMD_ID_STATISTICS_WTBL = 10,
+	UNI_CMD_ID_STATISTICS_LINK_LAYER_STATS = 128,
+	UNI_CMD_ID_STATISTICS_PPDU_LATENCY = 129,
+	UNI_CMD_ID_STATISTICS_CURRENT_TX_RATE = 130,
+	UNI_CMD_ID_STATISTICS_SET_TX_BITRATE_MONITOR = 131,
+	UNI_CMD_ID_STATISTICS_GET_PREDICT_TX_BITRATE = 132,
+	UNI_CMD_ID_STATISTICS_SET_ATPS_TYPE_RATE_MODE = 133,
+	UNI_CMD_ID_STATISTICS_SET_BEACON_REPORT = 134,
+	UNI_CMD_ID_STATISTICS_BSS_CURRENT_TX_RATE = 135,
+	UNI_CMD_ID_STATISTICS_GET_BSS_PREDICT_TX_BITRATE = 136,
+	UNI_CMD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
+	UNI_CMD_MIB_CNT_TX_FULL_BW = 86,
+	UNI_CMD_MIB_CNT_TX_AUTO_BW = 87,
+	UNI_CMD_MIB_CNT_CCA_SAMPLE_IDLE = 88,
+	UNI_CMD_MIB_CNT_CCA_SAMPLE_ACTIVE = 89,
+	UNI_CMD_MIB_CNT_CCA_TIME = 90,
+	UNI_CMD_MIB_CNT_S_20BW_CCA_TIME = 91,
+	UNI_CMD_MIB_CNT_S_40BW_CCA_TIME = 92,
+	UNI_CMD_MIB_CNT_S_80BW_CCA_TIME = 93,
+	UNI_CMD_MIB_CNT_S_160BW_CCA_TIME = 94,
+	UNI_CMD_MIB_CNT_S_P20BW_0_ED_TIME = 95,
+	UNI_CMD_MIB_CNT_S_P20BW_1_ED_TIME = 96,
+	UNI_CMD_MIB_CNT_S_P20BW_2_ED_TIME = 97,
+	UNI_CMD_MIB_CNT_S_P20BW_3_ED_TIME = 98,
+	UNI_CMD_MIB_CNT_S_P20BW_4_ED_TIME = 99,
+	UNI_CMD_MIB_CNT_S_P20BW_5_ED_TIME = 100,
+	UNI_CMD_MIB_CNT_S_P20BW_6_ED_TIME = 101,
+	UNI_CMD_MIB_CNT_S_P20BW_7_ED_TIME = 102,
+	UNI_CMD_MIB_CNT_S_P20BW_8_ED_TIME = 103,
+	UNI_CMD_MIB_CNT_S_P20BW_9_ED_TIME = 104,
+	UNI_CMD_MIB_CNT_S_P20BW_10_ED_TIME = 105,
+	UNI_CMD_MIB_CNT_S_P20BW_11_ED_TIME = 106,
+	UNI_CMD_MIB_CNT_S_P20BW_12_ED_TIME = 107,
+	UNI_CMD_MIB_CNT_S_P20BW_13_ED_TIME = 108,
+	UNI_CMD_MIB_CNT_S_P20BW_14_ED_TIME = 109,
+	UNI_CMD_MIB_CNT_S_P20BW_15_ED_TIME = 110,
+	UNI_CMD_MIB_CNT_TX_BW_320MHZ = 111,
+	UNI_CMD_MIB_CNT_TX_DDLMT_RNG0 = 112, /* Rng0~Rng4 112~116 */
+	UNI_CMD_MIB_CNT_BSS0_FRAME_RETRY_3 = 117, /* 117~120 */
+	UNI_CMD_MIB_CNT_BSS0_TX = 121, /* 121~124 */
+	UNI_CMD_MIB_CNT_BSS0_TX_DATA = 125, /* 125~128 */
+	UNI_CMD_MIB_CNT_BSS0_TX_BYTE = 129, /* 129~132 */
+	UNI_CMD_MIB_CNT_RX_OK_BSS0 = 133, /* 133~136 */
+	UNI_CMD_MIB_CNT_RX_BYTE_BSS0 = 137, /* 137~140 */
+	UNI_CMD_MIB_CNT_RX_DATA_BSS0 = 141, /* 141~144 */
+	UNI_CMD_MIB_CNT_MBSS0_TX_OK = 145, /* 145~160 */
+	UNI_CMD_MIB_CNT_MBSS0_TX_BYTE = 161, /* 161~176 */
+	UNI_CMD_MIB_CNT_RX_OK_MBSS0 = 177, /* 177~192 */
+	UNI_CMD_MIB_CNT_RX_BYTE_MBSS0 = 193, /* 193~208 */
+	UNI_CMD_MIB_CNT_AMPDU = 209,
+	UNI_CMD_MIB_CNT_AMPDU_MPDU = 210,
+	UNI_CMD_MIB_CNT_AMPDU_ACKED = 211,
+	UNI_CMD_MIB_CNT_MAX_NUM
+};
+
+enum ENUM_UNI_CMD_GET_STATISTICS_TAG {
+	UNI_CMD_GET_STATISTICS_TAG_BASIC = 0,
+	UNI_CMD_GET_STATISTICS_TAG_LINK_QUALITY = 1,
+	UNI_CMD_GET_STATISTICS_TAG_STA = 2,
+	UNI_CMD_GET_STATISTICS_TAG_BUG_REPORT = 3,
+	UNI_CMD_GET_STATISTICS_TAG_EML_STATS = 6,
+	UNI_CMD_GET_STATISTICS_TAG_REGULAR_STATS = 7,
+	UNI_CMD_GET_STATISTICS_TAG_BSS_LINK_QUALITY = 8,
+	UNI_CMD_GET_STATISTICS_TAG_GET_ML_CHNL_COND = 9,
+	UNI_CMD_GET_STATISTICS_TAG_STAT_WTBL = 10,
+	UNI_CMD_GET_STATISTICS_TAG_LINK_LAYER_STATS = 0x80,
+	UNI_CMD_GET_STATISTICS_TAG_PPDU_LATENCY,
+	UNI_CMD_GET_STATISTICS_TAG_CURRENT_TX_RATE,
+	UNI_CMD_GET_STATISTICS_TAG_BEACON_REPORT = 0x86,
+	UNI_CMD_GET_STATISTICS_TAG_BSS_CURRENT_TX_RATE = 0x87,
+	UNI_CMD_GET_STATISTICS_TAG_BSS_PRED_TX_BITRATE = 0x88,
+};
+
 #define UNI_WOW_DETECT_TYPE_MAGIC		BIT(0)
 #define UNI_WOW_DETECT_TYPE_ANY			BIT(1)
 #define UNI_WOW_DETECT_TYPE_DISCONNECT		BIT(2)
drivers/net/wireless/mediatek/mt76/mt7925/Makefile +1 -1
index 697a2bbce46c..41ac1ac8d716 100644
@@ -4,7 +4,7 @@ obj-$(CONFIG_MT7925_COMMON) += mt7925-common.o
 obj-$(CONFIG_MT7925E) += mt7925e.o
 obj-$(CONFIG_MT7925U) += mt7925u.o
 
-mt7925-common-y := mac.o mcu.o regd.o main.o init.o debugfs.o nan.o p2p.o
+mt7925-common-y := mac.o mcu.o regd.o main.o init.o debugfs.o nan.o p2p.o stats.o
 mt7925-common-$(CONFIG_NL80211_TESTMODE) += testmode.o
 mt7925e-y := pci.o pci_mac.o pci_mcu.o cached_cal.o
 mt7925u-y := usb.o
drivers/net/wireless/mediatek/mt76/mt7925/debugfs.c +345 -0

363 lines not on this page · raw message

drivers/net/wireless/mediatek/mt76/mt7925/stats.c new file +585 -0

585 lines not on this page · raw message

drivers/net/wireless/mediatek/mt76/mt7925/stats.h new file +309 -0

309 lines not on this page · raw message

Signature · 1 line
2.45.2
#13 lore raw

PATCH v6 2/2 wifi: mt76: mt7925: support per-channel survey dump during scan

In reply to Michael Shih

Report per-channel survey airtime (active/busy/rx/tx) so that "iw <dev> survey dump" shows non-zero airtime not only for the connected home channel, but also for every channel visited during a firmware-offloaded scan.

Two accounting paths are wired up:

(1) Home/operating channel (periodic mac_work):
mt7925 is firmware/chanctx managed and never goes through __mt76_set_channel(), so phy->chan_state used to stay pinned to its init default and the periodic survey was charged to the wrong channel. mt7925_survey_switch_channel() is added and called from assign_vif_chanctx() to settle the old channel, re-point chan_state/chandef to the operating channel, and re-base the firmware MIB snapshot so active/busy/rx/tx keep accumulating on the channel actually dwelt on.

(2) Scanned channels (scan-done event):
The scan-done CHNLINFO event now carries per-channel airtime (firmware Ch-Survey extension). mt7925_scan_update_survey() parses the per-channel array and folds the airtime deltas into each channel's mt76_channel_state. The firmware 6G channel id is converted back to the real channel number before lookup.

mt76_channel_state() is exported so the mt7925 module can map a band/channel pair to its channel state.

Usage:
(1) Connect STA to AP and generate traffic:

      dhclient ${WLAN_IF} -v
      ping 192.168.0.XXX -i0.1

(2) (Optional) Trigger a scan to collect other channels:
iw ${WLAN_IF} scan
or use wpa_supplicant / wpa_cli scan.

(3) Dump the survey:

      iw ${WLAN_IF} survey dump

(4) You will see per-channel airtime, e.g.:
Survey data from wls1
frequency: 5240 MHz
channel active time: 163258 ms
channel busy time: 34076 ms
channel receive time: 32084 ms
channel transmit time: 253 ms
- The connected/dwelt channel keeps increasing over time.
- Channels visited during scan accumulate airtime each scan.

---
v5: Submit for commiting cover letter (series)
v6: No change.

---
 drivers/net/wireless/mediatek/mt76/mac80211.c |   3 +-
 drivers/net/wireless/mediatek/mt76/mt76.h     |   2 +
 .../net/wireless/mediatek/mt76/mt7925/main.c  |  12 +
 .../net/wireless/mediatek/mt76/mt7925/mcu.h   |  30 ++
 .../wireless/mediatek/mt76/mt7925/mt7925.h    |   7 +
 .../net/wireless/mediatek/mt76/mt7925/pci.c   |   2 +-
 .../net/wireless/mediatek/mt76/mt7925/stats.c | 301 +++++++++++++++++-
 .../net/wireless/mediatek/mt76/mt7925/stats.h |   6 +
 .../net/wireless/mediatek/mt76/mt7925/usb.c   |   2 +-
 drivers/net/wireless/mediatek/mt76/mt792x.h   |   6 +
 10 files changed, 367 insertions(+), 4 deletions(-)
drivers/net/wireless/mediatek/mt76/mac80211.c +2 -1
index bd822193e769..0d139a808b77 100644
@@ -1060,7 +1060,7 @@ bool mt76_has_tx_pending(struct mt76_phy *phy)
 }
 EXPORT_SYMBOL_GPL(mt76_has_tx_pending);
 
-static struct mt76_channel_state *
+struct mt76_channel_state *
 mt76_channel_state(struct mt76_phy *phy, struct ieee80211_channel *c)
 {
 	struct mt76_sband *msband;
@@ -1076,6 +1076,7 @@ mt76_channel_state(struct mt76_phy *phy, struct ieee80211_channel *c)
 	idx = c - &msband->sband.channels[0];
 	return &msband->chan[idx];
 }
+EXPORT_SYMBOL_GPL(mt76_channel_state);
 
 void mt76_update_survey_active_time(struct mt76_phy *phy, ktime_t time)
 {
drivers/net/wireless/mediatek/mt76/mt76.h +2 -0
index da135e76aabb..57d316b586d0 100644
@@ -1578,6 +1578,8 @@ void mt76_update_survey(struct mt76_phy *phy);
 void mt76_phy_chandef_set(struct mt76_phy *phy,
 			  struct cfg80211_chan_def *chandef);
 void mt76_update_survey_active_time(struct mt76_phy *phy, ktime_t time);
+struct mt76_channel_state *
+mt76_channel_state(struct mt76_phy *phy, struct ieee80211_channel *c);
 int mt76_get_survey(struct ieee80211_hw *hw, int idx,
 		    struct survey_info *survey);
 int mt76_rx_signal(u8 chain_mask, s8 *chain_signal);
drivers/net/wireless/mediatek/mt76/mt7925/main.c +12 -0
index 222836699d15..12d4d14d57fe 100644
@@ -1698,6 +1698,10 @@ void mt7925_scan_work(struct work_struct *work)
 
 				mt7925_regd_change(phy, evt->alpha2);
 
+				mt7925_scan_update_survey(phy, evt,
+							  le16_to_cpu(tlv->len) -
+							  sizeof(struct tlv));
+
 				break;
 			case UNI_EVENT_SCAN_DONE_NLO:
 				ieee80211_sched_scan_results(phy->mt76->hw);
@@ -2570,7 +2574,15 @@ static int mt7925_assign_vif_chanctx(struct ieee80211_hw *hw,
 
 	mconf->mt76.ctx = ctx;
 	mctx->bss_conf = mconf;
+
+	/* Re-target op-channel survey accounting to the operating channel just
+	 * assigned, so cc_active/airtime accrue on the channel we actually
+	 * dwell on (mt7925 never goes through __mt76_set_channel()).
+	 */
+	mt7925_survey_switch_channel(mvif->phy, ctx->def.chan);
+
 	mt76_phy_chandef_set(mvif->phy->mt76, &ctx->def);
+
 	mutex_unlock(&dev->mt76.mutex);
 
 	return 0;
drivers/net/wireless/mediatek/mt76/mt7925/mcu.h +30 -0
index 11f9eac13ffc..2ed95b00e10f 100644
@@ -199,6 +199,36 @@ enum DMASHDL_GROUP_IDX {
 struct mt7925_mcu_scan_chinfo_event {
 	u8 nr_chan;
 	u8 alpha2[3];
+	/* Followed by nr_chan entries. The entry layout matches the firmware
+	 * UNI_EVENT_IE_CHNLINFO_T: a base part, optionally followed by the
+	 * Ch-Survey airtime extension (present when the firmware was built with
+	 * CONFIG_WIFI_RAM_CCN16_CHANNEL_SURVEY_STATS). Presence is detected at
+	 * runtime from the TLV length (see mt7925_scan_update_survey()).
+	 */
+	u8 chan_info[];
+} __packed;
+
+/* Base per-channel info (firmware SCAN_DONE_VERSION_SUPPORT_CU layout). */
+struct mt7925_mcu_scan_chinfo {
+	u8 channel_num;
+	u8 bcn_probe_cnt;
+	u8 mdrdy_cnt;
+	u8 util_val;
+	__le16 idle_time;
+	__le16 scan_time;	/* dwell time (ms) */
+} __packed;
+
+/* Ch-Survey extension appended after the base part
+ * (firmware SCAN_DONE_VERSION_SUPPORT_CH_SURVEY layout).
+ */
+struct mt7925_mcu_scan_chinfo_survey {
+	struct mt7925_mcu_scan_chinfo base;
+	u8 band;		/* 1=2G, 2=5G, 3=6G (firmware CMD_BAND_*) */
+	u8 rsv[3];
+	__le32 tx_time_us;
+	__le32 rx_time_us;	/* rx + obss */
+	__le32 busy_time_us;	/* tx + rx + obss + nonwifi */
+	__le32 active_time_us;	/* busy + idle = total */
 } __packed;
 
 enum {
drivers/net/wireless/mediatek/mt76/mt7925/mt7925.h +7 -0
index 1c20b4ae7497..faaf8134d574 100644
@@ -299,6 +299,13 @@ extern const struct ieee80211_ops mt7925_ops;
 int __mt7925_start(struct mt792x_phy *phy);
 int mt7925_register_device(struct mt792x_dev *dev);
 void mt7925_unregister_device(struct mt792x_dev *dev);
+void mt7925_update_channel(struct mt76_phy *mphy);
+void mt7925_survey_switch_channel(struct mt792x_phy *phy,
+				  struct ieee80211_channel *chan);
+struct mt7925_mcu_scan_chinfo_event;
+void mt7925_scan_update_survey(struct mt792x_phy *phy,
+			       struct mt7925_mcu_scan_chinfo_event *evt,
+			       int tlv_len);
 int mt7925_run_firmware(struct mt792x_dev *dev);
 int mt7925_mcu_set_bss_pm(struct mt792x_dev *dev,
 			  struct ieee80211_bss_conf *link_conf,
drivers/net/wireless/mediatek/mt76/mt7925/pci.c +1 -1
index 0d477dc1086c..939a46c0428b 100644
@@ -604,7 +604,7 @@ static int mt7925_pci_probe(struct pci_dev *pdev,
 		.sta_add = mt7925_mac_sta_add,
 		.sta_event = mt7925_mac_sta_event,
 		.sta_remove = mt7925_mac_sta_remove,
-		.update_survey = mt792x_update_channel,
+		.update_survey = mt7925_update_channel,
 	};
 	static const struct mt792x_hif_ops mt7925_pcie_ops = {
 		.init_reset = mt7925e_init_reset,
drivers/net/wireless/mediatek/mt76/mt7925/stats.c +300 -1

313 lines not on this page · raw message

drivers/net/wireless/mediatek/mt76/mt7925/stats.h +6 -0
index a70b9eb3aa80..a4cb8c4453ea 100644
@@ -291,6 +291,12 @@ int mt7925_mcu_get_mib_info(struct mt792x_dev *dev, u8 band_idx,
 			    const u32 *counters, u8 counter_num,
 			    u64 *values);
 
+/* Refresh per-channel survey airtime (TX/RX/OBSS/non-wifi) from the firmware
+ * MIB query and accumulate the delta into chan_state. Used by the MT7925/MT7935
+ * update_survey callback.
+ */
+int mt7925_mcu_get_chan_mib_info(struct mt792x_phy *phy);
+
 /* GET_STAT_INFO (UNI_CMD_ID_GET_STATISTICS = 0x23),
  * sub-command UNI_CMD_GET_STATISTICS_TAG_LINK_QUALITY = 1.
  *
drivers/net/wireless/mediatek/mt76/mt7925/usb.c +1 -1
index f97f787b2198..2d3bf035fdfc 100644
@@ -174,7 +174,7 @@ static int mt7925u_probe(struct usb_interface *usb_intf,
 		.sta_add = mt7925_mac_sta_add,
 		.sta_event = mt7925_mac_sta_event,
 		.sta_remove = mt7925_mac_sta_remove,
-		.update_survey = mt792x_update_channel,
+		.update_survey = mt7925_update_channel,
 	};
 	static const struct mt792x_hif_ops hif_ops = {
 		.mcu_init = mt7925u_mcu_init,
drivers/net/wireless/mediatek/mt76/mt792x.h +6 -0
index 4753ec20fe0c..192bad83ac2a 100644
@@ -228,6 +228,12 @@ struct mt792x_phy {
 
 	struct mt76_mib_stats mib;
 
+	/* survey: firmware reports accumulated airtime counters; keep the
+	 * previous snapshot so mt7925_mcu_get_chan_mib_info() can accumulate
+	 * deltas into chan_state (mirror mt7996 phy->state_ts).
+	 */
+	struct mt76_channel_state state_ts;
+
 	u8 sta_work_count;
 	u8 clc_chan_conf;
 	enum mt792x_reg_power_type power_type;
Signature · 1 line
2.45.2
#14 lore raw

PATCH v5 2/2 wifi: mt76: mt7925: support per-channel survey dump during scan

In reply to Michael Shih

Report per-channel survey airtime (active/busy/rx/tx) so that "iw <dev> survey dump" shows non-zero airtime not only for the connected home channel, but also for every channel visited during a firmware-offloaded scan.

Two accounting paths are wired up:

(1) Home/operating channel (periodic mac_work):
mt7925 is firmware/chanctx managed and never goes through __mt76_set_channel(), so phy->chan_state used to stay pinned to its init default and the periodic survey was charged to the wrong channel. mt7925_survey_switch_channel() is added and called from assign_vif_chanctx() to settle the old channel, re-point chan_state/chandef to the operating channel, and re-base the firmware MIB snapshot so active/busy/rx/tx keep accumulating on the channel actually dwelt on.

(2) Scanned channels (scan-done event):
The scan-done CHNLINFO event now carries per-channel airtime (firmware Ch-Survey extension). mt7925_scan_update_survey() parses the per-channel array and folds the airtime deltas into each channel's mt76_channel_state. The firmware 6G channel id is converted back to the real channel number before lookup.

mt76_channel_state() is exported so the mt7925 module can map a band/channel pair to its channel state.

Usage:
(1) Connect STA to AP and generate traffic:

      dhclient ${WLAN_IF} -v
      ping 192.168.0.XXX -i0.1

(2) (Optional) Trigger a scan to collect other channels:
iw ${WLAN_IF} scan
or use wpa_supplicant / wpa_cli scan.

(3) Dump the survey:

      iw ${WLAN_IF} survey dump

(4) You will see per-channel airtime, e.g.:
Survey data from wls1
frequency: 5240 MHz
channel active time: 163258 ms
channel busy time: 34076 ms
channel receive time: 32084 ms
channel transmit time: 253 ms
- The connected/dwelt channel keeps increasing over time.
- Channels visited during scan accumulate airtime each scan.

---
 drivers/net/wireless/mediatek/mt76/mac80211.c |   3 +-
 drivers/net/wireless/mediatek/mt76/mt76.h     |   2 +
 .../net/wireless/mediatek/mt76/mt7925/main.c  |  12 +
 .../net/wireless/mediatek/mt76/mt7925/mcu.h   |  30 ++
 .../wireless/mediatek/mt76/mt7925/mt7925.h    |   7 +
 .../net/wireless/mediatek/mt76/mt7925/pci.c   |   2 +-
 .../net/wireless/mediatek/mt76/mt7925/stats.c | 301 +++++++++++++++++-
 .../net/wireless/mediatek/mt76/mt7925/stats.h |   6 +
 .../net/wireless/mediatek/mt76/mt7925/usb.c   |   2 +-
 drivers/net/wireless/mediatek/mt76/mt792x.h   |   6 +
 10 files changed, 367 insertions(+), 4 deletions(-)
drivers/net/wireless/mediatek/mt76/mac80211.c +2 -1
index 08ed3fc6d386..11301428c5f9 100644
@@ -991,7 +991,7 @@ bool mt76_has_tx_pending(struct mt76_phy *phy)
 }
 EXPORT_SYMBOL_GPL(mt76_has_tx_pending);
 
-static struct mt76_channel_state *
+struct mt76_channel_state *
 mt76_channel_state(struct mt76_phy *phy, struct ieee80211_channel *c)
 {
 	struct mt76_sband *msband;
@@ -1007,6 +1007,7 @@ mt76_channel_state(struct mt76_phy *phy, struct ieee80211_channel *c)
 	idx = c - &msband->sband.channels[0];
 	return &msband->chan[idx];
 }
+EXPORT_SYMBOL_GPL(mt76_channel_state);
 
 void mt76_update_survey_active_time(struct mt76_phy *phy, ktime_t time)
 {
drivers/net/wireless/mediatek/mt76/mt76.h +2 -0
index 477d33a0022d..f74c6a4b0f9c 100644
@@ -1565,6 +1565,8 @@ void mt76_update_survey(struct mt76_phy *phy);
 void mt76_phy_chandef_set(struct mt76_phy *phy,
 			  struct cfg80211_chan_def *chandef);
 void mt76_update_survey_active_time(struct mt76_phy *phy, ktime_t time);
+struct mt76_channel_state *
+mt76_channel_state(struct mt76_phy *phy, struct ieee80211_channel *c);
 int mt76_get_survey(struct ieee80211_hw *hw, int idx,
 		    struct survey_info *survey);
 int mt76_rx_signal(u8 chain_mask, s8 *chain_signal);
drivers/net/wireless/mediatek/mt76/mt7925/main.c +12 -0
index ffbc6b954632..8e48ef0cb3e5 100644
@@ -1612,6 +1612,10 @@ void mt7925_scan_work(struct work_struct *work)
 
 				mt7925_regd_change(phy, evt->alpha2);
 
+				mt7925_scan_update_survey(phy, evt,
+							  le16_to_cpu(tlv->len) -
+							  sizeof(struct tlv));
+
 				break;
 			case UNI_EVENT_SCAN_DONE_NLO:
 				ieee80211_sched_scan_results(phy->mt76->hw);
@@ -2440,7 +2444,15 @@ static int mt7925_assign_vif_chanctx(struct ieee80211_hw *hw,
 
 	mconf->mt76.ctx = ctx;
 	mctx->bss_conf = mconf;
+
+	/* Re-target op-channel survey accounting to the operating channel just
+	 * assigned, so cc_active/airtime accrue on the channel we actually
+	 * dwell on (mt7925 never goes through __mt76_set_channel()).
+	 */
+	mt7925_survey_switch_channel(mvif->phy, ctx->def.chan);
+
 	mt76_phy_chandef_set(mvif->phy->mt76, &ctx->def);
+
 	mutex_unlock(&dev->mt76.mutex);
 
 	return 0;
drivers/net/wireless/mediatek/mt76/mt7925/mcu.h +30 -0
index 11f9eac13ffc..2ed95b00e10f 100644
@@ -199,6 +199,36 @@ enum DMASHDL_GROUP_IDX {
 struct mt7925_mcu_scan_chinfo_event {
 	u8 nr_chan;
 	u8 alpha2[3];
+	/* Followed by nr_chan entries. The entry layout matches the firmware
+	 * UNI_EVENT_IE_CHNLINFO_T: a base part, optionally followed by the
+	 * Ch-Survey airtime extension (present when the firmware was built with
+	 * CONFIG_WIFI_RAM_CCN16_CHANNEL_SURVEY_STATS). Presence is detected at
+	 * runtime from the TLV length (see mt7925_scan_update_survey()).
+	 */
+	u8 chan_info[];
+} __packed;
+
+/* Base per-channel info (firmware SCAN_DONE_VERSION_SUPPORT_CU layout). */
+struct mt7925_mcu_scan_chinfo {
+	u8 channel_num;
+	u8 bcn_probe_cnt;
+	u8 mdrdy_cnt;
+	u8 util_val;
+	__le16 idle_time;
+	__le16 scan_time;	/* dwell time (ms) */
+} __packed;
+
+/* Ch-Survey extension appended after the base part
+ * (firmware SCAN_DONE_VERSION_SUPPORT_CH_SURVEY layout).
+ */
+struct mt7925_mcu_scan_chinfo_survey {
+	struct mt7925_mcu_scan_chinfo base;
+	u8 band;		/* 1=2G, 2=5G, 3=6G (firmware CMD_BAND_*) */
+	u8 rsv[3];
+	__le32 tx_time_us;
+	__le32 rx_time_us;	/* rx + obss */
+	__le32 busy_time_us;	/* tx + rx + obss + nonwifi */
+	__le32 active_time_us;	/* busy + idle = total */
 } __packed;
 
 enum {
drivers/net/wireless/mediatek/mt76/mt7925/mt7925.h +7 -0
index 636efe038392..ac66c0a5daf6 100644
@@ -282,6 +282,13 @@ extern const struct ieee80211_ops mt7925_ops;
 int __mt7925_start(struct mt792x_phy *phy);
 int mt7925_register_device(struct mt792x_dev *dev);
 void mt7925_unregister_device(struct mt792x_dev *dev);
+void mt7925_update_channel(struct mt76_phy *mphy);
+void mt7925_survey_switch_channel(struct mt792x_phy *phy,
+				  struct ieee80211_channel *chan);
+struct mt7925_mcu_scan_chinfo_event;
+void mt7925_scan_update_survey(struct mt792x_phy *phy,
+			       struct mt7925_mcu_scan_chinfo_event *evt,
+			       int tlv_len);
 int mt7925_run_firmware(struct mt792x_dev *dev);
 int mt7925_mcu_set_bss_pm(struct mt792x_dev *dev,
 			  struct ieee80211_bss_conf *link_conf,
drivers/net/wireless/mediatek/mt76/mt7925/pci.c +1 -1
index 0d477dc1086c..939a46c0428b 100644
@@ -604,7 +604,7 @@ static int mt7925_pci_probe(struct pci_dev *pdev,
 		.sta_add = mt7925_mac_sta_add,
 		.sta_event = mt7925_mac_sta_event,
 		.sta_remove = mt7925_mac_sta_remove,
-		.update_survey = mt792x_update_channel,
+		.update_survey = mt7925_update_channel,
 	};
 	static const struct mt792x_hif_ops mt7925_pcie_ops = {
 		.init_reset = mt7925e_init_reset,
drivers/net/wireless/mediatek/mt76/mt7925/stats.c +300 -1

313 lines not on this page · raw message

drivers/net/wireless/mediatek/mt76/mt7925/stats.h +6 -0
index a70b9eb3aa80..a4cb8c4453ea 100644
@@ -291,6 +291,12 @@ int mt7925_mcu_get_mib_info(struct mt792x_dev *dev, u8 band_idx,
 			    const u32 *counters, u8 counter_num,
 			    u64 *values);
 
+/* Refresh per-channel survey airtime (TX/RX/OBSS/non-wifi) from the firmware
+ * MIB query and accumulate the delta into chan_state. Used by the MT7925/MT7935
+ * update_survey callback.
+ */
+int mt7925_mcu_get_chan_mib_info(struct mt792x_phy *phy);
+
 /* GET_STAT_INFO (UNI_CMD_ID_GET_STATISTICS = 0x23),
  * sub-command UNI_CMD_GET_STATISTICS_TAG_LINK_QUALITY = 1.
  *
drivers/net/wireless/mediatek/mt76/mt7925/usb.c +1 -1
index f97f787b2198..2d3bf035fdfc 100644
@@ -174,7 +174,7 @@ static int mt7925u_probe(struct usb_interface *usb_intf,
 		.sta_add = mt7925_mac_sta_add,
 		.sta_event = mt7925_mac_sta_event,
 		.sta_remove = mt7925_mac_sta_remove,
-		.update_survey = mt792x_update_channel,
+		.update_survey = mt7925_update_channel,
 	};
 	static const struct mt792x_hif_ops hif_ops = {
 		.mcu_init = mt7925u_mcu_init,
drivers/net/wireless/mediatek/mt76/mt792x.h +6 -0
index a7d71e007da0..2c7170c6a99e 100644
@@ -222,6 +222,12 @@ struct mt792x_phy {
 
 	struct mt76_mib_stats mib;
 
+	/* survey: firmware reports accumulated airtime counters; keep the
+	 * previous snapshot so mt7925_mcu_get_chan_mib_info() can accumulate
+	 * deltas into chan_state (mirror mt7996 phy->state_ts).
+	 */
+	struct mt76_channel_state state_ts;
+
 	u8 sta_work_count;
 	u8 clc_chan_conf;
 	enum mt792x_reg_power_type power_type;
Signature · 1 line
2.45.2
#15 lore raw

Re: [PATCH v5 2/2] wifi: mt76: mt7925: support per-channel survey dump during scan

Quoted 1 line · Michael Shih

(1) Home/operating channel (periodic mac_work):

At USB 3.0 and on PCIe the periodic query is no trouble. At USB 2.0 it times out under traffic and the chip gets reset:

mt7925u 5-1:1.0: Message 00030022 (seq 11) timeout

  runs with a reset                      stock    series
  USB 2.0, v7.4-rc1                      0 of 4   6 of 6
  USB 3.0, v7.4-rc1                      0 of 2   0 of 4
  PCIe, 7.3.4 + morrownr/mt76 38f40b4c   0 of 4   0 of 5

USB is a Netgear A9000 on firmware 20260813 and 20261016, PCIe an MT7925 (ASPM off) and an MT7927. Each run is a 20 s upload and a 60 s download as a station. The MT7927 shows no transmit time while uploading; the MT7925 does.

My own patch for these counters [1] trips over the same thing, so its v2 is on hold. Asked by hand, the firmware still answers several times slower during a USB 2.0 download.

Quoted 1 line

(2) Scanned channels (scan-done event):

Scanned channels stay empty. Both firmware versions send eight bytes per channel in the scan-done event.

[1] https://lore.kernel.org/linux-wireless/[email protected]/

Devin

#16 lore raw

Re: [PATCH v5 2/2] wifi: mt76: mt7925: support per-channel survey dump during scan

Hi Devin,

Sorry for not mentioning that this Driver change requires MT7925 FW change as well, this is the reason why there is no transmit time with this driver change only.

I am also preparing the FW change on MTK side, and the FW change will be provided to upstream on MTK's FW provision schedule.

Thanks,
Michael.

#17 lore raw

Re: [PATCH v5 2/2] wifi: mt76: mt7925: support per-channel survey dump during scan

Hi Michael,

Thanks for the explanation. A related question while the firmware change is being prepared: we can’t find a noise floor reading for the MT7925. mt792x_phy_get_nf() returns 0, and the idle-power (IPI) histogram that mt7915/mt7996 build their noise floor from reads as all zeros on this chip. Setting IPI_EN through debugfs didn’t stick and caused MCU timeouts and firmware reloads, so we stopped there.

Is a noise floor, or the IPI histogram, available from the MT7925 firmware, for example in the GET_MIB_INFO response or another MCU query? Or could it be added alongside this change? With it, the survey could report noise as well as busy time.

We’re running an A9000 on USB 2.0, mostly in monitor mode, with firmware WM 20260605184805. We’re happy to test the firmware and driver changes when they’re available.

Thanks,
Chris

Quoted 27 lines · Michael Shih (史君仲)

Hi Devin,

Sorry for not mentioning that this Driver change requires MT7925 FW change as well, this is the reason why there is no transmit time with this driver change only.

I am also preparing the FW change on MTK side, and the FW change will be provided to upstream on MTK's FW provision schedule.

Thanks,
Michael.

*********** MEDIATEK Confidentiality Notice
***********
The information contained in this e-mail message (including any attachments) may be confidential, proprietary, privileged, or otherwise exempt from disclosure under applicable laws. It is intended to be conveyed only to the designated recipient(s). Any use, dissemination, distribution, printing, retaining or copying of this e-mail (including its attachments) by unintended recipient(s) is strictly prohibited and may be unlawful. If you are not an intended recipient of this e-mail, or believe that you have received this e-mail in error, please notify the sender immediately (by replying to this e-mail), delete any and all copies of this e-mail (including any attachments) from your system, and do not disclose the content of this e-mail to any other person. Thank you!