Skip to contentSkip to conversation

wifi: cfg80211: Add short_beacon_tail/head/period

PATCH Superseded Gilad Itzkovitch 2 participants 3 messages Apr 12, 2023 – Apr 13, 2023

Subsystems (2)

v4 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

PATCH v4 1/2 wifi: cfg80211: Add short_beacon_tail/head/period

From: Kieran Frewen <[email protected]>

Support variables to handle short beacon period and adding a separate tail/head for them. Also, add short beacon period, head and tail attributes for user configuration.

---

Notes:
V4:
- squash cfg80211 commits together
- add protection for short head/tail with S1G band check
- better validation rule for short_beacon_period and align its types

 include/net/cfg80211.h       |  10 +++-
 include/uapi/linux/nl80211.h |  10 ++++
 net/wireless/nl80211.c       | 101 ++++++++++++++++++++++++++---------
 3 files changed, 96 insertions(+), 25 deletions(-)
include/net/cfg80211.h +9 -1
index 9e04f69712b1..6d0a31d85888 100644
@@ -1211,8 +1211,13 @@ struct cfg80211_rnr_elems {
  *	or %NULL if not changed
  * @tail: tail portion of beacon (after TIM IE)
  *	or %NULL if not changed
+ * @short_head: head portion of short beacon or %NULL if not changed
+ * @short_tail: short tail portion of beacon (after TIM IE)
+ *	or %NULL if not changed
  * @head_len: length of @head
  * @tail_len: length of @tail
+ * @short_head_len: length of @short_head
+ * @short_tail_len: length of @short_tail
  * @beacon_ies: extra information element(s) to add into Beacon frames or %NULL
  * @beacon_ies_len: length of beacon_ies in octets
  * @proberesp_ies: extra information element(s) to add into Probe Response
@@ -1241,6 +1246,7 @@ struct cfg80211_beacon_data {
 	unsigned int link_id;
 
 	const u8 *head, *tail;
+	const u8 *short_head, *short_tail;
 	const u8 *beacon_ies;
 	const u8 *proberesp_ies;
 	const u8 *assocresp_ies;
@@ -1252,6 +1258,7 @@ struct cfg80211_beacon_data {
 	s8 ftm_responder;
 
 	size_t head_len, tail_len;
+	size_t short_head_len, short_tail_len;
 	size_t beacon_ies_len;
 	size_t proberesp_ies_len;
 	size_t assocresp_ies_len;
@@ -1324,6 +1331,7 @@ struct cfg80211_unsol_bcast_probe_resp {
  * @beacon: beacon data
  * @beacon_interval: beacon interval
  * @dtim_period: DTIM period
+ * @short_beacon_period: S1G short beacon period
  * @ssid: SSID to be used in the BSS (note: may be %NULL if not provided from
  *	user space)
  * @ssid_len: length of @ssid
@@ -1365,7 +1373,7 @@ struct cfg80211_ap_settings {
 
 	struct cfg80211_beacon_data beacon;
 
-	int beacon_interval, dtim_period;
+	int beacon_interval, dtim_period, short_beacon_period;
 	const u8 *ssid;
 	size_t ssid_len;
 	enum nl80211_hidden_ssid hidden_ssid;
include/uapi/linux/nl80211.h +10 -0
index c59fec406da5..09ff24ed30ff 100644
@@ -2787,6 +2787,12 @@ enum nl80211_commands {
  *	indicates that the sub-channel is punctured. Higher 16 bits are
  *	reserved.
  *
+ * @NL80211_ATTR_SHORT_BEACON_PERIOD: (u16) period for S1G long beacon
+ * @NL80211_ATTR_SHORT_BEACON_HEAD: portion of the S1G short beacon before
+ *  the TIM element
+ * @NL80211_ATTR_SHORT_BEACON_TAIL: portion of the S1G short beacon after
+ *  the TIM element
+ *
  * @NL80211_ATTR_MAX_HW_TIMESTAMP_PEERS: Maximum number of peers that HW
  *	timestamping can be enabled for concurrently (u16), a wiphy attribute.
  *	A value of 0xffff indicates setting for all peers (i.e. not specifying
@@ -3336,6 +3342,10 @@ enum nl80211_attrs {
 
 	NL80211_ATTR_PUNCT_BITMAP,
 
+	NL80211_ATTR_SHORT_BEACON_PERIOD,
+	NL80211_ATTR_SHORT_BEACON_HEAD,
+	NL80211_ATTR_SHORT_BEACON_TAIL,
+
 	NL80211_ATTR_MAX_HW_TIMESTAMP_PEERS,
 	NL80211_ATTR_HW_TIMESTAMP_ENABLED,
 
net/wireless/nl80211.c +77 -24

201 lines not on this page · raw message

base-commit: aa2aa818cd1198cfa2498116d57cd9f13fea80e4

Signature · 1 line
2.34.1
#1 lore raw

PATCH v4 2/2 wifi: mac80211: S1G beacon/short beacon support

From: Kieran Frewen <[email protected]>

With the kernel able to send both short and long S1G beacons, include the ability for setting the short beacon period. If configured, use the S1G short beacon format. The S1G short beacon format includes a limited set of information elements. It also adds the support for distinguish short beacon head and tail.

---

Notes:
v4:
- squash mac80211 commits together
- address hitting short head/tail code path in nl80211.c
- update code style

 include/net/mac80211.h     |  2 ++
 net/mac80211/cfg.c         | 36 ++++++++++++++++++++++++++++++++++--
 net/mac80211/ieee80211_i.h |  3 +++
 net/mac80211/tx.c          | 22 ++++++++++++++++++++--
 4 files changed, 59 insertions(+), 4 deletions(-)
include/net/mac80211.h +2 -0
index 679421d37a42..fe24decbfd3c 100644
@@ -573,6 +573,7 @@ struct ieee80211_fils_discovery {
  *	Note also that this is not used with MLD associations, mac80211 doesn't
  *	know how to track beacons for all of the links for this.
  * @beacon_int: beacon interval
+ * @short_beacon_period: S1G short beacon period
  * @assoc_capability: capabilities taken from assoc resp
  * @basic_rates: bitmap of basic rates, each bit stands for an
  *	index into the rate table configured by the driver in
@@ -706,6 +707,7 @@ struct ieee80211_bss_conf {
 	bool enable_beacon;
 	u8 dtim_period;
 	u16 beacon_int;
+	u16 short_beacon_period;
 	u16 assoc_capability;
 	u64 sync_tsf;
 	u32 sync_device_ts;
net/mac80211/cfg.c +34 -2
index ebbd13d0c29a..7fa92b5b0421 100644
@@ -1111,6 +1111,7 @@ static int ieee80211_assign_beacon(struct ieee80211_sub_if_data *sdata,
 	struct cfg80211_rnr_elems *rnr = NULL;
 	struct beacon_data *new, *old;
 	int new_head_len, new_tail_len;
+	int new_short_head_len, new_short_tail_len;
 	int size, err;
 	u32 changed = BSS_CHANGED_BEACON;
 	struct ieee80211_bss_conf *link_conf = link->conf;
@@ -1127,6 +1128,13 @@ static int ieee80211_assign_beacon(struct ieee80211_sub_if_data *sdata,
 	else
 		new_head_len = old->head_len;
 
+	/* Short head is not a mandatory field */
+	new_short_head_len = 0;
+	if (params->short_head)
+		new_short_head_len = params->short_head_len;
+	else if (old && old->short_head)
+		new_short_head_len = old->short_head_len;
+
 	/* new or old tail? */
 	if (params->tail || !old)
 		/* params->tail_len will be zero for !params->tail */
@@ -1134,7 +1142,14 @@ static int ieee80211_assign_beacon(struct ieee80211_sub_if_data *sdata,
 	else
 		new_tail_len = old->tail_len;
 
-	size = sizeof(*new) + new_head_len + new_tail_len;
+	if (params->short_tail || !old)
+		/* params->short_tail_len will be zero for !params->short_tail */
+		new_short_tail_len = params->short_tail_len;
+	else
+		new_short_tail_len = old->short_tail_len;
+
+	size = sizeof(*new) + new_head_len + new_tail_len +
+		new_short_head_len + new_short_tail_len;
 
 	/* new or old multiple BSSID elements? */
 	if (params->mbssid_ies) {
@@ -1169,11 +1184,16 @@ static int ieee80211_assign_beacon(struct ieee80211_sub_if_data *sdata,
 	 */
 	new->head = ((u8 *) new) + sizeof(*new);
 	new->tail = new->head + new_head_len;
+	new->short_head = new->tail + new_tail_len;
+	new->short_tail = new->short_head + new_short_head_len;
 	new->head_len = new_head_len;
 	new->tail_len = new_tail_len;
+	new->short_head_len = new_short_head_len;
+	new->short_tail_len = new_short_tail_len;
+
 	/* copy in optional mbssid_ies */
 	if (mbssid) {
-		u8 *pos = new->tail + new->tail_len;
+		u8 *pos = new->short_tail + new->short_tail_len;
 
 		new->mbssid_ies = (void *)pos;
 		pos += struct_size(new->mbssid_ies, elem, mbssid->cnt);
@@ -1205,6 +1225,11 @@ static int ieee80211_assign_beacon(struct ieee80211_sub_if_data *sdata,
 	else
 		memcpy(new->head, old->head, new_head_len);
 
+	if (params->short_head)
+		memcpy(new->short_head, params->short_head, new_short_head_len);
+	else if (old && old->short_head)
+		memcpy(new->short_head, old->short_head, new_short_head_len);
+
 	/* copy in optional tail */
 	if (params->tail)
 		memcpy(new->tail, params->tail, new_tail_len);
@@ -1212,6 +1237,12 @@ static int ieee80211_assign_beacon(struct ieee80211_sub_if_data *sdata,
 		if (old)
 			memcpy(new->tail, old->tail, new_tail_len);
 
+	/* copy in optional short tail */
+	if (params->short_tail)
+		memcpy(new->short_tail, params->short_tail, new_short_tail_len);
+	else if (old)
+		memcpy(new->short_tail, old->short_tail, new_short_tail_len);
+
 	err = ieee80211_set_probe_resp(sdata, params->probe_resp,
 				       params->probe_resp_len, csa, cca, link);
 	if (err < 0) {
@@ -1405,6 +1436,7 @@ static int ieee80211_start_ap(struct wiphy *wiphy, struct net_device *dev,
 	}
 
 	link_conf->dtim_period = params->dtim_period;
+	link_conf->short_beacon_period = params->short_beacon_period;
 	link_conf->enable_beacon = true;
 	link_conf->allow_p2p_go_ps = sdata->vif.p2p;
 	link_conf->twt_responder = params->twt_responder;
net/mac80211/ieee80211_i.h +3 -0
index cdc80285efd4..867004f87a2c 100644
@@ -265,10 +265,13 @@ struct ieee80211_color_change_settings {
 
 struct beacon_data {
 	u8 *head, *tail;
+	u8 *short_head, *short_tail;
 	int head_len, tail_len;
+	int short_head_len, short_tail_len;
 	struct ieee80211_meshconf_ie *meshconf;
 	u16 cntdwn_counter_offsets[IEEE80211_MAX_CNTDWN_COUNTERS_NUM];
 	u8 cntdwn_current_counter;
+	u8 long_beacon_count;
 	struct cfg80211_mbssid_elems *mbssid_ies;
 	struct cfg80211_rnr_elems *rnr_ies;
 	struct rcu_head rcu_head;
net/mac80211/tx.c +20 -2
index dfe6b9c9b29e..2ea79f12fe21 100644
@@ -5256,6 +5256,18 @@ ieee80211_beacon_get_ap(struct ieee80211_hw *hw,
 	struct sk_buff *skb = NULL;
 	u16 csa_off_base = 0;
 	int mbssid_len;
+	bool is_short = false;
+
+	if (vif->cfg.s1g) {
+		if (beacon->long_beacon_count == 0) {
+			is_short = false;
+			beacon->long_beacon_count =
+				vif->bss_conf.short_beacon_period - 1;
+		} else {
+			is_short = true;
+			beacon->long_beacon_count--;
+		}
+	}
 
 	if (beacon->cntdwn_counter_offsets[0]) {
 		if (!is_template)
@@ -5278,7 +5290,11 @@ ieee80211_beacon_get_ap(struct ieee80211_hw *hw,
 		return NULL;
 
 	skb_reserve(skb, local->tx_headroom);
-	skb_put_data(skb, beacon->head, beacon->head_len);
+
+	if (is_short)
+		skb_put_data(skb, beacon->short_head, beacon->short_head_len);
+	else
+		skb_put_data(skb, beacon->head, beacon->head_len);
 
 	ieee80211_beacon_add_tim(sdata, link, &ap->ps, skb, is_template);
 
@@ -5296,7 +5312,9 @@ ieee80211_beacon_get_ap(struct ieee80211_hw *hw,
 		csa_off_base = skb->len;
 	}
 
-	if (beacon->tail)
+	if (beacon->short_tail && is_short)
+		skb_put_data(skb, beacon->short_tail, beacon->short_tail_len);
+	else if (beacon->tail && !is_short)
 		skb_put_data(skb, beacon->tail, beacon->tail_len);
 
 	if (ieee80211_beacon_protect(skb, local, sdata, link) < 0)
Signature · 1 line
2.34.1
#2 lore raw
In reply to Gilad Itzkovitch
kernel test robot noticed the following build warnings:

Hi Gilad,

kernel test robot noticed the following build warnings:

[auto build test WARNING on aa2aa818cd1198cfa2498116d57cd9f13fea80e4]

url:    https://github.com/intel-lab-lkp/linux/commits/Gilad-Itzkovitch/wifi-mac80211-S1G-beacon-short-beacon-support/20230413-071340
base:   aa2aa818cd1198cfa2498116d57cd9f13fea80e4
patch link:    https://lore.kernel.org/r/20230412231241.1587517-1-gilad.itzkovitch%40virscient.com
patch subject: [PATCH v4 1/2] wifi: cfg80211: Add short_beacon_tail/head/period
config: i386-randconfig-a005-20230410 (https://download.01.org/0day-ci/archive/20230413/[email protected]/config)
compiler: clang version 14.0.6 (https://github.com/llvm/llvm-project f28c006a5895fc0e329fe15fead81e37457cb1d1)

reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# https://github.com/intel-lab-lkp/linux/commit/0559af4e4729ccb2c2f378b51d5ccc1e35bb18f3
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Gilad-Itzkovitch/wifi-mac80211-S1G-beacon-short-beacon-support/20230413-071340 git checkout 0559af4e4729ccb2c2f378b51d5ccc1e35bb18f3
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=i386 olddefconfig COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=i386 SHELL=/bin/bash net/wireless/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <[email protected]>
| Link: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All warnings (new ones prefixed by >>):

>> net/wireless/nl80211.c:236:6: warning: variable 's1g_short_bcn' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
           if (len < offsetofend(typeof(*mgmt), frame_control))
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   net/wireless/nl80211.c:272:6: note: uninitialized use occurs here
           if (s1g_short_bcn)
               ^~~~~~~~~~~~~
   net/wireless/nl80211.c:236:2: note: remove the 'if' if its condition is always false
           if (len < offsetofend(typeof(*mgmt), frame_control))
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   net/wireless/nl80211.c:234:20: note: initialize the variable 's1g_short_bcn' to silence this warning
           bool s1g_short_bcn;
                             ^
                              = 0

1 warning generated.

vim +236 net/wireless/nl80211.c

a9455408b09395 Johannes Berg   2012-06-15  224  
f88eb7c0d002a6 Johannes Berg   2019-09-20  225  static int validate_beacon_head(const struct nlattr *attr,
f88eb7c0d002a6 Johannes Berg   2019-09-20  226  				struct netlink_ext_ack *extack)
f88eb7c0d002a6 Johannes Berg   2019-09-20  227  {
f88eb7c0d002a6 Johannes Berg   2019-09-20  228  	const u8 *data = nla_data(attr);
f88eb7c0d002a6 Johannes Berg   2019-09-20  229  	unsigned int len = nla_len(attr);
f88eb7c0d002a6 Johannes Berg   2019-09-20  230  	const struct element *elem;
f88eb7c0d002a6 Johannes Berg   2019-09-20  231  	const struct ieee80211_mgmt *mgmt = (void *)data;
1d47f1198d5811 Thomas Pedersen 2020-09-08  232  	unsigned int fixedlen, hdrlen;
9a6847ba174785 Johannes Berg   2021-04-08  233  	bool s1g_bcn;
0559af4e4729cc Kieran Frewen   2023-04-13  234  	bool s1g_short_bcn;
1d47f1198d5811 Thomas Pedersen 2020-09-08  235  
9a6847ba174785 Johannes Berg   2021-04-08 @236  	if (len < offsetofend(typeof(*mgmt), frame_control))
9a6847ba174785 Johannes Berg   2021-04-08  237  		goto err;
9a6847ba174785 Johannes Berg   2021-04-08  238  
9a6847ba174785 Johannes Berg   2021-04-08  239  	s1g_bcn = ieee80211_is_s1g_beacon(mgmt->frame_control);
0559af4e4729cc Kieran Frewen   2023-04-13  240  	s1g_short_bcn = ieee80211_is_s1g_short_beacon(mgmt->frame_control);
0559af4e4729cc Kieran Frewen   2023-04-13  241  	if (s1g_short_bcn) {
0559af4e4729cc Kieran Frewen   2023-04-13  242  		fixedlen = offsetof(struct ieee80211_ext,
0559af4e4729cc Kieran Frewen   2023-04-13  243  				    u.s1g_short_beacon.variable);
0559af4e4729cc Kieran Frewen   2023-04-13  244  		hdrlen = offsetof(struct ieee80211_ext, u.s1g_short_beacon);
0559af4e4729cc Kieran Frewen   2023-04-13  245  	} else if (s1g_bcn) {
1d47f1198d5811 Thomas Pedersen 2020-09-08  246  		fixedlen = offsetof(struct ieee80211_ext,
1d47f1198d5811 Thomas Pedersen 2020-09-08  247  				    u.s1g_beacon.variable);
1d47f1198d5811 Thomas Pedersen 2020-09-08  248  		hdrlen = offsetof(struct ieee80211_ext, u.s1g_beacon);
1d47f1198d5811 Thomas Pedersen 2020-09-08  249  	} else {
1d47f1198d5811 Thomas Pedersen 2020-09-08  250  		fixedlen = offsetof(struct ieee80211_mgmt,
f88eb7c0d002a6 Johannes Berg   2019-09-20  251  				    u.beacon.variable);
1d47f1198d5811 Thomas Pedersen 2020-09-08  252  		hdrlen = offsetof(struct ieee80211_mgmt, u.beacon);
1d47f1198d5811 Thomas Pedersen 2020-09-08  253  	}
f88eb7c0d002a6 Johannes Berg   2019-09-20  254  
f88eb7c0d002a6 Johannes Berg   2019-09-20  255  	if (len < fixedlen)
f88eb7c0d002a6 Johannes Berg   2019-09-20  256  		goto err;
f88eb7c0d002a6 Johannes Berg   2019-09-20  257  
1d47f1198d5811 Thomas Pedersen 2020-09-08  258  	if (ieee80211_hdrlen(mgmt->frame_control) != hdrlen)
f88eb7c0d002a6 Johannes Berg   2019-09-20  259  		goto err;
f88eb7c0d002a6 Johannes Berg   2019-09-20  260  
f88eb7c0d002a6 Johannes Berg   2019-09-20  261  	data += fixedlen;
f88eb7c0d002a6 Johannes Berg   2019-09-20  262  	len -= fixedlen;
f88eb7c0d002a6 Johannes Berg   2019-09-20  263  
f88eb7c0d002a6 Johannes Berg   2019-09-20  264  	for_each_element(elem, data, len) {
f88eb7c0d002a6 Johannes Berg   2019-09-20  265  		/* nothing */
f88eb7c0d002a6 Johannes Berg   2019-09-20  266  	}
f88eb7c0d002a6 Johannes Berg   2019-09-20  267  
f88eb7c0d002a6 Johannes Berg   2019-09-20  268  	if (for_each_element_completed(elem, data, len))
f88eb7c0d002a6 Johannes Berg   2019-09-20  269  		return 0;
f88eb7c0d002a6 Johannes Berg   2019-09-20  270  
f88eb7c0d002a6 Johannes Berg   2019-09-20  271  err:
0559af4e4729cc Kieran Frewen   2023-04-13  272  	if (s1g_short_bcn)
0559af4e4729cc Kieran Frewen   2023-04-13  273  		NL_SET_ERR_MSG_ATTR(extack, attr, "malformed S1G short beacon head");
0559af4e4729cc Kieran Frewen   2023-04-13  274  	else if (s1g_bcn)
0559af4e4729cc Kieran Frewen   2023-04-13  275  		NL_SET_ERR_MSG_ATTR(extack, attr, "malformed S1G beacon head");
0559af4e4729cc Kieran Frewen   2023-04-13  276  	else
f88eb7c0d002a6 Johannes Berg   2019-09-20  277  		NL_SET_ERR_MSG_ATTR(extack, attr, "malformed beacon head");
f88eb7c0d002a6 Johannes Berg   2019-09-20  278  	return -EINVAL;
f88eb7c0d002a6 Johannes Berg   2019-09-20  279  }
f88eb7c0d002a6 Johannes Berg   2019-09-20  280  
Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests