Skip to contentSkip to conversation

wifi: rtw88: 8822c: Parse channel from IE to correct invalid hardware reports

PATCH In review Ping-Ke Shih 1 participant 2 messages Jul 24, 2024 – Aug 2, 2024 Realtek wireless driver (rtw88)

lore
Share & tools
lore

Ping-Ke Shih

author maintainer
#0 lore raw

PATCH 1/1 wifi: rtw88: 8822c: Parse channel from IE to correct invalid hardware reports

From: Po-Hao Huang <[email protected]>

For CCK packets we could get incorrect reports from hardware. And this causes wrong frequencies being reported. Parse the channel information from IE if provided by AP to fix this.

---
 drivers/net/wireless/realtek/rtw88/main.h     |  1 +
 drivers/net/wireless/realtek/rtw88/pci.c      |  1 +
 drivers/net/wireless/realtek/rtw88/rtw8822c.c |  7 ++--
 drivers/net/wireless/realtek/rtw88/rx.c       | 41 +++++++++++++++++++
 drivers/net/wireless/realtek/rtw88/rx.h       | 13 ++++++
 drivers/net/wireless/realtek/rtw88/sdio.c     |  1 +
 drivers/net/wireless/realtek/rtw88/usb.c      |  2 +
 7 files changed, 63 insertions(+), 3 deletions(-)
drivers/net/wireless/realtek/rtw88/main.h +1 -0
index 9d21637cf5d5..37912dded128 100644
@@ -622,6 +622,7 @@ struct rtw_rx_pkt_stat {
 	bool crc_err;
 	bool decrypted;
 	bool is_c2h;
+	bool channel_invalid;
 
 	s32 signal_power;
 	u16 pkt_len;
drivers/net/wireless/realtek/rtw88/pci.c +1 -0
index a5b9d6c7be37..5d0580da13fb 100644
@@ -1088,6 +1088,7 @@ static u32 rtw_pci_rx_napi(struct rtw_dev *rtwdev, struct rtw_pci *rtwpci,
 			/* remove rx_desc */
 			skb_pull(new, pkt_offset);
 
+			rtw_update_rx_freq_for_invalid(rtwdev, new, &rx_status, &pkt_stat);
 			rtw_rx_stats(rtwdev, pkt_stat.vif, new);
 			memcpy(new->cb, &rx_status, sizeof(rx_status));
 			ieee80211_rx_napi(rtwdev->hw, NULL, new, napi);
drivers/net/wireless/realtek/rtw88/rtw8822c.c +4 -3
index bc807b13e9ce..96a233079e02 100644
@@ -2576,9 +2576,10 @@ static void query_phy_status_page0(struct rtw_dev *rtwdev, u8 *phy_status,
 	rx_power[RF_PATH_B] -= 110;
 
 	channel = GET_PHY_STAT_P0_CHANNEL(phy_status);
-	if (channel == 0)
-		channel = rtwdev->hal.current_channel;
-	rtw_set_rx_freq_band(pkt_stat, channel);
+	if (channel != 0)
+		rtw_set_rx_freq_band(pkt_stat, channel);
+	else
+		pkt_stat->channel_invalid = true;
 
 	pkt_stat->rx_power[RF_PATH_A] = rx_power[RF_PATH_A];
 	pkt_stat->rx_power[RF_PATH_B] = rx_power[RF_PATH_B];
drivers/net/wireless/realtek/rtw88/rx.c +41 -0

47 lines not on this page · raw message

drivers/net/wireless/realtek/rtw88/rx.h +13 -0
index d3668c4efc24..2f1539068f1a 100644
@@ -50,5 +50,18 @@ void rtw_rx_fill_rx_status(struct rtw_dev *rtwdev,
 			   struct ieee80211_hdr *hdr,
 			   struct ieee80211_rx_status *rx_status,
 			   u8 *phy_status);
+void rtw_update_rx_freq_from_ie(struct rtw_dev *rtwdev, struct sk_buff *skb,
+				struct ieee80211_rx_status *rx_status,
+				struct rtw_rx_pkt_stat *pkt_stat);
+
+static inline
+void rtw_update_rx_freq_for_invalid(struct rtw_dev *rtwdev, struct sk_buff *skb,
+				    struct ieee80211_rx_status *rx_status,
+				    struct rtw_rx_pkt_stat *pkt_stat)
+{
+	if (pkt_stat->channel_invalid)
+		rtw_update_rx_freq_from_ie(rtwdev, skb, rx_status, pkt_stat);
+}
+
 
 #endif
drivers/net/wireless/realtek/rtw88/sdio.c +1 -0
index 0cae5746f540..763aa8212a4b 100644
@@ -948,6 +948,7 @@ static void rtw_sdio_rx_skb(struct rtw_dev *rtwdev, struct sk_buff *skb,
 	skb_put(skb, pkt_stat->pkt_len);
 	skb_reserve(skb, pkt_offset);
 
+	rtw_update_rx_freq_for_invalid(rtwdev, skb, rx_status, pkt_stat);
 	rtw_rx_stats(rtwdev, pkt_stat->vif, skb);
 
 	ieee80211_rx_irqsafe(rtwdev->hw, skb);
drivers/net/wireless/realtek/rtw88/usb.c +2 -0
index 251a5726f3ee..9145c11a063e 100644
@@ -579,6 +579,8 @@ static void rtw_usb_rx_handler(struct work_struct *work)
 
 		skb_put(skb, pkt_stat.pkt_len);
 		skb_reserve(skb, pkt_offset);
+
+		rtw_update_rx_freq_for_invalid(rtwdev, skb, &rx_status, &pkt_stat);
 		memcpy(skb->cb, &rx_status, sizeof(rx_status));
 		ieee80211_rx_irqsafe(rtwdev->hw, skb);
 	}
Signature · 1 line
2.25.1
author maintainer
#1 lore raw
Quoted 8 lines · Ping-Ke Shih

From: Po-Hao Huang <[email protected]>

For CCK packets we could get incorrect reports from hardware. And this causes wrong frequencies being reported. Parse the channel information from IE if provided by AP to fix this.

1 patch(es) applied to rtw-next branch of rtw.git, thanks.

53ed4b25a79a wifi: rtw88: 8822c: Parse channel from IE to correct invalid hardware reports

---
https://github.com/pkshih/rtw.git