Linux wireless drivers development
 help / color / mirror / Atom feed
* [PATCH rtw-next v6 0/5] wifi: rtw89: monitor mode and raw frame injection fixes
@ 2026-11-17  9:41 Enver Ikromov
  2026-11-17  9:41 ` [PATCH rtw-next v6 1/5] wifi: rtw89: avoid NULL vif dereference in rtw89_ops_tx() Enver Ikromov
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: Enver Ikromov @ 2026-11-17  9:41 UTC (permalink / raw)
  To: Ping-Ke Shih; +Cc: Zong-Zhe Yang, linux-wireless, linux-kernel, Enver Ikromov

This series fixes a NULL vif dereference and a negative radiotap rate
index bug on the TX path, restores the operating channel after monitor
down/up on non-chanctx devices, and fixes control-frame seq_ctrl reads,
sequence preservation, NO_ACK, and retry limits for raw 802.11 frame
injection.

Tested on RTL8852AE (10ec:8852, firmware 0.13.36.2) across 2.4 GHz and
5 GHz.

Changes in v6:
- Focus the series strictly on the standalone monitor interface case
  (plus the concurrent NULL-vif crash guard in patch 1), dropping former
  patches 3, 4, 5, 6, and 8 (RX filter changes, RCU pure_monitor_mode_vif,
  AP self role, NL80211_FEATURE_ACTIVE_MONITOR, and host TX hook skips).
- Rewrite all commit messages concisely without function-level flow.
- Patch 1: use vif_to_rtwvif_safe().
- Patch 2: clamp negative rate indices to 0 with max_t().
- Patch 3 (was 10): move before injection changes, add
  rtwdev->support_chanctx, and reuse IEEE80211_CONF_CHANGE_CHANNEL in
  rtw89_ops_config().
- Patch 4 (was 7): keep control frames on the AC queue and only set
  seq = 0 for control frames.
- Patch 5 (was 9): simplify ASSIGN_SEQ handling and drop dead RTS/CTS,
  rate-index clamping, upd_wlan_hdr, and pci.c counter changes.
- Rebase onto latest rtw-next and wrap all lines to <= 80 columns.

Changes in v5:
- Split the NULL vif fix and negative rate index fix out as standalone
  patches 1-2 with Fixes: and Cc: stable tags.
- Split monitor injection into focused patches.
- Honor ASSIGN_SEQ, retries, and NO_ACK for injected frames.
- Restore channel on leaving idle for non-chanctx devices.

Changes in v3:
- Split into a patch series and use driver abstractions instead of
  direct register writes.

v5: https://lore.kernel.org/linux-wireless/20261113235211.1911-1-owner@ph4ntom-rev.uz/
v3: https://lore.kernel.org/linux-wireless/20261104203051.564-1-owner@ph4ntom-rev.uz/
v2: https://lore.kernel.org/linux-wireless/179371849554.20972.16232816164394690660@ph4ntom-rev.uz/
v1 (RFC): https://lore.kernel.org/linux-wireless/1a196d6dfbc.35537d221913104450.3720060455831933789@zoho.com/

Enver Ikromov (5):
  wifi: rtw89: avoid NULL vif dereference in rtw89_ops_tx()
  wifi: rtw89: handle negative rate index for injected frames
  wifi: rtw89: restore channel when leaving idle on non-chanctx devices
  wifi: rtw89: avoid reading seq_ctrl on control frames
  wifi: rtw89: honor ASSIGN_SEQ, retries, and NO_ACK for injected frames

 drivers/net/wireless/realtek/rtw89/core.c     | 27 ++++++++++++++++---
 drivers/net/wireless/realtek/rtw89/core.h     |  3 +++
 drivers/net/wireless/realtek/rtw89/mac.h      |  2 ++
 drivers/net/wireless/realtek/rtw89/mac80211.c | 16 ++++++++++-
 4 files changed, 44 insertions(+), 4 deletions(-)


base-commit: badf4c3c7679871a50cff1150f66e63187201757
-- 
2.56.0.windows.4


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH rtw-next v6 1/5] wifi: rtw89: avoid NULL vif dereference in rtw89_ops_tx()
  2026-11-17  9:41 [PATCH rtw-next v6 0/5] wifi: rtw89: monitor mode and raw frame injection fixes Enver Ikromov
@ 2026-11-17  9:41 ` Enver Ikromov
  2026-11-17  9:41 ` [PATCH rtw-next v6 2/5] wifi: rtw89: handle negative rate index for injected frames Enver Ikromov
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Enver Ikromov @ 2026-11-17  9:41 UTC (permalink / raw)
  To: Ping-Ke Shih; +Cc: Zong-Zhe Yang, linux-wireless, linux-kernel, Enver Ikromov

Injecting a raw frame on a passive monitor interface while a station or
AP interface is also up causes a kernel NULL pointer dereference,
because mac80211 has no virtual monitor vif in concurrent mode and
passes a NULL vif to the driver TX path.

Check the vif pointer with vif_to_rtwvif_safe() and drop frames without
a vif.

Fixes: a0e97ae3f332 ("wifi: rtw89: add ieee80211::remain_on_channel ops")
Cc: stable@vger.kernel.org
Signed-off-by: Enver Ikromov <owner@ph4ntom-rev.uz>
---
 drivers/net/wireless/realtek/rtw89/mac80211.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/realtek/rtw89/mac80211.c b/drivers/net/wireless/realtek/rtw89/mac80211.c
index c85ea82..7a55fed 100644
--- a/drivers/net/wireless/realtek/rtw89/mac80211.c
+++ b/drivers/net/wireless/realtek/rtw89/mac80211.c
@@ -23,11 +23,16 @@ static void rtw89_ops_tx(struct ieee80211_hw *hw,
 	struct rtw89_dev *rtwdev = hw->priv;
 	struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
 	struct ieee80211_vif *vif = info->control.vif;
-	struct rtw89_vif *rtwvif = vif_to_rtwvif(vif);
+	struct rtw89_vif *rtwvif = vif_to_rtwvif_safe(vif);
 	struct ieee80211_sta *sta = control->sta;
 	u32 flags = IEEE80211_SKB_CB(skb)->flags;
 	int ret, qsel;
 
+	if (unlikely(!rtwvif)) {
+		ieee80211_free_txskb(hw, skb);
+		return;
+	}
+
 	if (rtwvif->offchan && !(flags & IEEE80211_TX_CTL_TX_OFFCHAN) && sta) {
 		struct rtw89_sta *rtwsta = sta_to_rtwsta(sta);
 
-- 
2.56.0.windows.4


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH rtw-next v6 2/5] wifi: rtw89: handle negative rate index for injected frames
  2026-11-17  9:41 [PATCH rtw-next v6 0/5] wifi: rtw89: monitor mode and raw frame injection fixes Enver Ikromov
  2026-11-17  9:41 ` [PATCH rtw-next v6 1/5] wifi: rtw89: avoid NULL vif dereference in rtw89_ops_tx() Enver Ikromov
