2023-12-18 14:39:06

by Martin Kaistra

[permalink] [raw]
Subject: [PATCH 00/20] wifi: rtl8xxxu: Add concurrent mode for 8188f

This series adds the possibility to use two virtual interfaces on the
same channel. Supported combinations are STA+STA and STA+AP. The
conversion of the driver to support multiple interfaces is split into
individual patches to hopefully make it easier to understand what is
going on.

Thanks,
Martin

Martin Kaistra (20):
wifi: rtl8xxxu: remove assignment of priv->vif in
rtl8xxxu_bss_info_changed()
wifi: rtl8xxxu: prepare supporting two virtual interfaces
wifi: rtl8xxxu: support setting linktype for both interfaces
wifi: rtl8xxxu: 8188e: convert usage of priv->vif to priv->vifs[0]
wifi: rtl8xxxu: support setting mac address register for both
interfaces
wifi: rtl8xxxu: extend wifi connected check to both interfaces
wifi: rtl8xxxu: extend check for matching bssid to both interfaces
wifi: rtl8xxxu: support setting bssid register for multiple interfaces
wifi: rtl8xxxu: support multiple interfaces in set_aifs()
wifi: rtl8xxxu: support multiple interfaces in
update_beacon_work_callback()
wifi: rtl8xxxu: support multiple interfaces in configure_filter()
wifi: rtl8xxxu: support multiple interfaces in watchdog_callback()
wifi: rtl8xxxu: support multiple interfaces in
{add,remove}_interface()
wifi: rtl8xxxu: support multiple interfaces in bss_info_changed()
wifi: rtl8xxxu: support multiple interface in start_ap()
wifi: rtl8xxxu: support multiple interfaces in get_macid()
wifi: rtl8xxxu: remove obsolete priv->vif
wifi: rtl8xxxu: add hw crypto support for AP mode
wifi: rtl8xxxu: make supporting AP mode only on port 0 transparent
wifi: rtl8xxxu: declare concurrent mode support for 8188f

.../net/wireless/realtek/rtl8xxxu/rtl8xxxu.h | 16 +-
.../realtek/rtl8xxxu/rtl8xxxu_8188e.c | 2 +-
.../realtek/rtl8xxxu/rtl8xxxu_8188f.c | 1 +
.../wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 361 +++++++++++++-----
4 files changed, 283 insertions(+), 97 deletions(-)

--
2.39.2



2023-12-18 14:39:35

by Martin Kaistra

[permalink] [raw]
Subject: [PATCH 03/20] wifi: rtl8xxxu: support setting linktype for both interfaces

To prepare for concurrent mode, enhance the set_linktype function to be
able to set the linktype in the MSR register for both hardware ports.

Until the users of set_linktype can handle multiple interfaces, use
port_num = 0.

Signed-off-by: Martin Kaistra <[email protected]>
---
.../wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 37 +++++++++++--------
1 file changed, 22 insertions(+), 15 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
index 5b7c20970a973..305d6dd585dfa 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
+++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
@@ -1633,33 +1633,41 @@ rtl8xxxu_gen1_set_tx_power(struct rtl8xxxu_priv *priv, int channel, bool ht40)
}

