]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
wifi: rtw89: chan: allow callers to check if a link has no managed chanctx
authorZong-Zhe Yang <kevin_yang@realtek.com>
Mon, 15 Sep 2025 06:52:03 +0000 (14:52 +0800)
committerPing-Ke Shih <pkshih@realtek.com>
Thu, 18 Sep 2025 01:10:12 +0000 (09:10 +0800)
Originally, to directly align with the chanctx design, getter of managed
chanctx returned a default channel when a link doesn't own a chanctx yet.
Then, callers could simply use the return without trivial NULL checking.

But in MLD HW settings of next chip, there will be a special case that a
caller needs to check if a link has owned chanctx or not to determine
CCK hardware circuit working on HW-x. So, add a func *_or_null for this
first.

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

index f7d1c5d3b92e5a66da6fd38080e64a19e665d092..86f1b39a967fea81060d7387dc190e5659d5e1f2 100644 (file)
@@ -281,6 +281,7 @@ void rtw89_entity_init(struct rtw89_dev *rtwdev)
 {
        struct rtw89_hal *hal = &rtwdev->hal;
        struct rtw89_entity_mgnt *mgnt = &hal->entity_mgnt;
+       int i, j;
 
        hal->entity_pause = false;
        bitmap_zero(hal->entity_map, NUM_OF_RTW89_CHANCTX);
@@ -289,6 +290,11 @@ void rtw89_entity_init(struct rtw89_dev *rtwdev)
 
        INIT_LIST_HEAD(&mgnt->active_list);
 
+       for (i = 0; i < RTW89_MAX_INTERFACE_NUM; i++) {
+               for (j = 0; j < __RTW89_MLD_MAX_LINK_NUM; j++)
+                       mgnt->chanctx_tbl[i][j] = RTW89_CHANCTX_IDLE;
+       }
+
        rtw89_config_default_chandef(rtwdev);
 }
 
@@ -353,7 +359,7 @@ static void rtw89_normalize_link_chanctx(struct rtw89_dev *rtwdev,
 
 const struct rtw89_chan *__rtw89_mgnt_chan_get(struct rtw89_dev *rtwdev,
                                               const char *caller_message,
-                                              u8 link_index)
+                                              u8 link_index, bool nullchk)
 {
        struct rtw89_hal *hal = &rtwdev->hal;
        struct rtw89_entity_mgnt *mgnt = &hal->entity_mgnt;
@@ -400,6 +406,9 @@ const struct rtw89_chan *__rtw89_mgnt_chan_get(struct rtw89_dev *rtwdev,
        return rtw89_chan_get(rtwdev, chanctx_idx);
 
 dflt:
+       if (unlikely(nullchk))
+               return NULL;
+
        rtw89_debug(rtwdev, RTW89_DBG_CHAN,
                    "%s (%s): prefetch NULL on link index %u\n",
                    __func__, caller_message ?: "", link_index);
index b1175419f92b38eb08f2a8b64aa928c0b8e4870a..5b22764d5329574bbe2eb0af676532d09c66044f 100644 (file)
@@ -180,10 +180,16 @@ void rtw89_chanctx_proceed(struct rtw89_dev *rtwdev,
 
 const struct rtw89_chan *__rtw89_mgnt_chan_get(struct rtw89_dev *rtwdev,
                                               const char *caller_message,
-                                              u8 link_index);
+                                              u8 link_index, bool nullchk);
 
 #define rtw89_mgnt_chan_get(rtwdev, link_index) \
-       __rtw89_mgnt_chan_get(rtwdev, __func__, link_index)
+       __rtw89_mgnt_chan_get(rtwdev, __func__, link_index, false)
+
+static inline const struct rtw89_chan *
+rtw89_mgnt_chan_get_or_null(struct rtw89_dev *rtwdev, u8 link_index)
+{
+       return __rtw89_mgnt_chan_get(rtwdev, NULL, link_index, true);
+}
 
 struct rtw89_mcc_links_info {
        struct rtw89_vif_link *links[NUM_OF_RTW89_MCC_ROLES];