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
5 Configure multiple BSSID and enhanced multi-BSSID advertisement (EMA)
6 parameters in mac80211 for AP mode.
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.
11 Function ieee80211_stop() is modified to always bring down all the
12 non-transmitting interfaces first and the transmitting interface last.
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>
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
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.
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;
36 + struct ieee80211_vif *mbssid_tx_vif;
39 u8 drv_priv[] __aligned(sizeof(void *));
41 --- a/net/mac80211/cfg.c
42 +++ b/net/mac80211/cfg.c
43 @@ -112,6 +112,36 @@ static int ieee80211_set_mon_options(str
47 +static int ieee80211_set_ap_mbssid_options(struct ieee80211_sub_if_data *sdata,
48 + struct cfg80211_mbssid_config params)
50 + struct ieee80211_sub_if_data *tx_sdata;
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;
57 + if (sdata->vif.type != NL80211_IFTYPE_AP || !params.tx_wdev)
60 + tx_sdata = IEEE80211_WDEV_TO_SUB_IF(params.tx_wdev);
64 + if (tx_sdata == sdata) {
65 + sdata->vif.mbssid_tx_vif = &sdata->vif;
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;
72 + sdata->vif.bss_conf.ema_ap = true;
77 static struct wireless_dev *ieee80211_add_iface(struct wiphy *wiphy,
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;
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);
92 mutex_lock(&local->mtx);
93 err = ieee80211_vif_use_channel(sdata, ¶ms->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);
101 +static void ieee80211_stop_mbssid(struct ieee80211_sub_if_data *sdata)
103 + struct ieee80211_sub_if_data *tx_sdata, *non_tx_sdata, *tmp_sdata;
104 + struct ieee80211_vif *tx_vif = sdata->vif.mbssid_tx_vif;
109 + tx_sdata = vif_to_sdata(tx_vif);
110 + sdata->vif.mbssid_tx_vif = NULL;
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);
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);
128 static int ieee80211_stop(struct net_device *dev)
130 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
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;
137 list_for_each_entry_safe(vlan, tmpsdata, &sdata->u.ap.vlans,
139 dev_close(vlan->dev);
141 + ieee80211_stop_mbssid(sdata);
144 wiphy_lock(sdata->local->hw.wiphy);