wifi: rtl8xxxu: toggle P2P for supported devices
PATCH 1/1 wifi: rtl8xxxu: toggle P2P for supported devices
This is a MR to see if rtl8xxxu can be made to support P2P.
Theoretically this should be handled by mac80211 but it seems that drivers may have to take some extra steps depending on which device we are talking about. I know that this patch is so basic that it might be missing some H2C commands or similar for this to work on Realtek chips but I don't have the required knowledge for me to implement it, so if you know a place to read about I'll be glad to hear.
As of now only rtl8192ex devices have their P2P_CLIENT and P2P_GO wiphy interface modes ensured because those are the only ones I can test on my rtl8192eu card. The rest of chips have them set from what I've seen in a cursory Internet search, they might or might not work.
--- drivers/net/wireless/realtek/rtl8xxxu/8188e.c | 1 + drivers/net/wireless/realtek/rtl8xxxu/8188f.c | 1 + drivers/net/wireless/realtek/rtl8xxxu/8192c.c | 1 + drivers/net/wireless/realtek/rtl8xxxu/8192e.c | 1 + drivers/net/wireless/realtek/rtl8xxxu/8192f.c | 1 + drivers/net/wireless/realtek/rtl8xxxu/8710b.c | 1 + drivers/net/wireless/realtek/rtl8xxxu/8723a.c | 1 + drivers/net/wireless/realtek/rtl8xxxu/8723b.c | 1 + drivers/net/wireless/realtek/rtl8xxxu/core.c | 29 ++++++++++++++++++- .../net/wireless/realtek/rtl8xxxu/rtl8xxxu.h | 1 + 10 files changed, 37 insertions(+), 1 deletion(-)
drivers/net/wireless/realtek/rtl8xxxu/8188e.c +1 -0
@@ -1866,6 +1866,7 @@ struct rtl8xxxu_fileops rtl8188eu_fops = { .has_tx_report = 1, .init_reg_pkt_life_time = 1, .gen2_thermal_meter = 1, + .supports_p2p = 0, .max_sec_cam_num = 32, .adda_1t_init = 0x0b1b25a0, .adda_1t_path_on = 0x0bdb25a0,
drivers/net/wireless/realtek/rtl8xxxu/8188f.c +1 -0
@@ -1749,6 +1749,7 @@ struct rtl8xxxu_fileops rtl8188fu_fops = { .ustime_tsf_edca = 0x28, .max_aggr_num = 0x0c14, .supports_ap = 1, + .supports_p2p = 1, .max_macid_num = 16, .max_sec_cam_num = 16, .supports_concurrent = 1,
drivers/net/wireless/realtek/rtl8xxxu/8192c.c +1 -0
@@ -645,6 +645,7 @@ struct rtl8xxxu_fileops rtl8192cu_fops = { .tx_desc_size = sizeof(struct rtl8xxxu_txdesc32), .rx_desc_size = sizeof(struct rtl8xxxu_rxdesc16), .supports_ap = 1, + .supports_p2p = 1, .max_macid_num = 32, .max_sec_cam_num = 32, .adda_1t_init = 0x0b1b25a0,
drivers/net/wireless/realtek/rtl8xxxu/8192e.c +1 -0
@@ -1752,6 +1752,7 @@ struct rtl8xxxu_fileops rtl8192eu_fops = { .gen2_thermal_meter = 1, .needs_full_init = 1, .supports_ap = 1, + .supports_p2p = 1, .max_macid_num = 128, .max_sec_cam_num = 64, .adda_1t_init = 0x0fc01616,
drivers/net/wireless/realtek/rtl8xxxu/8192f.c +1 -0
@@ -2078,6 +2078,7 @@ struct rtl8xxxu_fileops rtl8192fu_fops = { .ustime_tsf_edca = 0x50, .max_aggr_num = 0x1f1f, .supports_ap = 1, + .supports_p2p = 1, .max_macid_num = 128, .max_sec_cam_num = 64, .trxff_boundary = 0x3f3f,
drivers/net/wireless/realtek/rtl8xxxu/8710b.c +1 -0
@@ -1860,6 +1860,7 @@ struct rtl8xxxu_fileops rtl8710bu_fops = { .ustime_tsf_edca = 0x28, .max_aggr_num = 0x0c14, .supports_ap = 1, + .supports_p2p = 0, .max_macid_num = 16, .max_sec_cam_num = 32, .adda_1t_init = 0x03c00016,
drivers/net/wireless/realtek/rtl8xxxu/8723a.c +1 -0
@@ -519,6 +519,7 @@ struct rtl8xxxu_fileops rtl8723au_fops = { .rx_agg_buf_size = 16000, .tx_desc_size = sizeof(struct rtl8xxxu_txdesc32), .rx_desc_size = sizeof(struct rtl8xxxu_rxdesc16), + .supports_p2p = 0, .max_sec_cam_num = 32, .adda_1t_init = 0x0b1b25a0, .adda_1t_path_on = 0x0bdb25a0,
drivers/net/wireless/realtek/rtl8xxxu/8723b.c +1 -0
@@ -1750,6 +1750,7 @@ struct rtl8xxxu_fileops rtl8723bu_fops = { .ustime_tsf_edca = 0x50, .max_aggr_num = 0x0c14, .supports_ap = 1, + .supports_p2p = 1, .max_macid_num = 128, .max_sec_cam_num = 64, .adda_1t_init = 0x01c00014,
drivers/net/wireless/realtek/rtl8xxxu/core.c +28 -1
@@ -1600,9 +1600,11 @@ static void rtl8xxxu_set_linktype(struct rtl8xxxu_priv *priv,case NL80211_IFTYPE_ADHOC : type =MSR_LINKTYPE_ADHOC ;break ; +case NL80211_IFTYPE_P2P_CLIENT :case NL80211_IFTYPE_STATION : type =MSR_LINKTYPE_STATION ;break ; +case NL80211_IFTYPE_P2P_GO :case NL80211_IFTYPE_AP : type =MSR_LINKTYPE_AP ;break ;
@@ -6780,6 +6782,7 @@ static int rtl8xxxu_add_interface(struct ieee80211_hw *hw,return -EOPNOTSUPP ;switch (vif->type) { +case NL80211_IFTYPE_P2P_CLIENT :case NL80211_IFTYPE_STATION :if (port_num ==0 ) {rtl8xxxu_stop_tx_beacon (priv);
@@ -6790,6 +6793,7 @@ static int rtl8xxxu_add_interface(struct ieee80211_hw *hw,rtl8xxxu_write8 (priv,REG_BEACON_CTRL , val8); }break ; +case NL80211_IFTYPE_P2P_GO :case NL80211_IFTYPE_AP :if (port_num ==1 ) {rtl8xxxu_switch_ports (priv);
@@ -6839,6 +6843,23 @@ static void rtl8xxxu_remove_interface(struct ieee80211_hw *hw, priv->vifs[rtlvif->port_num] =NULL ; } +static int rtl8xxxu_change_interface (struct ieee80211_hw *hw, +struct ieee80211_vif *vif, +enum nl80211_iftype new_type,bool p2p) +{ +struct rtl8xxxu_priv *priv = hw->priv; +int ret; + +dev_dbg (&priv->udev->dev,"%s: p2p %x\n" , __func__, p2p); + +rtl8xxxu_remove_interface (hw, vif); + vif->type = new_type; + vif->p2p = p2p; + ret =rtl8xxxu_add_interface (hw, vif); + +return ret; +} +static int rtl8xxxu_config (struct ieee80211_hw *hw,u32 changed) {struct rtl8xxxu_priv *priv = hw->priv;
@@ -7623,6 +7644,7 @@ static const struct ieee80211_ops rtl8xxxu_ops = { .tx = rtl8xxxu_tx, .wake_tx_queue = ieee80211_handle_wake_tx_queue, .add_interface = rtl8xxxu_add_interface, + .change_interface = rtl8xxxu_change_interface, .remove_interface = rtl8xxxu_remove_interface, .config = rtl8xxxu_config, .conf_tx = rtl8xxxu_conf_tx,
@@ -7755,7 +7777,9 @@ static void rtl8xxxu_deinit_led(struct rtl8xxxu_priv *priv)static const struct ieee80211_iface_limit rtl8xxxu_limits[] = { { .max =2 , .types =BIT (NL80211_IFTYPE_STATION ), }, - { .max =1 , .types =BIT (NL80211_IFTYPE_AP ), }, + { .max =1 , .types =BIT (NL80211_IFTYPE_AP ) | +BIT (NL80211_IFTYPE_P2P_CLIENT ) | +BIT (NL80211_IFTYPE_P2P_GO ), }, };static const struct ieee80211_iface_combination rtl8xxxu_combinations[] = {
@@ -7912,6 +7936,9 @@ static int rtl8xxxu_probe(struct usb_interface *interface, hw->wiphy->interface_modes =BIT (NL80211_IFTYPE_STATION );if (priv->fops->supports_ap) hw->wiphy->interface_modes |=BIT (NL80211_IFTYPE_AP ); +if (priv->fops->supports_p2p) + hw->wiphy->interface_modes |=BIT (NL80211_IFTYPE_P2P_CLIENT ) | +BIT (NL80211_IFTYPE_P2P_GO ); hw->queues =4 ; hw->wiphy->flags |=WIPHY_FLAG_HAS_CHANNEL_SWITCH ;
drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h +1 -0
@@ -2013,6 +2013,7 @@ struct rtl8xxxu_fileops {u8 ustime_tsf_edca;u16 max_aggr_num; u8 supports_ap:1; + u8 supports_p2p:1;u16 max_macid_num;u16 max_sec_cam_num;u32 adda_1t_init;
Signature · 1 line
2.50.0
Quoted 9 lines · Martin Rodriguez Reboredo
This is a MR to see if rtl8xxxu can be made to support P2P.
Theoretically this should be handled by mac80211 but it seems that drivers may have to take some extra steps depending on which device we are talking about. I know that this patch is so basic that it might be missing some H2C commands or similar for this to work on Realtek chips but I don't have the required knowledge for me to implement it, so if you know a place to read about I'll be glad to hear.
Quoted 6 lines
As of now only rtl8192ex devices have their
P2P_CLIENTandP2P_GOwiphy interface modes ensured because those are the only ones I can test on my rtl8192eu card. The rest of chips have them set from what I've seen in a cursory Internet search, they might or might not work.Signed-off-by Martin Rodriguez Reboredo <[email protected]>
So... does it work with your chip? How do we test?
Quoted 10 lines · On Wednesday 25 June 2025 13:01:04 Argentina Standard Time Bitterblue Smith…
On 25/06/2025 17:25, Martin Rodriguez Reboredo wrote:
[...]Quoted 6 lines
As of now only rtl8192ex devices have their
P2P_CLIENTandP2P_GOwiphy interface modes ensured because those are the only ones I can test on my rtl8192eu card. The rest of chips have them set from what I've seen in a cursory Internet search, they might or might not work.Signed-off-by Martin Rodriguez Reboredo <[email protected]>So... does it work with your chip? How do we test?
You can test this feature with GNOME Network Displays, that's the only userspace application I can think of. KDE doesn't offer anything yet and there's no other software out there that uses WiFi P2P, not even for simple file transfers. Maybe utils could be written like what was done for Bluez and be part of a known package like NetworkManager or a thing by themselves.
With respect to my case I say it's listed by wpa_cli and it gets detected by Network Displays, but I cannot do anything further than that. Because I don't know how to use wpa's utility properly and while I try to share my screen or see another one, I get no dice there. Maybe this is due to an incompatibility with my Samsung mobile or that for proper P2P support more functionalities need to be added to rtl8xxxu, I can say that as of now.
Quoted 13 lines · Martin Rodriguez Reboredo
Quoted 10 lines · On Wednesday 25 June 2025 13:01:04 Argentina Standard Time Bitterblue Smith…
On 25/06/2025 17:25, Martin Rodriguez Reboredo wrote:
[...]Quoted 6 lines
As of now only rtl8192ex devices have their
P2P_CLIENTandP2P_GOwiphy interface modes ensured because those are the only ones I can test on my rtl8192eu card. The rest of chips have them set from what I've seen in a cursory Internet search, they might or might not work.Signed-off-by Martin Rodriguez Reboredo <[email protected]>So... does it work with your chip? How do we test?
Quoted 8 lines
You can test this feature with GNOME Network Displays, that's the only userspace application I can think of. KDE doesn't offer anything yet and there's no other software out there that uses WiFi P2P, not even for simple file transfers. Maybe utils could be written like what was done for Bluez and be part of a known package like NetworkManager or a thing by themselves.
With respect to my case I say it's listed by
wpa_cliand it gets detected by Network Displays, but I cannot do anything further than that.
If you have two PC, use 'p2p_find' and 'p2p_connect' commands to make a p2p connection.
Quoted 3 lines
Because I don't
know how to use wpa's utility properly and while I try to share my screen or see another one, I get no dice there.
WiFi Display, which is a protocol over WiFi P2P, is used to share screen. IIRC it uses RTSP protocol to handshake RTP for streaming. Without a utility (I don't remember that though), it is not possible to setup a streaming session.
Quoted 3 lines
Maybe this is due to an incompatibility
with my Samsung mobile or that for proper P2P support more functionalities need to be added to rtl8xxxu, I can say that as of now.
I think what we can do in a PC is to setup a P2P connection (with an android phone is possible), and test ping or transfer a file via FTP and so on.
Quoted 1 line · Martin Rodriguez Reboredo
This is a MR to see if rtl8xxxu can be made to support P2P.
Sorry. What is MR?
Quoted 7 lines
Theoretically this should be handled by mac80211 but it seems that drivers may have to take some extra steps depending on which device we are talking about. I know that this patch is so basic that it might be missing some H2C commands or similar for this to work on Realtek chips but I don't have the required knowledge for me to implement it, so if you know a place to read about I'll be glad to hear.
The commit message looks informal. Just describe why/what patch does. If you want to share more information to readers, add information after s-o-b with "---".
Basically if a WiFi device can support station and AP modes, it can also support P2P mode. To work well, it needs to support additional P2P PS, such as NoA, which needs some H2C commands or registers to achieve. I'm not sure if chips supported by rtl8xxxu have these.
Quoted 5 lines
As of now only rtl8192ex devices have their
P2P_CLIENTandP2P_GOwiphy interface modes ensured because those are the only ones I can test on my rtl8192eu card. The rest of chips have them set from what I've seen in a cursory Internet search, they might or might not work.
Not sure what you really tested (I have seen another thread). Please mention what you tested in commit message.
Quoted 2 lines
Signed-off-by Martin Rodriguez Reboredo <[email protected]>
---
(add things you want to share)
Quoted 13 lines
--- drivers/net/wireless/realtek/rtl8xxxu/8188e.c | 1 + drivers/net/wireless/realtek/rtl8xxxu/8188f.c | 1 + drivers/net/wireless/realtek/rtl8xxxu/8192c.c | 1 + drivers/net/wireless/realtek/rtl8xxxu/8192e.c | 1 + drivers/net/wireless/realtek/rtl8xxxu/8192f.c | 1 + drivers/net/wireless/realtek/rtl8xxxu/8710b.c | 1 + drivers/net/wireless/realtek/rtl8xxxu/8723a.c | 1 + drivers/net/wireless/realtek/rtl8xxxu/8723b.c | 1 + drivers/net/wireless/realtek/rtl8xxxu/core.c | 29 ++++++++++++++++++- .../net/wireless/realtek/rtl8xxxu/rtl8xxxu.h | 1 + 10 files changed, 37 insertions(+), 1 deletion(-)
Quoted 4 lines · On Wednesday 25 June 2025 22:27:40 Argentina Standard Time Ping-Ke Shih wrote:
Quoted 1 line · Martin Rodriguez Reboredo
This is a MR to see if rtl8xxxu can be made to support P2P.
Sorry. What is MR?
Merge request in GitLab's jargon, like PR.
Quoted 10 lines
Quoted 6 lines
Theoretically this should be handled by mac80211 but it seems that drivers may have to take some extra steps depending on which device we are talking about. I know that this patch is so basic that it might be missing some H2C commands or similar for this to work on Realtek chips but I don't have the required knowledge for me to implement it, so if you know a place to read about I'll be glad to hear.
The commit message looks informal. Just describe why/what patch does. If you want to share more information to readers, add information after s-o-b with "---".
I admit that it doesn't look as a proper commit message, I'll take it into account in the next version of the patch.
Quoted 4 lines
Basically if a WiFi device can support station and AP modes, it can also support P2P mode. To work well, it needs to support additional P2P PS, such as NoA, which needs some H2C commands or registers to achieve. I'm not sure if chips supported by rtl8xxxu have these.
Many of these chips do have them, per some of the alternative drivers for them show in their sources. Perhaps in another patch some methods could be added to rtl8xxxu_fileops.
Quoted 1 line
[...]