]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
wifi: rtw89: roc: dynamically handle link id and link instance index
authorZong-Zhe Yang <kevin_yang@realtek.com>
Mon, 28 Apr 2025 11:24:55 +0000 (19:24 +0800)
committerPing-Ke Shih <pkshih@realtek.com>
Mon, 5 May 2025 01:50:00 +0000 (09:50 +0800)
Originally, a macro, RTW89_ROC_BY_LINK_INDEX, is used to decide the link
which deals with the ROC process. Before enabling MLO support, it's fine
to hard-code RTW89_ROC_BY_LINK_INDEX as 0 since the link instance-0 (on
HW-0) is always active. But, for the impending enablement of MLO support,
tweak the leaf functions to dynamically handle ROC link instance index.

Besides, in the follow-up, ROC caller will get a designated link and will
then drop RTW89_ROC_BY_LINK_INDEX.

Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20250428112456.13165-10-pkshih@realtek.com
drivers/net/wireless/realtek/rtw89/chan.c
drivers/net/wireless/realtek/rtw89/chan.h
drivers/net/wireless/realtek/rtw89/core.c
drivers/net/wireless/realtek/rtw89/core.h

index 355e582ecd19acb941cb7eaeb8de9f5ae34bd136..6d17456046d52376c3eeb67dda3eb85069b02c0c 100644 (file)
@@ -189,9 +189,10 @@ void rtw89_config_entity_chandef(struct rtw89_dev *rtwdev,
 }
 
 void rtw89_config_roc_chandef(struct rtw89_dev *rtwdev,
-                             enum rtw89_chanctx_idx idx,
+                             struct rtw89_vif_link *rtwvif_link,
                              const struct cfg80211_chan_def *chandef)
 {
+       enum rtw89_chanctx_idx idx = rtwvif_link->chanctx_idx;
        struct rtw89_hal *hal = &rtwdev->hal;
        enum rtw89_chanctx_idx cur;
 
@@ -205,6 +206,7 @@ void rtw89_config_roc_chandef(struct rtw89_dev *rtwdev,
                }
 
                hal->roc_chandef = *chandef;
+               hal->roc_link_index = rtw89_vif_link_inst_get_index(rtwvif_link);
        } else {
                cur = atomic_cmpxchg(&hal->roc_chanctx_idx, idx,
                                     RTW89_CHANCTX_IDLE);
@@ -339,11 +341,10 @@ const struct rtw89_chan *__rtw89_mgnt_chan_get(struct rtw89_dev *rtwdev,
 
        roc_idx = atomic_read(&hal->roc_chanctx_idx);
        if (roc_idx != RTW89_CHANCTX_IDLE) {
-               /* ROC is ongoing (given ROC runs on RTW89_ROC_BY_LINK_INDEX).
-                * If @link_index is the same as RTW89_ROC_BY_LINK_INDEX, get
-                * the ongoing ROC chanctx.
+               /* ROC is ongoing (given ROC runs on @hal->roc_link_index).
+                * If @link_index is the same, get the ongoing ROC chanctx.
                 */
-               if (link_index == RTW89_ROC_BY_LINK_INDEX)
+               if (link_index == hal->roc_link_index)
                        chanctx_idx = roc_idx;
        }
 
index 1bcb87a8f9ee073e9a093211b22ab50b3640d552..b42e044d7927224e9e40f0204f943cf33d382646 100644 (file)
@@ -103,7 +103,7 @@ void rtw89_config_entity_chandef(struct rtw89_dev *rtwdev,
                                 enum rtw89_chanctx_idx idx,
                                 const struct cfg80211_chan_def *chandef);
 void rtw89_config_roc_chandef(struct rtw89_dev *rtwdev,
-                             enum rtw89_chanctx_idx idx,
+                             struct rtw89_vif_link *rtwvif_link,
                              const struct cfg80211_chan_def *chandef);
 void rtw89_entity_init(struct rtw89_dev *rtwdev);
 enum rtw89_entity_mode rtw89_entity_recalc(struct rtw89_dev *rtwdev);
index c718dd83dc1e69e07bd69fb80a35181a0772fac4..268107b1e0393bec378cad31fff275a477b12e33 100644 (file)
@@ -3379,6 +3379,8 @@ void rtw89_roc_start(struct rtw89_dev *rtwdev, struct rtw89_vif *rtwvif)
                return;
        }
 
+       roc->link_id = rtwvif_link->link_id;
+
        rtw89_chanctx_pause(rtwdev, RTW89_CHANCTX_PAUSE_REASON_ROC);
 
        ret = rtw89_core_send_nullfunc(rtwdev, rtwvif_link, true, true);
@@ -3399,7 +3401,7 @@ void rtw89_roc_start(struct rtw89_dev *rtwdev, struct rtw89_vif *rtwvif)
        }
 
        cfg80211_chandef_create(&roc_chan, &roc->chan, NL80211_CHAN_NO_HT);
-       rtw89_config_roc_chandef(rtwdev, rtwvif_link->chanctx_idx, &roc_chan);
+       rtw89_config_roc_chandef(rtwdev, rtwvif_link, &roc_chan);
        rtw89_set_channel(rtwdev);
 
        reg = rtw89_mac_reg_by_idx(rtwdev, mac->rx_fltr, rtwvif_link->mac_idx);
@@ -3428,10 +3430,10 @@ void rtw89_roc_end(struct rtw89_dev *rtwdev, struct rtw89_vif *rtwvif)
        rtw89_leave_ips_by_hwflags(rtwdev);
        rtw89_leave_lps(rtwdev);
 
-       rtwvif_link = rtw89_vif_get_link_inst(rtwvif, RTW89_ROC_BY_LINK_INDEX);
+       rtwvif_link = rtwvif->links[roc->link_id];
        if (unlikely(!rtwvif_link)) {
-               rtw89_err(rtwdev, "roc end: find no link on HW-%u\n",
-                         RTW89_ROC_BY_LINK_INDEX);
+               rtw89_err(rtwdev, "roc end: find no link (link id %u)\n",
+                         roc->link_id);
                return;
        }
 
@@ -3439,7 +3441,7 @@ void rtw89_roc_end(struct rtw89_dev *rtwdev, struct rtw89_vif *rtwvif)
        rtw89_write32_mask(rtwdev, reg, B_AX_RX_FLTR_CFG_MASK, rtwdev->hal.rx_fltr);
 
        roc->state = RTW89_ROC_IDLE;
-       rtw89_config_roc_chandef(rtwdev, rtwvif_link->chanctx_idx, NULL);
+       rtw89_config_roc_chandef(rtwdev, rtwvif_link, NULL);
        rtw89_chanctx_proceed(rtwdev, NULL);
        ret = rtw89_core_send_nullfunc(rtwdev, rtwvif_link, true, false);
        if (ret)
index ce5521c413a1dd660e07299407da48ba85bea12c..5e4b096f42fc1c8c5f237c93dd37c05e6634ee73 100644 (file)
@@ -3454,6 +3454,7 @@ struct rtw89_roc {
        enum ieee80211_roc_type type;
        enum rtw89_roc_state state;
        int duration;
+       unsigned int link_id;
 };
 
 #define RTW89_P2P_MAX_NOA_NUM 2
@@ -4851,6 +4852,7 @@ struct rtw89_hal {
        bool no_mcs_12_13;
 
        atomic_t roc_chanctx_idx;
+       u8 roc_link_index;
 
        DECLARE_BITMAP(changes, NUM_OF_RTW89_CHANCTX_CHANGES);
        DECLARE_BITMAP(entity_map, NUM_OF_RTW89_CHANCTX);