d52a7a1cc0825d461847a9f9c73b80b24c0af9c5
[openwrt/staging/luka.git] /
1 From 24332f8068ff6df7f16aefee45d514de1de4de80 Mon Sep 17 00:00:00 2001
2 From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <rafal@milecki.pl>
3 Date: Thu, 26 Dec 2019 14:30:49 +0100
4 Subject: [PATCH] brcmfmac: simplify building interface combinations
5 MIME-Version: 1.0
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
8
9 Move similar/duplicated code out of combination specific code blocks.
10 This simplifies code a bit and allows adding more combinations later.
11 A list of combinations remains unchanged.
12
13 Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
14 Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
15 ---
16 .../broadcom/brcm80211/brcmfmac/cfg80211.c | 43 ++++++-------------
17 1 file changed, 14 insertions(+), 29 deletions(-)
18
19 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
20 +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
21 @@ -6479,12 +6479,13 @@ static int brcmf_setup_ifmodes(struct wi
22 struct ieee80211_iface_limit *c0_limits = NULL;
23 struct ieee80211_iface_limit *p2p_limits = NULL;
24 struct ieee80211_iface_limit *mbss_limits = NULL;
25 - bool mbss, p2p, rsdb;
26 + bool mbss, p2p, rsdb, mchan;
27 int i, c, n_combos;
28
29 mbss = brcmf_feat_is_enabled(ifp, BRCMF_FEAT_MBSS);
30 p2p = brcmf_feat_is_enabled(ifp, BRCMF_FEAT_P2P);
31 rsdb = brcmf_feat_is_enabled(ifp, BRCMF_FEAT_RSDB);
32 + mchan = brcmf_feat_is_enabled(ifp, BRCMF_FEAT_MCHAN);
33
34 n_combos = 1 + !!(p2p && !rsdb) + !!mbss;
35 combo = kcalloc(n_combos, sizeof(*combo), GFP_KERNEL);
36 @@ -6494,6 +6495,10 @@ static int brcmf_setup_ifmodes(struct wi
37 wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) |
38 BIT(NL80211_IFTYPE_ADHOC) |
39 BIT(NL80211_IFTYPE_AP);
40 + if (p2p)
41 + wiphy->interface_modes |= BIT(NL80211_IFTYPE_P2P_CLIENT) |
42 + BIT(NL80211_IFTYPE_P2P_GO) |
43 + BIT(NL80211_IFTYPE_P2P_DEVICE);
44
45 c = 0;
46 i = 0;
47 @@ -6505,48 +6510,28 @@ static int brcmf_setup_ifmodes(struct wi
48 c0_limits = kcalloc(2, sizeof(*c0_limits), GFP_KERNEL);
49 if (!c0_limits)
50 goto err;
51 - if (p2p && rsdb) {
52 - combo[c].num_different_channels = 2;
53 - wiphy->interface_modes |= BIT(NL80211_IFTYPE_P2P_CLIENT) |
54 - BIT(NL80211_IFTYPE_P2P_GO) |
55 - BIT(NL80211_IFTYPE_P2P_DEVICE);
56 - c0_limits[i].max = 2;
57 - c0_limits[i++].types = BIT(NL80211_IFTYPE_STATION);
58 +
59 + combo[c].num_different_channels = 1 + (rsdb || (p2p && mchan));
60 + c0_limits[i].max = 1 + rsdb;
61 + c0_limits[i++].types = BIT(NL80211_IFTYPE_STATION);
62 + if (p2p) {
63 c0_limits[i].max = 1;
64 c0_limits[i++].types = BIT(NL80211_IFTYPE_P2P_DEVICE);
65 - c0_limits[i].max = 2;
66 + c0_limits[i].max = 1 + rsdb;
67 c0_limits[i++].types = BIT(NL80211_IFTYPE_P2P_CLIENT) |
68 BIT(NL80211_IFTYPE_P2P_GO);
69 + }
70 + if (p2p && rsdb) {
71 c0_limits[i].max = 2;
72 c0_limits[i++].types = BIT(NL80211_IFTYPE_AP);
73 combo[c].max_interfaces = 5;
74 } else if (p2p) {
75 - if (brcmf_feat_is_enabled(ifp, BRCMF_FEAT_MCHAN))
76 - combo[c].num_different_channels = 2;
77 - else
78 - combo[c].num_different_channels = 1;
79 - c0_limits[i].max = 1;
80 - c0_limits[i++].types = BIT(NL80211_IFTYPE_STATION);
81 - wiphy->interface_modes |= BIT(NL80211_IFTYPE_P2P_CLIENT) |
82 - BIT(NL80211_IFTYPE_P2P_GO) |
83 - BIT(NL80211_IFTYPE_P2P_DEVICE);
84 - c0_limits[i].max = 1;
85 - c0_limits[i++].types = BIT(NL80211_IFTYPE_P2P_DEVICE);
86 - c0_limits[i].max = 1;
87 - c0_limits[i++].types = BIT(NL80211_IFTYPE_P2P_CLIENT) |
88 - BIT(NL80211_IFTYPE_P2P_GO);
89 combo[c].max_interfaces = i;
90 } else if (rsdb) {
91 - combo[c].num_different_channels = 2;
92 - c0_limits[i].max = 2;
93 - c0_limits[i++].types = BIT(NL80211_IFTYPE_STATION);
94 c0_limits[i].max = 2;
95 c0_limits[i++].types = BIT(NL80211_IFTYPE_AP);
96 combo[c].max_interfaces = 3;
97 } else {
98 - combo[c].num_different_channels = 1;
99 - c0_limits[i].max = 1;
100 - c0_limits[i++].types = BIT(NL80211_IFTYPE_STATION);
101 c0_limits[i].max = 1;
102 c0_limits[i++].types = BIT(NL80211_IFTYPE_AP);
103 combo[c].max_interfaces = i;