@ 2026-11-17  9:41 ` Enver Ikromov
  2026-11-17  9:41 ` [PATCH rtw-next v6 3/5] wifi: rtw89: restore channel when leaving idle on non-chanctx devices Enver Ikromov
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Enver Ikromov @ 2026-11-17  9:41 UTC (permalink / raw)
  To: Ping-Ke Shih; +Cc: Zong-Zhe Yang, linux-wireless, linux-kernel, Enver Ikromov

When user space injects a frame with a radiotap rate that is not
supported on the current band (for example 1 Mbps CCK on 5 GHz),
mac80211 sets the rate index to -1. Storing that index in an unsigned
byte turns it into 0xff and programs an invalid hardware rate into the
TX descriptor.

Clamp negative rate indices to 0 so the lowest valid band rate (1 Mbps
on 2.4 GHz, 6 Mbps on 5/6 GHz) is selected.

Fixes: e96abe4fd7cd ("wifi: rtw89: consider data rate/bandwidth/GI for injected packets")
Cc: stable@vger.kernel.org
Signed-off-by: Enver Ikromov <owner@ph4ntom-rev.uz>
---
 drivers/net/wireless/realtek/rtw89/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/wireless/realtek/rtw89/core.c b/drivers/net/wireless/realtek/rtw89/core.c
