a135e3d1b5164dc86d5804de59f5584746835003
[openwrt/staging/ansuel.git] /
1 From: John Crispin <john@phrozen.org>
2 Date: Wed, 15 Sep 2021 19:54:35 -0700
3 Subject: [PATCH] mac80211: MBSSID support in interface handling
4
5 Configure multiple BSSID and enhanced multi-BSSID advertisement (EMA)
6 parameters in mac80211 for AP mode.
7
8 For each interface, 'mbssid_tx_vif' points to the transmitting interface of
9 the MBSSID set. The pointer is set to NULL if MBSSID is disabled.
10
11 Function ieee80211_stop() is modified to always bring down all the
12 non-transmitting interfaces first and the transmitting interface last.
13
14 Signed-off-by: John Crispin <john@phrozen.org>
15 Co-developed-by: Aloka Dixit <alokad@codeaurora.org>
16 Signed-off-by: Aloka Dixit <alokad@codeaurora.org>
17 Link: https://lore.kernel.org/r/20210916025437.29138-3-alokad@codeaurora.org
18 [slightly change logic to be more obvious]
19 Signed-off-by: Johannes Berg <johannes.berg@intel.com>
20 ---
21
22 --- a/include/net/mac80211.h
23 +++ b/include/net/mac80211.h
24 @@ -1719,6 +1719,7 @@ enum ieee80211_offload_flags {
25 * write-protected by sdata_lock and local->mtx so holding either is fine
26 * for read access.
27 * @color_change_color: the bss color that will be used after the change.
28 + * @mbssid_tx_vif: Pointer to the transmitting interface if MBSSID is enabled.
29 */
30 struct ieee80211_vif {
31 enum nl80211_iftype type;
32 @@ -1750,6 +1751,8 @@ struct ieee80211_vif {
33 bool color_change_active;
34 u8 color_change_color;
35
36 + struct ieee80211_vif *mbssid_tx_vif;
37 +
38 /* must be last */
39 u8 drv_priv[] __aligned(sizeof(void *));
40 };
41 --- a/net/mac80211/cfg.c
42 +++ b/net/mac80211/cfg.c
43 @@ -112,6 +112,36 @@ static int ieee80211_set_mon_options(str
44 return 0;
45 }
46
47 +static int ieee80211_set_ap_mbssid_options(struct ieee80211_sub_if_data *sdata,
48 + struct cfg80211_mbssid_config params)
49 +{
50 + struct ieee80211_sub_if_data *tx_sdata;
51 +
52 + sdata->vif.mbssid_tx_vif = NULL;
53 + sdata->vif.bss_conf.bssid_index = 0;
54 + sdata->vif.bss_conf.nontransmitted = false;
55 + sdata->vif.bss_conf.ema_ap = false;
56 +
57 + if (sdata->vif.type != NL80211_IFTYPE_AP || !params.tx_wdev)
58 + return -EINVAL;
59 +
60 + tx_sdata = IEEE80211_WDEV_TO_SUB_IF(params.tx_wdev);
61 + if (!tx_sdata)
62 + return -EINVAL;
63 +
64 + if (tx_sdata == sdata) {
65 + sdata->vif.mbssid_tx_vif = &sdata->vif;
66 + } else {
67 + sdata->vif.mbssid_tx_vif = &tx_sdata->vif;
68 + sdata->vif.bss_conf.nontransmitted = true;
69 + sdata->vif.bss_conf.bssid_index = params.index;
70 + }
71 + if (params.ema)
72 + sdata->vif.bss_conf.ema_ap = true;
73 +
74 + return 0;
75 +}
76 +
77 static struct wireless_dev *ieee80211_add_iface(struct wiphy *wiphy,
78 const char *name,
79 unsigned char name_assign_type,
80 @@ -1107,6 +1137,14 @@ static int ieee80211_start_ap(struct wip
81 changed |= BSS_CHANGED_HE_BSS_COLOR;
82 }
83
84 + if (sdata->vif.type == NL80211_IFTYPE_AP &&
85 + params->mbssid_config.tx_wdev) {
86 + err = ieee80211_set_ap_mbssid_options(sdata,
87 + params->mbssid_config);
88 + if (err)
89 + return err;
90 + }
91 +
92 mutex_lock(&local->mtx);
93 err = ieee80211_vif_use_channel(sdata, &params->chandef,
94 IEEE80211_CHANCTX_SHARED);
95 --- a/net/mac80211/iface.c
96 +++ b/net/mac80211/iface.c
97 @@ -632,17 +632,46 @@ static void ieee80211_do_stop(struct iee
98 ieee80211_add_virtual_monitor(local);
99 }
100
101 +static void ieee80211_stop_mbssid(struct ieee80211_sub_if_data *sdata)
102 +{
103 + struct ieee80211_sub_if_data *tx_sdata, *non_tx_sdata, *tmp_sdata;
104 + struct ieee80211_vif *tx_vif = sdata->vif.mbssid_tx_vif;
105 +
106 + if (!tx_vif)
107 + return;
108 +
109 + tx_sdata = vif_to_sdata(tx_vif);
110 + sdata->vif.mbssid_tx_vif = NULL;
111 +
112 + list_for_each_entry_safe(non_tx_sdata, tmp_sdata,
113 + &tx_sdata->local->interfaces, list) {
114 + if (non_tx_sdata != sdata && non_tx_sdata != tx_sdata &&
115 + non_tx_sdata->vif.mbssid_tx_vif == tx_vif &&
116 + ieee80211_sdata_running(non_tx_sdata)) {
117 + non_tx_sdata->vif.mbssid_tx_vif = NULL;
118 + dev_close(non_tx_sdata->wdev.netdev);
119 + }
120 + }
121 +
122 + if (sdata != tx_sdata && ieee80211_sdata_running(tx_sdata)) {
123 + tx_sdata->vif.mbssid_tx_vif = NULL;
124 + dev_close(tx_sdata->wdev.netdev);
125 + }
126 +}
127 +
128 static int ieee80211_stop(struct net_device *dev)
129 {
130 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
131
132 - /* close all dependent VLAN interfaces before locking wiphy */
133 + /* close dependent VLAN and MBSSID interfaces before locking wiphy */
134 if (sdata->vif.type == NL80211_IFTYPE_AP) {
135 struct ieee80211_sub_if_data *vlan, *tmpsdata;
136
137 list_for_each_entry_safe(vlan, tmpsdata, &sdata->u.ap.vlans,
138 u.vlan.list)
139 dev_close(vlan->dev);
140 +
141 + ieee80211_stop_mbssid(sdata);
142 }
143
144 wiphy_lock(sdata->local->hw.wiphy);