All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] rtw89: limit RX status rate of VHT to MCS 9
@ 2021-12-30  1:16 Ping-Ke Shih
  2021-12-30  1:16 ` [PATCH 2/2] rtw89: encapsulate RX handlers to single function Ping-Ke Shih
  2021-12-30 21:23 ` [PATCH 1/2] rtw89: limit RX status rate of VHT to MCS 9 Johannes Berg
  0 siblings, 2 replies; 4+ messages in thread
From: Ping-Ke Shih @ 2021-12-30  1:16 UTC (permalink / raw)
  To: kvalo; +Cc: linux-wireless, rgoldwyn

8852AE can receive packets with VHT MCS10/11 that is out of specification,
so mac80211 warns and drops the packets, and it leads low TCP throughput.

  Rate marked as a VHT rate but data is invalid: MCS: 10, NSS: 2
  WARNING: CPU: 1 PID: 7817 at net/mac80211/rx.c:4856 ieee80211_rx_list+0x223/0x2f0 [mac80211]

Therefore, limit the report rate to VHT MCS9. Meanwhile, we want to know
we have received this kind of packets, so show the counter of VHT MCS10/11
in debugfs, like:

  TP TX: 1 [1] Mbps (lv: 1), RX: 460 [438] Mbps (lv: 4)
  Beacon: 18
  Avg packet length: TX=96, RX=3083
  RX count:
     Legacy: [0, 0, 0, 0]
       OFDM: [0, 0, 0, 0, 0, 0, 0, 0]
       HT 0: [0, 0, 0, 0, 0, 0, 0, 0]
       HT 1: [0, 0, 0, 0, 0, 0, 0, 0]
    VHT 1SS: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0][0, 0]
    VHT 2SS: [0, 0, 0, 0, 0, 0, 24, 718, 4591, 31564][418, 0]
     HE 1SS: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
     HE 2ss: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
  TX rate [0]: VHT 2SS MCS-9 SGI	(hw_rate=0x119)	==> agg_wait=1 (3500)
  RX rate [0]: VHT 2SS MCS-9 SGI	(hw_rate=0x119)
  RSSI: -28 dBm (raw=165, prev=163)

Buglink: https://bugzilla.suse.com/show_bug.cgi?id=1192891
Reported-by: Goldwyn Rodrigues <rgoldwyn@suse.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
---
 drivers/net/wireless/realtek/rtw89/core.c  | 13 +++++++++++++
 drivers/net/wireless/realtek/rtw89/debug.c | 22 ++++++++++++++--------
 2 files changed, 27 insertions(+), 8 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtw89/core.c b/drivers/net/wireless/realtek/rtw89/core.c
index 00ae86807dc21..4ab12f20eacdc 100644
--- a/drivers/net/wireless/realtek/rtw89/core.c
+++ b/drivers/net/wireless/realtek/rtw89/core.c
@@ -1062,6 +1062,16 @@ static void rtw89_core_rx_stats(struct rtw89_dev *rtwdev,
 	rtw89_iterate_vifs_bh(rtwdev, rtw89_vif_rx_stats_iter, &iter_data);
 }
 
