From: Ping-Ke Shih <pkshih@realtek.com>
To: <linux-wireless@vger.kernel.org>
Cc: <owen.hsiao@realtek.com>, <echuang@realtek.com>,
<henchy.chen@realtek.com>, <phhuang@realtek.com>,
<kevin_yang@realtek.com>
Subject: [PATCH rtw-next 11/14] wifi: rtw89: chan: introduce helper and refine active list iteration
Date: Wed, 26 Aug 2026 14:40:58 +0800 [thread overview]
Message-ID: <20260826064101.58892-12-pkshih@realtek.com> (raw)
In-Reply-To: <20260826064101.58892-1-pkshih@realtek.com>
From: Zong-Zhe Yang <kevin_yang@realtek.com>
Add a helper macro to iterate active vifs. Some chanctx handling iterated
all vifs and then checked if the link is active. In logical, it means only
the active vifs need to be counted there. So, also refine them to iterate
only active list.
Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
---
drivers/net/wireless/realtek/rtw89/chan.c | 14 ++++++--------
drivers/net/wireless/realtek/rtw89/debug.c | 3 +--
drivers/net/wireless/realtek/rtw89/fw.c | 6 ++----
drivers/net/wireless/realtek/rtw89/util.h | 4 ++++
4 files changed, 13 insertions(+), 14 deletions(-)
diff --git a/drivers/net/wireless/realtek/rtw89/chan.c b/drivers/net/wireless/realtek/rtw89/chan.c
index 99b52ca05fe2..7205fca8ac1a 100644
--- a/drivers/net/wireless/realtek/rtw89/chan.c
+++ b/drivers/net/wireless/realtek/rtw89/chan.c
@@ -185,7 +185,7 @@ static void rtw89_chan_update_punctured(struct rtw89_dev *rtwdev,
struct rtw89_vif *rtwvif;
unsigned int link_id;
- rtw89_for_each_rtwvif(rtwdev, rtwvif) {
+ rtw89_for_each_active_rtwvif(rtwdev, rtwvif) {
rtw89_vif_for_each_link(rtwvif, rtwvif_link, link_id) {
if (!rtwvif_link->chanctx_assigned ||
rtwvif_link->chanctx_idx != idx)
@@ -358,10 +358,8 @@ static void rtw89_entity_calculate_weight(struct rtw89_dev *rtwdev,
w->active_chanctxs++;
}
- rtw89_for_each_rtwvif(rtwdev, rtwvif) {
- if (rtw89_vif_is_active_role(rtwvif))
- w->active_roles++;
- }
+ rtw89_for_each_active_rtwvif(rtwdev, rtwvif)
+ w->active_roles++;
}
static void rtw89_normalize_link_chanctx(struct rtw89_dev *rtwdev,
@@ -553,7 +551,7 @@ static void rtw89_entity_recalc_mgnt_roles(struct rtw89_dev *rtwdev)
* which uses RTW89_CHANCTX_0 to put at position 0 and its designated
* link take RTW89_CHANCTX_0. (normalizing)
*/
- list_for_each_entry(role, &mgnt->active_list, mgnt_entry) {
+ rtw89_for_each_active_rtwvif(rtwdev, role) {
for (i = 0; i < role->links_inst_valid_num; i++) {
link = rtw89_vif_get_link_inst(role, i);
if (!link || !link->chanctx_assigned)
@@ -570,7 +568,7 @@ static void rtw89_entity_recalc_mgnt_roles(struct rtw89_dev *rtwdev)
}
fill:
- list_for_each_entry(role, &mgnt->active_list, mgnt_entry) {
+ rtw89_for_each_active_rtwvif(rtwdev, role) {
if (unlikely(pos >= RTW89_MAX_INTERFACE_NUM)) {
rtw89_warn(rtwdev,
"%s: active roles are over max iface num\n",
@@ -3335,7 +3333,7 @@ static void rtw89_swap_chanctx(struct rtw89_dev *rtwdev,
swap(hal->chanctx[idx1], hal->chanctx[idx2]);
- rtw89_for_each_rtwvif(rtwdev, rtwvif)
+ rtw89_for_each_active_rtwvif(rtwdev, rtwvif)
__rtw89_swap_chanctx(rtwvif, idx1, idx2);
cur = atomic_read(&hal->roc_chanctx_idx);
diff --git a/drivers/net/wireless/realtek/rtw89/debug.c b/drivers/net/wireless/realtek/rtw89/debug.c
index 7e640c7166e4..2417381bca1c 100644
--- a/drivers/net/wireless/realtek/rtw89/debug.c
+++ b/drivers/net/wireless/realtek/rtw89/debug.c
@@ -5463,12 +5463,11 @@ rtw89_debug_priv_diag_rf_get(struct rtw89_dev *rtwdev,
static void rtw89_dbg_diag_rf_set_rfk(struct rtw89_dev *rtwdev)
{
- struct rtw89_entity_mgnt *mgnt = &rtwdev->hal.entity_mgnt;
struct rtw89_vif_link *rtwvif_link;
struct rtw89_vif *rtwvif;
unsigned int link_id;
- list_for_each_entry(rtwvif, &mgnt->active_list, mgnt_entry)
+ rtw89_for_each_active_rtwvif(rtwdev, rtwvif)
rtw89_vif_for_each_link(rtwvif, rtwvif_link, link_id)
rtw89_chip_rfk_channel(rtwdev, rtwvif_link);
}
diff --git a/drivers/net/wireless/realtek/rtw89/fw.c b/drivers/net/wireless/realtek/rtw89/fw.c
index 18f4781d4e90..fd721c971ba3 100644
--- a/drivers/net/wireless/realtek/rtw89/fw.c
+++ b/drivers/net/wireless/realtek/rtw89/fw.c
@@ -10311,7 +10311,6 @@ static void rtw89_hw_scan_update_link_beacon_noa(struct rtw89_dev *rtwdev,
static void rtw89_hw_scan_update_beacon_noa(struct rtw89_dev *rtwdev, bool scan)
{
- const struct rtw89_entity_mgnt *mgnt = &rtwdev->hal.entity_mgnt;
const struct rtw89_hw_scan_info *scan_info = &rtwdev->scan_info;
const struct rtw89_chip_info *chip = rtwdev->chip;
struct rtw89_mac_chinfo_ax *chinfo_ax;
@@ -10351,7 +10350,7 @@ static void rtw89_hw_scan_update_beacon_noa(struct rtw89_dev *rtwdev, bool scan)
}
update:
- list_for_each_entry(rtwvif, &mgnt->active_list, mgnt_entry) {
+ rtw89_for_each_active_rtwvif(rtwdev, rtwvif) {
unsigned int link_id;
vif = rtwvif_to_vif(rtwvif);
@@ -10368,7 +10367,6 @@ static void rtw89_hw_scan_set_extra_op_info(struct rtw89_dev *rtwdev,
struct rtw89_vif *scan_rtwvif,
const struct rtw89_chan *scan_op)
{
- struct rtw89_entity_mgnt *mgnt = &rtwdev->hal.entity_mgnt;
struct rtw89_hw_scan_info *scan_info = &rtwdev->scan_info;
struct rtw89_hw_scan_extra_op *ext = &scan_info->extra_op;
struct rtw89_vif *tmp;
@@ -10377,7 +10375,7 @@ static void rtw89_hw_scan_set_extra_op_info(struct rtw89_dev *rtwdev,
if (!RTW89_CHK_FW_FEATURE(SCAN_OFFLOAD_EXTRA_OP, &rtwdev->fw))
return;
- list_for_each_entry(tmp, &mgnt->active_list, mgnt_entry) {
+ rtw89_for_each_active_rtwvif(rtwdev, tmp) {
const struct rtw89_chan *tmp_chan;
struct rtw89_vif_link *tmp_link;
diff --git a/drivers/net/wireless/realtek/rtw89/util.h b/drivers/net/wireless/realtek/rtw89/util.h
index c16e7a7f8bc9..aa87a520bdc3 100644
--- a/drivers/net/wireless/realtek/rtw89/util.h
+++ b/drivers/net/wireless/realtek/rtw89/util.h
@@ -21,6 +21,10 @@
#define rtw89_for_each_rtwvif(rtwdev, rtwvif) \
list_for_each_entry(rtwvif, &(rtwdev)->rtwvifs_list, list)
+/* call this function with wiphy mutex is held */
+#define rtw89_for_each_active_rtwvif(rtwdev, rtwvif) \
+ list_for_each_entry(rtwvif, &(rtwdev)->hal.entity_mgnt.active_list, mgnt_entry)
+
/* Before adding rtwvif to list, we need to check if it already exist, beacase
* in some case such as SER L2 happen during WoWLAN flow, calling reconfig
* twice cause the list to be added twice.
--
2.25.1
next prev parent reply other threads:[~2026-08-26 6:42 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-26 6:40 [PATCH rtw-next 00/14] wifi: rtw89: update RTL8922D capabilities and settings, and enable P2P device Ping-Ke Shih
2026-08-26 6:40 ` [PATCH rtw-next 01/14] wifi: rtw89: 8922de: add low latency quirk for Valve device Ping-Ke Shih
2026-08-26 6:40 ` [PATCH rtw-next 02/14] wifi: rtw89: 8922d: disable VCORE for thermal protection by default Ping-Ke Shih
2026-08-26 6:40 ` [PATCH rtw-next 03/14] wifi: rtw89: allow two station interfaces in SCC Ping-Ke Shih
2026-08-26 6:40 ` [PATCH rtw-next 04/14] wifi: rtw89: 8922d: update BB wrapper RFSI ctrl to v4 Ping-Ke Shih
2026-08-26 6:40 ` [PATCH rtw-next 05/14] wifi: rtw89: 8922d: set BB wrapper settings according to operating channel Ping-Ke Shih
2026-08-26 6:40 ` [PATCH rtw-next 06/14] wifi: rtw89: 8922d: move conditionally disabled TX shape to common flow Ping-Ke Shih
2026-08-26 6:40 ` [PATCH rtw-next 07/14] wifi: rtw89: 8922d: update BB wrapper RFSI ctrl to v5 Ping-Ke Shih
2026-08-26 6:40 ` [PATCH rtw-next 08/14] wifi: rtw89: 8922d: send RFE type to firmware Ping-Ke Shih
2026-08-26 6:40 ` [PATCH rtw-next 09/14] wifi: rtw89: 8922d: bypass RX IQK when scan Ping-Ke Shih
2026-08-26 6:40 ` [PATCH rtw-next 10/14] wifi: rtw89: 8922d: correct selection of CCK rate circuit Ping-Ke Shih
2026-08-26 6:40 ` Ping-Ke Shih [this message]
2026-08-26 6:40 ` [PATCH rtw-next 12/14] wifi: rtw89: regd: check only active vifs when recalculating 6 GHz power type Ping-Ke Shih
2026-08-26 6:41 ` [PATCH rtw-next 13/14] wifi: rtw89: skip tracking things when entity is paused Ping-Ke Shih
2026-08-26 6:41 ` [PATCH rtw-next 14/14] wifi: rtw89: add p2p device declaration Ping-Ke Shih
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260826064101.58892-12-pkshih@realtek.com \
--to=pkshih@realtek.com \
--cc=echuang@realtek.com \
--cc=henchy.chen@realtek.com \
--cc=kevin_yang@realtek.com \
--cc=linux-wireless@vger.kernel.org \
--cc=owen.hsiao@realtek.com \
--cc=phhuang@realtek.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox