]> www.infradead.org Git - users/hch/misc.git/commitdiff
wifi: mac80211: add tx_handlers_drop statistics to ethtool
authorSarika Sharma <quic_sarishar@quicinc.com>
Fri, 22 Aug 2025 05:21:10 +0000 (10:51 +0530)
committerJohannes Berg <johannes.berg@intel.com>
Wed, 10 Sep 2025 13:04:27 +0000 (15:04 +0200)
Currently tx_handlers_drop statistics are handled only for slow TX
path and only at radio level. This also requires
CONFIG_MAC80211_DEBUG_COUNTERS to be enabled to account the dropped
packets. There is no way to check these stats for fast TX,
at interface level and monitor without enabling the debug configuration.

Hence, add a new counter at the sdata level to track packets dropped
with reason as TX_DROP during transmission for fast path, slow path
and other tx management packets. Expose this via ethtool statistics,
to improve visibility into transmission failures at interface level
and aid debugging and performance monitoring.

Place the counter in ethtool with other available tx_* stats for
better readability and accurate tracking.

Sample output:
root@buildroot:~# ethtool -S wlan0
NIC statistics:
     rx_packets: 5904
     rx_bytes: 508122
     rx_duplicates: 12
     rx_fragments: 5900
     rx_dropped: 12
     tx_packets: 391487
     tx_bytes: 600423383
     tx_filtered: 0
     tx_retry_failed: 10332
     tx_retries: 1548
     tx_handlers_drop: 4
     ....

Co-developed-by: Hari Chandrakanthan <quic_haric@quicinc.com>
Signed-off-by: Hari Chandrakanthan <quic_haric@quicinc.com>
Signed-off-by: Sarika Sharma <quic_sarishar@quicinc.com>
Link: https://patch.msgid.link/20250822052110.513804-1-quic_sarishar@quicinc.com
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
net/mac80211/ethtool.c
net/mac80211/ieee80211_i.h
net/mac80211/tx.c

index 0397755a3bd1c70e3af96a28dae8c4d31b85d142..3d365626faa4f78a5d94d587e15f4164fa271f9e 100644 (file)
@@ -48,8 +48,8 @@ static const char ieee80211_gstrings_sta_stats[][ETH_GSTRING_LEN] = {
        "rx_duplicates", "rx_fragments", "rx_dropped",
        "tx_packets", "tx_bytes",
        "tx_filtered", "tx_retry_failed", "tx_retries",
-       "sta_state", "txrate", "rxrate", "signal",
-       "channel", "noise", "ch_time", "ch_time_busy",
+       "tx_handlers_drop", "sta_state", "txrate", "rxrate",
+       "signal", "channel", "noise", "ch_time", "ch_time_busy",
        "ch_time_ext_busy", "ch_time_rx", "ch_time_tx"
 };
 #define STA_STATS_LEN  ARRAY_SIZE(ieee80211_gstrings_sta_stats)
@@ -120,6 +120,7 @@ static void ieee80211_get_stats(struct net_device *dev,
                i = 0;
                ADD_STA_STATS(&sta->deflink);
 
+               data[i++] = sdata->tx_handlers_drop;
                data[i++] = sta->sta_state;
 
 
@@ -145,6 +146,7 @@ static void ieee80211_get_stats(struct net_device *dev,
                        sta_set_sinfo(sta, &sinfo, false);
                        i = 0;
                        ADD_STA_STATS(&sta->deflink);
+                       data[i++] = sdata->tx_handlers_drop;
                }
        }
 
index 07f5fb11569b5820ed29e83db4b3d6f9eb55f75b..8a666faeb1eced912b84a2567e0db9460d295448 100644 (file)
@@ -1218,6 +1218,7 @@ struct ieee80211_sub_if_data {
        } debugfs;
 #endif
 
+       u32 tx_handlers_drop;
        /* must be last, dynamically sized area in this! */
        struct ieee80211_vif vif;
 };
index 0ece8d89e0944b0d607f67522f2cdcbadfab8d75..a27e2af5d569f5b4064832f81e1ed0549dd92a3c 100644 (file)
@@ -1814,6 +1814,7 @@ static int invoke_tx_handlers_early(struct ieee80211_tx_data *tx)
 
  txh_done:
        if (unlikely(res == TX_DROP)) {
+               tx->sdata->tx_handlers_drop++;
                I802_DEBUG_INC(tx->local->tx_handlers_drop);
                if (tx->skb)
                        ieee80211_free_txskb(&tx->local->hw, tx->skb);
@@ -1858,6 +1859,7 @@ static int invoke_tx_handlers_late(struct ieee80211_tx_data *tx)
 
  txh_done:
        if (unlikely(res == TX_DROP)) {
+               tx->sdata->tx_handlers_drop++;
                I802_DEBUG_INC(tx->local->tx_handlers_drop);
                if (tx->skb)
                        ieee80211_free_txskb(&tx->local->hw, tx->skb);
@@ -1942,6 +1944,7 @@ static bool ieee80211_tx(struct ieee80211_sub_if_data *sdata,
 
        if (unlikely(res_prepare == TX_DROP)) {
                ieee80211_free_txskb(&local->hw, skb);
+               tx.sdata->tx_handlers_drop++;
                return true;
        } else if (unlikely(res_prepare == TX_QUEUED)) {
                return true;
@@ -3728,8 +3731,10 @@ void __ieee80211_xmit_fast(struct ieee80211_sub_if_data *sdata,
        r = ieee80211_xmit_fast_finish(sdata, sta, fast_tx->pn_offs,
                                       fast_tx->key, &tx);
        tx.skb = NULL;
-       if (r == TX_DROP)
+       if (r == TX_DROP) {
+               tx.sdata->tx_handlers_drop++;
                goto free;
+       }
 
        if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN)
                sdata = container_of(sdata->bss,