index 1e8b60e..37ff745 100644
--- a/drivers/net/wireless/realtek/rtw89/core.c
+++ b/drivers/net/wireless/realtek/rtw89/core.c
@@ -1259,7 +1259,7 @@ static void rtw89_core_tx_update_injection(struct rtw89_dev *rtwdev,
 	enum mac80211_rate_control_flags flags = info->control.rates[0].flags;
 	struct rtw89_tx_desc_info *desc_info = &tx_req->desc_info;
 	const struct rtw89_chan *chan;
-	u8 idx = info->control.rates[0].idx;
+	u8 idx = max_t(s8, info->control.rates[0].idx, 0);
 	u8 nss, mcs;
 
 	desc_info->use_rate = true;
-- 
2.56.0.windows.4


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH rtw-next v6 3/5] wifi: rtw89: restore channel when leaving idle on non-chanctx devices
  2026-11-17  9:41 [PATCH rtw-next v6 0/5] wifi: rtw89: monitor mode and raw frame injection fixes Enver Ikromov
  2026-11-17  9:41 ` [PATCH rtw-next v6 1/5] wifi: rtw89: avoid NULL vif dereference in rtw89_ops_tx() Enver Ikromov
  2026-11-17  9:41 ` [PATCH rtw-next v6 2/5] wifi: rtw89: handle negative rate index for injected frames Enver Ikromov
@ 2026-11-17  9:41 ` Enver Ikromov
  2026-11-18  6:30   ` Zong-Zhe Yang
  2026-11-17  9:41 ` [PATCH rtw-next v6 4/5] wifi: rtw89: avoid reading seq_ctrl on control frames Enver Ikromov
  2026-11-17  9:41 ` [PATCH rtw-next v6 5/5] wifi: rtw89: honor ASSIGN_SEQ, retries, and NO_ACK for injected frames Enver Ikromov
  4 siblings, 1 reply; 7+ messages in thread
From: Enver Ikromov @ 2026-11-17  9:41 UTC (permalink / raw)
  To: Ping-Ke Shih; +Cc: Zong-Zhe Yang, linux-wireless, linux-kernel, Enver Ikromov

Fix the operating channel not being restored after bringing a monitor
interface down and back up on devices that do not use native chanctx
callbacks (such as RTL8852AE when firmware lacks beacon filtering).

Stopping the interface powers down the PHY while mac80211 retains the
previous chandef and omits IEEE80211_CONF_CHANGE_CHANNEL on restart.
Record support_chanctx in rtwdev and set IEEE80211_CONF_CHANGE_CHANNEL
when re-entering monitor mode from idle on non-chanctx devices so the
channel is applied again.

Signed-off-by: Enver Ikromov <owner@ph4ntom-rev.uz>
---
 drivers/net/wireless/realtek/rtw89/core.c     | 1 +
 drivers/net/wireless/realtek/rtw89/core.h     | 1 +
 drivers/net/wireless/realtek/rtw89/mac80211.c | 9 +++++++++
 3 files changed, 11 insertions(+)

diff --git a/drivers/net/wireless/realtek/rtw89/core.c b/drivers/net/wireless/realtek/rtw89/core.c
index 37ff745..8333b26 100644
--- a/drivers/net/wireless/realtek/rtw89/core.c
+++ b/drivers/net/wireless/realtek/rtw89/core.c
@@ -7761,6 +7761,7 @@ struct rtw89_dev *rtw89_alloc_ieee80211_hw(struct device *device,
 	rtwdev->board = info->board;
 	rtwdev->fw.req.firmware = firmware;
 	rtwdev->fw.fw_format = fw_format;
+	rtwdev->support_chanctx = !no_chanctx;
 	rtwdev->support_mlo = support_mlo;
 
 	bitmap_copy(rtwdev->quirks, &chip->default_quirks, NUM_OF_RTW89_QUIRKS);
diff --git a/drivers/net/wireless/realtek/rtw89/core.h b/drivers/net/wireless/realtek/rtw89/core.h
index 8e93cf1..780ec47 100644
--- a/drivers/net/wireless/realtek/rtw89/core.h
+++ b/drivers/net/wireless/realtek/rtw89/core.h
@@ -7703,6 +7703,7 @@ struct rtw89_dev {
 	const struct rtw89_io_ops *io;
 
 	bool dbcc_en;
+	bool support_chanctx;
 	bool support_mlo;
 	enum rtw89_mlo_dbcc_mode mlo_dbcc_mode;
 	struct rtw89_hw_scan_info scan_info;
diff --git a/drivers/net/wireless/realtek/rtw89/mac80211.c b/drivers/net/wireless/realtek/rtw89/mac80211.c
index 7a55fed..a385e57 100644
--- a/drivers/net/wireless/realtek/rtw89/mac80211.c
+++ b/drivers/net/wireless/realtek/rtw89/mac80211.c
@@ -89,6 +89,7 @@ static void rtw89_ops_stop(struct ieee80211_hw *hw, bool suspend)
 static int rtw89_ops_config(struct ieee80211_hw *hw, int radio_idx, u32 changed)
 {
 	struct rtw89_dev *rtwdev = hw->priv;
+	bool no_chanctx = !rtwdev->support_chanctx;
 
 	lockdep_assert_wiphy(hw->wiphy);
 
@@ -97,6 +98,14 @@ static int rtw89_ops_config(struct ieee80211_hw *hw, int radio_idx, u32 changed)
 
 	rtw89_leave_ps_mode(rtwdev);
 
+	if (no_chanctx &&
+	    (changed & (IEEE80211_CONF_CHANGE_IDLE |
+			IEEE80211_CONF_CHANGE_MONITOR)) ==
+	    (IEEE80211_CONF_CHANGE_IDLE | IEEE80211_CONF_CHANGE_MONITOR)) {
+		if (!(hw->conf.flags & IEEE80211_CONF_IDLE))
+			changed |= IEEE80211_CONF_CHANGE_CHANNEL;
+	}
+
 	if ((changed & IEEE80211_CONF_CHANGE_IDLE) &&
 	    !(hw->conf.flags & IEEE80211_CONF_IDLE))
 		rtw89_leave_ips(rtwdev);
-- 
2.56.0.windows.4


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH rtw-next v6 4/5] wifi: rtw89: avoid reading seq_ctrl on control frames
  2026-11-17  9:41 [PATCH rtw-next v6 0/5] wifi: rtw89: monitor mode and raw frame injection fixes Enver Ikromov
                   ` (2 preceding siblings ...)
  2026-11-17  9:41 ` [PATCH rtw-next v6 3/5] wifi: rtw89: restore channel when leaving idle on non-chanctx devices Enver Ikromov
@ 2026-11-17  9:41 ` Enver Ikromov
  2026-11-17  9:41 ` [PATCH rtw-next v6 5/5] wifi: rtw89: honor ASSIGN_SEQ, retries, and NO_ACK for injected frames Enver Ikromov
  4 siblings, 0 replies; 7+ messages in thread
From: Enver Ikromov @ 2026-11-17  9:41 UTC (permalink / raw)
  To: Ping-Ke Shih; +Cc: Zong-Zhe Yang, linux-wireless, linux-kernel, Enver Ikromov

Injected 802.11 control frames such as 10-byte ACK/CTS or 16-byte RTS
do not carry a sequence control field and are shorter than a 24-byte
3-address header.

Set seq to 0 for control frames instead of reading hdr->seq_ctrl.

Signed-off-by: Enver Ikromov <owner@ph4ntom-rev.uz>
---
 drivers/net/wireless/realtek/rtw89/core.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/realtek/rtw89/core.c b/drivers/net/wireless/realtek/rtw89/core.c
index 8333b26..e599058 100644
--- a/drivers/net/wireless/realtek/rtw89/core.c
+++ b/drivers/net/wireless/realtek/rtw89/core.c
@@ -1317,7 +1317,10 @@ rtw89_core_tx_update_desc_info(struct rtw89_dev *rtwdev,
 	else if (tx_req->vif)
 		desc_info->mlo = ieee80211_vif_is_mld(tx_req->vif);
 
-	seq = (le16_to_cpu(hdr->seq_ctrl) & IEEE80211_SCTL_SEQ) >> 4;
+	if (ieee80211_is_ctl(hdr->frame_control))
+		seq = 0;
+	else
+		seq = (le16_to_cpu(hdr->seq_ctrl) & IEEE80211_SCTL_SEQ) >> 4;
 	addr_cam = rtw89_get_addr_cam_of(tx_req->rtwvif_link,
 					 tx_req->rtwsta_link);
 	if (addr_cam->valid && desc_info->mlo)
-- 
2.56.0.windows.4


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH rtw-next v6 5/5] wifi: rtw89: honor ASSIGN_SEQ, retries, and NO_ACK for injected frames
  2026-11-17  9:41 [PATCH rtw-next v6 0/5] wifi: rtw89: monitor mode and raw frame injection fixes Enver Ikromov
                   ` (3 preceding siblings ...)
  2026-11-17  9:41 ` [PATCH rtw-next v6 4/5] wifi: rtw89: avoid reading seq_ctrl on control frames Enver Ikromov
@ 2026-11-17  9:41 ` Enver Ikromov
  4 siblings, 0 replies; 7+ messages in thread
From: Enver Ikromov @ 2026-11-17  9:41 UTC (permalink / raw)
  To: Ping-Ke Shih; +Cc: Zong-Zhe Yang, linux-wireless, linux-kernel, Enver Ikromov

Injected management frames currently overwrite caller-supplied sequence
numbers because hardware sequence numbering remains enabled when
IEEE80211_TX_CTL_ASSIGN_SEQ is unset, and injected frames ignore NO_ACK
and explicit radiotap retry limits.

Preserve the caller's sequence number when IEEE80211_TX_CTL_ASSIGN_SEQ
is not set, apply NO_ACK in TX descriptors and completion status, and
honor radiotap retry counts up to RTW89_TX_DATA_CNT_LMT_MAX (63).

Signed-off-by: Enver Ikromov <owner@ph4ntom-rev.uz>
---
 drivers/net/wireless/realtek/rtw89/core.c | 19 ++++++++++++++++++-
 drivers/net/wireless/realtek/rtw89/core.h |  2 ++
 drivers/net/wireless/realtek/rtw89/mac.h  |  2 ++
 3 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/realtek/rtw89/core.c b/drivers/net/wireless/realtek/rtw89/core.c
index e599058..712c10a 100644
--- a/drivers/net/wireless/realtek/rtw89/core.c
+++ b/drivers/net/wireless/realtek/rtw89/core.c
@@ -1265,6 +1265,20 @@ static void rtw89_core_tx_update_injection(struct rtw89_dev *rtwdev,
 	desc_info->use_rate = true;
 	desc_info->dis_data_fb = true;
 
+	if (!(info->flags & IEEE80211_TX_CTL_ASSIGN_SEQ)) {
+		desc_info->hw_ssn_sel = 0;
+		desc_info->hw_seq_mode = 0;
+	}
+
+	if (info->flags & IEEE80211_TX_CTL_NO_ACK) {
+		desc_info->no_ack = true;
+		desc_info->tx_cnt_lmt_en = true;
+		desc_info->tx_cnt_lmt = 1;
+	} else if (info->control.rates[0].count) {
+		desc_info->tx_cnt_lmt_en = true;
+		desc_info->tx_cnt_lmt = info->control.rates[0].count;
+	}
+
 	if (flags & IEEE80211_TX_RC_160_MHZ_WIDTH)
 		desc_info->data_bw = 3;
 	else if (flags & IEEE80211_TX_RC_80_MHZ_WIDTH)
@@ -1800,7 +1814,9 @@ static __le32 rtw89_build_txwd_body5_v2(struct rtw89_tx_desc_info *desc_info)
 
 static __le32 rtw89_build_txwd_body6_v2(struct rtw89_tx_desc_info *desc_info)
 {
-	u32 dword = FIELD_PREP(BE_TXD_BODY6_UPD_WLAN_HDR, desc_info->upd_wlan_hdr);
+	u32 dword = FIELD_PREP(BE_TXD_BODY6_NO_ACK, desc_info->no_ack) |
+		    FIELD_PREP(BE_TXD_BODY6_UPD_WLAN_HDR,
+			       desc_info->upd_wlan_hdr);
 
 	return cpu_to_le32(dword);
 }
@@ -7540,6 +7556,7 @@ static int rtw89_core_register_hw(struct rtw89_dev *rtwdev)
 	hw->queues = IEEE80211_NUM_ACS;
 	hw->max_rx_aggregation_subframes = chip->max_rx_agg_num;
 	hw->max_tx_aggregation_subframes = chip->max_tx_agg_num;
+	hw->max_rate_tries = RTW89_TX_DATA_CNT_LMT_MAX;
 	hw->uapsd_max_sp_len = IEEE80211_WMM_IE_STA_QOSINFO_SP_ALL;
 
 	hw->radiotap_mcs_details |= IEEE80211_RADIOTAP_MCS_HAVE_FEC |
diff --git a/drivers/net/wireless/realtek/rtw89/core.h b/drivers/net/wireless/realtek/rtw89/core.h
index 780ec47..3065e11 100644
--- a/drivers/net/wireless/realtek/rtw89/core.h
+++ b/drivers/net/wireless/realtek/rtw89/core.h
@@ -1278,6 +1278,7 @@ struct rtw89_tx_desc_info {
 	bool tx_cnt_lmt_en;
 	u8 sn: 4;
 	u8 tx_cnt_lmt: 6;
+#define RTW89_TX_DATA_CNT_LMT_MAX	0x3f
 	u8 addr_info_nr;
 	u8 sec_keyid;
 	u8 sec_type;
@@ -1300,6 +1301,7 @@ struct rtw89_tx_desc_info {
 	bool stbc;
 	bool ldpc;
 	bool upd_wlan_hdr;
+	bool no_ack;
 	bool mlo;
 	bool sw_mld;
 };
diff --git a/drivers/net/wireless/realtek/rtw89/mac.h b/drivers/net/wireless/realtek/rtw89/mac.h
index 2e76bb1..c94b34b 100644
--- a/drivers/net/wireless/realtek/rtw89/mac.h
+++ b/drivers/net/wireless/realtek/rtw89/mac.h
@@ -1896,6 +1896,8 @@ void rtw89_tx_rpt_tx_status(struct rtw89_dev *rtwdev, struct sk_buff *skb,
 	info = IEEE80211_SKB_CB(skb);
 	ieee80211_tx_info_clear_status(info);
 
+	if (info->flags & IEEE80211_TX_CTL_NO_ACK)
+		info->flags |= IEEE80211_TX_STAT_NOACK_TRANSMITTED;
 	if (tx_status == RTW89_TX_DONE)
 		info->flags |= IEEE80211_TX_STAT_ACK;
 	else
-- 
2.56.0.windows.4


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* RE: [PATCH rtw-next v6 3/5] wifi: rtw89: restore channel when leaving idle on non-chanctx devices
  2026-11-17  9:41 ` [PATCH rtw-next v6 3/5] wifi: rtw89: restore channel when leaving idle on non-chanctx devices Enver Ikromov
@ 2026-11-18  6:30   ` Zong-Zhe Yang
  0 siblings, 0 replies; 7+ messages in thread
From: Zong-Zhe Yang @ 2026-11-18  6:30 UTC (permalink / raw)
  To: Enver Ikromov, Ping-Ke Shih
  Cc: linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org

Enver Ikromov <owner@ph4ntom-rev.uz> wrote:
> 
> Fix the operating channel not being restored after bringing a monitor
> interface down and back up on devices that do not use native chanctx
> callbacks (such as RTL8852AE when firmware lacks beacon filtering).
> 
> Stopping the interface powers down the PHY while mac80211 retains the
> previous chandef and omits IEEE80211_CONF_CHANGE_CHANNEL on restart.
> Record support_chanctx in rtwdev and set
> IEEE80211_CONF_CHANGE_CHANNEL
> when re-entering monitor mode from idle on non-chanctx devices so the
> channel is applied again.
> 
> Signed-off-by: Enver Ikromov <owner@ph4ntom-rev.uz>
> ---
>  drivers/net/wireless/realtek/rtw89/core.c     | 1 +
>  drivers/net/wireless/realtek/rtw89/core.h     | 1 +
>  drivers/net/wireless/realtek/rtw89/mac80211.c | 9 +++++++++
>  3 files changed, 11 insertions(+)
> 
> diff --git a/drivers/net/wireless/realtek/rtw89/core.c
> b/drivers/net/wireless/realtek/rtw89/core.c
> index 37ff745..8333b26 100644
> --- a/drivers/net/wireless/realtek/rtw89/core.c
> +++ b/drivers/net/wireless/realtek/rtw89/core.c
> @@ -7761,6 +7761,7 @@ struct rtw89_dev
> *rtw89_alloc_ieee80211_hw(struct device *device,
>         rtwdev->board = info->board;
>         rtwdev->fw.req.firmware = firmware;
>         rtwdev->fw.fw_format = fw_format;
> +       rtwdev->support_chanctx = !no_chanctx;
>         rtwdev->support_mlo = support_mlo;
> 
>         bitmap_copy(rtwdev->quirks, &chip->default_quirks,
> NUM_OF_RTW89_QUIRKS);
> diff --git a/drivers/net/wireless/realtek/rtw89/core.h
> b/drivers/net/wireless/realtek/rtw89/core.h
> index 8e93cf1..780ec47 100644
> --- a/drivers/net/wireless/realtek/rtw89/core.h
> +++ b/drivers/net/wireless/realtek/rtw89/core.h
> @@ -7703,6 +7703,7 @@ struct rtw89_dev {
>         const struct rtw89_io_ops *io;
> 
>         bool dbcc_en;
> +       bool support_chanctx;
>         bool support_mlo;
>         enum rtw89_mlo_dbcc_mode mlo_dbcc_mode;
>         struct rtw89_hw_scan_info scan_info;
> diff --git a/drivers/net/wireless/realtek/rtw89/mac80211.c
> b/drivers/net/wireless/realtek/rtw89/mac80211.c
> index 7a55fed..a385e57 100644
> --- a/drivers/net/wireless/realtek/rtw89/mac80211.c
> +++ b/drivers/net/wireless/realtek/rtw89/mac80211.c
> @@ -89,6 +89,7 @@ static void rtw89_ops_stop(struct ieee80211_hw *hw,
> bool suspend)
>  static int rtw89_ops_config(struct ieee80211_hw *hw, int radio_idx, u32
> changed)
>  {
>         struct rtw89_dev *rtwdev = hw->priv;
> +       bool no_chanctx = !rtwdev->support_chanctx;
> 
>         lockdep_assert_wiphy(hw->wiphy);
> 
> @@ -97,6 +98,14 @@ static int rtw89_ops_config(struct ieee80211_hw *hw,
> int radio_idx, u32 changed)
> 
>         rtw89_leave_ps_mode(rtwdev);
> 
> +       if (no_chanctx &&
> +           (changed & (IEEE80211_CONF_CHANGE_IDLE |
> +                       IEEE80211_CONF_CHANGE_MONITOR)) ==
> +           (IEEE80211_CONF_CHANGE_IDLE |
> IEEE80211_CONF_CHANGE_MONITOR)) {
> +               if (!(hw->conf.flags & IEEE80211_CONF_IDLE))

How about

    If (!rtwdev->support_chanctx &&
      changed & IEEE80211_CONF_CHANGE_IDLE &&
      changed & IEEE80211_CONF_CHANGE_ MONITOR &&
      !(hw->conf.flags & IEEE80211_CONF_IDLE))

Additionally,
    (changed & (IEEE80211_CONF_CHANGE_IDLE |
              IEEE80211_CONF_CHANGE_MONITOR))
seems to be true for any first iface (even if not a monitor) by
ieee80211_hw_conf_init(). So, perhaps the condition should be

    If (!rtwdev->support_chanctx &&
      changed & IEEE80211_CONF_CHANGE_IDLE &&
      changed & IEEE80211_CONF_CHANGE_ MONITOR &&
      !(hw->conf.flags & IEEE80211_CONF_IDLE) &&
      hw->conf.flags & IEEE80211_CONF_MONITOR)

> +                       changed |=
> IEEE80211_CONF_CHANGE_CHANNEL;
> +       }
> +
>         if ((changed & IEEE80211_CONF_CHANGE_IDLE) &&
>             !(hw->conf.flags & IEEE80211_CONF_IDLE))
>                 rtw89_leave_ips(rtwdev);
> --
> 2.56.0.windows.4


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2026-11-18  6:30 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-17  9:41 [PATCH rtw-next v6 0/5] wifi: rtw89: monitor mode and raw frame injection fixes Enver Ikromov
2026-11-17  9:41 ` [PATCH rtw-next v6 1/5] wifi: rtw89: avoid NULL vif dereference in rtw89_ops_tx() Enver Ikromov
2026-11-17  9:41 ` [PATCH rtw-next v6 2/5] wifi: rtw89: handle negative rate index for injected frames Enver Ikromov
2026-11-17  9:41 ` [PATCH rtw-next v6 3/5] wifi: rtw89: restore channel when leaving idle on non-chanctx devices Enver Ikromov
2026-11-18  6:30   ` Zong-Zhe Yang
2026-11-17  9:41 ` [PATCH rtw-next v6 4/5] wifi: rtw89: avoid reading seq_ctrl on control frames Enver Ikromov
2026-11-17  9:41 ` [PATCH rtw-next v6 5/5] wifi: rtw89: honor ASSIGN_SEQ, retries, and NO_ACK for injected frames Enver Ikromov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox