Linux wireless drivers development
 help / color / mirror / Atom feed
From: Ping-Ke Shih <pkshih@realtek.com>
To: <linux-wireless@vger.kernel.org>
Cc: <ku920601@realtek.com>, <damon.chen@realtek.com>,
	<phhuang@realtek.com>, <kevin_yang@realtek.com>
Subject: [PATCH rtw-next 01/11] wifi: rtw89: coex: add a notify entry for dynamic MLO RF-path switch
Date: Thu, 12 Nov 2026 14:05:50 +0800	[thread overview]
Message-ID: <20261112060600.71784-2-pkshih@realtek.com> (raw)
In-Reply-To: <20261112060600.71784-1-pkshih@realtek.com>

From: Ching-Te Ku <ku920601@realtek.com>

MLO link combinations such as MLD2L1R_NONMLD let the firmware switch
the WL RF-path binding at runtime between 2+0, 0+2 and 1+1, instead of
keeping it fixed for the lifetime of the link. struct
rtw89_btc_wl_mlo_info already carries mrcx_mode, mrcx_act_hwb_map and
mrcx_bt_slot_rsp to describe that runtime state, and
rtw89_fw_h2c_cxdrv_mlo_v2() already forwards them to the firmware, but
nothing in the driver ever wrote these three fields. _set_bind_info()
and _set_coex_binding() both read mrcx_act_hwb_map to resolve which
HW-band a given WL RF-path currently serves while in this mode, and
with the field always zero they always resolved to the same band,
regardless of what the firmware actually switched to.

Add rtw89_btc_ntfy_mrcx_info(), a notify entry a caller can use to push
the current RF-path switch state into those three fields and let the
coex engine react to it. Mirroring the driver's existing per-HW-band
link_mode array, a mode change updates whichever MAC index the active
HW-band map selects, and a dual-band-MCC link mode is required before
any change is applied, since the RF-path binding is only ambiguous in
that state. A dedicated reason code and notify counter are added for
this entry so it can be told apart from other re-run triggers in coex
dumps.

This only adds the coex-internal entry point; nothing in the driver
calls it yet, since the trigger for a firmware-side RF-path switch
needs to be wired up from the MLO channel-context code.

Signed-off-by: Ching-Te Ku <ku920601@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
---
 drivers/net/wireless/realtek/rtw89/coex.c | 62 +++++++++++++++++++++++
 drivers/net/wireless/realtek/rtw89/coex.h | 11 ++++
 drivers/net/wireless/realtek/rtw89/core.h |  1 +
 3 files changed, 74 insertions(+)

diff --git a/drivers/net/wireless/realtek/rtw89/coex.c b/drivers/net/wireless/realtek/rtw89/coex.c
index 61e8b601ca34..751ad0cfd4ea 100644
--- a/drivers/net/wireless/realtek/rtw89/coex.c
+++ b/drivers/net/wireless/realtek/rtw89/coex.c
@@ -978,6 +978,7 @@ enum btc_reason_and_action {
 	BTC_RSN_NTFY_SPECIFIC_PACKET,
 	BTC_RSN_NTFY_POWEROFF,
 	BTC_RSN_NTFY_ROLE_INFO,
+	BTC_RSN_NTFY_GENERIC,
 	BTC_RSN_CMD_SET_COEX,
 	BTC_RSN_ACT1_WORK,
 	BTC_RSN_BT_DEVINFO_WORK,
@@ -10529,6 +10530,67 @@ void rtw89_btc_ntfy_wl_sta(struct rtw89_dev *rtwdev)
 	}
 }
 
