]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
wifi: rtw89: mcc: correct frequency when MCC
authorChih-Kang Chang <gary.chang@realtek.com>
Tue, 10 Jun 2025 13:00:25 +0000 (21:00 +0800)
committerPing-Ke Shih <pkshih@realtek.com>
Mon, 16 Jun 2025 05:29:18 +0000 (13:29 +0800)
The frequency get from PPDU status set as center channel during MCC,
but we need to report to mac80211 as primary channel. Therefore, we
use the chanctx information in software to instead it.

Signed-off-by: Chih-Kang Chang <gary.chang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20250610130034.14692-4-pkshih@realtek.com
drivers/net/wireless/realtek/rtw89/core.c

index 0a4c420000b853cbd2cba76be2817b08623e1290..4252717b158422e90eb24b2c03c06f0b6c3454cb 100644 (file)
@@ -2478,6 +2478,41 @@ static void rtw89_core_update_rx_freq_from_ie(struct rtw89_dev *rtwdev,
        rx_status->freq = ieee80211_channel_to_frequency(chan, rx_status->band);
 }
 
+static void rtw89_core_correct_mcc_chan(struct rtw89_dev *rtwdev,
+                                       struct rtw89_rx_desc_info *desc_info,
+                                       struct ieee80211_rx_status *rx_status,
+                                       struct rtw89_rx_phy_ppdu *phy_ppdu)
+{
+       enum rtw89_chip_gen chip_gen = rtwdev->chip->chip_gen;
+       struct rtw89_vif_link *rtwvif_link;
+       struct rtw89_sta_link *rtwsta_link;
+       const struct rtw89_chan *chan;
+       u8 mac_id = desc_info->mac_id;
+       enum rtw89_entity_mode mode;
+       enum nl80211_band band;
+
+       mode = rtw89_get_entity_mode(rtwdev);
+       if (likely(mode != RTW89_ENTITY_MODE_MCC))
+               return;
+
+       if (chip_gen == RTW89_CHIP_BE && phy_ppdu)
+               mac_id = phy_ppdu->mac_id;
+
+       rcu_read_lock();
+
+       rtwsta_link = rtw89_assoc_link_rcu_dereference(rtwdev, mac_id);
+       if (!rtwsta_link)
+               goto out;
+
+       rtwvif_link = rtwsta_link->rtwvif_link;
+       chan = rtw89_chan_get(rtwdev, rtwvif_link->chanctx_idx);
+       band = rtw89_hw_to_nl80211_band(chan->band_type);
+       rx_status->freq = ieee80211_channel_to_frequency(chan->primary_channel, band);
+
+out:
+       rcu_read_unlock();
+}
+
 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,
@@ -2496,6 +2531,7 @@ static void rtw89_core_rx_to_mac80211(struct rtw89_dev *rtwdev,
        rtw89_core_update_radiotap(rtwdev, skb_ppdu, rx_status);
        rtw89_core_validate_rx_signal(rx_status);
        rtw89_core_update_rx_freq_from_ie(rtwdev, skb_ppdu, rx_status);
+       rtw89_core_correct_mcc_chan(rtwdev, desc_info, rx_status, phy_ppdu);
 
        /* In low power mode, it does RX in thread context. */
        local_bh_disable();