multiple bssid and EMA support in AP mode
Subsystems (2)
v10 cover multiple bssid and EMA support in AP mode
This patchset adds support for multiple BSSID and
enhanced multi-BSSID advertisements for AP mode.
HWSIM support will be added in a separate patchset.
John Crispin (4):
nl80211: multiple bssid and EMA support in AP mode
mac80211: multiple bssid support in interface handling
mac80211: MBSSID and EMA support in beacon handling
mac80211: CSA on non-transmitting interfaces
include/net/cfg80211.h | 51 +++++++ include/net/mac80211.h | 123 ++++++++++++++- include/uapi/linux/nl80211.h | 101 ++++++++++++- net/mac80211/cfg.c | 198 +++++++++++++++++++++++-- net/mac80211/debugfs.c | 2 + net/mac80211/ieee80211_i.h | 2 + net/mac80211/iface.c | 12 ++ net/mac80211/tx.c | 189 ++++++++++++++++++++--- net/wireless/nl80211.c | 280 ++++++++++++++++++++++++++++++----- 9 files changed, 883 insertions(+), 75 deletions(-)
base-commit: 5d869070569a23aa909c6e7e9d010fc438a492ef
Signature · 1 line
2.31.1
PATCH v10 1/4 nl80211: multiple bssid and EMA support in AP mode
From: John Crispin <[email protected]>
This commit adds new attributes to configure support for multiple BSSID and advanced multi-BSSID advertisements (EMA) in AP mode.
New nested attributes:
(1) NL80211_ATTR_MBSSID_CONFIG: Per interface settings.
(2) NL80211_ATTR_MBSSID_ELEMS: MBSSID elements to be added in beacons. Both are required from the userspace for successful configuration.
Configuration options:
(1) NL80211_MBSSID_CONFIG_ATTR_PARENT: Index of the transmitting interface as advertised by the kernel
(2) NL80211_MBSSID_CONFIG_ATTR_COUNT: Total number of interfaces in the set
(3) NL80211_MBSSID_CONFIG_ATTR_INDEX: Index of the interfaces getting set up in MBSSID set. Range: 1 to NL80211_MBSSID_CONFIG_ATTR_COUNT-1.
(4) NL80211_MBSSID_CONFIG_ATTR_EMA: Set to 1 if enhanced multi-BSSID advertisements should be enabled.
Elements data:
(1) NL80211_MBSSID_ELEMS_ATTR_COUNT: Number of MBSSID elements
(2) NL80211_MBSSID_ELEMS_ATTR_DATA: Elements data. If EMA is enabled, these elements will be added in separate beacon templates.
Memory for the elements is allocated dynamically. While this change frees the memory in existing functions which call nl80211_parse_beacon(), a comment is added to indicate the new references to do the same.
---
v10: Shorter variable names and more descriptive comments
include/net/cfg80211.h | 51 +++++++ include/uapi/linux/nl80211.h | 101 ++++++++++++- net/wireless/nl80211.c | 280 ++++++++++++++++++++++++++++++----- 3 files changed, 392 insertions(+), 40 deletions(-)
include/net/cfg80211.h +51 -0
@@ -1033,6 +1033,38 @@ struct cfg80211_crypto_settings {enum nl80211_sae_pwe_mechanism sae_pwe; }; +/** +* struct cfg80211_mbssid_config - AP settings for multi bssid +* +* @parent: interface index of the transmitted profile in the MBSSID set +* @index: index of this AP in the multi bssid group. +* @count: the total number of multi bssid peer APs. +* @ema: Shall the beacons be sent out in EMA mode. +*/ +struct cfg80211_mbssid_config { +u32 parent; +u8 index; +u8 count; +bool ema; +}; + +/** +* struct cfg80211_mbssid_elems - Multiple BSSID elements +* +* @cnt: Number of elements in array %elems. +* +* @elem: Array of multiple BSSID element(s) to be added into Beacon frames. +* @elem.data: Data for multiple BSSID elements. +* @elem.len: Length of data. +*/ +struct cfg80211_mbssid_elems { +u8 cnt; +struct { +u8 *data; +size_t len; + } elem[]; +}; +/** * struct cfg80211_beacon_data - beacon data * @head: head portion of beacon (before TIM IE)
@@ -1051,6 +1083,7 @@ struct cfg80211_crypto_settings {* @assocresp_ies_len: length of assocresp_ies in octets * @probe_resp_len: length of probe response template (@probe_resp) * @probe_resp: probe response template (AP mode only) +* @mbssid: multiple BSSID elements * @ftm_responder: enable FTM responder functionality; -1 for no change * (which also implies no change in LCI/civic location data) * @lci: Measurement Report element content, starting with Measurement Token
@@ -1068,6 +1101,7 @@ struct cfg80211_beacon_data {const u8 *probe_resp;const u8 *lci;const u8 *civicloc; +struct cfg80211_mbssid_elems *mbssid;s8 ftm_responder;size_t head_len, tail_len;
@@ -1182,6 +1216,7 @@ enum cfg80211_ap_settings_flags {* @he_oper: HE operation IE (or %NULL if HE isn't enabled) * @fils_discovery: FILS discovery transmission parameters * @unsol_bcast_probe_resp: Unsolicited broadcast probe response parameters +* @mbssid: AP settings for multiple bssid */ struct cfg80211_ap_settings {struct cfg80211_chan_def chandef;
@@ -1214,6 +1249,7 @@ struct cfg80211_ap_settings {struct cfg80211_he_bss_color he_bss_color;struct cfg80211_fils_discovery fils_discovery;struct cfg80211_unsol_bcast_probe_resp unsol_bcast_probe_resp; +struct cfg80211_mbssid_config mbssid; };/**
@@ -4945,6 +4981,16 @@ struct wiphy_iftype_akm_suites {* configuration through the %NL80211_TID_CONFIG_ATTR_RETRY_SHORT and * %NL80211_TID_CONFIG_ATTR_RETRY_LONG attributes * @sar_capa: SAR control capabilities +* +* @mbssid: Describes driver's multiple BSSID configuration support +* @mbssid.max_interfaces: maximum number of interfaces supported by the driver +* in a multiple BSSID set that can ben configured using +* %NL80211_MBSSID_CONFIG_ATTR_COUNT. +* Kernel supports only one MBSSID per wiphy. +* @mbssid.max_periodicity: maximum profile periodicity supported by the driver +* that can be configured using %NL80211_MBSSID_ELEMS_ATTR_COUNT. +* This value is used only when enhanced multi-BSSID advertisements feature +* is enabled through %NL80211_MBSSID_CONFIG_ATTR_EMA flag. */ struct wiphy {struct mutex mtx;
@@ -5087,6 +5133,11 @@ struct wiphy {const struct cfg80211_sar_capa *sar_capa; +struct { +u8 max_interfaces; +u8 max_periodicity; + } mbssid; +char priv[]__aligned(NETDEV_ALIGN) ; };
include/uapi/linux/nl80211.h +100 -1
135 lines not on this page · raw message
net/wireless/nl80211.c +241 -39
441 lines not on this page · raw message
base-commit: 5d869070569a23aa909c6e7e9d010fc438a492ef
Signature · 1 line
2.31.1
Re: [PATCH v10 1/4] nl80211: multiple bssid and EMA support in AP mode
Quoted 5 lines · Aloka Dixit
From: John Crispin <[email protected]>
This commit adds new attributes to configure support for multiple BSSID and advanced multi-BSSID advertisements (EMA) in AP mode.
Hi Johannes,
Please provide comments on this patch-set.
Thanks.
Johannes Berg
maintainerRe: [PATCH v10 1/4] nl80211: multiple bssid and EMA support in AP mode
In reply to Aloka DixitHi Aloka,
Sorry for the long delay.
Quoted 2 lines
Reported-by kernel test robot <[email protected]>Reported-by Dan Carpenter <[email protected]>
Please drop those, you can list them in the version annotations, but they didn't really report the feature or something :)
Quoted 3 lines
+ * @mbssid.max_interfaces: maximum number of interfaces supported by the driver
+ * in a multiple BSSID set that can ben configured using
+ * %NL80211_MBSSID_CONFIG_ATTR_COUNT.
I don't quite understand why you need this as well as NL80211_EXT_FEATURE_MBSSID_AP? Isn't it quite clear that if you have mbssid.max_interfaces then it must support MBSSID_AP, and vice versa?
Also, I don't think I am happy with the code that lets you advertise NL80211_EXT_FEATURE_MBSSID_AP and not have a max_interfaces, and then the kernel just accepts an arbitrary number - if that's the case, why bother advertising max_interfaces at all?
IOW, I think you should drop NL80211_EXT_FEATURE_MBSSID_AP and force having max_interfaces.
Quoted 6 lines
+/**
+ * enumnl80211_mbssid_config_attributes- Attributes to configure/advertise
+ * multiple BSSID and enhanced multi-BSSID advertisements in AP mode.
+ *
+ * @__NL80211_MBSSID_CONFIG_ATTR_INVALID: Invalid
+ *
Quoted 8 lines
+ * @NL80211_MBSSID_CONFIG_ATTR_PARENT: For a non-transmitted BSSID, this
+ * attribute provides the interface index (u32) of the transmitted profile.
+ * Must match one of the interface indices advertised by the kernel.
+ * Mandatory parameter for non-transmitting interfaces, ignored for the
+ * transmitting interface.
+ *
+ * @NL80211_MBSSID_CONFIG_ATTR_COUNT: Total number of BSSs (u8) in the
+ * multiple BSSID set. Mandatory attribute with minimum value of 1.
I have a feeling we've discussed this before and I just forgot - but why do we need the count at all? Shouldn't that be obvious by the various values of ..._CONFIG_ATTR_INDEX?
What happens if you call it with
* index=1, count=3
* index=2, count=3
* index=3, count=4
for three non-transmitting interfaces? That would cause ... issues?
But that sort of means the drivers cannot rely on the 'count' anyway, unless it's somehow only set up on the *first* (transmitting) interface, or something like that, and then validated later? But that means cfg80211 cannot do the validation, and so what's the point?
What is it needed for anyway? Couldn't you just take the maximum index plus 1 as the count? Somehow we've got to be keeping track of all of that anyhow.
Perhaps we should actually do _more_ tracking in cfg80211 and link it to the parent, and then track that the index space is allocated contiguously?
Also, regarding the count, what if you never reach it, because you only configure
* index=1, count=4
* index=2, count=4
and that's it - seems like the count thing just causes confusion and tracking it internally makes more sense?
mac80211 also never even uses the count, afaict.
Quoted 4 lines
+ * @NL80211_MBSSID_CONFIG_ATTR_INDEX: The index of this BSS (u8) in the
+ * multiple BSSID set. Mandatory parameter for non-transmitting interfaces,
+ * ignored for the transmitting interface.
+ * Range: 1 to %NL80211_MBSSID_CONFIG_ATTR_COUNT-1.
0 is for the transmitting interface then?
Quoted 5 lines
+ * @NL80211_MBSSID_CONFIG_ATTR_EMA: Userspace and the drivers should use this
+ * flag to indicate if enhanced multi-BSSID advertisements (EMA AP) feature
+ * is supported/enabled. When set, beacons are generated as per EMA rules,
+ * see %nl80211_mbssid_elems_attributes for details. Drivers must set
+ *NL80211_EXT_FEATURE_EMA_APfor this flag to be used.
I guess 'used' -> 'permitted' or something.
Quoted 3 lines
+ * @NL80211_MBSSID_ELEMS_ATTR_COUNT: Number of multiple BSSID elements (u8).
+ * This attribute is also used to advertise the maximum profile periodicity
+ * supported by the driver if EMA is enabled.
This one I see even less value in than the count above - isn't that simply counting the number of entries in ...MBSSID_ELEMS_ATTR_DATA?
FWIW, your code is also quite happy to let userspace crash the kernel if it specifies _COUNT=1 and then has 100 entries in _DATA, as far as I can tell.
Again, I think you should remove this and just count the entries in ..._ATTR_DATA first.
net/wireless/nl80211.c sar_policy[NL80211_SAR_ATTR_MAX + 1] = { · line 443
Quoted 4 lines
net/wireless/nl80211.c +4
-0+static const struct nla_policy +nl80211_mbssid_elems_policy[NL80211_MBSSID_ELEMS_ATTR_MAX +1 ] = { + [NL80211_MBSSID_ELEMS_ATTR_COUNT ] = { .type =NLA_U8 }, + [NL80211_MBSSID_ELEMS_ATTR_DATA ] = { .type =NLA_NESTED },
Some of this could be more explicit, e.g. if we keep COUNT despite the discussion above, the policy should specify a min value of 1.
Same is probably true elsewhere.
net/wireless/nl80211.c nl80211_put_sar_specs(struct cfg80211_registered_device *rdev, · line 2222
Quoted 4 lines
net/wireless/nl80211.c +4
-0+static int nl80211_put_mbssid_support (struct wiphy *wiphy, +struct sk_buff *msg) +{ +struct nlattr *config =NULL , *elems =NULL ;
You don't need that - you can move those into the ifs
net/wireless/nl80211.c nl80211_put_sar_specs(struct cfg80211_registered_device *rdev, · line 2257
Quoted 5 lines
net/wireless/nl80211.c +5
-0+fail: +if (elems) +nla_nest_cancel (msg, elems); +if (config) +nla_nest_cancel (msg, config);
because you don't need that
net/wireless/nl80211.c static int validate_beacon_tx_rate(struct cfg80211_registered_device *rdev, · line 5036
Quoted 13 lines
net/wireless/nl80211.c +13
-0+static int nl80211_parse_mbssid_config (struct wiphy *wiphy, +struct net_device *dev, +struct nlattr *attrs,u8 num_elems, +struct cfg80211_mbssid_config *config) +{ +struct nlattr *tb[NL80211_MBSSID_CONFIG_ATTR_MAX +1 ]; +struct net_device *parent; + +if (!wiphy_ext_feature_isset (wiphy,NL80211_EXT_FEATURE_MBSSID_AP )) +return -EOPNOTSUPP ; + +if (nla_parse_nested (tb,NL80211_MBSSID_CONFIG_ATTR_MAX , attrs,NULL , +NULL ) || !tb[NL80211_MBSSID_CONFIG_ATTR_COUNT ])
please reformat
net/wireless/nl80211.c static int validate_beacon_tx_rate(struct cfg80211_registered_device *rdev, · line 5046
Quoted 10 lines
net/wireless/nl80211.c +10
-0+return -EINVAL ; + + config->ema =nla_get_flag (tb[NL80211_MBSSID_CONFIG_ATTR_EMA ]); +if (config->ema) { +if (!wiphy_ext_feature_isset (wiphy,NL80211_EXT_FEATURE_EMA_AP )) +return -EOPNOTSUPP ; + +/* nl80211_parse_mbssid_elems() sets this value */ +if (!num_elems || (wiphy->mbssid.max_periodicity && + num_elems > wiphy->mbssid.max_periodicity))
the !num_elems check should be moved to the policy, and I think mbssid.max_periodicity should be required
net/wireless/nl80211.c static int validate_beacon_tx_rate(struct cfg80211_registered_device *rdev, · line 5053
Quoted 4 lines
net/wireless/nl80211.c +4
-0+ config->count =nla_get_u8 (tb[NL80211_MBSSID_CONFIG_ATTR_COUNT ]); +if (!config->count || (wiphy->mbssid.max_interfaces && + config->count > wiphy->mbssid.max_interfaces)) +return -EINVAL ;
same with max_interfaces imho.
Quoted 4 lines
net/wireless/nl80211.c +4
-0+ +if (tb[NL80211_MBSSID_CONFIG_ATTR_PARENT ]) { + config->parent =nla_get_u32 (tb[NL80211_MBSSID_CONFIG_ATTR_PARENT ]); + parent =__dev_get_by_index (wiphy_net (wiphy), config->parent);
net/wireless/nl80211.c static int validate_beacon_tx_rate(struct cfg80211_registered_device *rdev, · line 5067
Quoted 10 lines
net/wireless/nl80211.c +10
-0+if (!parent || !parent->ieee80211_ptr) +return -EINVAL ; + +if (parent == dev) + config->parent =0 ; + } + +if (tb[NL80211_MBSSID_CONFIG_ATTR_INDEX ] && config->parent) { + config->index =nla_get_u8 (tb[NL80211_MBSSID_CONFIG_ATTR_INDEX ]); +if (!config->index || config->index >= config->count)
policy check for the index please
Quoted 24 lines
net/wireless/nl80211.c +24
-0+return -EINVAL ; + } + +return 0 ; +} + +static struct cfg80211_mbssid_elems * +nl80211_parse_mbssid_elems (struct wiphy *wiphy,struct nlattr *attrs) +{ +struct nlattr *nl_elems, *tb[NL80211_MBSSID_ELEMS_ATTR_MAX +1 ]; +struct cfg80211_mbssid_elems *elems =NULL ; +int rem_elems; +u8 i =0 , num_elems; + +if (!wiphy_ext_feature_isset (wiphy,NL80211_EXT_FEATURE_MBSSID_AP )) +return NULL ; + +if (nla_parse_nested (tb,NL80211_MBSSID_ELEMS_ATTR_MAX , attrs,NULL , +NULL ) || + !tb[NL80211_MBSSID_ELEMS_ATTR_COUNT ] || + !tb[NL80211_MBSSID_ELEMS_ATTR_DATA ]) +return NULL ; + + num_elems =nla_get_u8 (tb[NL80211_MBSSID_ELEMS_ATTR_COUNT ]);
net/wireless/nl80211.c static int validate_beacon_tx_rate(struct cfg80211_registered_device *rdev, · line 5101
Quoted 10 lines
net/wireless/nl80211.c +10
-0+if (!num_elems) +return NULL ; + + elems =kzalloc (struct_size (elems, elem, num_elems),GFP_KERNEL ); +if (!elems) +return NULL ; + + elems->cnt = num_elems; +nla_for_each_nested (nl_elems, tb[NL80211_MBSSID_ELEMS_ATTR_DATA ], + rem_elems) {
This is the bug I was talking about - num_elems can be much less than the actual number of elements in here.
johannes
PATCH v10 2/4 mac80211: multiple bssid support in interface handling
In reply to Aloka DixitFrom: John Crispin <[email protected]>
This change adds a new helper function ieee80211_set_mbssid_options() to set multiple BSSID and enhanced multi-BSSID advertisement (EMA) configuration in mac80211.
New flags are set per interface to indicate transmitting/non-transmitting and EMA enabled/disabled configurations. Value 0 indicates that the AP does not support multiple BSSID advertisements.
For non-transmitting profiles, a parent pointer points to the transmitting interface from the global list of interfaces per wiphy.
When ieee80211_do_stop() is called for a non-transmitting interface, it first brings down the transmitting interface.
When ieee80211_del_iface() is called for the transmitting interface, it first brings down all the non-transmitting interfaces.
---
v10: Released wiphy->mtx before dev_close().
New flag for IEEE80211_HW_SUPPORTS_EMA_AP. ieee80211_set_mbssid_options() returns int instead of void.
include/net/mac80211.h | 34 ++++++++++++++++++- net/mac80211/cfg.c | 74 ++++++++++++++++++++++++++++++++++++++++++ net/mac80211/debugfs.c | 2 ++ net/mac80211/iface.c | 12 +++++++ 4 files changed, 121 insertions(+), 1 deletion(-)
include/net/mac80211.h +33 -1
@@ -631,6 +631,7 @@ struct ieee80211_fils_discovery {* @s1g: BSS is S1G BSS (affects Association Request format). * @beacon_tx_rate: The configured beacon transmit rate that needs to be passed * to driver when rate control is offloaded to firmware. +* @mbssid: Multiple bssid settings for AP mode */ struct ieee80211_bss_conf {const u8 *bssid;
@@ -700,6 +701,7 @@ struct ieee80211_bss_conf {u32 unsol_bcast_probe_resp_interval;bool s1g;struct cfg80211_bitrate_mask beacon_tx_rate; +struct cfg80211_mbssid_config mbssid; };/**
@@ -1663,6 +1665,20 @@ enum ieee80211_offload_flags { IEEE80211_OFFLOAD_DECAP_ENABLED = BIT(2), }; +/** +* enum ieee80211_vif_mbssid_flags - virtual interface multiple bssid flags +* +* @IEEE80211_VIF_MBSSID_TX: Set for the transmitting profile. +* @IEEE80211_VIF_MBSSID_NON_TX: Set for non-transmitting profiles. +* @IEEE80211_VIF_MBSSID_EMA: Set when enhanced multi-BSS advertisements +* are enabled. +*/ +enum ieee80211_vif_mbssid_flags { +IEEE80211_VIF_MBSSID_TX =BIT (1 ), +IEEE80211_VIF_MBSSID_NON_TX =BIT (2 ), +IEEE80211_VIF_MBSSID_EMA =BIT (3 ), +}; +/** * struct ieee80211_vif - per-interface data *
@@ -1709,6 +1725,10 @@ enum ieee80211_offload_flags {* protected by fq->lock. * @offload_flags: 802.3 -> 802.11 enapsulation offload flags, see * &enum ieee80211_offload_flags. +* +* @mbssid: Multiple BSSID configurations. +* @mbssid.parent: Interface index of the transmitted BSS. +* @mbssid.flags: multiple bssid flags, see enum ieee80211_vif_mbssid_flags. */ struct ieee80211_vif {enum nl80211_iftype type;
@@ -1737,6 +1757,11 @@ struct ieee80211_vif {bool txqs_stopped[IEEE80211_NUM_ACS ]; +struct { +struct ieee80211_vif *parent; +u32 flags; + } mbssid; +/* must be last */ u8 drv_priv[]__aligned(sizeof(void *)) ; };
@@ -2381,7 +2406,7 @@ struct ieee80211_txq {* @IEEE80211_HW_TX_STATUS_NO_AMPDU_LEN: Driver does not report accurate A-MPDU * length in tx status information * -* @IEEE80211_HW_SUPPORTS_MULTI_BSSID: Hardware supports multi BSSID +* @IEEE80211_HW_SUPPORTS_MULTI_BSSID: Hardware supports multi BSSID in STA mode * * @IEEE80211_HW_SUPPORTS_ONLY_HE_MULTI_BSSID: Hardware supports multi BSSID * only for HE APs. Applies if @IEEE80211_HW_SUPPORTS_MULTI_BSSID is set.
@@ -2402,6 +2427,11 @@ struct ieee80211_txq {* usage and 802.11 frames with %RX_FLAG_ONLY_MONITOR set for monitor to * the stack. * +* @IEEE80211_HW_SUPPORTS_MBSSID_AP: Hardware supports multiple BSSID +* advertisements in AP mode. +* @IEEE80211_HW_SUPPORTS_EMA_AP: Hardware supports enhanced multiple BSSID +* advertisements in AP mode. +* * @NUM_IEEE80211_HW_FLAGS: number of hardware flags, used for sizing arrays */ enum ieee80211_hw_flags {
@@ -2457,6 +2487,8 @@ enum ieee80211_hw_flags {IEEE80211_HW_SUPPORTS_TX_ENCAP_OFFLOAD ,IEEE80211_HW_SUPPORTS_RX_DECAP_OFFLOAD ,IEEE80211_HW_SUPPORTS_CONC_MON_RX_DECAP , +IEEE80211_HW_SUPPORTS_MBSSID_AP , +IEEE80211_HW_SUPPORTS_EMA_AP ,/* keep last, obviously */ NUM_IEEE80211_HW_FLAGS
net/mac80211/cfg.c +74 -0
92 lines not on this page · raw message
net/mac80211/debugfs.c +2 -0
@@ -457,6 +457,8 @@ static const char *hw_flag_names[] = {FLAG (SUPPORTS_TX_ENCAP_OFFLOAD ),FLAG (SUPPORTS_RX_DECAP_OFFLOAD ),FLAG (SUPPORTS_CONC_MON_RX_DECAP ), +FLAG (SUPPORTS_MBSSID_AP ), +FLAG (SUPPORTS_EMA_AP ), #undef FLAG };
net/mac80211/iface.c +12 -0
@@ -375,6 +375,18 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata, bool going_dostruct cfg80211_chan_def chandef;bool cancel_scan;struct cfg80211_nan_func *func; +struct ieee80211_sub_if_data *parent; + +if (sdata->vif.type ==NL80211_IFTYPE_AP && +ieee80211_hw_check (&local->hw,SUPPORTS_MBSSID_AP ) && + sdata->vif.mbssid.flags &IEEE80211_VIF_MBSSID_NON_TX ) { + parent =vif_to_sdata (sdata->vif.mbssid.parent); +if (parent &&ieee80211_sdata_running (parent)) { +wiphy_unlock (local->hw.wiphy); +dev_close (parent->wdev.netdev); +wiphy_lock (local->hw.wiphy); + } + }clear_bit (SDATA_STATE_RUNNING , &sdata->state);
Signature · 1 line
2.31.1
Johannes Berg
maintainerRe: [PATCH v10 2/4] mac80211: multiple bssid support in interface handling
Quoted 5 lines · Aloka Dixit
+ * @IEEE80211_HW_SUPPORTS_MBSSID_AP: Hardware supports multiple BSSID
+ * advertisements in AP mode.
+ * @IEEE80211_HW_SUPPORTS_EMA_AP: Hardware supports enhanced multiple BSSID
+ * advertisements in AP mode.
Is there a good reason for these - the driver can just set the extended nl80211 flags instead and we can check, or nl80211 already checked?
Quoted 10 lines
net/mac80211/cfg.c +8
-0+static int ieee80211_set_mbssid_options (struct ieee80211_sub_if_data *sdata, +struct cfg80211_mbssid_config params) +{ +struct ieee80211_local *local = sdata->local; +struct wiphy *wiphy = local->hw.wiphy; +struct net_device *parent; +struct ieee80211_sub_if_data *psdata; +
net/mac80211/cfg.c static int ieee80211_set_mon_options(struct ieee80211_sub_if_data *sdata, · line 131
Quoted 10 lines
net/mac80211/cfg.c +10
-0+if (!params.count || sdata->vif.type !=NL80211_IFTYPE_AP || + !ieee80211_hw_check (&local->hw,SUPPORTS_MBSSID_AP )) +return -EINVAL ; + + sdata->vif.mbssid.parent =NULL ; + sdata->vif.mbssid.flags =IEEE80211_VIF_MBSSID_TX ; +if (params.parent) { + parent =__dev_get_by_index (wiphy_net (wiphy), params.parent); +if (!parent || !parent->ieee80211_ptr) +return -EINVAL ;
Hm wait, didn't I see the same code in cfg80211 - maybe cfg80211 should just pass the pointer?
Quoted 9 lines
static int
ieee80211_del_iface(struct wiphy *wiphy, struct wireless_dev *wdev){net/mac80211/cfg.c +6
-0+struct ieee80211_sub_if_data *sdata =IEEE80211_WDEV_TO_SUB_IF (wdev); +struct ieee80211_local *local; +struct ieee80211_vif *vif; + +if (!sdata) +return 0 ;
net/mac80211/cfg.c static struct wireless_dev *ieee80211_add_iface(struct wiphy *wiphy, · line 197
Quoted 10 lines
net/mac80211/cfg.c +10
-0+ + local = sdata->local; + vif = &sdata->vif; +if (vif->type ==NL80211_IFTYPE_AP && +ieee80211_hw_check (&local->hw,SUPPORTS_MBSSID_AP )) { +if (vif->mbssid.flags &IEEE80211_VIF_MBSSID_TX ) { +struct ieee80211_sub_if_data *child, *tmpsdata; + +wiphy_unlock (local->hw.wiphy); +mutex_lock (&local->iflist_mtx);
I really don't think you can drop the locking like that in the middle of something. That's almost always a recipe for disaster.
Quoted 4 lines
net/mac80211/iface.c +0
-0@@ -375,6 +375,18 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata, bool going_do struct cfg80211_chan_def chandef; bool cancel_scan; struct cfg80211_nan_func *func;
net/mac80211/iface.c static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata, bool going_do · line 387
Quoted 10 lines
net/mac80211/iface.c +10
-0+struct ieee80211_sub_if_data *parent; + +if (sdata->vif.type ==NL80211_IFTYPE_AP && +ieee80211_hw_check (&local->hw,SUPPORTS_MBSSID_AP ) && + sdata->vif.mbssid.flags &IEEE80211_VIF_MBSSID_NON_TX ) { + parent =vif_to_sdata (sdata->vif.mbssid.parent); +if (parent &&ieee80211_sdata_running (parent)) { +wiphy_unlock (local->hw.wiphy); +dev_close (parent->wdev.netdev); +wiphy_lock (local->hw.wiphy);
Same here.
johannes
Re: [PATCH v10 2/4] mac80211: multiple bssid support in interface handling
Quoted 47 lines · Johannes Berg
Quoted 1 line · Aloka Dixit
Hm wait, didn't I see the same code in cfg80211 - maybe cfg80211 should just pass the pointer?
Quoted 10 lines
static int
ieee80211_del_iface(struct wiphy *wiphy, struct wireless_dev *wdev){(quoted diff) +1
-0+ struct ieee80211_sub_if_data *sdata =
IEEE80211_WDEV_TO_SUB_IF(wdev);net/mac80211/cfg.c +5
-0+struct ieee80211_local *local; +struct ieee80211_vif *vif; + +if (!sdata) +return 0 ;net/mac80211/cfg.c static struct wireless_dev *ieee80211_add_iface(struct wiphy *wiphy, · line 197
Quoted 10 lines
net/mac80211/cfg.c +10
-0+ + local = sdata->local; + vif = &sdata->vif; +if (vif->type ==NL80211_IFTYPE_AP && +ieee80211_hw_check (&local->hw,SUPPORTS_MBSSID_AP )) { +if (vif->mbssid.flags &IEEE80211_VIF_MBSSID_TX ) { +struct ieee80211_sub_if_data *child, *tmpsdata; + +wiphy_unlock (local->hw.wiphy); +mutex_lock (&local->iflist_mtx);I really don't think you can drop the locking like that in the middle of something. That's almost always a recipe for disaster.
Quoted 5 lines
(quoted diff) +0
-0@@ -375,6 +375,18 @@ static void ieee80211_do_stop(struct
ieee80211_sub_if_data*sdata, boolgoing_do
structcfg80211_chan_defchandef;
boolcancel_scan;
structcfg80211_nan_func*func;net/mac80211/iface.c static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata, bool going_do · line 387
Quoted 10 lines
net/mac80211/iface.c +10
-0+struct ieee80211_sub_if_data *parent; + +if (sdata->vif.type ==NL80211_IFTYPE_AP && +ieee80211_hw_check (&local->hw,SUPPORTS_MBSSID_AP ) && + sdata->vif.mbssid.flags &IEEE80211_VIF_MBSSID_NON_TX ) { + parent =vif_to_sdata (sdata->vif.mbssid.parent); +if (parent &&ieee80211_sdata_running (parent)) { +wiphy_unlock (local->hw.wiphy); +dev_close (parent->wdev.netdev); +wiphy_lock (local->hw.wiphy);Same here.
Quoted 1 line
johannes
Hi Johannes,
Thanks for the comments, will go through all, but need your help with this particular one -
I'm not able to come up with a different solution which does not cause a deadlock by continuing to hold wiphy_lock() as we discussed last time that dev_close() will in turn call into cfg80211.
You had suggested looking at dev_close() for VLAN, that code also doesn't lock wiphy_lock hence I did same here but locked 'local->iflist_mtx'. Dropping both won't be good for sure.
Can you please suggest a better way? I'm really not able to come up with one.
Thanks.
Johannes Berg
maintainerRe: [PATCH v10 2/4] mac80211: multiple bssid support in interface handling
Hi Aloka,
Quoted 23 lines
Quoted 23 lines
Quoted 10 lines
static int
ieee80211_del_iface(struct wiphy *wiphy, struct wireless_dev *wdev)
{(quoted diff) +1
-0+ struct ieee80211_sub_if_data *sdata =
IEEE80211_WDEV_TO_SUB_IF(wdev);net/mac80211/cfg.c +5
-0+struct ieee80211_local *local; +struct ieee80211_vif *vif; + +if (!sdata) +return 0 ;net/mac80211/cfg.c static struct wireless_dev *ieee80211_add_iface(struct wiphy *wiphy, · line 197
Quoted 10 lines
net/mac80211/cfg.c +10
-0+ + local = sdata->local; + vif = &sdata->vif; +if (vif->type ==NL80211_IFTYPE_AP && +ieee80211_hw_check (&local->hw,SUPPORTS_MBSSID_AP )) { +if (vif->mbssid.flags &IEEE80211_VIF_MBSSID_TX ) { +struct ieee80211_sub_if_data *child, *tmpsdata; + +wiphy_unlock (local->hw.wiphy); +mutex_lock (&local->iflist_mtx);I really don't think you can drop the locking like that in the middle of something. That's almost always a recipe for disaster.
[...]
Quoted 11 lines
I'm not able to come up with a different solution which does not cause a deadlock by continuing to hold
wiphy_lock()as we discussed last time thatdev_close()will in turn call into cfg80211.You had suggested looking at
dev_close()for VLAN, that code also doesn't lockwiphy_lockhence I did same here but locked 'local->iflist_mtx'. Dropping both won't be good for sure.Can you please suggest a better way? I'm really not able to come up with one.
Yeah, it's a tricky one for sure, especially with the locking changes.
Now that I look at this more closely - the code in ieee80211_del_iface() must be redundant since the interface has to go through ieee80211_do_stop() (perhaps during this) if it's actually up?
However, I'm hnsure why you don't understand the VLAN code - see what I did in commit d5befb224edb ("mac80211: fix deadlock in AP/VLAN handling")?
johannes
PATCH v10 3/4 mac80211: MBSSID and EMA support in beacon handling
In reply to Aloka DixitFrom: John Crispin <[email protected]>
New fields added in struct beacon_data to store all MBSSID elements and the index of the next element to be included in beacon template.
For a non-EMA AP, a single beacon template is generated with all elements. For an EMA AP, multiple beacon templates are generated and each includes a single MBSSID element. EMA profile periodicity equals the count of elements.
This patch also generates and includes multiple BSSID configuration element in each beacon template for both EMA/non-EMA AP when MBSSID is enabled.
New field added in struct ieee80211_mutable_offsets to store offset of the first MBSSID element in beacons. Also the offset for channel switch announcement (CSA) is modified to account for MBSSID length.
Depending on the hardware support and the usecase, drivers should use following functions for beacon generation:
(1) ieee80211_beacon_get_template() - Existing function for legacy beacon generation for non-MBSSID APs. No change in prototype.
(2) ieee80211_beacon_get_template_ema_next() - Generate the next EMA beacon template using the 'ema_index' stored in beacon_data.
(3) ieee80211_beacon_get_template_ema_list() - Generate all EMA templates. Drivers must call ieee80211_beacon_free_ema_list() to free the memory.
This commit also adds a missing free() for sdata->u.ap.next_beacon in ieee80211_set_csa_beacon() and sets the pointer to NULL in case of error.
---
v10: Added the lock missing in v9 for ieee80211_beacon_get_tim()
include/net/mac80211.h | 89 +++++++++++++++++ net/mac80211/cfg.c | 116 ++++++++++++++++++++--- net/mac80211/ieee80211_i.h | 2 + net/mac80211/tx.c | 189 ++++++++++++++++++++++++++++++++----- 4 files changed, 363 insertions(+), 33 deletions(-)
include/net/mac80211.h +89 -0
@@ -4897,12 +4897,14 @@ void ieee80211_report_low_ack(struct ieee80211_sta *sta, u32 num_packets);* @cntdwn_counter_offs: array of IEEE80211_MAX_CNTDWN_COUNTERS_NUM offsets * to countdown counters. This array can contain zero values which * should be ignored. +* @mbssid_offset: position of the multiple bssid element */ struct ieee80211_mutable_offsets {u16 tim_offset;u16 tim_length;u16 cntdwn_counter_offs[IEEE80211_MAX_CNTDWN_COUNTERS_NUM ]; +u16 mbssid_offset; };/**
@@ -4929,6 +4931,93 @@ ieee80211_beacon_get_template(struct ieee80211_hw *hw,struct ieee80211_vif *vif, struct ieee80211_mutable_offsets *offs); +/** +* enum ieee80211_bcn_tmpl_ema - EMA beacon generation type +* +* When enhanced multi-BSSID advertisements (EMA) mode is enabled, the +* non-transmitting profiles from the multiple BSSID set are split into more +* than one multiple BSSID elements if required. Each EMA beacon includes only +* one element to reduce the total size. The number of beacons required to +* cover all profiles is called as the profile periodicity of the set. +* +* In MAC80211, the multiple BSSID elements passed by the application are +* stored in a array and the index of the next element (starting from 0) to be +* included in the beacon template is tracked through the member ema_index of +* struct beacon_data. +* +* @IEEE80211_BCN_EMA_NONE: Used when EMA is disabled. Only one beacon +* template will be generated which includes all multiple BSSID elements. +* @IEEE80211_BCN_EMA_NEXT: Used when EMA is enabled. Includes the next +* multiple BSSID element while generating the beacon template. +* @IEEE80211_BCN_EMA_BASE: Used when EMA is enabled. Beacon template includes +* the multiple MBSSID element at a specified index which should be set +* to a value more than or equal to IEEE80211_BCN_EMA_BASE. +*/ +enum ieee80211_bcn_tmpl_ema { +IEEE80211_BCN_EMA_NONE =-2 , +IEEE80211_BCN_EMA_NEXT =-1 , +IEEE80211_BCN_EMA_BASE =0 , +}; + +/** +* ieee80211_beacon_get_template_ema_next - EMA beacon template generation +* function for drivers using the sw offload path. +* @hw: pointer obtained from ieee80211_alloc_hw(). +* @vif: &struct ieee80211_vif pointer from the add_interface callback. +* @offs: &struct ieee80211_mutable_offsets pointer to struct that will +* receive the offsets that may be updated by the driver. +* +* This function follows the same rules as ieee80211_beacon_get_template() +* but returns a beacon template which includes the next multiple BSSID +* element. +* +* Return: The beacon template. %NULL on error. +*/ +struct sk_buff *ieee80211_beacon_get_template_ema_next (struct ieee80211_hw *hw, +struct ieee80211_vif *vif, +struct ieee80211_mutable_offsets *offs); + +/** +* struct ieee80211_ema_bcn_list - list entry of an EMA beacon +* @list: the list pointer. +* @skb: the skb containing this specific beacon +* @offs: &struct ieee80211_mutable_offsets pointer to struct that will +* receive the offsets that may be updated by the driver. +*/ +struct ieee80211_ema_bcn_list { +struct list_head list; +struct sk_buff *skb; +struct ieee80211_mutable_offsets offs; +}; + +/** +* ieee80211_beacon_get_template_ema_list - EMA beacon template generation +* function for drivers using the hw offload. +* @hw: pointer obtained from ieee80211_alloc_hw(). +* @vif: &struct ieee80211_vif pointer from the add_interface callback. +* @head: linked list head that will get populated with +* &struct ieee80211_ema_bcn_list pointers. +* +* This function follows the same rules as ieee80211_beacon_get_template() +* but returns a linked list of all beacon templates required to cover all +* profiles in the multiple BSSID set. Each template includes only one multiple +* BSSID element. +* +* Return: The nuber of entries in the list or 0 on error. +*/ +int ieee80211_beacon_get_template_ema_list (struct ieee80211_hw *hw, +struct ieee80211_vif *vif, +struct list_head *head); + +/** +* ieee80211_beacon_free_ema_list - free an EMA beacon template list +* @head: linked list head containing &struct ieee80211_ema_bcn_list pointers. +* +* This function will free a list previously acquired by calling +* ieee80211_beacon_get_template_ema_list() +*/ +void ieee80211_beacon_free_ema_list (struct list_head *head); +/** * ieee80211_beacon_get_tim - beacon generation function * @hw: pointer obtained from ieee80211_alloc_hw().
net/mac80211/cfg.c +104 -12
222 lines not on this page · raw message
net/mac80211/ieee80211_i.h +2 -0
@@ -261,6 +261,8 @@ struct beacon_data {struct ieee80211_meshconf_ie *meshconf;u16 cntdwn_counter_offsets[IEEE80211_MAX_CNTDWN_COUNTERS_NUM ];u8 cntdwn_current_counter; +struct cfg80211_mbssid_elems *mbssid; +u16 ema_index;struct rcu_head rcu_head; };
net/mac80211/tx.c +168 -21
293 lines not on this page · raw message
Signature · 1 line
2.31.1
PATCH v10 4/4 mac80211: CSA on non-transmitting interfaces
In reply to Aloka DixitFrom: John Crispin <[email protected]>
Trigger ieee80211_csa_finish() on the non-transmitting interfaces when channel switch concludes on the transmitting interface.
The mutex wiphy->mtx is released before locking sdata->local->iflist_mtx to avoid deadlock with any other code path which may be using the same mutexes in opposite order.
---
v10: Used iflist_mtx instead of rcu_read_lock() as most other accesses
to sdata->local->interfaces do so.
net/mac80211/cfg.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-)
net/mac80211/cfg.c +15 -2
@@ -3254,8 +3254,21 @@ void ieee80211_csa_finish(struct ieee80211_vif *vif) {struct ieee80211_sub_if_data *sdata =vif_to_sdata (vif); -ieee80211_queue_work (&sdata->local->hw, - &sdata->csa_finalize_work); +if (sdata->vif.mbssid.flags &IEEE80211_VIF_MBSSID_TX ) { +struct ieee80211_sub_if_data *child; + +wiphy_unlock (sdata->local->hw.wiphy); +mutex_lock (&sdata->local->iflist_mtx); +list_for_each_entry (child, &sdata->local->interfaces, list) +if (child->vif.mbssid.parent == vif && +ieee80211_sdata_running (child)) +ieee80211_queue_work (&child->local->hw, + &child->csa_finalize_work); +mutex_unlock (&sdata->local->iflist_mtx); +wiphy_lock (sdata->local->hw.wiphy); + } + +ieee80211_queue_work (&sdata->local->hw, &sdata->csa_finalize_work); }EXPORT_SYMBOL (ieee80211_csa_finish);
Signature · 1 line
2.31.1
Johannes Berg
maintainerRe: [PATCH v10 4/4] mac80211: CSA on non-transmitting interfaces
net/mac80211/cfg.c void ieee80211_csa_finish(struct ieee80211_vif *vif) · line 3268
Quoted 13 lines · Aloka Dixit
net/mac80211/cfg.c +12
-0+if (sdata->vif.mbssid.flags &IEEE80211_VIF_MBSSID_TX ) { +struct ieee80211_sub_if_data *child; + +wiphy_unlock (sdata->local->hw.wiphy); +mutex_lock (&sdata->local->iflist_mtx); +list_for_each_entry (child, &sdata->local->interfaces, list) +if (child->vif.mbssid.parent == vif && +ieee80211_sdata_running (child)) +ieee80211_queue_work (&child->local->hw, + &child->csa_finalize_work); +mutex_unlock (&sdata->local->iflist_mtx); +wiphy_lock (sdata->local->hw.wiphy);
Same here wrt. locking, but for queueing work it shouldn't matter?
johannes