static void rtl8xxxu_set_linktype(struct rtl8xxxu_priv *priv,
- enum nl80211_iftype linktype)
+ enum nl80211_iftype linktype, int port_num)
{
- u8 val8;
-
- val8 = rtl8xxxu_read8(priv, REG_MSR);
- val8 &= ~MSR_LINKTYPE_MASK;
+ u8 val8, type;

switch (linktype) {
case NL80211_IFTYPE_UNSPECIFIED:
- val8 |= MSR_LINKTYPE_NONE;
+ type = MSR_LINKTYPE_NONE;
break;
case NL80211_IFTYPE_ADHOC:
- val8 |= MSR_LINKTYPE_ADHOC;
+ type = MSR_LINKTYPE_ADHOC;
break;
case NL80211_IFTYPE_STATION:
- val8 |= MSR_LINKTYPE_STATION;
+ type = MSR_LINKTYPE_STATION;
break;
case NL80211_IFTYPE_AP:
- val8 |= MSR_LINKTYPE_AP;
+ type = MSR_LINKTYPE_AP;
break;
default:
- goto out;
+ return;
+ }
+
+ switch (port_num) {
+ case 0:
+ val8 = rtl8xxxu_read8(priv, REG_MSR) & 0x0c;
+ val8 |= type;
+ break;
+ case 1:
+ val8 = rtl8xxxu_read8(priv, REG_MSR) & 0x03;
+ val8 |= type << 2;
+ break;
+ default:
+ return;
}

rtl8xxxu_write8(priv, REG_MSR, val8);
-out:
- return;
}

static void
@@ -4236,7 +4244,6 @@ static int rtl8xxxu_init_device(struct ieee80211_hw *hw)
}

rtl8xxxu_set_mac(priv);
- rtl8xxxu_set_linktype(priv, NL80211_IFTYPE_STATION);

