]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
wifi: rtw89: do RF calibration once setting channel when running pure monitor mode
authorPing-Ke Shih <pkshih@realtek.com>
Tue, 11 Nov 2025 02:24:51 +0000 (10:24 +0800)
committerPing-Ke Shih <pkshih@realtek.com>
Thu, 13 Nov 2025 01:38:29 +0000 (09:38 +0800)
To be able to capture and inject packets in monitor mode, do RF calibration
once setting certain channel. Since calibration costs time, do not change
behavior of normal usage, which do calibration only when starting as AP
or going to connect AP.

Since driver declares IEEE80211_HW_WANT_MONITOR_VIF, the pure monitor vif
must be only one when adding interface with type NL80211_IFTYPE_MONITOR.
Otherwise, monitor vif must be NULL.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20251111022452.28093-8-pkshih@realtek.com
drivers/net/wireless/realtek/rtw89/core.c
drivers/net/wireless/realtek/rtw89/core.h
drivers/net/wireless/realtek/rtw89/mac80211.c

index a5c451eed5a7c3a6fddba799bf110a6f78480d96..a15a911484bbba19b64faef652fa8832294b3c30 100644 (file)
@@ -470,6 +470,22 @@ void rtw89_core_set_chip_txpwr(struct rtw89_dev *rtwdev)
        __rtw89_core_set_chip_txpwr(rtwdev, chan, RTW89_PHY_1);
 }
 
+static void rtw89_chip_rfk_channel_for_pure_mon_vif(struct rtw89_dev *rtwdev,
+                                                   enum rtw89_phy_idx phy_idx)
+{
+       struct rtw89_vif *rtwvif = rtwdev->pure_monitor_mode_vif;
+       struct rtw89_vif_link *rtwvif_link;
+
+       if (!rtwvif)
+               return;
+
+       rtwvif_link = rtw89_vif_get_link_inst(rtwvif, phy_idx);
+       if (!rtwvif_link)
+               return;
+
+       rtw89_chip_rfk_channel(rtwdev, rtwvif_link);
+}
+
 static void __rtw89_set_channel(struct rtw89_dev *rtwdev,
                                const struct rtw89_chan *chan,
                                enum rtw89_mac_idx mac_idx,
@@ -498,6 +514,8 @@ static void __rtw89_set_channel(struct rtw89_dev *rtwdev,
        }
 
        rtw89_set_entity_state(rtwdev, phy_idx, true);
+
+       rtw89_chip_rfk_channel_for_pure_mon_vif(rtwdev, phy_idx);
 }
 
 int rtw89_set_channel(struct rtw89_dev *rtwdev)
index 4da73153513a41b6e7b4e70afd4ef8327ec1aa5b..f63857b389d76285c660fbd32bb5954058cb0ed6 100644 (file)
@@ -6125,6 +6125,7 @@ struct rtw89_dev {
        int napi_budget_countdown;
 
        struct rtw89_debugfs *debugfs;
+       struct rtw89_vif *pure_monitor_mode_vif;
 
        /* HCI related data, keep last */
        u8 priv[] __aligned(sizeof(void *));
index a19304ff83064dcefbe2bbd613628689f75d39c0..14c8864bd2013591e2213495c57308f71d583e3f 100644 (file)
@@ -220,6 +220,8 @@ static int rtw89_ops_add_interface(struct ieee80211_hw *hw,
        if (ret)
                goto unset_link;
 
+       rtwdev->pure_monitor_mode_vif = vif->type == NL80211_IFTYPE_MONITOR ?
+                                       rtwvif : NULL;
        rtw89_recalc_lps(rtwdev);
        return 0;
 
@@ -267,6 +269,8 @@ bottom:
        rtw89_core_release_bit_map(rtwdev->hw_port, port);
        rtw89_release_mac_id(rtwdev, macid);
 
+       rtwdev->pure_monitor_mode_vif = NULL;
+
        rtw89_recalc_lps(rtwdev);
        rtw89_enter_ips_by_hwflags(rtwdev);
 }