* [RFC PATCH 1/4] wifi: rtw89: declare P2P_DEVICE in interface modes/combinations
2026-08-22 17:42 [RFC PATCH 0/4] wifi: rtw89: add NL80211_IFTYPE_P2P_DEVICE support andres parra
@ 2026-08-22 17:42 ` andres parra
2026-08-22 17:42 ` [RFC PATCH 2/4] wifi: rtw89: map P2P_DEVICE to RTW89_WIFI_ROLE_P2P_DEVICE andres parra
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: andres parra @ 2026-08-22 17:42 UTC (permalink / raw)
To: linux-wireless; +Cc: andres parra
Add BIT(NL80211_IFTYPE_P2P_DEVICE) to hw->wiphy->interface_modes, and a
dedicated { .max = 1, .types = BIT(NL80211_IFTYPE_P2P_DEVICE) } limit
entry to both rtw89_iface_limits[] and rtw89_iface_limits_mcc[],
mirroring how mt792x (mt7921/7922/7925) scopes the same interface type
in its own iface_limit tables rather than merging it into the existing
AP/P2P_CLIENT/P2P_GO bucket.
RTW89_MAX_INTERFACE_NUM (2) is left untouched: it also sizes
rtw89_entity_mgnt's active_roles[]/chanctx_tbl[][] arrays, a real
firmware-resource-tracking constraint, not just a wiphy-advertised
limit. This keeps the new P2P-Device bucket within the existing cap
(e.g. STATION + P2P-Device concurrently), and explicitly defers full
3-way concurrency (STATION + P2P-Client/GO + P2P-Device at once) to a
later change, rather than growing those tracking arrays speculatively.
This commit is purely declarative: no code path creates a P2P-Device
vif yet, so no runtime behavior change is expected for any existing
interface type. Part 1 of 2 for NL80211_IFTYPE_P2P_DEVICE support;
see rtw89-p2p-device-project's PLAN.md/BUILD_LOG.md for the full
research and design behind this change.
Signed-off-by: andres parra <andres.parrab@gmail.com>
---
core.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/core.c b/core.c
index 397ebbf..5cf29bf 100644
--- a/core.c
+++ b/core.c
@@ -176,6 +176,10 @@ static const struct ieee80211_iface_limit rtw89_iface_limits[] = {
BIT(NL80211_IFTYPE_P2P_GO) |
BIT(NL80211_IFTYPE_AP),
},
+ {
+ .max = 1,
+ .types = BIT(NL80211_IFTYPE_P2P_DEVICE),
+ },
};
static const struct ieee80211_iface_limit rtw89_iface_limits_mcc[] = {
@@ -188,6 +192,10 @@ static const struct ieee80211_iface_limit rtw89_iface_limits_mcc[] = {
.types = BIT(NL80211_IFTYPE_P2P_CLIENT) |
BIT(NL80211_IFTYPE_P2P_GO),
},
+ {
+ .max = 1,
+ .types = BIT(NL80211_IFTYPE_P2P_DEVICE),
+ },
};
static const struct ieee80211_iface_combination rtw89_iface_combs[] = {
@@ -7517,7 +7525,8 @@ static int rtw89_core_register_hw(struct rtw89_dev *rtwdev)
hw->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) |
BIT(NL80211_IFTYPE_AP) |
BIT(NL80211_IFTYPE_P2P_CLIENT) |
- BIT(NL80211_IFTYPE_P2P_GO);
+ BIT(NL80211_IFTYPE_P2P_GO) |
+ BIT(NL80211_IFTYPE_P2P_DEVICE);
if (hal->ant_diversity) {
hw->wiphy->available_antennas_tx = 0x3;
--
2.55.0
^ permalink raw reply related [flat|nested] 6+ messages in thread* [RFC PATCH 2/4] wifi: rtw89: map P2P_DEVICE to RTW89_WIFI_ROLE_P2P_DEVICE
2026-08-22 17:42 [RFC PATCH 0/4] wifi: rtw89: add NL80211_IFTYPE_P2P_DEVICE support andres parra
2026-08-22 17:42 ` [RFC PATCH 1/4] wifi: rtw89: declare P2P_DEVICE in interface modes/combinations andres parra
@ 2026-08-22 17:42 ` andres parra
2026-08-22 17:42 ` [RFC PATCH 3/4] wifi: rtw89: handle P2P_DEVICE in net_type/self_role switch andres parra
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: andres parra @ 2026-08-22 17:42 UTC (permalink / raw)
To: linux-wireless; +Cc: andres parra
Extend rtw89_vif_type_mapping()'s switch with
RTW89_TYPE_MAPPING(P2P_DEVICE), same generic macro already used for
ADHOC/MONITOR/MESH_POINT. Without this, a P2P-Device vif reaching this
function (now possible after the previous commit advertised the mode)
would fall through to the default: WARN_ON(1) case.
RTW89_WIFI_ROLE_P2P_DEVICE already existed in enum rtw89_wifi_role
before this change, and every existing consumer of wifi_role
(chan.c, ps.c, phy.c, coex.c) already handles it correctly by falling
through their "not STATION"/"not P2P_CLIENT" branches, since a
P2P-Device role has no BSS/association state those checks assume for
other roles. The BT-coexistence firmware command path
(RTW89_SET_FWCMD_CXROLE_ROLE_P2P_DEV in fw.c, three call sites) already
consumes this role generically via a role-bitmap built from
rtw89_vif_type_mapping()'s output, so this one-line mapping is
sufficient to make P2P-Device role signaling to firmware work with no
further changes needed there.
Part 2 of 2 for NL80211_IFTYPE_P2P_DEVICE support. Together with the
previous commit, this is the full v1 diff per this project's Phase 2
design (see rtw89-p2p-device-project's PLAN.md/BUILD_LOG.md): a real,
startable/stoppable P2P-Device wdev with working BT-coex signaling and
remain_on_channel (already present on this chip/firmware, unaffected
by this change). No start_p2p_device/stop_p2p_device driver ops are
needed -- mac80211 core (net/mac80211/cfg.c) implements those
generically and calls the ordinary add_interface/remove_interface ops,
which require no vif->type-specific handling on this driver (confirmed
by reading rtw89_ops_add_interface() in full).
Signed-off-by: andres parra <andres.parrab@gmail.com>
---
core.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/core.c b/core.c
index 5cf29bf..c8f12ef 100644
--- a/core.c
+++ b/core.c
@@ -5702,6 +5702,7 @@ void rtw89_vif_type_mapping(struct rtw89_vif_link *rtwvif_link, bool assoc)
RTW89_TYPE_MAPPING(ADHOC);
RTW89_TYPE_MAPPING(MONITOR);
RTW89_TYPE_MAPPING(MESH_POINT);
+ RTW89_TYPE_MAPPING(P2P_DEVICE);
default:
WARN_ON(1);
break;
--
2.55.0
^ permalink raw reply related [flat|nested] 6+ messages in thread* [RFC PATCH 3/4] wifi: rtw89: handle P2P_DEVICE in net_type/self_role switch
2026-08-22 17:42 [RFC PATCH 0/4] wifi: rtw89: add NL80211_IFTYPE_P2P_DEVICE support andres parra
2026-08-22 17:42 ` [RFC PATCH 1/4] wifi: rtw89: declare P2P_DEVICE in interface modes/combinations andres parra
2026-08-22 17:42 ` [RFC PATCH 2/4] wifi: rtw89: map P2P_DEVICE to RTW89_WIFI_ROLE_P2P_DEVICE andres parra
@ 2026-08-22 17:42 ` andres parra
2026-08-22 17:42 ` [RFC PATCH 4/4] wifi: rtw89: raise RTW89_MAX_INTERFACE_NUM to 3 for P2P-Device concurrency andres parra
2026-08-26 7:03 ` [RFC PATCH 0/4] wifi: rtw89: add NL80211_IFTYPE_P2P_DEVICE support Ping-Ke Shih
4 siblings, 0 replies; 6+ messages in thread
From: andres parra @ 2026-08-22 17:42 UTC (permalink / raw)
To: linux-wireless; +Cc: andres parra
rtw89_vif_type_mapping() has a second switch (vif->type) beyond the
wifi_role mapping already fixed -- this one sets net_type/self_role
and also ends in a default: WARN_ON(1). Live-tested on real hardware
(RTL8922AE): the moment wpa_supplicant/NetworkManager requested a
P2P-Device wdev (NL80211_CMD_START_P2P_DEVICE), this WARN_ON fired
immediately, confirmed via the exact call chain this project's
BUILD_LOG.md had already traced by hand: nl80211_start_p2p_device ->
ieee80211_start_p2p_device -> ieee80211_do_open -> drv_add_interface ->
rtw89_ops_add_interface -> __rtw89_ops_add_iface_link ->
rtw89_vif_type_mapping.
This second switch was present in the original research grep
(core.c:5702, two switch(vif->type) sites found) but was not actually
read/analyzed at the time -- a real gap in that research pass, caught
by this live test rather than by review.
Add NL80211_IFTYPE_P2P_DEVICE alongside the existing MONITOR case,
which also just breaks without setting net_type/self_role: a
P2P-Device interface has no BSS/association state, so leaving these at
their zero-initialized defaults (RTW89_NET_TYPE_NO_LINK,
RTW89_SELF_ROLE_CLIENT) is correct, same reasoning already applied to
MONITOR.
Verified live: after this fix, wpa_supplicant successfully created a
real P2P-Device wdev (confirmed via `iw dev`: phy#1 now lists a
non-netdev interface, type P2P-device, alongside wlan0), with zero
WARN/BUG in dmesg for the whole boot, and normal STA association/
roaming continuing to work correctly (multiple successful associate/
reassociate cycles observed with this driver loaded).
Signed-off-by: andres parra <andres.parrab@gmail.com>
---
core.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/core.c b/core.c
index c8f12ef..b4f8d27 100644
--- a/core.c
+++ b/core.c
@@ -5734,6 +5734,7 @@ void rtw89_vif_type_mapping(struct rtw89_vif_link *rtwvif_link, bool assoc)
rtwvif_link->addr_cam.sec_ent_mode = RTW89_ADDR_CAM_SEC_NORMAL;
break;
case NL80211_IFTYPE_MONITOR:
+ case NL80211_IFTYPE_P2P_DEVICE:
break;
default:
WARN_ON(1);
--
2.55.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [RFC PATCH 4/4] wifi: rtw89: raise RTW89_MAX_INTERFACE_NUM to 3 for P2P-Device concurrency
2026-08-22 17:42 [RFC PATCH 0/4] wifi: rtw89: add NL80211_IFTYPE_P2P_DEVICE support andres parra
` (2 preceding siblings ...)
2026-08-22 17:42 ` [RFC PATCH 3/4] wifi: rtw89: handle P2P_DEVICE in net_type/self_role switch andres parra
@ 2026-08-22 17:42 ` andres parra
2026-08-26 7:03 ` [RFC PATCH 0/4] wifi: rtw89: add NL80211_IFTYPE_P2P_DEVICE support Ping-Ke Shih
4 siblings, 0 replies; 6+ messages in thread
From: andres parra @ 2026-08-22 17:42 UTC (permalink / raw)
To: linux-wireless; +Cc: andres parra
Live-tested last night: a real GO negotiation against an actual TV
succeeded (P2P-GO-NEG-SUCCESS), but forming the actual data connection
failed with P2P-GROUP-FORMATION-FAILURE while the laptop stayed
connected to its normal STA WiFi -- completing the cast needs three
concurrent interfaces (STA + P2P-Device + the new P2P-Client group
link), and RTW89_MAX_INTERFACE_NUM was deliberately left at 2 in the
v1 design.
Traced whether raising this strains the driver's separate,
firmware-capability-tied MCC (Multi-Channel-Concurrent) role limit,
NUM_OF_RTW89_MCC_ROLES (= 2, unrelated to this constant, chan.h:51):
it does not. rtw89_entity_mgnt's active_roles[]/chanctx_tbl[][] arrays
(sized by RTW89_MAX_INTERFACE_NUM) are only populated for links with
chanctx_assigned == true, which is set in exactly one place --
rtw89_chanctx_ops_assign_vif(), the assign_vif_chanctx driver op --
and a P2P-Device vif's remain_on_channel is dispatched straight to the
driver's native ROC op, bypassing assign_vif_chanctx entirely (already
established: this only applies to emulate_chanctx-less drivers, which
this chip is not). So a P2P-Device link's chanctx_assigned stays false
for its whole lifetime and never occupies an MCC-role slot -- in the
real STA+P2P-Device+P2P-Client scenario, only STA and the P2P-Client
link ever get a real chanctx assignment, exactly matching
NUM_OF_RTW89_MCC_ROLES = 2, unchanged and unstrained.
The actual P2P-GROUP-FORMATION-FAILURE originates purely at the
mac80211/cfg80211 layer (ieee80211_check_combinations(), a plain
interface-count check against wiphy->iface_combinations[].max_interfaces,
itself set from this constant) -- this one-line change is the complete
fix for that. rtw89_iface_combs[]'s max_interfaces fields and
rtw89_entity_mgnt's array sizes already reference the macro
symbolically, so both grow automatically with no separate edit.
static_assert(RTW89_MAX_INTERFACE_NUM >= NUM_OF_RTW89_MCC_ROLES) still
holds (3 >= 2). Full research trail in this project's BUILD_LOG.md.
Signed-off-by: andres parra <andres.parrab@gmail.com>
---
core.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/core.h b/core.h
index 2b21d96..83675f0 100644
--- a/core.h
+++ b/core.h
@@ -6340,7 +6340,7 @@ enum rtw89_entity_mode {
RTW89_ENTITY_MODE_UNHANDLED = -ESRCH,
};
-#define RTW89_MAX_INTERFACE_NUM 2
+#define RTW89_MAX_INTERFACE_NUM 3
/* only valid when running with chanctx_ops */
struct rtw89_entity_mgnt {
--
2.55.0
^ permalink raw reply related [flat|nested] 6+ messages in thread* RE: [RFC PATCH 0/4] wifi: rtw89: add NL80211_IFTYPE_P2P_DEVICE support
2026-08-22 17:42 [RFC PATCH 0/4] wifi: rtw89: add NL80211_IFTYPE_P2P_DEVICE support andres parra
` (3 preceding siblings ...)
2026-08-22 17:42 ` [RFC PATCH 4/4] wifi: rtw89: raise RTW89_MAX_INTERFACE_NUM to 3 for P2P-Device concurrency andres parra
@ 2026-08-26 7:03 ` Ping-Ke Shih
4 siblings, 0 replies; 6+ messages in thread
From: Ping-Ke Shih @ 2026-08-26 7:03 UTC (permalink / raw)
To: andres parra, linux-wireless@vger.kernel.org
andres parra <andres.parrab@gmail.com> wrote:
> Hi,
>
> I'm not a professional kernel developer -- this is my first
> substantive contribution to this subsystem, so please bear with me if
> anything here doesn't follow convention, and I'd appreciate direct
> correction on anything I've gotten wrong.
You should apply your patch to kernel tree, and generate patches.
Otherwise, the path is wrong:
diff --git a/core.c b/core.c
For Realtek WiFi drivers, the tree should be rtw-next [1].
It seems like you repeatedly describe similar messages in every
patch. Not sure if this is because the 4 patches are small.
[1] https://github.com/pkshih/rtw.git rtw-next
>
> rtw89 does not currently declare NL80211_IFTYPE_P2P_DEVICE anywhere in
> interface_modes, which means wpa_supplicant/NetworkManager can never
> create a real P2P-Device wdev on this hardware, and Wi-Fi Direct
> casting (Miracast/WFD) to a smart TV never works: GO negotiation never
> even starts. Confirmed absent across every rtw89 chip variant, not
> just RTL8922AE. mt792x (mt7921/7922/7925) implements this correctly on
> comparable modern, MCU-firmware-based hardware, and was used as the
> reference model for this series.
We have developed this recently [2]. Please take patches 11/14 ~14/14
and test if it works in your side.
[2] https://lore.kernel.org/linux-wireless/20260826064101.58892-12-pkshih@realtek.com/T/#u
>
> 1. If the AP the STA link is associated to does an ordinary channel
> switch (CTRL-EVENT-CHANNEL-SWITCH) onto a different channel than
> the one an active P2P-Client group is using, the P2P link is
> dropped outright (beacon loss, then a locally-generated disconnect)
> and never re-established automatically. I don't know whether this
> is a pre-existing limitation in the existing MCC entity-management
> code (rtw89_entity_mgnt / chan.c) that would reproduce identically
> with a stock, unmodified P2P_CLIENT/GO connection unrelated to this
> series, or something specific to a P2P-Device wdev being present.
> Have not yet had the chance to test against a stock driver to
> isolate which.
Could you try the same test on the patches I mentioned above?
And, share the test flow step by step.
>
> 2. If the STA link and the P2P-Client link end up on genuinely
> different *bands* (STA on 5GHz, P2P on 2.4GHz -- WFD is 2.4GHz-only)
> rather than just different channels on the same band, the
> connection stays up but has a real, repeatable performance cost --
> confirmed clean at the RF link level (zero tx retries/failures on
> the P2P link, good signal, decent PHY rate throughout) via
> `station dump`, so it doesn't look like a radio-quality problem.
> Grepped this driver for any equivalent to Intel iwlwifi's CDB
> (Concurrent Dual-Band, IWL_UCODE_TLV_CAPA_CDB_SUPPORT, a distinct
> LMAC per band) or MediaTek mt76's DBDC (Dual-Band Dual-Concurrent,
> MCU_EXT_CMD_DBDC_CTRL) -- found nothing under either name. Is that
> because RTL8922AE genuinely lacks equivalent hardware/firmware
> capability (in which case this is a real ceiling, not something
> software can fix), or does it exist under different terminology I
> haven't found?
rtw89 doesn't support dual bands concurrency simultaneously, it uses
power saving mechanism to do TDMA timeslot sharing.
^ permalink raw reply [flat|nested] 6+ messages in thread