diff mbox series

[v5,3/3] wifi: mac80211: Clarify per-link tx stats.

Message ID 20241218232519.3156080-3-greearb@candelatech.com (mailing list archive)
State New
Delegated to: Johannes Berg
Headers show
Series [v5,1/3] wifi: mac80211: Assign tx-stats to the proper link. | expand

Commit Message

Ben Greear Dec. 18, 2024, 11:25 p.m. UTC
From: Ben Greear <greearb@candelatech.com>

In the tx path, deflink tx stats are increased for the packets
requested to be transmitted.  At that point, we cannot know the
actual link that will be used to transmit.  Rename those stats with
req_ prefix to show they are requested.

Signed-off-by: Ben Greear <greearb@candelatech.com>
---
 net/mac80211/sta_info.c |  6 +++---
 net/mac80211/sta_info.h |  8 +++++---
 net/mac80211/tx.c       | 20 ++++++++++----------
 3 files changed, 18 insertions(+), 16 deletions(-)
diff mbox series

Patch

diff --git a/net/mac80211/sta_info.c b/net/mac80211/sta_info.c
index aa22f09e6d14..c8c64271eb26 100644
--- a/net/mac80211/sta_info.c
+++ b/net/mac80211/sta_info.c
@@ -2522,7 +2522,7 @@  static void sta_set_tidstats(struct sta_info *sta,
 
 	if (!(tidstats->filled & BIT(NL80211_TID_STATS_TX_MSDU))) {
 		tidstats->filled |= BIT(NL80211_TID_STATS_TX_MSDU);
-		tidstats->tx_msdu = sta->deflink.tx_stats.msdu[tid];
+		tidstats->tx_msdu = sta->deflink.tx_stats.req_msdu[tid];
 	}
 
 	if (!(tidstats->filled & BIT(NL80211_TID_STATS_TX_MSDU_RETRIES)) &&
@@ -2606,14 +2606,14 @@  void sta_set_sinfo(struct sta_info *sta, struct station_info *sinfo,
 			       BIT_ULL(NL80211_STA_INFO_TX_BYTES)))) {
 		sinfo->tx_bytes = 0;
 		for (ac = 0; ac < IEEE80211_NUM_ACS; ac++)
-			sinfo->tx_bytes += sta->deflink.tx_stats.bytes[ac];
+			sinfo->tx_bytes += sta->deflink.tx_stats.req_bytes[ac];
 		sinfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_BYTES64);
 	}
 
 	if (!(sinfo->filled & BIT_ULL(NL80211_STA_INFO_TX_PACKETS))) {
 		sinfo->tx_packets = 0;
 		for (ac = 0; ac < IEEE80211_NUM_ACS; ac++)
-			sinfo->tx_packets += sta->deflink.tx_stats.packets[ac];
+			sinfo->tx_packets += sta->deflink.tx_stats.req_packets[ac];
 		sinfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_PACKETS);
 	}
 
diff --git a/net/mac80211/sta_info.h b/net/mac80211/sta_info.h
index fc59e6410082..40179a9ec0bc 100644
--- a/net/mac80211/sta_info.h
+++ b/net/mac80211/sta_info.h
@@ -553,14 +553,16 @@  struct link_sta_info {
 
 	/* Updated from TX path only, no locking requirements */
 	struct {
-		u64 packets[IEEE80211_NUM_ACS];
-		u64 bytes[IEEE80211_NUM_ACS];
+		/* Packets and bytes requested to be transmitted, deflink only */
+		u64 req_packets[IEEE80211_NUM_ACS];
+		u64 req_bytes[IEEE80211_NUM_ACS];
 		/* Packets and bytes reported transmitted (per link) */
 		u64 rep_packets;
 		u64 rep_bytes;
 		struct ieee80211_tx_rate last_rate;
 		struct rate_info last_rate_info;
-		u64 msdu[IEEE80211_NUM_TIDS + 1];
+		/* Requested to be transmitted */
+		u64 req_msdu[IEEE80211_NUM_TIDS + 1];
 	} tx_stats;
 
 	enum ieee80211_sta_rx_bandwidth cur_max_bandwidth;
diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c
index a24636bda679..ab89dac99cf5 100644
--- a/net/mac80211/tx.c
+++ b/net/mac80211/tx.c
@@ -866,7 +866,7 @@  ieee80211_tx_h_sequence(struct ieee80211_tx_data *tx)
 		hdr->seq_ctrl = cpu_to_le16(tx->sdata->sequence_number);
 		tx->sdata->sequence_number += 0x10;
 		if (tx->sta)
-			tx->sta->deflink.tx_stats.msdu[IEEE80211_NUM_TIDS]++;
+			tx->sta->deflink.tx_stats.req_msdu[IEEE80211_NUM_TIDS]++;
 		return TX_CONTINUE;
 	}
 
@@ -880,7 +880,7 @@  ieee80211_tx_h_sequence(struct ieee80211_tx_data *tx)
 
 	/* include per-STA, per-TID sequence counter */
 	tid = ieee80211_get_tid(hdr);
-	tx->sta->deflink.tx_stats.msdu[tid]++;
+	tx->sta->deflink.tx_stats.req_msdu[tid]++;
 
 	hdr->seq_ctrl = ieee80211_tx_next_seq(tx->sta, tid);
 
@@ -1033,10 +1033,10 @@  ieee80211_tx_h_stats(struct ieee80211_tx_data *tx)
 
 	skb_queue_walk(&tx->skbs, skb) {
 		ac = skb_get_queue_mapping(skb);
-		tx->sta->deflink.tx_stats.bytes[ac] += skb->len;
+		tx->sta->deflink.tx_stats.req_bytes[ac] += skb->len;
 	}
 	if (ac >= 0)
-		tx->sta->deflink.tx_stats.packets[ac]++;
+		tx->sta->deflink.tx_stats.req_packets[ac]++;
 
 	return TX_CONTINUE;
 }
@@ -3575,18 +3575,18 @@  ieee80211_xmit_fast_finish(struct ieee80211_sub_if_data *sdata,
 	}
 
 	if (skb_shinfo(skb)->gso_size)
-		sta->deflink.tx_stats.msdu[tid] +=
+		sta->deflink.tx_stats.req_msdu[tid] +=
 			DIV_ROUND_UP(skb->len, skb_shinfo(skb)->gso_size);
 	else
-		sta->deflink.tx_stats.msdu[tid]++;
+		sta->deflink.tx_stats.req_msdu[tid]++;
 
 	info->hw_queue = sdata->vif.hw_queue[skb_get_queue_mapping(skb)];
 
 	/* statistics normally done by ieee80211_tx_h_stats (but that
 	 * has to consider fragmentation, so is more complex)
 	 */
-	sta->deflink.tx_stats.bytes[skb_get_queue_mapping(skb)] += skb->len;
-	sta->deflink.tx_stats.packets[skb_get_queue_mapping(skb)]++;
+	sta->deflink.tx_stats.req_bytes[skb_get_queue_mapping(skb)] += skb->len;
+	sta->deflink.tx_stats.req_packets[skb_get_queue_mapping(skb)]++;
 
 	if (pn_offs) {
 		u64 pn;
@@ -4672,8 +4672,8 @@  static void ieee80211_8023_xmit(struct ieee80211_sub_if_data *sdata,
 	}
 
 	dev_sw_netstats_tx_add(dev, skbs, len);
-	sta->deflink.tx_stats.packets[queue] += skbs;
-	sta->deflink.tx_stats.bytes[queue] += len;
+	sta->deflink.tx_stats.req_packets[queue] += skbs;
+	sta->deflink.tx_stats.req_bytes[queue] += len;
 
 	ieee80211_tpt_led_trig_tx(local, len);