Skip to content

Commit a21bf90

Browse files
jwrdegoedeKalle Valo
authored andcommitted
brcmfmac: use ISO3166 country code and 0 rev as fallback on some devices
This is a second attempt at honering the country code send out by access points. This was first added in commit b0b524f ("brcmfmac: use ISO3166 country code and 0 rev as fallback"). Subsequently this was reverted in commit 151a7c1 ("Revert "brcmfmac: use ISO3166 country code and 0 rev as fallback""), because it was causing issues with AP mode on some brcmfmac models (specifically on BCM4359/9). Many devices ship with a nvram ccode value of X2/XT/XU/XV/ALL which are all special world-wide compatibility ccode-s. Most of these world-wide ccode-s allow passive scan mode only for 2.4GHz channels 12-14, only enabling them when an AP is seen on them. But at least on brcmfmac43455 devices this is not working correctly, these do not see accesspoints on channels 12-14 unless the ccode is changes to a country where these channels are allowed. Translating received country codes to an ISO3166 country code and 0 rev ccreq fixes devices using a brcmfmac43455 with a X2/XT/XU/XV/ALL ccode not seeing accesspoints on channels 12-14. To avoid this causing issues on other brcmfmac models again, the fallback is limited to only brcmfmac4345* chips this time. Cc: Shawn Guo <[email protected]> Cc: Soeren Moch <[email protected]> Cc: Fabio Aiuto <[email protected]> Signed-off-by: Hans de Goede <[email protected]> Tested-by: Soeren Moch <[email protected]>  # on BCM4359/9 Signed-off-by: Kalle Valo <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent db38d9c commit a21bf90

File tree

1 file changed

+27
-6
lines changed
  • drivers/net/wireless/broadcom/brcm80211/brcmfmac

1 file changed

+27
-6
lines changed

drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include <brcmu_utils.h>
1717
#include <defs.h>
1818
#include <brcmu_wifi.h>
19+
#include <brcm_hw_ids.h>
1920
#include "core.h"
2021
#include "debug.h"
2122
#include "tracepoint.h"
@@ -7476,6 +7477,16 @@ int brcmf_cfg80211_wait_vif_event(struct brcmf_cfg80211_info *cfg,
74767477
vif_event_equals(event, action), timeout);
74777478
}
74787479

7480+
static bool brmcf_use_iso3166_ccode_fallback(struct brcmf_pub *drvr)
7481+
{
7482+
switch (drvr->bus_if->chip) {
7483+
case BRCM_CC_4345_CHIP_ID:
7484+
return true;
7485+
default:
7486+
return false;
7487+
}
7488+
}
7489+
74797490
static s32 brcmf_translate_country_code(struct brcmf_pub *drvr, char alpha2[2],
74807491
struct brcmf_fil_country_le *ccreq)
74817492
{
@@ -7484,18 +7495,28 @@ static s32 brcmf_translate_country_code(struct brcmf_pub *drvr, char alpha2[2],
74847495
s32 found_index;
74857496
int i;
74867497

7487-
country_codes = drvr->settings->country_codes;
7488-
if (!country_codes) {
7489-
brcmf_dbg(TRACE, "No country codes configured for device\n");
7490-
return -EINVAL;
7491-
}
7492-
74937498
if ((alpha2[0] == ccreq->country_abbrev[0]) &&
74947499
(alpha2[1] == ccreq->country_abbrev[1])) {
74957500
brcmf_dbg(TRACE, "Country code already set\n");
74967501
return -EAGAIN;
74977502
}
74987503

7504+
country_codes = drvr->settings->country_codes;
7505+
if (!country_codes) {
7506+
if (brmcf_use_iso3166_ccode_fallback(drvr)) {
7507+
brcmf_dbg(TRACE, "No country codes configured for device, using ISO3166 code and 0 rev\n");
7508+
memset(ccreq, 0, sizeof(*ccreq));
7509+
ccreq->country_abbrev[0] = alpha2[0];
7510+
ccreq->country_abbrev[1] = alpha2[1];
7511+
ccreq->ccode[0] = alpha2[0];
7512+
ccreq->ccode[1] = alpha2[1];
7513+
return 0;
7514+
}
7515+
7516+
brcmf_dbg(TRACE, "No country codes configured for device\n");
7517+
return -EINVAL;
7518+
}
7519+
74997520
found_index = -1;
75007521
for (i = 0; i < country_codes->table_size; i++) {
75017522
cc = &country_codes->table[i];

0 commit comments

Comments
 (0)