From: John Crispin <john@phrozen.org>
To: Johannes Berg <johannes@sipsolutions.net>
Cc: linux-wireless@vger.kernel.org, ath11k@lists.infradead.org,
John Crispin <john@phrozen.org>
Subject: [PATCH 04/12] mac80211: add multiple bssid support
Date: Thu, 4 Jun 2020 09:09:44 +0200 [thread overview]
Message-ID: <20200604070952.15481-5-john@phrozen.org> (raw)
In-Reply-To: <20200604070952.15481-1-john@phrozen.org>
When bringing up multi bssid APs we need to track the parent-child relation
of non-transmitting and transmitting VAPs.
The patch makes sure that
* a parent can not be deleted while it has children
* a parent can only be opened when all children are open
* a childs parent needs to exist when the child is added
* a child can only be closed when its parent is already closed
This patch ensures the above by using a linked list to track the relations.
Signed-off-by: John Crispin <john@phrozen.org>
---
include/net/mac80211.h | 20 ++++++++++++++
net/mac80211/cfg.c | 61 ++++++++++++++++++++++++++++++++++++++++++
net/mac80211/iface.c | 16 +++++++++++
net/mac80211/util.c | 27 +++++++++++++++++++
4 files changed, 124 insertions(+)
diff --git a/include/net/mac80211.h b/include/net/mac80211.h
index b6b4de0e4b5e..bb2edace71a9 100644
--- a/include/net/mac80211.h
+++ b/include/net/mac80211.h
@@ -6529,4 +6529,24 @@ u32 ieee80211_calc_tx_airtime(struct ieee80211_hw *hw,
*/
bool ieee80211_set_hw_80211_encap(struct ieee80211_vif *vif, bool enable);
+/**
+ * ieee80211_get_multi_bssid_mode - get a vifs multi bssid mode.
+ *
+ * This function is used to help look up the multi bssid mode which is tracked
+ * inside the wdev.
+ *
+ * @vif: &struct ieee80211_vif pointer from the add_interface callback.
+ */
+enum nl80211_multi_bssid_mode ieee80211_get_multi_bssid_mode(struct ieee80211_vif *vif);
+
+/**
+ * ieee80211_get_multi_bssid_parent - get a vifs multi bssid parent.
+ *
+ * This function is used to help look up the multi bssid parent which is tracked
+ * inside the wdev.
+ *
+ * @vif: &struct ieee80211_vif pointer from the add_interface callback.
+ */
+struct ieee80211_vif *ieee80211_get_multi_bssid_parent(struct ieee80211_vif *vif);
+
#endif /* MAC80211_H */
diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
index ea3791a930e8..e4f73567d873 100644
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
@@ -111,6 +111,42 @@ static int ieee80211_set_mon_options(struct ieee80211_sub_if_data *sdata,
return 0;
}
+static int ieee80211_set_multi_bssid_options(struct ieee80211_sub_if_data *sdata,
+ struct vif_params *params)
+{
+ struct ieee80211_local *local = sdata->local;
+ struct wiphy *wiphy = local->hw.wiphy;
+ struct net_device *parent;
+
+ if (params->multi_bssid_mode &&
+ !ieee80211_hw_check(&local->hw, SUPPORTS_MULTI_BSSID))
+ return -ENOTSUPP;
+
+ switch (params->multi_bssid_mode) {
+ case NL80211_MULTIPLE_BSSID_NON_TRANSMITTED:
+ parent = __dev_get_by_index(wiphy_net(wiphy),
+ params->multi_bssid_parent);
+ if (!parent || !parent->ieee80211_ptr ||
+ parent->ieee80211_ptr->multi_bssid_mode !=
+ NL80211_MULTIPLE_BSSID_TRANSMITTED)
+ return -EINVAL;
+ sdata->wdev.multi_bssid_parent = parent->ieee80211_ptr;
+ list_add(&sdata->wdev.multi_bssid_list,
+ &parent->ieee80211_ptr->multi_bssid_list);
+ break;
+
+ case NL80211_MULTIPLE_BSSID_TRANSMITTED:
+ INIT_LIST_HEAD(&sdata->wdev.multi_bssid_list);
+ break;
+
+ default:
+ break;
+ }
+ sdata->wdev.multi_bssid_mode = params->multi_bssid_mode;
+
+ return 0;
+}
+
static struct wireless_dev *ieee80211_add_iface(struct wiphy *wiphy,
const char *name,
unsigned char name_assign_type,
@@ -136,11 +172,36 @@ static struct wireless_dev *ieee80211_add_iface(struct wiphy *wiphy,
}
}
+ if (type == NL80211_IFTYPE_AP) {
+ err = ieee80211_set_multi_bssid_options(sdata, params);
+ if (err) {
+ ieee80211_if_remove(sdata);
+ return NULL;
+ }
+ }
+
return wdev;
}
static int ieee80211_del_iface(struct wiphy *wiphy, struct wireless_dev *wdev)
{
+ struct ieee80211_sub_if_data *sdata;
+
+ sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
+ switch (sdata->wdev.multi_bssid_mode) {
+ case NL80211_MULTIPLE_BSSID_TRANSMITTED:
+ if (!list_empty(&sdata->wdev.multi_bssid_list))
+ return -EBUSY;
+ break;
+
+ case NL80211_MULTIPLE_BSSID_NON_TRANSMITTED:
+ list_del(&sdata->wdev.multi_bssid_list);
+ break;
+
+ default:
+ break;
+ }
+
ieee80211_if_remove(IEEE80211_WDEV_TO_SUB_IF(wdev));
return 0;
diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
index d069825705d6..4d3d8ee99960 100644
--- a/net/mac80211/iface.c
+++ b/net/mac80211/iface.c
@@ -535,6 +535,15 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
}
case NL80211_IFTYPE_AP:
sdata->bss = &sdata->u.ap;
+ if (wdev->multi_bssid_mode == NL80211_MULTIPLE_BSSID_TRANSMITTED) {
+ struct wireless_dev *child;
+
+ /* make sure all children are already up */
+ list_for_each_entry(child, &wdev->multi_bssid_list,
+ multi_bssid_list)
+ if (!wdev_running(child))
+ return -ENETDOWN;
+ }
break;
case NL80211_IFTYPE_MESH_POINT:
case NL80211_IFTYPE_STATION:
@@ -795,6 +804,7 @@ static int ieee80211_open(struct net_device *dev)
static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
bool going_down)
{
+ struct wireless_dev *wdev = ieee80211_vif_to_wdev(&sdata->vif);
struct ieee80211_local *local = sdata->local;
unsigned long flags;
struct sk_buff *skb, *tmp;
@@ -805,6 +815,12 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
bool cancel_scan;
struct cfg80211_nan_func *func;
+ if (sdata->vif.type == NL80211_IFTYPE_AP &&
+ wdev->multi_bssid_mode == NL80211_MULTIPLE_BSSID_NON_TRANSMITTED)
+ /* make sure the parent is already down */
+ if (wdev_running(wdev->multi_bssid_parent))
+ return;
+
clear_bit(SDATA_STATE_RUNNING, &sdata->state);
cancel_scan = rcu_access_pointer(local->scan_sdata) == sdata;
diff --git a/net/mac80211/util.c b/net/mac80211/util.c
index 20436c86b9bf..a7c4d6a44e21 100644
--- a/net/mac80211/util.c
+++ b/net/mac80211/util.c
@@ -847,6 +847,33 @@ struct wireless_dev *ieee80211_vif_to_wdev(struct ieee80211_vif *vif)
}
EXPORT_SYMBOL_GPL(ieee80211_vif_to_wdev);
+enum nl80211_multi_bssid_mode ieee80211_get_multi_bssid_mode(struct ieee80211_vif *vif)
+{
+ struct ieee80211_sub_if_data *sdata;
+
+ if (!vif)
+ return 0;
+
+ sdata = vif_to_sdata(vif);
+
+ return sdata->wdev.multi_bssid_mode;
+}
+EXPORT_SYMBOL_GPL(ieee80211_get_multi_bssid_mode);
+
+struct ieee80211_vif *ieee80211_get_multi_bssid_parent(struct ieee80211_vif *vif)
+{
+ struct ieee80211_sub_if_data *sdata;
+
+ if (!vif)
+ return NULL;
+
+ sdata = vif_to_sdata(vif);
+ if (sdata->wdev.multi_bssid_parent)
+ return wdev_to_ieee80211_vif(sdata->wdev.multi_bssid_parent);
+ return NULL;
+}
+EXPORT_SYMBOL_GPL(ieee80211_get_multi_bssid_parent);
+
/*
* Nothing should have been stuffed into the workqueue during
* the suspend->resume cycle. Since we can't check each caller
--
2.20.1
_______________________________________________
ath11k mailing list
ath11k@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/ath11k
WARNING: multiple messages have this Message-ID (diff)
From: John Crispin <john@phrozen.org>
To: Johannes Berg <johannes@sipsolutions.net>
Cc: linux-wireless@vger.kernel.org, ath11k@lists.infradead.org,
John Crispin <john@phrozen.org>
Subject: [PATCH 04/12] mac80211: add multiple bssid support
Date: Thu, 4 Jun 2020 09:09:44 +0200 [thread overview]
Message-ID: <20200604070952.15481-5-john@phrozen.org> (raw)
In-Reply-To: <20200604070952.15481-1-john@phrozen.org>
When bringing up multi bssid APs we need to track the parent-child relation
of non-transmitting and transmitting VAPs.
The patch makes sure that
* a parent can not be deleted while it has children
* a parent can only be opened when all children are open
* a childs parent needs to exist when the child is added
* a child can only be closed when its parent is already closed
This patch ensures the above by using a linked list to track the relations.
Signed-off-by: John Crispin <john@phrozen.org>
---
include/net/mac80211.h | 20 ++++++++++++++
net/mac80211/cfg.c | 61 ++++++++++++++++++++++++++++++++++++++++++
net/mac80211/iface.c | 16 +++++++++++
net/mac80211/util.c | 27 +++++++++++++++++++
4 files changed, 124 insertions(+)
diff --git a/include/net/mac80211.h b/include/net/mac80211.h
index b6b4de0e4b5e..bb2edace71a9 100644
--- a/include/net/mac80211.h
+++ b/include/net/mac80211.h
@@ -6529,4 +6529,24 @@ u32 ieee80211_calc_tx_airtime(struct ieee80211_hw *hw,
*/
bool ieee80211_set_hw_80211_encap(struct ieee80211_vif *vif, bool enable);
+/**
+ * ieee80211_get_multi_bssid_mode - get a vifs multi bssid mode.
+ *
+ * This function is used to help look up the multi bssid mode which is tracked
+ * inside the wdev.
+ *
+ * @vif: &struct ieee80211_vif pointer from the add_interface callback.
+ */
+enum nl80211_multi_bssid_mode ieee80211_get_multi_bssid_mode(struct ieee80211_vif *vif);
+
+/**
+ * ieee80211_get_multi_bssid_parent - get a vifs multi bssid parent.
+ *
+ * This function is used to help look up the multi bssid parent which is tracked
+ * inside the wdev.
+ *
+ * @vif: &struct ieee80211_vif pointer from the add_interface callback.
+ */
+struct ieee80211_vif *ieee80211_get_multi_bssid_parent(struct ieee80211_vif *vif);
+
#endif /* MAC80211_H */
diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
index ea3791a930e8..e4f73567d873 100644
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
@@ -111,6 +111,42 @@ static int ieee80211_set_mon_options(struct ieee80211_sub_if_data *sdata,
return 0;
}
+static int ieee80211_set_multi_bssid_options(struct ieee80211_sub_if_data *sdata,
+ struct vif_params *params)
+{
+ struct ieee80211_local *local = sdata->local;
+ struct wiphy *wiphy = local->hw.wiphy;
+ struct net_device *parent;
+
+ if (params->multi_bssid_mode &&
+ !ieee80211_hw_check(&local->hw, SUPPORTS_MULTI_BSSID))
+ return -ENOTSUPP;
+
+ switch (params->multi_bssid_mode) {
+ case NL80211_MULTIPLE_BSSID_NON_TRANSMITTED:
+ parent = __dev_get_by_index(wiphy_net(wiphy),
+ params->multi_bssid_parent);
+ if (!parent || !parent->ieee80211_ptr ||
+ parent->ieee80211_ptr->multi_bssid_mode !=
+ NL80211_MULTIPLE_BSSID_TRANSMITTED)
+ return -EINVAL;
+ sdata->wdev.multi_bssid_parent = parent->ieee80211_ptr;
+ list_add(&sdata->wdev.multi_bssid_list,
+ &parent->ieee80211_ptr->multi_bssid_list);
+ break;
+
+ case NL80211_MULTIPLE_BSSID_TRANSMITTED:
+ INIT_LIST_HEAD(&sdata->wdev.multi_bssid_list);
+ break;
+
+ default:
+ break;
+ }
+ sdata->wdev.multi_bssid_mode = params->multi_bssid_mode;
+
+ return 0;
+}
+
static struct wireless_dev *ieee80211_add_iface(struct wiphy *wiphy,
const char *name,
unsigned char name_assign_type,
@@ -136,11 +172,36 @@ static struct wireless_dev *ieee80211_add_iface(struct wiphy *wiphy,
}
}
+ if (type == NL80211_IFTYPE_AP) {
+ err = ieee80211_set_multi_bssid_options(sdata, params);
+ if (err) {
+ ieee80211_if_remove(sdata);
+ return NULL;
+ }
+ }
+
return wdev;
}
static int ieee80211_del_iface(struct wiphy *wiphy, struct wireless_dev *wdev)
{
+ struct ieee80211_sub_if_data *sdata;
+
+ sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
+ switch (sdata->wdev.multi_bssid_mode) {
+ case NL80211_MULTIPLE_BSSID_TRANSMITTED:
+ if (!list_empty(&sdata->wdev.multi_bssid_list))
+ return -EBUSY;
+ break;
+
+ case NL80211_MULTIPLE_BSSID_NON_TRANSMITTED:
+ list_del(&sdata->wdev.multi_bssid_list);
+ break;
+
+ default:
+ break;
+ }
+
ieee80211_if_remove(IEEE80211_WDEV_TO_SUB_IF(wdev));
return 0;
diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
index d069825705d6..4d3d8ee99960 100644
--- a/net/mac80211/iface.c
+++ b/net/mac80211/iface.c
@@ -535,6 +535,15 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
}
case NL80211_IFTYPE_AP:
sdata->bss = &sdata->u.ap;
+ if (wdev->multi_bssid_mode == NL80211_MULTIPLE_BSSID_TRANSMITTED) {
+ struct wireless_dev *child;
+
+ /* make sure all children are already up */
+ list_for_each_entry(child, &wdev->multi_bssid_list,
+ multi_bssid_list)
+ if (!wdev_running(child))
+ return -ENETDOWN;
+ }
break;
case NL80211_IFTYPE_MESH_POINT:
case NL80211_IFTYPE_STATION:
@@ -795,6 +804,7 @@ static int ieee80211_open(struct net_device *dev)
static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
bool going_down)
{
+ struct wireless_dev *wdev = ieee80211_vif_to_wdev(&sdata->vif);
struct ieee80211_local *local = sdata->local;
unsigned long flags;
struct sk_buff *skb, *tmp;
@@ -805,6 +815,12 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
bool cancel_scan;
struct cfg80211_nan_func *func;
+ if (sdata->vif.type == NL80211_IFTYPE_AP &&
+ wdev->multi_bssid_mode == NL80211_MULTIPLE_BSSID_NON_TRANSMITTED)
+ /* make sure the parent is already down */
+ if (wdev_running(wdev->multi_bssid_parent))
+ return;
+
clear_bit(SDATA_STATE_RUNNING, &sdata->state);
cancel_scan = rcu_access_pointer(local->scan_sdata) == sdata;
diff --git a/net/mac80211/util.c b/net/mac80211/util.c
index 20436c86b9bf..a7c4d6a44e21 100644
--- a/net/mac80211/util.c
+++ b/net/mac80211/util.c
@@ -847,6 +847,33 @@ struct wireless_dev *ieee80211_vif_to_wdev(struct ieee80211_vif *vif)
}
EXPORT_SYMBOL_GPL(ieee80211_vif_to_wdev);
+enum nl80211_multi_bssid_mode ieee80211_get_multi_bssid_mode(struct ieee80211_vif *vif)
+{
+ struct ieee80211_sub_if_data *sdata;
+
+ if (!vif)
+ return 0;
+
+ sdata = vif_to_sdata(vif);
+
+ return sdata->wdev.multi_bssid_mode;
+}
+EXPORT_SYMBOL_GPL(ieee80211_get_multi_bssid_mode);
+
+struct ieee80211_vif *ieee80211_get_multi_bssid_parent(struct ieee80211_vif *vif)
+{
+ struct ieee80211_sub_if_data *sdata;
+
+ if (!vif)
+ return NULL;
+
+ sdata = vif_to_sdata(vif);
+ if (sdata->wdev.multi_bssid_parent)
+ return wdev_to_ieee80211_vif(sdata->wdev.multi_bssid_parent);
+ return NULL;
+}
+EXPORT_SYMBOL_GPL(ieee80211_get_multi_bssid_parent);
+
/*
* Nothing should have been stuffed into the workqueue during
* the suspend->resume cycle. Since we can't check each caller
--
2.20.1
next prev parent reply other threads:[~2020-06-04 7:10 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-04 7:09 [PATCH 00/12] mac80211: add multiple bssid support John Crispin
2020-06-04 7:09 ` John Crispin
2020-06-04 7:09 ` [PATCH 01/12] nl80211: add basic " John Crispin
2020-06-04 7:09 ` John Crispin
2020-06-10 0:25 ` Rajkumar Manoharan
2020-06-10 0:25 ` Rajkumar Manoharan
2020-06-04 7:09 ` [PATCH 02/12] nl80211: add attributes for multiple bssid related settings John Crispin
2020-06-04 7:09 ` John Crispin
2020-06-11 4:24 ` Rajkumar Manoharan
2020-06-11 4:24 ` Rajkumar Manoharan
2020-06-04 7:09 ` [PATCH 03/12] nl80211: add attributes to set beacon transmit mode John Crispin
2020-06-04 7:09 ` John Crispin
2020-06-04 7:09 ` John Crispin [this message]
2020-06-04 7:09 ` [PATCH 04/12] mac80211: add multiple bssid support John Crispin
2020-06-04 7:09 ` [PATCH 05/12] mac80211: add multiple bssid IE parsing John Crispin
2020-06-04 7:09 ` John Crispin
2020-06-04 7:09 ` [PATCH 06/12] mac80211: propagate multi bssid settings when starting an AP John Crispin
2020-06-04 7:09 ` John Crispin
2020-06-04 7:09 ` [PATCH 07/12] mac80211: propagate beacon tx mode to the driver John Crispin
2020-06-04 7:09 ` John Crispin
2020-06-04 7:09 ` [PATCH 08/12] ath11k: pass multiple bssid info to FW when a new vdev is created John Crispin
2020-06-04 7:09 ` John Crispin
2020-06-04 7:09 ` [PATCH 09/12] ath11k: add a struct to pass parameters into ath11k_wmi_vdev_up John Crispin
2020-06-04 7:09 ` John Crispin
2020-06-04 7:09 ` [PATCH 10/12] ath11k: add the multiple bssid IE offset to the beacon template John Crispin
2020-06-04 7:09 ` John Crispin
2020-06-04 7:09 ` [PATCH 11/12] ath11k: set beacon tx mode John Crispin
2020-06-04 7:09 ` John Crispin
2020-06-04 7:09 ` [PATCH 12/12] ath11k: set the multiple bssid hw cap John Crispin
2020-06-04 7:09 ` John Crispin
2020-06-08 11:09 ` Kalle Valo
2020-06-08 11:09 ` Kalle Valo
2020-06-08 11:29 ` John Crispin
2020-06-08 11:29 ` John Crispin
2020-06-11 4:44 ` Rajkumar Manoharan
2020-06-11 4:44 ` Rajkumar Manoharan
2020-06-09 3:35 ` [PATCH 00/12] mac80211: add multiple bssid support Rajkumar Manoharan
2020-06-09 3:35 ` Rajkumar Manoharan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200604070952.15481-5-john@phrozen.org \
--to=john@phrozen.org \
--cc=ath11k@lists.infradead.org \
--cc=johannes@sipsolutions.net \
--cc=linux-wireless@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.