+void rtw89_btc_ntfy_mrcx_info(struct rtw89_dev *rtwdev,
+			      enum rtw89_mlo_coex_mode mode,
+			      u8 act_hwb_map, u8 bt_slot_rsp)
+{
+	struct rtw89_btc *btc = &rtwdev->btc;
+	struct rtw89_btc_wl_info *wl = &btc->cx.wl;
+	struct rtw89_btc_wl_role_info *wl_rinfo = &wl->role_info;
+	struct rtw89_btc_wl_mlo_info *mlo_info = &wl->mlo_info;
+	bool link_mode_chg;
+	u8 link_mode;
+
+	rtw89_debug(rtwdev, RTW89_DBG_BTC,
+		    "[BTC], %s(): mode=%d, act_hwb_map=0x%x, bt_slot_rsp=%d\n",
+		    __func__, mode, act_hwb_map, bt_slot_rsp);
+	btc->dm.cnt_notify[BTC_NCNT_GENERIC]++;
+
+	mlo_info->mrcx_mode = mode;
+	mlo_info->mrcx_act_hwb_map = act_hwb_map;
+	mlo_info->mrcx_bt_slot_rsp = bt_slot_rsp;
+
+	if (wl_rinfo->link_mode[RTW89_MAC_0] != BTC_WLINK_DB_MCC &&
+	    wl_rinfo->link_mode[RTW89_MAC_1] != BTC_WLINK_DB_MCC)
+		return;
+
+	link_mode_chg = true;
+
+	/* the driver may change link mode to relieve band-switch effort */
+	switch (mode) {
+	case RTW89_MRCX_1CH_WB_H0:
+	case RTW89_MRCX_1CH_WB_H1:
+	case RTW89_MRCX_TDMRA_2CH_WB_WB:
+		link_mode = BTC_WLINK_STA;
+		break;
+	case RTW89_MRCX_TDMRA_1CH_W_B:
+		/*
+		 * both WL ports share one 2.4 GHz channel (W), BT
+		 * time-shares the remaining slots (B); treat as SCC.
+		 */
+		link_mode = BTC_WLINK_SCC;
+		break;
+	case RTW89_MRCX_TDMRA_2CH_W_W_B:
+		link_mode = BTC_WLINK_SB_MCC;
+		break;
+	default:
+		link_mode_chg = false;
+		break;
+	}
+
+	wl->link_mode_chg = link_mode_chg;
+
+	if (link_mode_chg) {
+		if (act_hwb_map & BIT(RTW89_MAC_0))
+			wl_rinfo->link_mode[RTW89_MAC_0] = link_mode;
+
+		if (act_hwb_map & BIT(RTW89_MAC_1))
+			wl_rinfo->link_mode[RTW89_MAC_1] = link_mode;
+	}
+
+	_run_coex(rtwdev, BTC_RSN_NTFY_GENERIC);
+}
+
 static u8 rtw89_btc_c2h_get_index_by_ver(struct rtw89_dev *rtwdev, u8 func)
 {
 	struct rtw89_btc *btc = &rtwdev->btc;
diff --git a/drivers/net/wireless/realtek/rtw89/coex.h b/drivers/net/wireless/realtek/rtw89/coex.h
index 38ffd0eff2c3..c3779cff9538 100644
--- a/drivers/net/wireless/realtek/rtw89/coex.h
+++ b/drivers/net/wireless/realtek/rtw89/coex.h
@@ -314,6 +314,14 @@ enum btc_mlo_rf_combin {
 	BTC_MLO_RF_2_PLUS_2 = 3,
 };
 
+enum rtw89_mlo_coex_mode {
+	RTW89_MRCX_1CH_WB_H0,
+	RTW89_MRCX_1CH_WB_H1,
+	RTW89_MRCX_TDMRA_1CH_W_B,
+	RTW89_MRCX_TDMRA_2CH_WB_WB,
+	RTW89_MRCX_TDMRA_2CH_W_W_B,
+};
+
 void rtw89_btc_init(struct rtw89_dev *rtwdev);
 void rtw89_btc_ntfy_poweron(struct rtw89_dev *rtwdev);
 void rtw89_btc_ntfy_poweroff(struct rtw89_dev *rtwdev);
@@ -336,6 +344,9 @@ void rtw89_btc_ntfy_wl_rfk(struct rtw89_dev *rtwdev, u8 phy_map,
 			   enum btc_wl_rfk_type type,
 			   enum btc_wl_rfk_state state);
 void rtw89_btc_ntfy_wl_sta(struct rtw89_dev *rtwdev);
+void rtw89_btc_ntfy_mrcx_info(struct rtw89_dev *rtwdev,
+			      enum rtw89_mlo_coex_mode mode,
+			      u8 act_hwb_map, u8 bt_slot_rsp);
 void rtw89_btc_c2h_handle(struct rtw89_dev *rtwdev, struct sk_buff *skb,
 			  u32 len, u8 class, u8 func);
 ssize_t rtw89_btc_dump_info(struct rtw89_dev *rtwdev, char *buf, size_t bufsz);
diff --git a/drivers/net/wireless/realtek/rtw89/core.h b/drivers/net/wireless/realtek/rtw89/core.h
index 7f84ee59f825..01da0b30a7ab 100644
--- a/drivers/net/wireless/realtek/rtw89/core.h
+++ b/drivers/net/wireless/realtek/rtw89/core.h
@@ -1364,6 +1364,7 @@ enum rtw89_btc_ncnt {
 	BTC_NCNT_RFK_TIMEOUT,
 	BTC_NCNT_SHOW_COEX_INFO,
 	BTC_NCNT_ROLE_INFO,
+	BTC_NCNT_GENERIC,
 	BTC_NCNT_CONTROL,
 	BTC_NCNT_RADIO_STATE,
 	BTC_NCNT_CUSTOMERIZE,
-- 
2.53.0


  reply	other threads:[~2026-11-12  6:06 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-12  6:05 [PATCH rtw-next 00/11] wifi: rtw89: correct no 2GHz band condition, update RTL8922D settings Ping-Ke Shih
2026-11-12  6:05 ` Ping-Ke Shih [this message]
2026-11-12  6:05 ` [PATCH rtw-next 02/11] wifi: rtw89: pci: reclaim TXBD before fully draining Ping-Ke Shih
2026-11-12  6:05 ` [PATCH rtw-next 03/11] wifi: rtw89: 8922d: use efuse bias for CCK RX gain Ping-Ke Shih
2026-11-12  6:05 ` [PATCH rtw-next 04/11] wifi: rtw89: 8922d: set CFR clip threshold while setting channel Ping-Ke Shih
2026-11-12  6:05 ` [PATCH rtw-next 05/11] wifi: rtw89: 8922d: correct thermal trim range to -16~+16 programmed in efuse Ping-Ke Shih
2026-11-12  6:05 ` [PATCH rtw-next 06/11] wifi: rtw89: introduce bitmap of supported bands to deal with quirks Ping-Ke Shih
2026-11-12  6:05 ` [PATCH rtw-next 07/11] wifi: rtw89: get default channel based on supported bands Ping-Ke Shih
2026-11-12  6:05 ` [PATCH rtw-next 08/11] wifi: rtw89: fix band assignment in rtw89_core_update_rx_freq_from_ie() Ping-Ke Shih
2026-11-12  6:05 ` [PATCH rtw-next 09/11] wifi: rtw89: Update sequence for MLO link switch Ping-Ke Shih
2026-11-12  6:05 ` [PATCH rtw-next 10/11] wifi: rtw89: 8922d: enable dynamic antenna gain Ping-Ke Shih
2026-11-12  6:06 ` [PATCH rtw-next 11/11] wifi: rtw89: phy: fix antenna gain unit in debug output 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=20261112060600.71784-2-pkshih@realtek.com \
    --to=pkshih@realtek.com \
    --cc=damon.chen@realtek.com \
    --cc=kevin_yang@realtek.com \
    --cc=ku920601@realtek.com \
    --cc=linux-wireless@vger.kernel.org \
    --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