Skip to content

Commit 2e5f66f

Browse files
Pontus FuchsKalle Valo
authored andcommitted
brcmfmac: Build wiphy mode and interface combinations dynamically
Switch from using semi hard coded interface combinations. This makes it easier to announce what the firmware actually supports. This fixes the case where brcmfmac announces p2p but the firmware doesn't support it. Reviewed-by: Pieter-Paul Giesberts <[email protected]> Reviewed-by: Hante Meuleman <[email protected]> Reviewed-by: Arend Van Spriel <[email protected]> Signed-off-by: Pontus Fuchs <[email protected]> Signed-off-by: Arend van Spriel <[email protected]> Signed-off-by: Kalle Valo <[email protected]>
1 parent 2b560d7 commit 2e5f66f

File tree

1 file changed

+68
-68
lines changed

1 file changed

+68
-68
lines changed

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

Lines changed: 68 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,6 @@
5252
#define BRCMF_PNO_SCAN_COMPLETE 1
5353
#define BRCMF_PNO_SCAN_INCOMPLETE 0
5454

55-
#define BRCMF_IFACE_MAX_CNT 3
56-
5755
#define WPA_OUI "\x00\x50\xF2" /* WPA OUI */
5856
#define WPA_OUI_TYPE 1
5957
#define RSN_OUI "\x00\x0F\xAC" /* RSN OUI */
@@ -5640,53 +5638,6 @@ static int brcmf_setup_wiphybands(struct wiphy *wiphy)
56405638
return 0;
56415639
}
56425640

5643-
static const struct ieee80211_iface_limit brcmf_iface_limits_mbss[] = {
5644-
{
5645-
.max = 1,
5646-
.types = BIT(NL80211_IFTYPE_STATION) |
5647-
BIT(NL80211_IFTYPE_ADHOC)
5648-
},
5649-
{
5650-
.max = 4,
5651-
.types = BIT(NL80211_IFTYPE_AP)
5652-
},
5653-
{
5654-
.max = 1,
5655-
.types = BIT(NL80211_IFTYPE_P2P_CLIENT) |
5656-
BIT(NL80211_IFTYPE_P2P_GO)
5657-
},
5658-
{
5659-
.max = 1,
5660-
.types = BIT(NL80211_IFTYPE_P2P_DEVICE)
5661-
}
5662-
};
5663-
5664-
static const struct ieee80211_iface_limit brcmf_iface_limits_sbss[] = {
5665-
{
5666-
.max = 2,
5667-
.types = BIT(NL80211_IFTYPE_STATION) |
5668-
BIT(NL80211_IFTYPE_ADHOC) |
5669-
BIT(NL80211_IFTYPE_AP)
5670-
},
5671-
{
5672-
.max = 1,
5673-
.types = BIT(NL80211_IFTYPE_P2P_CLIENT) |
5674-
BIT(NL80211_IFTYPE_P2P_GO)
5675-
},
5676-
{
5677-
.max = 1,
5678-
.types = BIT(NL80211_IFTYPE_P2P_DEVICE)
5679-
}
5680-
};
5681-
static struct ieee80211_iface_combination brcmf_iface_combos[] = {
5682-
{
5683-
.max_interfaces = BRCMF_IFACE_MAX_CNT,
5684-
.num_different_channels = 1,
5685-
.n_limits = ARRAY_SIZE(brcmf_iface_limits_sbss),
5686-
.limits = brcmf_iface_limits_sbss,
5687-
}
5688-
};
5689-
56905641
static const struct ieee80211_txrx_stypes
56915642
brcmf_txrx_stypes[NUM_NL80211_IFTYPES] = {
56925643
[NL80211_IFTYPE_STATION] = {
@@ -5716,6 +5667,67 @@ brcmf_txrx_stypes[NUM_NL80211_IFTYPES] = {
57165667
}
57175668
};
57185669

5670+
static int brcmf_setup_ifmodes(struct wiphy *wiphy, struct brcmf_if *ifp)
5671+
{
5672+
struct ieee80211_iface_combination *combo = NULL;
5673+
struct ieee80211_iface_limit *limits = NULL;
5674+
int i = 0, max_iface_cnt;
5675+
5676+
combo = kzalloc(sizeof(*combo), GFP_KERNEL);
5677+
if (!combo)
5678+
goto err;
5679+
5680+
limits = kzalloc(sizeof(*limits) * 4, GFP_KERNEL);
5681+
if (!limits)
5682+
goto err;
5683+
5684+
wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) |
5685+
BIT(NL80211_IFTYPE_ADHOC) |
5686+
BIT(NL80211_IFTYPE_AP);
5687+
5688+
if (brcmf_feat_is_enabled(ifp, BRCMF_FEAT_MCHAN))
5689+
combo->num_different_channels = 2;
5690+
else
5691+
combo->num_different_channels = 1;
5692+
5693+
if (brcmf_feat_is_enabled(ifp, BRCMF_FEAT_MBSS)) {
5694+
limits[i].max = 1;
5695+
limits[i++].types = BIT(NL80211_IFTYPE_STATION);
5696+
limits[i].max = 4;
5697+
limits[i++].types = BIT(NL80211_IFTYPE_AP);
5698+
max_iface_cnt = 5;
5699+
} else {
5700+
limits[i].max = 2;
5701+
limits[i++].types = BIT(NL80211_IFTYPE_STATION) |
5702+
BIT(NL80211_IFTYPE_AP);
5703+
max_iface_cnt = 2;
5704+
}
5705+
5706+
if (brcmf_feat_is_enabled(ifp, BRCMF_FEAT_P2P)) {
5707+
wiphy->interface_modes |= BIT(NL80211_IFTYPE_P2P_CLIENT) |
5708+
BIT(NL80211_IFTYPE_P2P_GO) |
5709+
BIT(NL80211_IFTYPE_P2P_DEVICE);
5710+
limits[i].max = 1;
5711+
limits[i++].types = BIT(NL80211_IFTYPE_P2P_CLIENT) |
5712+
BIT(NL80211_IFTYPE_P2P_GO);
5713+
limits[i].max = 1;
5714+
limits[i++].types = BIT(NL80211_IFTYPE_P2P_DEVICE);
5715+
max_iface_cnt += 2;
5716+
}
5717+
combo->max_interfaces = max_iface_cnt;
5718+
combo->limits = limits;
5719+
combo->n_limits = i;
5720+
5721+
wiphy->iface_combinations = combo;
5722+
wiphy->n_iface_combinations = 1;
5723+
return 0;
5724+
5725+
err:
5726+
kfree(limits);
5727+
kfree(combo);
5728+
return -ENOMEM;
5729+
}
5730+
57195731
static void brcmf_wiphy_pno_params(struct wiphy *wiphy)
57205732
{
57215733
/* scheduled scan settings */
@@ -5746,32 +5758,18 @@ static void brcmf_wiphy_wowl_params(struct wiphy *wiphy)
57465758
static int brcmf_setup_wiphy(struct wiphy *wiphy, struct brcmf_if *ifp)
57475759
{
57485760
struct ieee80211_supported_band *band;
5749-
struct ieee80211_iface_combination ifc_combo;
57505761
__le32 bandlist[3];
57515762
u32 n_bands;
57525763
int err, i;
57535764

57545765
wiphy->max_scan_ssids = WL_NUM_SCAN_MAX;
57555766
wiphy->max_scan_ie_len = BRCMF_SCAN_IE_LEN_MAX;
57565767
wiphy->max_num_pmkids = WL_NUM_PMKIDS_MAX;
5757-
wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) |
5758-
BIT(NL80211_IFTYPE_ADHOC) |
5759-
BIT(NL80211_IFTYPE_AP) |
5760-
BIT(NL80211_IFTYPE_P2P_CLIENT) |
5761-
BIT(NL80211_IFTYPE_P2P_GO) |
5762-
BIT(NL80211_IFTYPE_P2P_DEVICE);
5763-
/* need VSDB firmware feature for concurrent channels */
5764-
ifc_combo = brcmf_iface_combos[0];
5765-
if (brcmf_feat_is_enabled(ifp, BRCMF_FEAT_MCHAN))
5766-
ifc_combo.num_different_channels = 2;
5767-
if (brcmf_feat_is_enabled(ifp, BRCMF_FEAT_MBSS)) {
5768-
ifc_combo.n_limits = ARRAY_SIZE(brcmf_iface_limits_mbss),
5769-
ifc_combo.limits = brcmf_iface_limits_mbss;
5770-
}
5771-
wiphy->iface_combinations = kmemdup(&ifc_combo,
5772-
sizeof(ifc_combo),
5773-
GFP_KERNEL);
5774-
wiphy->n_iface_combinations = ARRAY_SIZE(brcmf_iface_combos);
5768+
5769+
err = brcmf_setup_ifmodes(wiphy, ifp);
5770+
if (err)
5771+
return err;
5772+
57755773
wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM;
57765774
wiphy->cipher_suites = __wl_cipher_suites;
57775775
wiphy->n_cipher_suites = ARRAY_SIZE(__wl_cipher_suites);
@@ -6036,6 +6034,8 @@ static void brcmf_free_wiphy(struct wiphy *wiphy)
60366034
if (!wiphy)
60376035
return;
60386036

6037+
if (wiphy->iface_combinations)
6038+
kfree(wiphy->iface_combinations->limits);
60396039
kfree(wiphy->iface_combinations);
60406040
if (wiphy->bands[IEEE80211_BAND_2GHZ]) {
60416041
kfree(wiphy->bands[IEEE80211_BAND_2GHZ]->channels);

0 commit comments

Comments
 (0)