/*
* Configure initial WMAC settings
@@ -4964,7 +4971,7 @@ rtl8xxxu_bss_info_changed(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
if (changed & BSS_CHANGED_ASSOC) {
dev_dbg(dev, "Changed ASSOC: %i!\n", vif->cfg.assoc);

- rtl8xxxu_set_linktype(priv, vif->type);
+ rtl8xxxu_set_linktype(priv, vif->type, 0);

if (vif->cfg.assoc) {
u32 ramask;
@@ -6610,7 +6617,7 @@ static int rtl8xxxu_add_interface(struct ieee80211_hw *hw,
ret = -EOPNOTSUPP;
}

- rtl8xxxu_set_linktype(priv, vif->type);
+ rtl8xxxu_set_linktype(priv, vif->type, 0);
ether_addr_copy(priv->mac_addr, vif->addr);
rtl8xxxu_set_mac(priv);

--
2.39.2


2023-12-18 14:39:43

by Martin Kaistra

[permalink] [raw]
Subject: [PATCH 11/20] wifi: rtl8xxxu: support multiple interfaces in configure_filter()

As we only want to support AP mode/sending beacons on port 0, change
from priv->vif to priv->vifs[0] in the check for AP mode.
Additionally, if we are in AP mode, don't filter RX beacon and probe
response frames to still allow working STATION mode on the other
interface.

Signed-off-by: Martin Kaistra <[email protected]>
---
drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
index 6683ff0f4d8c7..f54d7b1647792 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
+++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
@@ -6782,8 +6782,8 @@ static void rtl8xxxu_configure_filter(struct ieee80211_hw *hw,
else
rcr |= RCR_CHECK_BSSID_BEACON | RCR_CHECK_BSSID_MATCH;

- if (priv->vif && priv->vif->type == NL80211_IFTYPE_AP)
- rcr &= ~RCR_CHECK_BSSID_MATCH;
+ if (priv->vifs[0] && priv->vifs[0]->type == NL80211_IFTYPE_AP)
+ rcr &= ~(RCR_CHECK_BSSID_MATCH | RCR_CHECK_BSSID_BEACON);

if (*total_flags & FIF_CONTROL)
rcr |= RCR_ACCEPT_CTRL_FRAME;
--
2.39.2


2023-12-18 14:39:51

by Martin Kaistra

[permalink] [raw]
Subject: [PATCH 09/20] wifi: rtl8xxxu: support multiple interfaces in set_aifs()

In concurrent mode supported by this driver, both interfaces will use
the same channel and same wireless mode.
It is therefore possible to get the wireless mode by checking the first
connected interface.

Signed-off-by: Martin Kaistra <[email protected]>
---
.../wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 18 +++++++++++-------
1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
index 2b546bce01237..827e715f0e585 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
+++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
@@ -4913,14 +4913,18 @@ static void rtl8xxxu_set_aifs(struct rtl8xxxu_priv *priv, u8 slot_time)
u8 aifs, aifsn, sifs;
int i;

- if (priv->vif) {
- struct ieee80211_sta *sta;
+ for (i = 0; i < ARRAY_SIZE(priv->vifs); i++) {
+ if (priv->vifs[i]) {
+ struct ieee80211_sta *sta;

- rcu_read_lock();
- sta = ieee80211_find_sta(priv->vif, priv->vif->bss_conf.bssid);
- if (sta)
- wireless_mode = rtl8xxxu_wireless_mode(priv->hw, sta);
- rcu_read_unlock();
+ rcu_read_lock();
+ sta = ieee80211_find_sta(priv->vifs[i], priv->vifs[i]->bss_conf.bssid);
+ if (sta)
+ wireless_mode = rtl8xxxu_wireless_mode(priv->hw, sta);
+ rcu_read_unlock();
+ }
+ if (wireless_mode)
+ break;
}

if (priv->hw->conf.chandef.chan->band == NL80211_BAND_5GHZ ||
--
2.39.2


2023-12-18 14:41:03

by Martin Kaistra

[permalink] [raw]
Subject: [PATCH 20/20] wifi: rtl8xxxu: declare concurrent mode support for 8188f

Everything is in place now for concurrent mode, we can tell the system
that we support it.
We will allow a maximum of 2 virtual interfaces, one of them can be in
AP mode.

Signed-off-by: Martin Kaistra <[email protected]>
---
.../net/wireless/realtek/rtl8xxxu/rtl8xxxu.h | 1 +
.../realtek/rtl8xxxu/rtl8xxxu_8188f.c | 1 +
.../wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 19 +++++++++++++++++++
3 files changed, 21 insertions(+)

diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h
index a0222d2666000..f0c21a41b4b85 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h
+++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h
@@ -1991,6 +1991,7 @@ struct rtl8xxxu_fileops {
u8 init_reg_rxfltmap:1;
u8 init_reg_pkt_life_time:1;
u8 init_reg_hmtfr:1;
+ u8 supports_concurrent:1;
u8 ampdu_max_time;
u8 ustime_tsf_edca;
u16 max_aggr_num;
diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188f.c b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188f.c
index 1e1c8fa194cb8..80f3c39c7444a 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188f.c
+++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188f.c
@@ -1751,6 +1751,7 @@ struct rtl8xxxu_fileops rtl8188fu_fops = {
.max_aggr_num = 0x0c14,
.supports_ap = 1,
.max_macid_num = 16,
+ .supports_concurrent = 1,
.adda_1t_init = 0x03c00014,
.adda_1t_path_on = 0x03c00014,
.trxff_boundary = 0x3f7f,
diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
index 595f447874f4d..32fd723687e90 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
+++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
@@ -7634,6 +7634,20 @@ static void rtl8xxxu_deinit_led(struct rtl8xxxu_priv *priv)
led_classdev_unregister(led);
}

+struct ieee80211_iface_limit rtl8xxxu_limits[] = {
+ { .max = 2, .types = BIT(NL80211_IFTYPE_STATION), },
+ { .max = 1, .types = BIT(NL80211_IFTYPE_AP), },
+};
+
+struct ieee80211_iface_combination rtl8xxxu_combinations[] = {
+ {
+ .limits = rtl8xxxu_limits,
+ .n_limits = ARRAY_SIZE(rtl8xxxu_limits),
+ .max_interfaces = 2,
+ .num_different_channels = 1,
+ },
+};
+
static int rtl8xxxu_probe(struct usb_interface *interface,
const struct usb_device_id *id)
{
@@ -7780,6 +7794,11 @@ static int rtl8xxxu_probe(struct usb_interface *interface,
hw->wiphy->interface_modes |= BIT(NL80211_IFTYPE_AP);
hw->queues = 4;

+ if (priv->fops->supports_concurrent) {
+ hw->wiphy->iface_combinations = rtl8xxxu_combinations;
+ hw->wiphy->n_iface_combinations = ARRAY_SIZE(rtl8xxxu_combinations);
+ }
+
sband = &rtl8xxxu_supported_band;
sband->ht_cap.ht_supported = true;
sband->ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K;
--
2.39.2


2023-12-19 22:14:01

by Bitterblue Smith

[permalink] [raw]
Subject: Re: [PATCH 00/20] wifi: rtl8xxxu: Add concurrent mode for 8188f

On 18/12/2023 16:36, Martin Kaistra wrote:
> This series adds the possibility to use two virtual interfaces on the
> same channel. Supported combinations are STA+STA and STA+AP. The
> conversion of the driver to support multiple interfaces is split into
> individual patches to hopefully make it easier to understand what is
> going on.
>
> Thanks,
> Martin
>

Nice work! I'm glad to see this driver get more features.

2023-12-20 05:56:24

by Ping-Ke Shih

[permalink] [raw]
Subject: RE: [PATCH 09/20] wifi: rtl8xxxu: support multiple interfaces in set_aifs()



> -----Original Message-----
> From: Martin Kaistra <[email protected]>
> Sent: Monday, December 18, 2023 10:37 PM
> To: [email protected]
> Cc: Jes Sorensen <[email protected]>; Kalle Valo <[email protected]>; Ping-Ke Shih
> <[email protected]>; Bitterblue Smith <[email protected]>; Sebastian Andrzej Siewior
> <[email protected]>
> Subject: [PATCH 09/20] wifi: rtl8xxxu: support multiple interfaces in set_aifs()
>
> In concurrent mode supported by this driver, both interfaces will use
> the same channel and same wireless mode.
> It is therefore possible to get the wireless mode by checking the first
> connected interface.
>
> Signed-off-by: Martin Kaistra <[email protected]>
> ---
> .../wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 18 +++++++++++-------
> 1 file changed, 11 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
> b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
> index 2b546bce01237..827e715f0e585 100644
> --- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
> +++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
> @@ -4913,14 +4913,18 @@ static void rtl8xxxu_set_aifs(struct rtl8xxxu_priv *priv, u8 slot_time)
> u8 aifs, aifsn, sifs;
> int i;
>
> - if (priv->vif) {
> - struct ieee80211_sta *sta;
> + for (i = 0; i < ARRAY_SIZE(priv->vifs); i++) {
> + if (priv->vifs[i]) {

if (!priv->vifs[i])
continue;

Then, you can only stir few code.

Ping-Ke


2023-12-20 06:33:38

by Ping-Ke Shih

[permalink] [raw]
Subject: RE: [PATCH 00/20] wifi: rtl8xxxu: Add concurrent mode for 8188f



> -----Original Message-----
> From: Bitterblue Smith <[email protected]>
> Sent: Wednesday, December 20, 2023 6:03 AM
> To: Martin Kaistra <[email protected]>; [email protected]
> Cc: Jes Sorensen <[email protected]>; Kalle Valo <[email protected]>; Ping-Ke Shih
> <[email protected]>; Sebastian Andrzej Siewior <[email protected]>
> Subject: Re: [PATCH 00/20] wifi: rtl8xxxu: Add concurrent mode for 8188f
>
> On 18/12/2023 16:36, Martin Kaistra wrote:
> > This series adds the possibility to use two virtual interfaces on the
> > same channel. Supported combinations are STA+STA and STA+AP. The
> > conversion of the driver to support multiple interfaces is split into
> > individual patches to hopefully make it easier to understand what is
> > going on.
> >
> > Thanks,
> > Martin
> >
>
> Nice work! I'm glad to see this driver get more features.

Agree! It seems this driver can possible to support P2P as well.

I have reviewed this patchset, and please feel free to add my reviewed-by
Reviewed-by: Ping-Ke Shih <[email protected]>
if I have no comment on patches and you don't change them by v2.

Ping-Ke