Skip to contentSkip to conversation

mac80211: add BSS color change support

PATCH In review John Crispin 2 participants 6 messages Nov 3, 2020 – Nov 6, 2020

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

v6 cover mac80211: add BSS color change support

This series adds support for BSS color collission detection and change.

This series depends on the multiple bssid one.

Changes in V6
* rebase on current next tree
* add 2 addition guards

John Crispin (3):
nl80211: add support for BSS coloring
mac80211: add support for BSS color change
ath11k: add support for BSS color change

 drivers/net/wireless/ath/ath11k/mac.c |  35 ++++
 drivers/net/wireless/ath/ath11k/mac.h |   1 +
 drivers/net/wireless/ath/ath11k/wmi.c |  57 ++++++
 drivers/net/wireless/ath/ath11k/wmi.h |  14 ++
 include/net/cfg80211.h                |  95 ++++++++++
 include/net/mac80211.h                |  28 +++
 include/uapi/linux/nl80211.h          |  46 +++++
 net/mac80211/cfg.c                    | 250 +++++++++++++++++++++++++-
 net/mac80211/ieee80211_i.h            |  12 ++
 net/mac80211/iface.c                  |   3 +
 net/mac80211/tx.c                     |  24 ++-
 net/wireless/nl80211.c                | 135 ++++++++++++++
 net/wireless/rdev-ops.h               |  12 ++
 net/wireless/trace.h                  |  47 +++++
 14 files changed, 741 insertions(+), 18 deletions(-)
Signature · 1 line
2.25.1
#1 lore raw

PATCH v6 1/3 nl80211: add support for BSS coloring

This patch adds support for BSS color collisions to the wireless subsystem. Add the required functionality to nl80211 that will notify about color collisions, triggering the color change and notifying when it is completed.

---
 include/net/cfg80211.h       |  95 ++++++++++++++++++++++++
 include/uapi/linux/nl80211.h |  46 ++++++++++++
 net/wireless/nl80211.c       | 135 +++++++++++++++++++++++++++++++++++
 net/wireless/rdev-ops.h      |  12 ++++
 net/wireless/trace.h         |  47 ++++++++++++
 5 files changed, 335 insertions(+)
include/net/cfg80211.h +95 -0
index 0be0c11c95fd..ed4c08e38f70 100644
@@ -1272,6 +1272,27 @@ struct cfg80211_csa_settings {
 	u8 count;
 };
 
+/**
+ * struct cfg80211_color_change_settings - color change settings
+ *
+ * Used for color change
+ *
+ * @beacon_color_change: beacon data while performing the change
+ * @counter_offsets_beacon: offsets of the counters within the beacon (tail)
+ * @counter_offsets_presp: offsets of the counters within the probe response
+ * @beacon_after: beacon data to be used after the change
+ * @count: number of beacons until the change
+ * @color: the color that we will have after the change
+ */
+struct cfg80211_color_change_settings {
+	struct cfg80211_beacon_data beacon_color_change;
+	u16 counter_offset_beacon;
+	u16 counter_offset_presp;
+	struct cfg80211_beacon_data beacon_after;
+	u8 count;
+	u8 color;
+};
+
 #define CFG80211_MAX_NUM_DIFFERENT_CHANNELS 10
 
 /**
@@ -3954,6 +3975,7 @@ struct mgmt_frame_regs {
  *	This callback may sleep.
  * @reset_tid_config: Reset TID specific configuration for the peer, for the
  *	given TIDs. This callback may sleep.
+ * @color_change: initiate a color change (with color change).
  */
 struct cfg80211_ops {
 	int	(*suspend)(struct wiphy *wiphy, struct cfg80211_wowlan *wow);
@@ -4282,6 +4304,9 @@ struct cfg80211_ops {
 				  struct cfg80211_tid_config *tid_conf);
 	int	(*reset_tid_config)(struct wiphy *wiphy, struct net_device *dev,
 				    const u8 *peer, u8 tids);
+	int	(*color_change)(struct wiphy *wiphy,
+				struct net_device *dev,
+				struct cfg80211_color_change_settings *params);
 };
 
 /*
@@ -8059,4 +8084,74 @@ void cfg80211_update_owe_info_event(struct net_device *netdev,
  */
 void cfg80211_bss_flush(struct wiphy *wiphy);
 
+
+/*
+ * cfg80211_bss_color_notify - notify about bss color event
+ * @dev: network device
+ * @gfp: allocation flags
+ * notif: the actual event we want to notify
+ * @count: the number of TBTTs until the color change happens
+ * @color_bitmap: representations of the colors that the local BSS is aware of
+ */
+void cfg80211_bss_color_notify(struct net_device *dev,
+			       gfp_t gfp, enum nl80211_commands notify,
+			       u8 count, u64 color_bitmap);
+
+/*
+ * cfg80211_obss_color_collision_notify - notify about bss color collisions
+ * @dev: network device
+ * @color_bitmap: representations of the colors that the local BSS is aware of
+ */
+static inline void cfg80211_obss_color_collision_notify(struct net_device *dev,
+							u64 color_bitmap)
+{
+	cfg80211_bss_color_notify(dev, GFP_KERNEL,
+				 NL80211_CMD_OBSS_COLOR_COLLISION,
+				 0, color_bitmap);
+}
+
+/*
+ * cfg80211_color_change_started_notify - notify color change start
+ * @dev: the device on which the color is switched
+ * @count: the number of TBTTs until the color change happens
+ *
+ * Inform the userspace about the color change that has just
+ * started.
+ */
+static inline void cfg80211_color_change_started_notify(struct net_device *dev,
+							u8 count)
+{
+	cfg80211_bss_color_notify(dev, GFP_KERNEL,
+				 NL80211_CMD_COLOR_CHANGE_ANNOUNCEMENT_STARTED,
+				 count, 0);
+}
+
+/*
+ * cfg80211_color_change_aborted_notify - notify color change abort
+ * @dev: the device on which the color is switched
+ *
+ * Inform the userspace about the color change that has just
+ * started.
+ */
+static inline void cfg80211_color_change_aborted_notify(struct net_device *dev)
+{
+	cfg80211_bss_color_notify(dev, GFP_KERNEL,
+				 NL80211_CMD_COLOR_CHANGE_ANNOUNCEMENT_ABORTED,
+				 0, 0);
+}
+
+/*
+ * cfg80211_color_change_notify - notify color change completion
+ * @dev: the device on which the color was switched
+ *
+ * Inform the userspace about the color change that has just
+ * completed.
+ */
+static inline void cfg80211_color_change_notify(struct net_device *dev)
+{
+	cfg80211_bss_color_notify(dev, GFP_KERNEL,
+				 NL80211_CMD_COLOR_CHANGE_ANNOUNCEMENT_COMPLETED,
+				 0, 0);
+}
+
 #endif /* __NET_CFG80211_H */
include/uapi/linux/nl80211.h +46 -0

82 lines not on this page · raw message

net/wireless/nl80211.c +135 -0

159 lines not on this page · raw message

net/wireless/rdev-ops.h +12 -0
index 950d57494168..752db69783ab 100644
@@ -1356,4 +1356,16 @@ static inline int rdev_reset_tid_config(struct cfg80211_registered_device *rdev,
 	return ret;
 }
 
+static inline int rdev_color_change(struct cfg80211_registered_device *rdev,
+				    struct net_device *dev,
+				    struct cfg80211_color_change_settings *params)
+{
+	int ret;
+
+	trace_rdev_color_change(&rdev->wiphy, dev, params);
+	ret = rdev->ops->color_change(&rdev->wiphy, dev, params);
+	trace_rdev_return_int(&rdev->wiphy, ret);
+	return ret;
+}
+
 #endif /* __CFG80211_RDEV_OPS */
net/wireless/trace.h +47 -0

53 lines not on this page · raw message

Signature · 1 line
2.25.1
maintainer
#2 lore raw

Re: [PATCH V6 1/3] nl80211: add support for BSS coloring

include/net/cfg80211.h void cfg80211_update_owe_info_event(struct net_device *netdev, · line 8089

Quoted 3 lines
include/net/cfg80211.h +3 -0
+
+/*
+ * cfg80211_bss_color_notify - notify about bss color event

These all need /**

I was going to fix that (and some below things), but it got a bit complex, and there's a question ... and patch 2 needs significant work anyway.

include/uapi/linux/nl80211.h enum nl80211_commands { · line 1430

Quoted 6 lines
include/uapi/linux/nl80211.h +6 -0
+	NL80211_CMD_OBSS_COLOR_COLLISION,
+
+	NL80211_CMD_COLOR_CHANGE,
+	NL80211_CMD_COLOR_CHANGE_ANNOUNCEMENT_STARTED,
+	NL80211_CMD_COLOR_CHANGE_ANNOUNCEMENT_ABORTED,
+	NL80211_CMD_COLOR_CHANGE_ANNOUNCEMENT_COMPLETED,

Might make sense to multiplex that into a single NL80211_CMD_COLOR_CHANGE event? Not sure, it doesn't matter too much now, but ... we do have limited commands eventually :-)

Quoted 2 lines

+ * @NL80211_ATTR_COLOR_CHANGE_ANNOUNCEMENT_IES: Nested set of attributes containing the IE
+ * information for the time while performing a color switch.

_ELEMS perhaps?

Should probably also be a bit more specific on what's used from there.

Quoted 2 lines

+ * @NL80211_ATTR_COLOR_CHANGE_ANNOUNCEMENT_C_OFF_BEACON: An array of offsets (u16) to the color
+ * switch counters in the beacons tail (%NL80211_ATTR_BEACON_TAIL).

Is this inside or outside, for example? I think outside, but should it be? I guess should be just like CSA though.

Quoted 2 lines

+ * @NL80211_ATTR_COLOR_CHANGE_ANNOUNCEMENT_C_OFF_PRESP: An array of offsets (u16) to the color
+ * switch counters in the probe response (%NL80211_ATTR_PROBE_RESP).

This is unused?

include/uapi/linux/nl80211.h enum nl80211_attrs { · line 3078

Quoted 12 lines

* @NUM_NL80211_ATTR: total number of nl80211_attrs available
* @NL80211_ATTR_MAX: highest attribute number currently defined
* @__NL80211_ATTR_AFTER_LAST: internal use

include/uapi/linux/nl80211.h +5 -0
@@ -3035,6 +3071,12 @@ enum nl80211_attrs {
 	NL80211_ATTR_MULTIPLE_BSSID_IES,
 	NL80211_ATTR_MULTIPLE_BSSID_EMA,
 
+	NL80211_ATTR_OBSS_COLOR_BITMAP,
+
+	NL80211_ATTR_COLOR_CHANGE_ANNOUNCEMENT_COUNT,
+	NL80211_ATTR_COLOR_CHANGE_ANNOUNCEMENT_COLOR,
+	NL80211_ATTR_COLOR_CHANGE_ANNOUNCEMENT_IES,

and in fact not defined?

net/wireless/nl80211.c static int nl80211_set_tid_config(struct sk_buff *skb, · line 14601

Quoted 7 lines
net/wireless/nl80211.c +7 -0
+static int nl80211_color_change(struct sk_buff *skb, struct genl_info *info)
+{
+	struct cfg80211_registered_device *rdev = info->user_ptr[0];
+	struct net_device *dev = info->user_ptr[1];
+	struct wireless_dev *wdev = dev->ieee80211_ptr;
+	struct cfg80211_color_change_settings params;
+	static struct nlattr *color_change_attrs[NL80211_ATTR_MAX + 1];

I'd prefer you didn't. I'm working on getting rid of the RTNL in most places, and that just adds more complexity to that ... please dynamically allocate it.

Also, it just reserves space in the binary for a very rarely used code path.

net/wireless/nl80211.c static int nl80211_set_tid_config(struct sk_buff *skb, · line 14605

Quoted 4 lines
net/wireless/nl80211.c +4 -0
+	int err, len;
+
+	if (!rdev->ops->color_change ||
+	    !(wiphy_ext_feature_isset(&rdev->wiphy, NL80211_EXT_FEATURE_BSS_COLOR)))

some line wrapping in some places would be nice - not sure if this one is affected, but still, you have a few that wouldn't be hard to wrap IMHO.

net/wireless/nl80211.c static int nl80211_set_tid_config(struct sk_buff *skb, · line 14627

Quoted 3 lines
net/wireless/nl80211.c +3 -0
+	err = nla_parse_nested(color_change_attrs, NL80211_ATTR_MAX,
+			       info->attrs[NL80211_ATTR_COLOR_CHANGE_ANNOUNCEMENT_IES],
+			       nl80211_policy, NULL);

Please pass info->extack through to the last argument.

net/wireless/nl80211.c static int nl80211_set_tid_config(struct sk_buff *skb, · line 14631

Quoted 4 lines
net/wireless/nl80211.c +4 -0
+	if (err)
+		return err;
+
+	err = nl80211_parse_beacon(rdev, color_change_attrs, &params.beacon_color_change);

(here for example, re wrapping)

net/wireless/nl80211.c static int nl80211_set_tid_config(struct sk_buff *skb, · line 14644

Quoted 10 lines
net/wireless/nl80211.c +10 -0
+	if (!info->attrs[NL80211_ATTR_CNTDWN_OFFS_BEACON])
+		return -EINVAL;
+
+	len = nla_len(info->attrs[NL80211_ATTR_CNTDWN_OFFS_BEACON]);
+	if (len != sizeof(u16))
+		return -EINVAL;
+
+	memcpy(&params.counter_offset_beacon,
+	       nla_data(info->attrs[NL80211_ATTR_CNTDWN_OFFS_BEACON]),
+	       sizeof(u16));

In the CSA case, this comes from the *inner* attributes. In your case, it comes from the *outer*. IMHO that's super confusing.

net/wireless/nl80211.c static int nl80211_set_tid_config(struct sk_buff *skb, · line 14654

Quoted 9 lines
net/wireless/nl80211.c +9 -0
+	if (params.counter_offset_beacon >= params.beacon_color_change.tail_len)
+		return -EINVAL;
+
+	if (params.beacon_color_change.tail[params.counter_offset_beacon] != params.count)
+		return -EINVAL;
+
+	if (info->attrs[NL80211_ATTR_CNTDWN_OFFS_PRESP]) {
+		params.counter_offset_presp =
+			nla_get_u16(info->attrs[NL80211_ATTR_CNTDWN_OFFS_PRESP]);

same here.

In CSA this is also allowed to be an array - the parsing code probably needs to be different because we currently don't validate the size/type of this to be NLA_U16, just like you did above with the NL80211_ATTR_CNTDWN_OFFS_BEACON.

johannes

#3 lore raw

PATCH v6 2/3 mac80211: add support for BSS color change

In reply to John Crispin

The color change announcement is very similar to how CSA works where we have an IE that includes a counter. When the counter hits 0, the new color is applied via an updated beacon.

This patch makes the CSA counter functionality reusable, rather than implementing it again. This also allows for future reuse incase support for other counter IEs gets added.

---
 include/net/mac80211.h     |  28 +++++
 net/mac80211/cfg.c         | 250 +++++++++++++++++++++++++++++++++++--
 net/mac80211/ieee80211_i.h |  12 ++
 net/mac80211/iface.c       |   3 +
 net/mac80211/tx.c          |  24 ++--
 5 files changed, 299 insertions(+), 18 deletions(-)
include/net/mac80211.h +28 -0
index 051b7cae2516..078dd77f69d2 100644
@@ -1718,6 +1718,10 @@ enum ieee80211_vif_multiple_bssid_flags {
  * @multiple_bssid.parent: a non-transmitted bssid has a transmitted parent.
  * @multiple_bssid.flags: multiple bssid flags, see
  *	&enum ieee80211_vif_multiple_bssid_flags
+ * @color_change_active: marks whether a color change is going on. Internally it is
+ *	write-protected by sdata_lock and local->mtx so holding either is fine
+ *	for read access.
+ * @color_change_color: the color that we will have after the change.
  */
 struct ieee80211_vif {
 	enum nl80211_iftype type;
@@ -1750,6 +1754,9 @@ struct ieee80211_vif {
 		u32 flags;
 	} multiple_bssid;
 
+	bool color_change_active;
+	u8 color_change_color;
+
 	/* must be last */
 	u8 drv_priv[] __aligned(sizeof(void *));
 };
@@ -5073,6 +5080,16 @@ void ieee80211_csa_finish(struct ieee80211_vif *vif);
  */
 bool ieee80211_beacon_cntdwn_is_complete(struct ieee80211_vif *vif);
 
+/**
+ * ieee80211_color_change_finish - notify mac80211 about color change
+ * @vif: &struct ieee80211_vif pointer from the add_interface callback.
+ *
+ * After a color change announcement was scheduled and the counter in this
+ * announcement hits 1, this function must be called by the driver to
+ * notify mac80211 that the color can be changed
+ */
+void ieee80211_color_change_finish(struct ieee80211_vif *vif);
+
 /**
  * ieee80211_proberesp_get - retrieve a Probe Response template
  * @hw: pointer obtained from ieee80211_alloc_hw().
@@ -6805,4 +6822,15 @@ struct sk_buff *ieee80211_get_fils_discovery_tmpl(struct ieee80211_hw *hw,
 struct sk_buff *
 ieee80211_get_unsol_bcast_probe_resp_tmpl(struct ieee80211_hw *hw,
 					  struct ieee80211_vif *vif);
+/**
+ * ieeee80211_obss_color_collision_notify notify userland about a BSS color
+ * collision.
+ *
+ * @vif: &struct ieee80211_vif pointer from the add_interface callback.
+ * @color_bitmap: a 64 bit bitmap representing the colors that the local BSS is
+ *	aware of.
+ */
+void
+ieeee80211_obss_color_collision_notify(struct ieee80211_vif *vif,
+				       u64 color_bitmap);
 #endif /* MAC80211_H */
net/mac80211/cfg.c +241 -9

334 lines not on this page · raw message

net/mac80211/ieee80211_i.h +12 -0
index e510abc5ace2..2eb96a514dc6 100644
@@ -255,6 +255,13 @@ struct ieee80211_csa_settings {
 	u8 count;
 };
 
+struct ieee80211_color_change_settings {
+	u16 counter_offset_beacon;
+	u16 counter_offset_presp;
+
+	u8 count;
+};
+
 struct beacon_data {
 	u8 *head, *tail;
 	int head_len, tail_len;
@@ -941,6 +948,8 @@ struct ieee80211_sub_if_data {
 	bool csa_block_tx; /* write-protected by sdata_lock and local->mtx */
 	struct cfg80211_chan_def csa_chandef;
 
+	struct work_struct color_change_finalize_work;
+
 	struct list_head assigned_chanctx_list; /* protected by chanctx_mtx */
 	struct list_head reserved_chanctx_list; /* protected by chanctx_mtx */
 
@@ -1758,6 +1767,9 @@ void ieee80211_csa_finalize_work(struct work_struct *work);
 int ieee80211_channel_switch(struct wiphy *wiphy, struct net_device *dev,
 			     struct cfg80211_csa_settings *params);
 
+/* color change handling */
+void ieee80211_color_change_finalize_work(struct work_struct *work);
+
 /* interface handling */
 #define MAC80211_SUPPORTED_FEATURES_TX	(NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM | \
 					 NETIF_F_HW_CSUM | NETIF_F_SG | \
net/mac80211/iface.c +3 -0
index 63a0391d2b66..f0d317de5833 100644
@@ -485,6 +485,8 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
 				   GFP_KERNEL);
 	}
 
+	cancel_work_sync(&sdata->color_change_finalize_work);
+
 	/* APs need special treatment */
 	if (sdata->vif.type == NL80211_IFTYPE_AP) {
 		struct ieee80211_sub_if_data *vlan, *tmpsdata;
@@ -1539,6 +1541,7 @@ static void ieee80211_setup_sdata(struct ieee80211_sub_if_data *sdata,
 	INIT_WORK(&sdata->work, ieee80211_iface_work);
 	INIT_WORK(&sdata->recalc_smps, ieee80211_recalc_smps_work);
 	INIT_WORK(&sdata->csa_finalize_work, ieee80211_csa_finalize_work);
+	INIT_WORK(&sdata->color_change_finalize_work, ieee80211_color_change_finalize_work);
 	INIT_LIST_HEAD(&sdata->assigned_chanctx_list);
 	INIT_LIST_HEAD(&sdata->reserved_chanctx_list);
 
net/mac80211/tx.c +15 -9
index ca0d49af9a0f..1f69fe4c4356 100644
@@ -4546,11 +4546,12 @@ static int ieee80211_beacon_add_tim(struct ieee80211_sub_if_data *sdata,
 static void ieee80211_set_beacon_cntdwn(struct ieee80211_sub_if_data *sdata,
 					struct beacon_data *beacon)
 {
+	u16 *bcn_offsets, *resp_offsets;
 	struct probe_resp *resp;
 	u8 *beacon_data;
 	size_t beacon_data_len;
 	int i;
-	u8 count = beacon->cntdwn_current_counter;
+	u8 count, max_count = 1;
 
 	switch (sdata->vif.type) {
 	case NL80211_IFTYPE_AP:
@@ -4570,21 +4571,25 @@ static void ieee80211_set_beacon_cntdwn(struct ieee80211_sub_if_data *sdata,
 	}
 
 	rcu_read_lock();
-	for (i = 0; i < IEEE80211_MAX_CNTDWN_COUNTERS_NUM; ++i) {
-		resp = rcu_dereference(sdata->u.ap.probe_resp);
+	resp = rcu_dereference(sdata->u.ap.probe_resp);
 
-		if (beacon->cntdwn_counter_offsets[i]) {
-			if (WARN_ON_ONCE(beacon->cntdwn_counter_offsets[i] >=
-					 beacon_data_len)) {
+	bcn_offsets = beacon->cntdwn_counter_offsets;
+	resp_offsets = resp->cntdwn_counter_offsets;
+	count = beacon->cntdwn_current_counter;
+	if (sdata->vif.csa_active)
+		max_count = IEEE80211_MAX_CNTDWN_COUNTERS_NUM;
+
+	for (i = 0; i < max_count; ++i) {
+		if (bcn_offsets[i]) {
+			if (WARN_ON_ONCE(bcn_offsets[i] >= beacon_data_len)) {
 				rcu_read_unlock();
 				return;
 			}
-
-			beacon_data[beacon->cntdwn_counter_offsets[i]] = count;
+			beacon_data[bcn_offsets[i]] = count;
 		}
 
 		if (sdata->vif.type == NL80211_IFTYPE_AP && resp)
-			resp->data[resp->cntdwn_counter_offsets[i]] = count;
+			resp->data[resp_offsets[i]] = count;
 	}
 	rcu_read_unlock();
 }
@@ -4830,6 +4835,7 @@ __ieee80211_beacon_get(struct ieee80211_hw *hw,
 			if (offs) {
 				offs->tim_offset = beacon->head_len;
 				offs->tim_length = skb->len - beacon->head_len;
+				offs->cntdwn_counter_offs[0] = beacon->cntdwn_counter_offsets[0];
 
 				/* for AP the csa offsets are from tail */
 				csa_off_base = skb->len;
Signature · 1 line
2.25.1
maintainer
#4 lore raw

Re: [PATCH V6 2/3] mac80211: add support for BSS color change

include/net/mac80211.h struct sk_buff *ieee80211_get_fils_discovery_tmpl(struct ieee80211_hw *hw, · line 6827

Quoted 8 lines · John Crispin
include/net/mac80211.h +3 -0
@@ -6805,4 +6822,15 @@ struct sk_buff *ieee80211_get_fils_discovery_tmpl(struct ieee80211_hw *hw,
 struct sk_buff *
 ieee80211_get_unsol_bcast_probe_resp_tmpl(struct ieee80211_hw *hw,
 					  struct ieee80211_vif *vif);
+/**
+ * ieeee80211_obss_color_collision_notify notify userland about a BSS color
+ * collision.

missing a "-" here

Quoted 8 lines
net/mac80211/cfg.c +8 -0
+static void ieee80211_color_change_bss_config_notify(struct ieee80211_sub_if_data *sdata,
+						     u8 color, int enable, u32 changed)
+{
+	sdata->vif.bss_conf.he_bss_color.color = color;
+	sdata->vif.bss_conf.he_bss_color.enabled = enable;
+	changed |= BSS_CHANGED_HE_BSS_COLOR;
+
+	ieee80211_bss_info_change_notify(sdata, changed);

net/mac80211/cfg.c static int ieee80211_reset_tid_config(struct wiphy *wiphy, · line 4292

Quoted 10 lines
net/mac80211/cfg.c +10 -0
+
+	if (ieee80211_hw_check(&sdata->local->hw, SUPPORTS_MULTI_BSSID_AP) &&
+	    !sdata->vif.multiple_bssid.parent) {
+		struct ieee80211_sub_if_data *child;
+
+		rcu_read_lock();
+		list_for_each_entry_rcu(child, &sdata->local->interfaces, list) {
+			if (child->vif.multiple_bssid.parent != &sdata->vif)
+				continue;
+			sdata_lock(child);

Err, you can't lock a mutex in an atomic context opened by rcu_read_lock().

I guess you can just take the iflist_mtx or something, but this certainly doesn't seem right.

Also, since it's being called under sdata_lock(parent), it'll need some lockdep annotations to be able to do this.

net/mac80211/cfg.c static int ieee80211_reset_tid_config(struct wiphy *wiphy, · line 4295

Quoted 3 lines
net/mac80211/cfg.c +3 -0
+			child->vif.bss_conf.he_bss_color.color = color;
+			child->vif.bss_conf.he_bss_color.enabled = enable;
+			ieee80211_bss_info_change_notify(child, BSS_CHANGED_HE_BSS_COLOR);

And the driver is also allowed to sleep in this IIRC, so you can't call it under rcu_read_lock().

johannes

#5 lore raw

PATCH v6 3/3 ath11k: add support for BSS color change

In reply to John Crispin

Whenever the MAC detects a color collision or any of its associated station detects one the FW will send out an event. Add the code to parse and handle this event and pass the data up to mac80211.

The FW does not provide an offload feature such as the one used for CSA. The color change process is hence triggered via the beacon offload tx completion events sent out by the FW.

---
 drivers/net/wireless/ath/ath11k/mac.c | 35 ++++++++++++++++
 drivers/net/wireless/ath/ath11k/mac.h |  1 +
 drivers/net/wireless/ath/ath11k/wmi.c | 57 +++++++++++++++++++++++++++
 drivers/net/wireless/ath/ath11k/wmi.h | 14 +++++++
 4 files changed, 107 insertions(+)
drivers/net/wireless/ath/ath11k/mac.c +35 -0
index 7f8dd47d2333..825470dafbb0 100644
@@ -809,6 +809,22 @@ static int ath11k_mac_setup_bcn_tmpl(struct ath11k_vif *arvif)
 	return ret;
 }
 
+void ath11k_mac_bcn_tx_event(struct ath11k_vif *arvif)
+{
+	struct ieee80211_vif *vif = arvif->vif;
+
+	if (!vif->color_change_active)
+		return;
+
+	if (ieee80211_beacon_cntdwn_is_complete(vif)) {
+		ieee80211_color_change_finish(vif);
+		return;
+	}
+
+	ieee80211_beacon_update_cntdwn(vif);
+	ath11k_mac_setup_bcn_tmpl(arvif);
+}
+
 static void ath11k_control_beaconing(struct ath11k_vif *arvif,
 				     struct ieee80211_bss_conf *info)
 {
@@ -2095,6 +2111,24 @@ static void ath11k_mac_op_bss_info_changed(struct ieee80211_hw *hw,
 			if (ret)
 				ath11k_warn(ar->ab, "failed to set bss color collision on vdev %i: %d\n",
 					    arvif->vdev_id,  ret);
+
+			param_id = WMI_VDEV_PARAM_BSS_COLOR;
+			if (info->he_bss_color.enabled)
+				param_value = info->he_bss_color.color <<
+						IEEE80211_HE_OPERATION_BSS_COLOR_OFFSET;
+			else
+				param_value = IEEE80211_HE_OPERATION_BSS_COLOR_DISABLED;
+
+			ret = ath11k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id,
+							    param_id,
+							    param_value);
+			if (ret)
+				ath11k_warn(ar->ab,
+					    "failed to set bss color param on vdev %i: %d\n",
+					    arvif->vdev_id,  ret);
+
+			ath11k_info(ar->ab, "bss color param 0x%x set on vdev %i\n",
+				    param_value, arvif->vdev_id);
 		} else if (vif->type == NL80211_IFTYPE_STATION) {
 			ret = ath11k_wmi_send_bss_color_change_enable_cmd(ar,
 									  arvif->vdev_id,
@@ -6250,6 +6284,7 @@ static int __ath11k_mac_register(struct ath11k *ar)
 
 	wiphy_ext_feature_set(ar->hw->wiphy, NL80211_EXT_FEATURE_CQM_RSSI_LIST);
 	wiphy_ext_feature_set(ar->hw->wiphy, NL80211_EXT_FEATURE_STA_TX_PWR);
+	wiphy_ext_feature_set(ar->hw->wiphy, NL80211_EXT_FEATURE_BSS_COLOR);
 
 	ar->hw->wiphy->cipher_suites = cipher_suites;
 	ar->hw->wiphy->n_cipher_suites = ARRAY_SIZE(cipher_suites);
drivers/net/wireless/ath/ath11k/mac.h +1 -0
index 0607479774a9..55978744e170 100644
@@ -146,4 +146,5 @@ int ath11k_mac_tx_mgmt_pending_free(int buf_id, void *skb, void *ctx);
 u8 ath11k_mac_bw_to_mac80211_bw(u8 bw);
 enum ath11k_supported_bw ath11k_mac_mac80211_bw_to_ath11k_bw(enum rate_info_bw bw);
 enum hal_encrypt_type ath11k_dp_tx_get_encrypt_type(u32 cipher);
+void ath11k_mac_bcn_tx_event(struct ath11k_vif *arvif);
 #endif
drivers/net/wireless/ath/ath11k/wmi.c +57 -0

87 lines not on this page · raw message

drivers/net/wireless/ath/ath11k/wmi.h +14 -0
index 5a32ba0eb4f5..4f7078369b3c 100644
@@ -740,6 +740,7 @@ enum wmi_tlv_event_id {
 	WMI_MDNS_STATS_EVENTID = WMI_TLV_CMD(WMI_GRP_MDNS_OFL),
 	WMI_SAP_OFL_ADD_STA_EVENTID = WMI_TLV_CMD(WMI_GRP_SAP_OFL),
 	WMI_SAP_OFL_DEL_STA_EVENTID,
+	WMI_OBSS_COLOR_COLLISION_DETECTION_EVENTID = WMI_EVT_GRP_START_ID(WMI_GRP_OBSS_OFL),
 	WMI_OCB_SET_CONFIG_RESP_EVENTID = WMI_TLV_CMD(WMI_GRP_OCB),
 	WMI_OCB_GET_TSF_TIMER_RESP_EVENTID,
 	WMI_DCC_GET_STATS_RESP_EVENTID,
@@ -4768,6 +4769,13 @@ struct wmi_obss_spatial_reuse_params_cmd {
 #define ATH11K_BSS_COLOR_COLLISION_DETECTION_STA_PERIOD_MS	10000
 #define ATH11K_BSS_COLOR_COLLISION_DETECTION_AP_PERIOD_MS	5000
 
+enum wmi_bss_color_collision {
+	WMI_BSS_COLOR_COLLISION_DISABLE = 0,
+	WMI_BSS_COLOR_COLLISION_DETECTION,
+	WMI_BSS_COLOR_FREE_SLOT_TIMER_EXPIRY,
+	WMI_BSS_COLOR_FREE_SLOT_AVAILABLE,
+};
+
 struct wmi_obss_color_collision_cfg_params_cmd {
 	u32 tlv_header;
 	u32 vdev_id;
@@ -4785,6 +4793,12 @@ struct wmi_bss_color_change_enable_params_cmd {
 	u32 enable;
 } __packed;
 
+struct wmi_obss_color_collision_event {
+	u32 vdev_id;
+	u32 evt_type;
+	u64 obss_color_bitmap;
+} __packed;
+
 #define ATH11K_IPV4_TH_SEED_SIZE 5
 #define ATH11K_IPV6_TH_SEED_SIZE 11
 
Signature · 1 line
2.25.1