+static void rtw89_core_correct_vht_rate(struct ieee80211_rx_status *rx_status)
+{
+	/* Our hardware can receive the VHT packet with rate higher than MCS 9.
+	 * This kind of packet is out of specification and dropped by mac80211,
+	 * and it leads very low TCP throughput.
+	 */
+	if (rx_status->encoding == RX_ENC_VHT && rx_status->rate_idx > 9)
+		rx_status->rate_idx = 9;
+}
+
 static void rtw89_correct_cck_chan(struct rtw89_dev *rtwdev,
 				   struct ieee80211_rx_status *status)
 {
@@ -1106,6 +1116,7 @@ static void rtw89_core_rx_pending_skb(struct rtw89_dev *rtwdev,
 		rtw89_correct_cck_chan(rtwdev, rx_status);
 		rtw89_core_hw_to_sband_rate(rx_status);
 		rtw89_core_rx_stats(rtwdev, phy_ppdu, desc_info, skb_ppdu);
+		rtw89_core_correct_vht_rate(rx_status);
 		ieee80211_rx_napi(rtwdev->hw, NULL, skb_ppdu, &rtwdev->napi);
 		rtwdev->napi_budget_countdown--;
 	}
@@ -1334,6 +1345,7 @@ static void rtw89_core_flush_ppdu_rx_queue(struct rtw89_dev *rtwdev,
 		rx_status = IEEE80211_SKB_RXCB(skb_ppdu);
 		rtw89_core_hw_to_sband_rate(rx_status);
 		rtw89_core_rx_stats(rtwdev, NULL, desc_info, skb_ppdu);
+		rtw89_core_correct_vht_rate(rx_status);
 		ieee80211_rx_napi(rtwdev->hw, NULL, skb_ppdu, &rtwdev->napi);
 		rtwdev->napi_budget_countdown--;
 	}
@@ -1367,6 +1379,7 @@ void rtw89_core_rx(struct rtw89_dev *rtwdev,
 	} else {
 		rtw89_core_hw_to_sband_rate(rx_status);
 		rtw89_core_rx_stats(rtwdev, NULL, desc_info, skb);
+		rtw89_core_correct_vht_rate(rx_status);
 		ieee80211_rx_napi(rtwdev->hw, NULL, skb, &rtwdev->napi);
 		rtwdev->napi_budget_countdown--;
 	}
diff --git a/drivers/net/wireless/realtek/rtw89/debug.c b/drivers/net/wireless/realtek/rtw89/debug.c
index 9756d75ef24e1..fb2f4870172d9 100644
--- a/drivers/net/wireless/realtek/rtw89/debug.c
+++ b/drivers/net/wireless/realtek/rtw89/debug.c
@@ -2322,16 +2322,17 @@ rtw89_debug_append_rx_rate(struct seq_file *m, struct rtw89_pkt_stat *pkt_stat,
 static const struct rtw89_rx_rate_cnt_info {
 	enum rtw89_hw_rate first_rate;
 	int len;
+	int ext;
 	const char *rate_mode;
 } rtw89_rx_rate_cnt_infos[] = {
-	{RTW89_HW_RATE_CCK1, 4, "Legacy:"},
-	{RTW89_HW_RATE_OFDM6, 8, "OFDM:"},
-	{RTW89_HW_RATE_MCS0, 8, "HT 0:"},
-	{RTW89_HW_RATE_MCS8, 8, "HT 1:"},
-	{RTW89_HW_RATE_VHT_NSS1_MCS0, 10, "VHT 1SS:"},
-	{RTW89_HW_RATE_VHT_NSS2_MCS0, 10, "VHT 2SS:"},
-	{RTW89_HW_RATE_HE_NSS1_MCS0, 12, "HE 1SS:"},
-	{RTW89_HW_RATE_HE_NSS2_MCS0, 12, "HE 2ss:"},
+	{RTW89_HW_RATE_CCK1, 4, 0, "Legacy:"},
+	{RTW89_HW_RATE_OFDM6, 8, 0, "OFDM:"},
+	{RTW89_HW_RATE_MCS0, 8, 0, "HT 0:"},
+	{RTW89_HW_RATE_MCS8, 8, 0, "HT 1:"},
+	{RTW89_HW_RATE_VHT_NSS1_MCS0, 10, 2, "VHT 1SS:"},
+	{RTW89_HW_RATE_VHT_NSS2_MCS0, 10, 2, "VHT 2SS:"},
+	{RTW89_HW_RATE_HE_NSS1_MCS0, 12, 0, "HE 1SS:"},
+	{RTW89_HW_RATE_HE_NSS2_MCS0, 12, 0, "HE 2ss:"},
 };
 
 static int rtw89_debug_priv_phy_info_get(struct seq_file *m, void *v)
@@ -2356,6 +2357,11 @@ static int rtw89_debug_priv_phy_info_get(struct seq_file *m, void *v)
 		seq_printf(m, "%10s [", info->rate_mode);
 		rtw89_debug_append_rx_rate(m, pkt_stat,
 					   info->first_rate, info->len);
+		if (info->ext) {
+			seq_puts(m, "][");
+			rtw89_debug_append_rx_rate(m, pkt_stat,
+						   info->first_rate + info->len, info->ext);
+		}
 		seq_puts(m, "]\n");
 	}
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] rtw89: encapsulate RX handlers to single function
  2021-12-30  1:16 [PATCH 1/2] rtw89: limit RX status rate of VHT to MCS 9 Ping-Ke Shih
@ 2021-12-30  1:16 ` Ping-Ke Shih
  2021-12-30 21:23 ` [PATCH 1/2] rtw89: limit RX status rate of VHT to MCS 9 Johannes Berg
  1 sibling, 0 replies; 4+ messages in thread
From: Ping-Ke Shih @ 2021-12-30  1:16 UTC (permalink / raw)
  To: kvalo; +Cc: linux-wireless, rgoldwyn

We have three points to receive packets to mac80211 with three different
kinds of status. Many handlers are common and can be shared, so I move
them together, and I don't change the logic at all.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
---
 drivers/net/wireless/realtek/rtw89/core.c | 36 +++++++++++------------
 1 file changed, 18 insertions(+), 18 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtw89/core.c b/drivers/net/wireless/realtek/rtw89/core.c
index 4ab12f20eacdc..ddbefd3d93584 100644
--- a/drivers/net/wireless/realtek/rtw89/core.c
+++ b/drivers/net/wireless/realtek/rtw89/core.c
@@ -1095,6 +1095,19 @@ static void rtw89_core_hw_to_sband_rate(struct ieee80211_rx_status *rx_status)
 	rx_status->rate_idx -= 4;
 }
 
+static void rtw89_core_rx_to_mac80211(struct rtw89_dev *rtwdev,
+				      struct rtw89_rx_phy_ppdu *phy_ppdu,
+				      struct rtw89_rx_desc_info *desc_info,
+				      struct sk_buff *skb_ppdu,
+				      struct ieee80211_rx_status *rx_status)
+{
+	rtw89_core_hw_to_sband_rate(rx_status);
+	rtw89_core_rx_stats(rtwdev, phy_ppdu, desc_info, skb_ppdu);
+	rtw89_core_correct_vht_rate(rx_status);
+	ieee80211_rx_napi(rtwdev->hw, NULL, skb_ppdu, &rtwdev->napi);
+	rtwdev->napi_budget_countdown--;
+}
+
 static void rtw89_core_rx_pending_skb(struct rtw89_dev *rtwdev,
 				      struct rtw89_rx_phy_ppdu *phy_ppdu,
 				      struct rtw89_rx_desc_info *desc_info,
@@ -1114,11 +1127,7 @@ static void rtw89_core_rx_pending_skb(struct rtw89_dev *rtwdev,
 		if (rtw89_core_rx_ppdu_match(rtwdev, desc_info, rx_status))
 			rtw89_chip_query_ppdu(rtwdev, phy_ppdu, rx_status);
 		rtw89_correct_cck_chan(rtwdev, rx_status);
-		rtw89_core_hw_to_sband_rate(rx_status);
-		rtw89_core_rx_stats(rtwdev, phy_ppdu, desc_info, skb_ppdu);
-		rtw89_core_correct_vht_rate(rx_status);
-		ieee80211_rx_napi(rtwdev->hw, NULL, skb_ppdu, &rtwdev->napi);
-		rtwdev->napi_budget_countdown--;
+		rtw89_core_rx_to_mac80211(rtwdev, phy_ppdu, desc_info, skb_ppdu, rx_status);
 	}
 }
 
@@ -1343,11 +1352,7 @@ static void rtw89_core_flush_ppdu_rx_queue(struct rtw89_dev *rtwdev,
 	skb_queue_walk_safe(&ppdu_sts->rx_queue[band], skb_ppdu, tmp) {
 		skb_unlink(skb_ppdu, &ppdu_sts->rx_queue[band]);
 		rx_status = IEEE80211_SKB_RXCB(skb_ppdu);
-		rtw89_core_hw_to_sband_rate(rx_status);
-		rtw89_core_rx_stats(rtwdev, NULL, desc_info, skb_ppdu);
-		rtw89_core_correct_vht_rate(rx_status);
-		ieee80211_rx_napi(rtwdev->hw, NULL, skb_ppdu, &rtwdev->napi);
-		rtwdev->napi_budget_countdown--;
+		rtw89_core_rx_to_mac80211(rtwdev, NULL, desc_info, skb_ppdu, rx_status);
 	}
 }
 
@@ -1374,15 +1379,10 @@ void rtw89_core_rx(struct rtw89_dev *rtwdev,
 	memset(rx_status, 0, sizeof(*rx_status));
 	rtw89_core_update_rx_status(rtwdev, desc_info, rx_status);
 	if (desc_info->long_rxdesc &&
-	    BIT(desc_info->frame_type) & PPDU_FILTER_BITMAP) {
+	    BIT(desc_info->frame_type) & PPDU_FILTER_BITMAP)
 		skb_queue_tail(&ppdu_sts->rx_queue[band], skb);
-	} else {
-		rtw89_core_hw_to_sband_rate(rx_status);
-		rtw89_core_rx_stats(rtwdev, NULL, desc_info, skb);
-		rtw89_core_correct_vht_rate(rx_status);
-		ieee80211_rx_napi(rtwdev->hw, NULL, skb, &rtwdev->napi);
-		rtwdev->napi_budget_countdown--;
-	}
+	else
+		rtw89_core_rx_to_mac80211(rtwdev, NULL, desc_info, skb, rx_status);
 }
 EXPORT_SYMBOL(rtw89_core_rx);
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] rtw89: limit RX status rate of VHT to MCS 9
  2021-12-30  1:16 [PATCH 1/2] rtw89: limit RX status rate of VHT to MCS 9 Ping-Ke Shih
  2021-12-30  1:16 ` [PATCH 2/2] rtw89: encapsulate RX handlers to single function Ping-Ke Shih
@ 2021-12-30 21:23 ` Johannes Berg
  2022-01-03  1:43   ` Pkshih
  1 sibling, 1 reply; 4+ messages in thread
From: Johannes Berg @ 2021-12-30 21:23 UTC (permalink / raw)
  To: Ping-Ke Shih, kvalo; +Cc: linux-wireless, rgoldwyn

On Thu, 2021-12-30 at 09:16 +0800, Ping-Ke Shih wrote:
> 8852AE can receive packets with VHT MCS10/11 that is out of specification,
> so mac80211 warns and drops the packets, and it leads low TCP throughput.
> 
>   Rate marked as a VHT rate but data is invalid: MCS: 10, NSS: 2
> 

We already support these in cfg80211 for brcmfmac, arguably we could
just add support in mac80211 instead?

johannes

^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: [PATCH 1/2] rtw89: limit RX status rate of VHT to MCS 9
  2021-12-30 21:23 ` [PATCH 1/2] rtw89: limit RX status rate of VHT to MCS 9 Johannes Berg
@ 2022-01-03  1:43   ` Pkshih
  0 siblings, 0 replies; 4+ messages in thread
From: Pkshih @ 2022-01-03  1:43 UTC (permalink / raw)
  To: Johannes Berg, kvalo; +Cc: linux-wireless, rgoldwyn


> -----Original Message-----
> From: Johannes Berg <johannes@sipsolutions.net>
> Sent: Friday, December 31, 2021 5:24 AM
> To: Pkshih <pkshih@realtek.com>; kvalo@kernel.org
> Cc: linux-wireless@vger.kernel.org; rgoldwyn@suse.com
> Subject: Re: [PATCH 1/2] rtw89: limit RX status rate of VHT to MCS 9
> 
> On Thu, 2021-12-30 at 09:16 +0800, Ping-Ke Shih wrote:
> > 8852AE can receive packets with VHT MCS10/11 that is out of specification,
> > so mac80211 warns and drops the packets, and it leads low TCP throughput.
> >
> >   Rate marked as a VHT rate but data is invalid: MCS: 10, NSS: 2
> >
> 
> We already support these in cfg80211 for brcmfmac, arguably we could
> just add support in mac80211 instead?
> 

I have sent out a patchset [1] including driver patches. 

[1] https://lore.kernel.org/linux-wireless/20220103013623.17052-1-pkshih@realtek.com/T/#m9da1574cc94a43ac20ae9c3bbda331aa09892249

--
Ping-Ke


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-01-03  1:43 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-30  1:16 [PATCH 1/2] rtw89: limit RX status rate of VHT to MCS 9 Ping-Ke Shih
2021-12-30  1:16 ` [PATCH 2/2] rtw89: encapsulate RX handlers to single function Ping-Ke Shih
2021-12-30 21:23 ` [PATCH 1/2] rtw89: limit RX status rate of VHT to MCS 9 Johannes Berg
2022-01-03  1:43   ` Pkshih

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.