Skip to contentSkip to conversation

mac80211: increment rx stats according to USES_RSS flag

PATCH In review Thiraviyam Mariyappan 2 participants 6 messages Feb 17, 2021 – May 6, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 mac80211: increment rx stats according to USES_RSS flag

Currently, rx_stats were updated regardless of USES_RSS flag is enabled/disabled. So, updating the rx_stats from percpu pointers according to the USES_RSS flag.

---
v2:
*Subject(mac80211: fix rx byte values not updated on mesh link) and commit log changed.

---
 net/mac80211/mesh.h       |  2 ++
 net/mac80211/mesh_plink.c |  4 ++-
 net/mac80211/rx.c         | 75 +++++++++++++++++++++++++++++++----------------
 3 files changed, 55 insertions(+), 26 deletions(-)
net/mac80211/mesh.h +2 -0
index 40492d1..c8d9103 100644
@@ -318,6 +318,8 @@ void mesh_path_discard_frame(struct ieee80211_sub_if_data *sdata,
 void mesh_path_tx_root_frame(struct ieee80211_sub_if_data *sdata);
 
 bool mesh_action_is_path_sel(struct ieee80211_mgmt *mgmt);
+struct ieee80211_sta_rx_stats *ieee80211_get_rx_stats(struct ieee80211_hw *hw,
+						      struct sta_info *sta);
 
 #ifdef CONFIG_MAC80211_MESH
 static inline
net/mac80211/mesh_plink.c +3 -1
index aca26df..44b6ebb 100644
@@ -416,6 +416,7 @@ static void mesh_sta_info_init(struct ieee80211_sub_if_data *sdata,
 	struct ieee80211_supported_band *sband;
 	u32 rates, basic_rates = 0, changed = 0;
 	enum ieee80211_sta_rx_bandwidth bw = sta->sta.bandwidth;
+	struct ieee80211_sta_rx_stats *stats;
 
 	sband = ieee80211_get_sband(sdata);
 	if (!sband)
@@ -425,7 +426,8 @@ static void mesh_sta_info_init(struct ieee80211_sub_if_data *sdata,
 					&basic_rates);
 
 	spin_lock_bh(&sta->mesh->plink_lock);
-	sta->rx_stats.last_rx = jiffies;
+	stats = ieee80211_get_rx_stats(&local->hw, sta);
+	stats->last_rx = jiffies;
 
 	/* rates and capabilities don't change during peering */
 	if (sta->mesh->plink_state == NL80211_PLINK_ESTAB &&
net/mac80211/rx.c +50 -25

188 lines not on this page · raw message

Signature · 7 lines
2.7.4


-- 
ath11k mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/ath11k
maintainer
#1 lore raw
Quoted 3 lines · Thiraviyam Mariyappan

Currently, rx_stats were updated regardless of USES_RSS flag is enabled/disabled. So, updating the rx_stats from percpu pointers according to the USES_RSS flag.

I guess I'll fix it this time, but the commit log is still not saying what it should.

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches#commit_messages

Please, everyone @codeaurora, pay attention. I don't want to have this discussion for every patch.

johannes

maintainer
#2 lore raw
In reply to Thiraviyam Mariyappan
Quoted 3 lines · Thiraviyam Mariyappan

Currently, rx_stats were updated regardless of USES_RSS flag is enabled/disabled. So, updating the rx_stats from percpu pointers according to the USES_RSS flag.

OK actually, I'm not going to fix the commit log, you'll probably have to resend it anyway.

net/mac80211/mesh_plink.c static void mesh_sta_info_init(struct ieee80211_sub_if_data *sdata, · line 430

Quoted 7 lines
net/mac80211/mesh_plink.c +2 -1
@@ -425,7 +426,8 @@ static void mesh_sta_info_init(struct ieee80211_sub_if_data *sdata,
  					&basic_rates);
 
  	spin_lock_bh(&sta->mesh->plink_lock);
-	sta->rx_stats.last_rx = jiffies;
+	stats = ieee80211_get_rx_stats(&local->hw, sta);
+	stats->last_rx = jiffies;

This doesn't really make much sense? Not sure why that is even updating anything at all, it doesn't update anything else?

Or at least you didn't change anything else, maybe you should have?

net/mac80211/rx.c ieee80211_rx_h_sta_process(struct ieee80211_rx_data *rx) · line 1748

Quoted 7 lines
net/mac80211/rx.c +1 -1
@@ -1734,49 +1745,49 @@ ieee80211_rx_h_sta_process(struct ieee80211_rx_data *rx)
  	 * something went wrong the first time.
  	 */
  	if (rx->sdata->vif.type == NL80211_IFTYPE_ADHOC) {
-		u8 *bssid = ieee80211_get_bssid(hdr, rx->skb->len,
+		u8 *bssid = ieee80211_get_bssid(hdr, skb->len,

That seems unrelated.

net/mac80211/rx.c ieee80211_rx_h_mgmt(struct ieee80211_rx_data *rx) · line 3655

Quoted 11 lines
net/mac80211/rx.c +4 -2
@@ -3625,8 +3648,10 @@ ieee80211_rx_h_mgmt(struct ieee80211_rx_data *rx)
  	/* queue up frame and kick off work to process it */
  	skb_queue_tail(&sdata->skb_queue, rx->skb);
  	ieee80211_queue_work(&rx->local->hw, &sdata->work);
-	if (rx->sta)
-		rx->sta->rx_stats.packets++;
+	if (rx->sta) {
+		stats = ieee80211_get_rx_stats(&rx->sdata->local->hw, rx->sta);
+		stats->packets++;
+	}
 

Picking this for no particular reason - everything else in this patch is unnecessary since we have rx_path_lock held afaict, so it doesn't matter. The whole per-cpu status stuff only matters once you get into fast-rx path.

I'd argue that had you written a proper commit log that actually says why you need to change things, you'd probably even have noticed these issues yourself.

johannes

Signature · 3 lines
ath11k mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/ath11k
#3 lore raw
Quoted 4 lines · Johannes Berg
Quoted 3 lines · Thiraviyam Mariyappan

Currently, rx_stats were updated regardless of USES_RSS flag is enabled/disabled. So, updating the rx_stats from percpu pointers according to the USES_RSS flag.

The issue is rx packets not incremented in mesh link and this change made to overcome the issue.

Quoted 38 lines

OK actually, I'm not going to fix the commit log, you'll probably have to resend it anyway.

net/mac80211/mesh_plink.c static void mesh_sta_info_init(struct · line 431

Quoted 8 lines
net/mac80211/mesh_plink.c +2 -1
@@ -425,7 +426,8 @@ static void mesh_sta_info_init(struct 
 ieee80211_sub_if_data *sdata,
  					&basic_rates);
 
  	spin_lock_bh(&sta->mesh->plink_lock);
-	sta->rx_stats.last_rx = jiffies;
+	stats = ieee80211_get_rx_stats(&local->hw, sta);
+	stats->last_rx = jiffies;

This doesn't really make much sense? Not sure why that is even updating anything at all, it doesn't update anything else?

Or at least you didn't change anything else, maybe you should have?

net/mac80211/rx.c ieee80211_rx_h_sta_process(struct · line 1749

Quoted 8 lines
net/mac80211/rx.c +1 -1
@@ -1734,49 +1745,49 @@ ieee80211_rx_h_sta_process(struct 
 ieee80211_rx_data *rx)
  	 * something went wrong the first time.
  	 */
  	if (rx->sdata->vif.type == NL80211_IFTYPE_ADHOC) {
-		u8 *bssid = ieee80211_get_bssid(hdr, rx->skb->len,
+		u8 *bssid = ieee80211_get_bssid(hdr, skb->len,

That seems unrelated.

Quoted 9 lines
net/mac80211/rx.c +2 -2
@@ -3625,8 +3648,10 @@ ieee80211_rx_h_mgmt(struct ieee80211_rx_data 
 *rx)
  	/* queue up frame and kick off work to process it */
  	skb_queue_tail(&sdata->skb_queue, rx->skb);
  	ieee80211_queue_work(&rx->local->hw, &sdata->work);
-	if (rx->sta)
-		rx->sta->rx_stats.packets++;
+	if (rx->sta) {
+		stats = ieee80211_get_rx_stats(&rx->sdata->local->hw, rx->sta);
Quoted 8 lines

net/mac80211/rx.c ieee80211_rx_h_defragment(struct ieee80211_rx_data *rx) · line 2351

Quoted 3 lines
net/mac80211/rx.c +2 -0
+		stats->packets++;
+	}
 

Picking this for no particular reason - everything else in this patch is unnecessary since we have rx_path_lock held afaict, so it doesn't matter. The whole per-cpu status stuff only matters once you get into fast-rx path.

In case of Mesh fast_rx is not applicable, but still USES_RSS can be enabled from driver when parallel RX is supported by HW/Driver, right? Hence checked for USES_RSS support to update per cpu stats.Please correct me if the meaning of USES_RSS is misunderstood and it applies only when fast_rx for a STA is enabled.

Quoted 7 lines

I'd argue that had you written a proper commit log that actually says why you need to change things, you'd probably even have noticed these issues yourself.

johannes

maintainer
#4 lore raw
Quoted 3 lines · Thiraviyam Mariyappan

In case of Mesh fast_rx is not applicable, but still USES_RSS can be enabled from driver when parallel RX is supported by HW/Driver, right?

Yes, I guess that's true.

Quoted 4 lines

Hence checked for USES_RSS support to update per cpu stats.Please correct me if the meaning of USES_RSS is misunderstood and it applies only when fast_rx for a STA is enabled.

Well, actually using multi-queue is pointless or even counter-productive when you don't have fast-RX, since then you'll run into a common lock, and doing much processing on multiple CPUs but under a common lock might well be worse than doing it on a single CPU in the first place, since you'll bounce the lock around all the time.

However, you're right that the driver might generally advertise USES_RSS, but then not do it for mesh, but that throws off some statistics.

Something like this might then be a much better fix though?

net/mac80211/sta_info.c +3 -6
index ec6973ee88ef..f87e883862d9 100644
@@ -2092,7 +2092,7 @@ sta_get_last_rx_stats(struct sta_info *sta)
 	struct ieee80211_local *local = sta->local;
 	int cpu;
 
-	if (!ieee80211_hw_check(&local->hw, USES_RSS))
+	if (!sta->pcpu_rx_stats)
 		return stats;
 
 	for_each_possible_cpu(cpu) {
@@ -2192,9 +2192,7 @@ static void sta_set_tidstats(struct sta_info *sta,
 	int cpu;
 
 	if (!(tidstats->filled & BIT(NL80211_TID_STATS_RX_MSDU))) {
-		if (!ieee80211_hw_check(&local->hw, USES_RSS))
-			tidstats->rx_msdu +=
-				sta_get_tidstats_msdu(&sta->rx_stats, tid);
+		tidstats->rx_msdu += sta_get_tidstats_msdu(&sta->rx_stats, tid);
 
 		if (sta->pcpu_rx_stats) {
 			for_each_possible_cpu(cpu) {
@@ -2308,8 +2306,7 @@ void sta_set_sinfo(struct sta_info *sta, struct station_info *sinfo,
 
 	if (!(sinfo->filled & (BIT_ULL(NL80211_STA_INFO_RX_BYTES64) |
 			       BIT_ULL(NL80211_STA_INFO_RX_BYTES)))) {
-		if (!ieee80211_hw_check(&local->hw, USES_RSS))
-			sinfo->rx_bytes += sta_get_stats_bytes(&sta->rx_stats);
+		sinfo->rx_bytes += sta_get_stats_bytes(&sta->rx_stats);
 
 		if (sta->pcpu_rx_stats) {
 			for_each_possible_cpu(cpu) {

johannes

#5 lore raw
Quoted 18 lines · Johannes Berg
Quoted 3 lines · Thiraviyam Mariyappan

In case of Mesh fast_rx is not applicable, but still USES_RSS can be enabled from driver when parallel RX is supported by HW/Driver, right?

Yes, I guess that's true.

Quoted 4 lines

Hence checked for USES_RSS support to update per cpu stats.Please correct me if the meaning of USES_RSS is misunderstood and it applies only when fast_rx for a STA is enabled.

Well, actually using multi-queue is pointless or even counter-productive when you don't have fast-RX, since then you'll run into a common lock, and doing much processing on multiple CPUs but under a common lock might well be worse than doing it on a single CPU in the first place, since you'll bounce the lock around all the time.

Quoted 5 lines

However, you're right that the driver might generally advertise USES_RSS, but then not do it for mesh, but that throws off some statistics.

Something like this might then be a much better fix though?

Below fix good to me and working fine.

Quoted 41 lines
net/mac80211/sta_info.c +2 -4
index ec6973ee88ef..f87e883862d9 100644
@@ -2092,7 +2092,7 @@ sta_get_last_rx_stats(struct sta_info *sta)
 	struct ieee80211_local *local = sta->local;
 	int cpu;
 
-	if (!ieee80211_hw_check(&local->hw, USES_RSS))
+	if (!sta->pcpu_rx_stats)
 		return stats;
 
 	for_each_possible_cpu(cpu) {
@@ -2192,9 +2192,7 @@ static void sta_set_tidstats(struct sta_info 
 *sta,
 	int cpu;
 
 	if (!(tidstats->filled & BIT(NL80211_TID_STATS_RX_MSDU))) {
-		if (!ieee80211_hw_check(&local->hw, USES_RSS))
-			tidstats->rx_msdu +=
-				sta_get_tidstats_msdu(&sta->rx_stats, tid);
+		tidstats->rx_msdu += sta_get_tidstats_msdu(&sta->rx_stats, tid);
 
 		if (sta->pcpu_rx_stats) {
net/mac80211/sta_info.c +1 -2
 			for_each_possible_cpu(cpu) {
@@ -2308,8 +2306,7 @@ void sta_set_sinfo(struct sta_info *sta, struct
 station_info *sinfo,
 
 	if (!(sinfo->filled & (BIT_ULL(NL80211_STA_INFO_RX_BYTES64) |
 			       BIT_ULL(NL80211_STA_INFO_RX_BYTES)))) {
-		if (!ieee80211_hw_check(&local->hw, USES_RSS))
-			sinfo->rx_bytes += sta_get_stats_bytes(&sta->rx_stats);
+		sinfo->rx_bytes += sta_get_stats_bytes(&sta->rx_stats);
 
 		if (sta->pcpu_rx_stats) {

for_each_possible_cpu(cpu) {

johannes