wifi: mt76: mt7921e: report tx retries/failed counts in tx free event
authorDeren Wu <deren.wu@mediatek.com>
Mon, 15 May 2023 15:18:50 +0000 (23:18 +0800)
committerFelix Fietkau <nbd@nbd.name>
Tue, 25 Jul 2023 19:59:41 +0000 (21:59 +0200)
Get missing tx retries/failed counts from txfree done events and report
them via mt7921_sta_statistics().

Signed-off-by: Deren Wu <deren.wu@mediatek.com>
Reviewed-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
drivers/net/wireless/mediatek/mt76/mt76_connac2_mac.h
drivers/net/wireless/mediatek/mt76/mt7921/mac.c
drivers/net/wireless/mediatek/mt76/mt7921/main.c

index fabf637..bd2a924 100644 (file)
@@ -34,7 +34,7 @@ enum {
 
 #define MT_TX_FREE_MSDU_CNT            GENMASK(9, 0)
 #define MT_TX_FREE_WLAN_ID             GENMASK(23, 14)
-#define MT_TX_FREE_LATENCY             GENMASK(12, 0)
+#define MT_TX_FREE_COUNT               GENMASK(12, 0)
 /* 0: success, others: dropped */
 #define MT_TX_FREE_STATUS              GENMASK(14, 13)
 #define MT_TX_FREE_MSDU_ID             GENMASK(30, 16)
index a2e9d7b..2d3f394 100644 (file)
@@ -614,6 +614,7 @@ static void mt7921_mac_tx_free(struct mt7921_dev *dev, void *data, int len)
        struct mt76_dev *mdev = &dev->mt76;
        struct mt76_txwi_cache *txwi;
        struct ieee80211_sta *sta = NULL;
+       struct mt76_wcid *wcid = NULL;
        struct sk_buff *skb, *tmp;
        void *end = data + len;
        LIST_HEAD(free_list);
@@ -637,7 +638,6 @@ static void mt7921_mac_tx_free(struct mt7921_dev *dev, void *data, int len)
                 */
                if (info & MT_TX_FREE_PAIR) {
                        struct mt7921_sta *msta;
-                       struct mt76_wcid *wcid;
                        u16 idx;
 
                        count++;
@@ -658,6 +658,12 @@ static void mt7921_mac_tx_free(struct mt7921_dev *dev, void *data, int len)
                msdu = FIELD_GET(MT_TX_FREE_MSDU_ID, info);
                stat = FIELD_GET(MT_TX_FREE_STATUS, info);
 
+               if (wcid) {
+                       wcid->stats.tx_retries +=
+                               FIELD_GET(MT_TX_FREE_COUNT, info) - 1;
+                       wcid->stats.tx_failed += !!stat;
+               }
+
                txwi = mt76_token_release(mdev, msdu, &wake);
                if (!txwi)
                        continue;
index d183982..199da4b 100644 (file)
@@ -1399,6 +1399,12 @@ static void mt7921_sta_statistics(struct ieee80211_hw *hw,
                sinfo->txrate.he_dcm = txrate->he_dcm;
                sinfo->txrate.he_ru_alloc = txrate->he_ru_alloc;
        }
+       sinfo->tx_failed = msta->wcid.stats.tx_failed;
+       sinfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_FAILED);
+
+       sinfo->tx_retries = msta->wcid.stats.tx_retries;
+       sinfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_RETRIES);
+
        sinfo->txrate.flags = txrate->flags;
        sinfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_BITRATE);