2022-09-14 03:38:12

by Ian Lin

[permalink] [raw]
Subject: [PATCH 0/5] Fix connect/p2p issue series

Fix several connect and p2p issues.

Brian Henriquez (1):
brcmfmac: correctly remove all p2p vif

Chung-Hsien Hsu (1):
brcmfmac: fix P2P device discovery failure

Prasanna Kerekoppa (1):
brcmfmac: Avoiding Connection delay

Syed Rafiuddeen (1):
brcmfmac: Update SSID of hidden AP while informing its bss to cfg80211
layer

Wataru Gohda (1):
brcmfmac: Fix for when connect request is not success

.../broadcom/brcm80211/brcmfmac/cfg80211.c | 31 +++++++++++++++++--
.../broadcom/brcm80211/brcmfmac/p2p.c | 10 ++++--
2 files changed, 36 insertions(+), 5 deletions(-)

--
2.25.0


2022-09-14 03:38:42

by Ian Lin

[permalink] [raw]
Subject: [PATCH 1/5] brcmfmac: correctly remove all p2p vif

From: Brian Henriquez <[email protected]>

When deleting a P2P AGO interface we should make sure that
relevant entry in bss_idx[] array is removed. We were always
removing only 'vif' at P2PAPI_BSSCFG_CONNECTION before,
regardless of the number of created P2P AGO interfaces.
brcmfmac: correctly remove all p2p vif

Signed-off-by: Brian Henriquez <[email protected]>
Signed-off-by: Chi-hsien Lin <[email protected]>
Signed-off-by: Ian Lin <[email protected]>
---
drivers/net/wireless/broadcom/brcm80211/brcmfmac/p2p.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/p2p.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/p2p.c
index 479041f070f9..b3d706a2e68c 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/p2p.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/p2p.c
@@ -2424,8 +2424,12 @@ int brcmf_p2p_del_vif(struct wiphy *wiphy, struct wireless_dev *wdev)
brcmf_remove_interface(vif->ifp, true);

brcmf_cfg80211_arm_vif_event(cfg, NULL);
- if (iftype != NL80211_IFTYPE_P2P_DEVICE)
- p2p->bss_idx[P2PAPI_BSSCFG_CONNECTION].vif = NULL;
+ if (iftype != NL80211_IFTYPE_P2P_DEVICE) {
+ if (vif == p2p->bss_idx[P2PAPI_BSSCFG_CONNECTION].vif)
+ p2p->bss_idx[P2PAPI_BSSCFG_CONNECTION].vif = NULL;
+ if (vif == p2p->bss_idx[P2PAPI_BSSCFG_CONNECTION2].vif)
+ p2p->bss_idx[P2PAPI_BSSCFG_CONNECTION2].vif = NULL;
+ }

return err;
}
--
2.25.0

2022-09-14 03:38:42

by Ian Lin

[permalink] [raw]
Subject: [PATCH 2/5] brcmfmac: Fix for when connect request is not success

From: Wataru Gohda <[email protected]>

Currently brcmfmac is expecting to be set for both
BRCMF_VIF_STATUS_EAP_SUCCESS and BRCMF_VIF_STATUS_EAP status bit based
on dongle event and those bits are cleared to complete connect request
successfully.

But when connect request is finished unsuccessfully, either
BRCMF_VIF_STATUS_EAP_SUCCESS / BRCMF_VIF_STATUS_EAP bits are not
cleared depending on how the connect fail event happens. These status
bits are carried over to following new connect request and this will lead
to generate below kernel warning for some case. Worst case status
mismatch happens between dongle and wpa_supplicant.

WARNING: ../net/wireless/sme.c:756 __cfg80211_connect_result+0x42c/0x4a0 [cfg80211]

The fix is to clear the BRCMF_VIF_STATUS_EAP_SUCCESS /
BRCMF_VIF_STATUS_EAP bits during the link down process and add to call
link down process when link down event received during
BRCMF_VIF_STATUS_CONNECTING as well as BRCMF_VIF_STATUS_CONNECTED
state.

Signed-off-by: Wataru Gohda <[email protected]>
Signed-off-by: Chi-hsien Lin <[email protected]>
Signed-off-by: Ian Lin <[email protected]>
---
.../broadcom/brcm80211/brcmfmac/cfg80211.c | 18 +++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
index 7c72ea26a7d7..7e9354768cfe 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
@@ -1417,6 +1417,8 @@ static void brcmf_link_down(struct brcmf_cfg80211_vif *vif, u16 reason,
locally_generated, GFP_KERNEL);
}
clear_bit(BRCMF_VIF_STATUS_CONNECTING, &vif->sme_state);
+ clear_bit(BRCMF_VIF_STATUS_EAP_SUCCESS, &vif->sme_state);
+ clear_bit(BRCMF_VIF_STATUS_ASSOC_SUCCESS, &vif->sme_state);
clear_bit(BRCMF_SCAN_STATUS_SUPPRESS, &cfg->scan_status);
brcmf_btcoex_set_mode(vif, BRCMF_BTCOEX_ENABLED, 0);
if (vif->profile.use_fwsup != BRCMF_PROFILE_FWSUP_NONE) {
@@ -2269,6 +2271,8 @@ brcmf_cfg80211_disconnect(struct wiphy *wiphy, struct net_device *ndev,

clear_bit(BRCMF_VIF_STATUS_CONNECTED, &ifp->vif->sme_state);
clear_bit(BRCMF_VIF_STATUS_CONNECTING, &ifp->vif->sme_state);
+ clear_bit(BRCMF_VIF_STATUS_EAP_SUCCESS, &ifp->vif->sme_state);
+ clear_bit(BRCMF_VIF_STATUS_ASSOC_SUCCESS, &ifp->vif->sme_state);
cfg80211_disconnected(ndev, reason_code, NULL, 0, true, GFP_KERNEL);

memcpy(&scbval.ea, &profile->bssid, ETH_ALEN);
@@ -6063,6 +6067,10 @@ brcmf_bss_connect_done(struct brcmf_cfg80211_info *cfg,
&ifp->vif->sme_state);
conn_params.status = WLAN_STATUS_SUCCESS;
} else {
+ clear_bit(BRCMF_VIF_STATUS_EAP_SUCCESS,
+ &ifp->vif->sme_state);
+ clear_bit(BRCMF_VIF_STATUS_ASSOC_SUCCESS,
+ &ifp->vif->sme_state);
conn_params.status = WLAN_STATUS_AUTH_TIMEOUT;
}
conn_params.links[0].bssid = profile->bssid;
@@ -6160,9 +6168,13 @@ brcmf_notify_connect_status(struct brcmf_if *ifp,
} else if (brcmf_is_linkdown(ifp->vif, e)) {
brcmf_dbg(CONN, "Linkdown\n");
if (!brcmf_is_ibssmode(ifp->vif) &&
- test_bit(BRCMF_VIF_STATUS_CONNECTED,
- &ifp->vif->sme_state)) {
- if (memcmp(profile->bssid, e->addr, ETH_ALEN))
+ (test_bit(BRCMF_VIF_STATUS_CONNECTED,
+ &ifp->vif->sme_state) ||
+ test_bit(BRCMF_VIF_STATUS_CONNECTING,
+ &ifp->vif->sme_state))) {
+ if (test_bit(BRCMF_VIF_STATUS_CONNECTED,
+ &ifp->vif->sme_state) &&
+ memcmp(profile->bssid, e->addr, ETH_ALEN))
return err;

brcmf_bss_connect_done(cfg, ndev, e, false);
--
2.25.0

2022-09-14 03:38:59

by Ian Lin

[permalink] [raw]
Subject: [PATCH 3/5] brcmfmac: Avoiding Connection delay

From: Prasanna Kerekoppa <[email protected]>

Channel info passed by supplicant is not given to firmware. This causes
delay (about 3seconds) due to full scan. Supplicant already provides the
channel info for the specific SSID. channel_hint carries this channel
info for the connect call back.

Patch has been verified on 43012 and 43455.

Signed-off-by: Prasanna Kerekoppa <[email protected]>
Signed-off-by: Chung-Hsien Hsu <[email protected]>
Signed-off-by: Chi-hsien Lin <[email protected]>
Signed-off-by: Ian Lin <[email protected]>
---
drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c | 6 ++++++
1 file changed, 6 insertions(+)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
index 7e9354768cfe..eba03a994e95 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
@@ -2049,6 +2049,12 @@ brcmf_cfg80211_connect(struct wiphy *wiphy, struct net_device *ndev,
return -EOPNOTSUPP;
}

+ if (sme->channel_hint)
+ chan = sme->channel_hint;
+
+ if (sme->bssid_hint)
+ sme->bssid = sme->bssid_hint;
+
if (ifp->vif == cfg->p2p.bss_idx[P2PAPI_BSSCFG_PRIMARY].vif) {
/* A normal (non P2P) connection request setup. */
ie = NULL;
--
2.25.0

2022-09-14 03:38:59

by Ian Lin

[permalink] [raw]
Subject: [PATCH 4/5] brcmfmac: Update SSID of hidden AP while informing its bss to cfg80211 layer

From: Syed Rafiuddeen <[email protected]>

cfg80211 layer on DUT STA is disconnecting ongoing connection attempt after
receiving association response, because cfg80211 layer does not have valid
AP bss information. On association response event, brcmfmac communicates
the AP bss information to cfg80211 layer, but SSID seem to be empty in AP
bss information, and cfg80211 layer prints kernel warning and then
disconnects the ongoing connection attempt.

SSID is empty in SSID IE, but 'bi->SSID' contains a valid SSID, so
updating the SSID for hidden AP while informing its bss information
to cfg80211 layer.

Signed-off-by: Syed Rafiuddeen <[email protected]>
Signed-off-by: Chung-Hsien Hsu <[email protected]>
Signed-off-by: Chi-hsien Lin <[email protected]>
Signed-off-by: Ian Lin <[email protected]>
---
.../net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c | 7 +++++++
1 file changed, 7 insertions(+)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
index eba03a994e95..ca5cbbb622d2 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
@@ -3003,6 +3003,7 @@ static s32 brcmf_inform_single_bss(struct brcmf_cfg80211_info *cfg,
u8 *notify_ie;
size_t notify_ielen;
struct cfg80211_inform_bss bss_data = {};
+ const struct brcmf_tlv *ssid = NULL;

if (le32_to_cpu(bi->length) > WL_BSS_INFO_MAX) {
bphy_err(drvr, "Bss info is larger than buffer. Discarding\n");
@@ -3032,6 +3033,12 @@ static s32 brcmf_inform_single_bss(struct brcmf_cfg80211_info *cfg,
notify_ielen = le32_to_cpu(bi->ie_length);
bss_data.signal = (s16)le16_to_cpu(bi->RSSI) * 100;

+ ssid = brcmf_parse_tlvs(notify_ie, notify_ielen, WLAN_EID_SSID);
+ if (ssid && ssid->data[0] == '\0' && ssid->len == bi->SSID_len) {
+ /* Update SSID for hidden AP */
+ memcpy((u8 *)ssid->data, bi->SSID, bi->SSID_len);
+ }
+
brcmf_dbg(CONN, "bssid: %pM\n", bi->BSSID);
brcmf_dbg(CONN, "Channel: %d(%d)\n", channel, freq);
brcmf_dbg(CONN, "Capability: %X\n", notify_capability);
--
2.25.0

2022-09-14 03:39:23

by Ian Lin

[permalink] [raw]
Subject: [PATCH 5/5] brcmfmac: fix P2P device discovery failure

From: Chung-Hsien Hsu <[email protected]>

Commit 2de64ca7c9fa ("brcmfmac: p2p: Deal with set but unused
variables") removed the setting of vif for p2p device discovery in
brcmf_p2p_scan_prep(), causing the discovery failure.

Add back the setting to brcmf_p2p_scan_prep() to fix this.

Fixes: 2de64ca7c9fa ("brcmfmac: p2p: Deal with set but unused variables")
Signed-off-by: Chung-Hsien Hsu <[email protected]>
Signed-off-by: Ian Lin <[email protected]>
---
drivers/net/wireless/broadcom/brcm80211/brcmfmac/p2p.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/p2p.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/p2p.c
index b3d706a2e68c..068f8fe0e0c4 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/p2p.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/p2p.c
@@ -912,6 +912,8 @@ int brcmf_p2p_scan_prep(struct wiphy *wiphy,
if (err)
return err;

+ vif = p2p->bss_idx[P2PAPI_BSSCFG_DEVICE].vif;
+
/* override .run_escan() callback. */
cfg->escan_info.run = brcmf_p2p_run_escan;
}
--
2.25.0

2022-09-22 05:09:43

by Kalle Valo

[permalink] [raw]
Subject: Re: [PATCH 4/5] brcmfmac: Update SSID of hidden AP while informing its bss to cfg80211 layer

Ian Lin <[email protected]> writes:

> From: Syed Rafiuddeen <[email protected]>
>
> cfg80211 layer on DUT STA is disconnecting ongoing connection attempt after
> receiving association response, because cfg80211 layer does not have valid
> AP bss information. On association response event, brcmfmac communicates
> the AP bss information to cfg80211 layer, but SSID seem to be empty in AP
> bss information, and cfg80211 layer prints kernel warning and then
> disconnects the ongoing connection attempt.
>
> SSID is empty in SSID IE, but 'bi->SSID' contains a valid SSID, so
> updating the SSID for hidden AP while informing its bss information
> to cfg80211 layer.
>
> Signed-off-by: Syed Rafiuddeen <[email protected]>

Syed's email address in From does not match with s-o-b.

> @@ -3032,6 +3033,12 @@ static s32 brcmf_inform_single_bss(struct brcmf_cfg80211_info *cfg,
> notify_ielen = le32_to_cpu(bi->ie_length);
> bss_data.signal = (s16)le16_to_cpu(bi->RSSI) * 100;
>
> + ssid = brcmf_parse_tlvs(notify_ie, notify_ielen, WLAN_EID_SSID);
> + if (ssid && ssid->data[0] == '\0' && ssid->len == bi->SSID_len) {
> + /* Update SSID for hidden AP */
> + memcpy((u8 *)ssid->data, bi->SSID, bi->SSID_len);
> + }

memcpy() takes a void pointer so the cast is not needed.

--
https://patchwork.kernel.org/project/linux-wireless/list/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches

2022-09-23 02:06:28

by Ian Lin

[permalink] [raw]
Subject: Re: [PATCH 4/5] brcmfmac: Update SSID of hidden AP while informing its bss to cfg80211 layer



On 9/22/2022 12:44 PM, Kalle Valo wrote:
> Ian Lin <[email protected]> writes:
>
>> From: Syed Rafiuddeen <[email protected]>
>>
>> cfg80211 layer on DUT STA is disconnecting ongoing connection attempt after
>> receiving association response, because cfg80211 layer does not have valid
>> AP bss information. On association response event, brcmfmac communicates
>> the AP bss information to cfg80211 layer, but SSID seem to be empty in AP
>> bss information, and cfg80211 layer prints kernel warning and then
>> disconnects the ongoing connection attempt.
>>
>> SSID is empty in SSID IE, but 'bi->SSID' contains a valid SSID, so
>> updating the SSID for hidden AP while informing its bss information
>> to cfg80211 layer.
>>
>> Signed-off-by: Syed Rafiuddeen <[email protected]>
> Syed's email address in From does not match with s-o-b.
>
>> @@ -3032,6 +3033,12 @@ static s32 brcmf_inform_single_bss(struct brcmf_cfg80211_info *cfg,
>> notify_ielen = le32_to_cpu(bi->ie_length);
>> bss_data.signal = (s16)le16_to_cpu(bi->RSSI) * 100;
>>
>> + ssid = brcmf_parse_tlvs(notify_ie, notify_ielen, WLAN_EID_SSID);
>> + if (ssid && ssid->data[0] == '\0' && ssid->len == bi->SSID_len) {
>> + /* Update SSID for hidden AP */
>> + memcpy((u8 *)ssid->data, bi->SSID, bi->SSID_len);
>> + }
> memcpy() takes a void pointer so the cast is not needed.
There should be a type casting since 'ssid' is a const pointer.
As you saw there will be build warning in PATCH v2 (sorry I didn't
notice that locally)
I will send PATCH v3 to restore type casting, is that ok?

2022-09-23 15:35:06

by Jeff Johnson

[permalink] [raw]
Subject: Re: [PATCH 4/5] brcmfmac: Update SSID of hidden AP while informing its bss to cfg80211 layer

On 9/22/2022 6:52 PM, Lin Ian (CSSITB CSS ICW SW WFS / EE) wrote:
>
>
> On 9/22/2022 12:44 PM, Kalle Valo wrote:
>> Ian Lin <[email protected]> writes:
>>
>>> From: Syed Rafiuddeen <[email protected]>
>>>
>>> cfg80211 layer on DUT STA is disconnecting ongoing connection attempt
>>> after
>>> receiving association response, because cfg80211 layer does not have
>>> valid
>>> AP bss information. On association response event, brcmfmac communicates
>>> the AP bss information to cfg80211 layer, but SSID seem to be empty
>>> in AP
>>> bss information, and cfg80211 layer prints kernel warning and then
>>> disconnects the ongoing connection attempt.
>>>
>>> SSID is empty in SSID IE, but 'bi->SSID' contains a valid SSID, so
>>> updating the SSID for hidden AP while informing its bss information
>>> to cfg80211 layer.
>>>
>>> Signed-off-by: Syed Rafiuddeen <[email protected]>
>> Syed's email address in From does not match with s-o-b.
>>
>>> @@ -3032,6 +3033,12 @@ static s32 brcmf_inform_single_bss(struct
>>> brcmf_cfg80211_info *cfg,
>>>        notify_ielen = le32_to_cpu(bi->ie_length);
>>>        bss_data.signal = (s16)le16_to_cpu(bi->RSSI) * 100;
>>>
>>> +     ssid = brcmf_parse_tlvs(notify_ie, notify_ielen, WLAN_EID_SSID);
>>> +     if (ssid && ssid->data[0] == '\0' && ssid->len == bi->SSID_len) {
>>> +             /* Update SSID for hidden AP */
>>> +             memcpy((u8 *)ssid->data, bi->SSID, bi->SSID_len);
>>> +     }
>> memcpy() takes a void pointer so the cast is not needed.
> There should be a type casting since 'ssid' is a const pointer.
> As you saw there will be build warning in PATCH v2 (sorry I didn't
> notice that locally)
> I will send PATCH v3 to restore type casting, is that ok?
>

writing through a const pointer seems broken.
Should you instead remove the const qualifier from the declaration?
const struct brcmf_tlv *ssid = NULL;

if the problem is that brcmf_parse_tlvs() itself returns a const
pointer, then I'd typecast during the assignment instead of the memcpy()
call.

also note the NULL initializer is unnecessary since it is always
overwritten by the call to brcmf_parse_tlvs()


2022-09-26 08:05:19

by Kalle Valo

[permalink] [raw]
Subject: Re: [PATCH 4/5] brcmfmac: Update SSID of hidden AP while informing its bss to cfg80211 layer

Jeff Johnson <[email protected]> writes:

>>>> @@ -3032,6 +3033,12 @@ static s32 brcmf_inform_single_bss(struct
>>>> brcmf_cfg80211_info *cfg,
>>>>        notify_ielen = le32_to_cpu(bi->ie_length);
>>>>        bss_data.signal = (s16)le16_to_cpu(bi->RSSI) * 100;
>>>>
>>>> +     ssid = brcmf_parse_tlvs(notify_ie, notify_ielen, WLAN_EID_SSID);
>>>> +     if (ssid && ssid->data[0] == '\0' && ssid->len == bi->SSID_len) {
>>>> +             /* Update SSID for hidden AP */
>>>> +             memcpy((u8 *)ssid->data, bi->SSID, bi->SSID_len);
>>>> +     }
>>> memcpy() takes a void pointer so the cast is not needed.
>>
>> There should be a type casting since 'ssid' is a const pointer.
>> As you saw there will be build warning in PATCH v2 (sorry I didn't
>> notice that locally)
>> I will send PATCH v3 to restore type casting, is that ok?
>>
>
> writing through a const pointer seems broken.

Yeah, this is exactly why I don't like casting. I see so often casts
removing the const and that can lead to another problems.

--
https://patchwork.kernel.org/project/linux-wireless/list/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches