2023-12-18 14:38:22

by Martin Kaistra

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

As sta_info->macid does not get set in station mode, we can simplify
this function by directly returning 0 if sta itself or sta_info is not
set.

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

diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
index 3851fc90339e0..ad76cddef81b2 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
+++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
@@ -4053,10 +4053,13 @@ static inline u8 rtl8xxxu_get_macid(struct rtl8xxxu_priv *priv,
{
struct rtl8xxxu_sta_info *sta_info;

- if (!priv->vif || priv->vif->type == NL80211_IFTYPE_STATION || !sta)
+ if (!sta)
return 0;

sta_info = (struct rtl8xxxu_sta_info *)sta->drv_priv;
+ if (!sta_info)
+ return 0;
+
return sta_info->macid;
}

--
2.39.2



2023-12-20 06:14:59

by Ping-Ke Shih

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



> -----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 16/20] wifi: rtl8xxxu: support multiple interfaces in get_macid()
>
> As sta_info->macid does not get set in station mode, we can simplify
> this function by directly returning 0 if sta itself or sta_info is not
> set.
>
> Signed-off-by: Martin Kaistra <[email protected]>
> ---
> drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
> b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
> index 3851fc90339e0..ad76cddef81b2 100644
> --- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
> +++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
> @@ -4053,10 +4053,13 @@ static inline u8 rtl8xxxu_get_macid(struct rtl8xxxu_priv *priv,
> {
> struct rtl8xxxu_sta_info *sta_info;
>
> - if (!priv->vif || priv->vif->type == NL80211_IFTYPE_STATION || !sta)
> + if (!sta)
> return 0;
>
> sta_info = (struct rtl8xxxu_sta_info *)sta->drv_priv;
> + if (!sta_info)
> + return 0;
> +
> return sta_info->macid;

I checked where driver assign macid, and only

if (vif->type == NL80211_IFTYPE_AP) {
sta_info->macid = rtl8xxxu_acquire_macid(priv);

That means STA mode can be macid == 0 always, right?
This will be a problem. At least TX rate will be incorrect.

Ping-Ke


2023-12-20 16:40:35

by Martin Kaistra

[permalink] [raw]
Subject: Re: [PATCH 16/20] wifi: rtl8xxxu: support multiple interfaces in get_macid()

Am 20.12.23 um 07:14 schrieb Ping-Ke Shih:
>
>
>> -----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 16/20] wifi: rtl8xxxu: support multiple interfaces in get_macid()
>>
>> As sta_info->macid does not get set in station mode, we can simplify
>> this function by directly returning 0 if sta itself or sta_info is not
>> set.
>>
>> Signed-off-by: Martin Kaistra <[email protected]>
>> ---
>> drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 5 ++++-
>> 1 file changed, 4 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
>> b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
>> index 3851fc90339e0..ad76cddef81b2 100644
>> --- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
>> +++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
>> @@ -4053,10 +4053,13 @@ static inline u8 rtl8xxxu_get_macid(struct rtl8xxxu_priv *priv,
>> {
>> struct rtl8xxxu_sta_info *sta_info;
>>
>> - if (!priv->vif || priv->vif->type == NL80211_IFTYPE_STATION || !sta)
>> + if (!sta)
>> return 0;
>>
>> sta_info = (struct rtl8xxxu_sta_info *)sta->drv_priv;
>> + if (!sta_info)
>> + return 0;
>> +
>> return sta_info->macid;
>
> I checked where driver assign macid, and only
>
> if (vif->type == NL80211_IFTYPE_AP) {
> sta_info->macid = rtl8xxxu_acquire_macid(priv);
>
> That means STA mode can be macid == 0 always, right?
> This will be a problem. At least TX rate will be incorrect.

Yes, currently macid for STA mode is always 0. Would it be enough to set macid
in STA mode to either 0 or 1 depending on port_num?

>
> Ping-Ke
>


2023-12-21 08:10:39

by Ping-Ke Shih

[permalink] [raw]
Subject: Re: [PATCH 16/20] wifi: rtl8xxxu: support multiple interfaces in get_macid()

On Wed, 2023-12-20 at 17:40 +0100, Martin Kaistra wrote:
>
> Am 20.12.23 um 07:14 schrieb Ping-Ke Shih:
> >
> >
> > I checked where driver assign macid, and only
> >
> > if (vif->type == NL80211_IFTYPE_AP) {
> > sta_info->macid = rtl8xxxu_acquire_macid(priv);
> >
> > That means STA mode can be macid == 0 always, right?
> > This will be a problem. At least TX rate will be incorrect.
>
> Yes, currently macid for STA mode is always 0. Would it be enough to set macid
> in STA mode to either 0 or 1 depending on port_num?
>

I am not very sure if macid 0 plays a special role, but others (macid >= 1)
can be dynamically assigned to each stations.

I think we can reserve macid 0 and 1 for port 0 and 1 respectively,
and dynamically assign macid 2 or larger to TDLS or AP mode peer, like

macid port num STA mode AP mode
------ ---------- ------------- ---------------------------
0 0 to/from AP broadcast
1 1 to/from AP X
2~ 0 or 1 to/from TDLS to/from connected station