2022-11-07 21:33:20

by Gilad Itzkovitch

[permalink] [raw]
Subject: [PATCH 1/4] wifi: cfg80211: Add long_beacon_interval and short_beacon_tail

From: Kieran Frewen <[email protected]>

Support variables to handle short beacon period and adding a
separate tail for them.

Signed-off-by: Kieran Frewen <[email protected]>
Co-developed-by: Gilad Itzkovitch <[email protected]>
Signed-off-by: Gilad Itzkovitch <[email protected]>
---
include/net/cfg80211.h | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index 11a370e64143..7f785b81b8e3 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -1179,8 +1179,11 @@ struct cfg80211_mbssid_elems {
* or %NULL if not changed
* @tail: tail portion of beacon (after TIM IE)
* 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_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
@@ -1207,7 +1210,7 @@ struct cfg80211_mbssid_elems {
struct cfg80211_beacon_data {
unsigned int link_id;

- const u8 *head, *tail;
+ const u8 *head, *tail, *short_tail;
const u8 *beacon_ies;
const u8 *proberesp_ies;
const u8 *assocresp_ies;
@@ -1217,7 +1220,7 @@ struct cfg80211_beacon_data {
struct cfg80211_mbssid_elems *mbssid_ies;
s8 ftm_responder;

- size_t head_len, tail_len;
+ size_t head_len, tail_len, short_tail_len;
size_t beacon_ies_len;
size_t proberesp_ies_len;
size_t assocresp_ies_len;
@@ -1328,7 +1331,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;
--
2.34.1



2022-11-07 21:33:22

by Gilad Itzkovitch

[permalink] [raw]
Subject: [PATCH 3/4] wifi: nl80211: update attributes netlink for S1G short beacon

From: Kieran Frewen <[email protected]>

Add short beacon period and tail attributes for user configuration

Signed-off-by: Kieran Frewen <[email protected]>
Co-developed-by: Gilad Itzkovitch <[email protected]>
Signed-off-by: Gilad Itzkovitch <[email protected]>
---
include/uapi/linux/nl80211.h | 9 +++++++++
net/wireless/nl80211.c | 15 +++++++++++++++
2 files changed, 24 insertions(+)

diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h
index c14a91bbca7c..ef6318012965 100644
--- a/include/uapi/linux/nl80211.h
+++ b/include/uapi/linux/nl80211.h
@@ -2751,6 +2751,10 @@ enum nl80211_commands {
* the incoming frame RX timestamp.
* @NL80211_ATTR_TD_BITMAP: Transition Disable bitmap, for subsequent
* (re)associations.
+ *
+ * @NL80211_ATTR_SHORT_BEACON_PERIOD: S1G short beacon period in TUs.
+ * @NL80211_ATTR_SHORT_BEACON_TAIL: portion of the short beacon after the TIM.
+ *
* @NUM_NL80211_ATTR: total number of nl80211_attrs available
* @NL80211_ATTR_MAX: highest attribute number currently defined
* @__NL80211_ATTR_AFTER_LAST: internal use
@@ -3280,6 +3284,9 @@ enum nl80211_attrs {
NL80211_ATTR_RX_HW_TIMESTAMP,
NL80211_ATTR_TD_BITMAP,

+ NL80211_ATTR_SHORT_BEACON_PERIOD,
+ NL80211_ATTR_SHORT_BEACON_TAIL,
+
/* add attributes here, update the policy in nl80211.c */

__NL80211_ATTR_AFTER_LAST,
@@ -4963,6 +4970,7 @@ enum nl80211_bss_scan_width {
* @NL80211_BSS_FREQUENCY_OFFSET: frequency offset in KHz
* @NL80211_BSS_MLO_LINK_ID: MLO link ID of the BSS (u8).
* @NL80211_BSS_MLD_ADDR: MLD address of this BSS if connected to it.
+ * @NL80211_BSS_SHORT_BEACON_PERIOD: S1G short beacon period in TUs
* @__NL80211_BSS_AFTER_LAST: internal
* @NL80211_BSS_MAX: highest BSS attribute
*/
@@ -4990,6 +4998,7 @@ enum nl80211_bss {
NL80211_BSS_FREQUENCY_OFFSET,
NL80211_BSS_MLO_LINK_ID,
NL80211_BSS_MLD_ADDR,
+ NL80211_BSS_SHORT_BEACON_PERIOD,

/* keep last */
__NL80211_BSS_AFTER_LAST,
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 148f66edb015..6a8b1e935d58 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -805,6 +805,11 @@ static const struct nla_policy nl80211_policy[NUM_NL80211_ATTR] = {
[NL80211_ATTR_MLD_ADDR] = NLA_POLICY_EXACT_LEN(ETH_ALEN),
[NL80211_ATTR_MLO_SUPPORT] = { .type = NLA_FLAG },
[NL80211_ATTR_MAX_NUM_AKM_SUITES] = { .type = NLA_REJECT },
+ [NL80211_ATTR_SHORT_BEACON_PERIOD] = { .type = NLA_U16 },
+ [NL80211_ATTR_SHORT_BEACON_TAIL] =
+ NLA_POLICY_VALIDATE_FN(NLA_BINARY, validate_ie_attr,
+ IEEE80211_MAX_DATA_LEN),
+
};

/* policy for the key attributes */
@@ -5440,6 +5445,12 @@ static int nl80211_parse_beacon(struct cfg80211_registered_device *rdev,
haveinfo = true;
}

+ if (attrs[NL80211_ATTR_SHORT_BEACON_TAIL]) {
+ bcn->short_tail = nla_data(attrs[NL80211_ATTR_SHORT_BEACON_TAIL]);
+ bcn->short_tail_len = nla_len(attrs[NL80211_ATTR_SHORT_BEACON_TAIL]);
+ haveinfo = true;
+ }
+
if (!haveinfo)
return -EINVAL;

@@ -5804,6 +5815,10 @@ static int nl80211_start_ap(struct sk_buff *skb, struct genl_info *info)
nla_get_u32(info->attrs[NL80211_ATTR_BEACON_INTERVAL]);
params->dtim_period =
nla_get_u32(info->attrs[NL80211_ATTR_DTIM_PERIOD]);
+ if (info->attrs[NL80211_ATTR_SHORT_BEACON_PERIOD])
+ params->short_beacon_period =
+ nla_get_u32(info->attrs[NL80211_ATTR_SHORT_BEACON_PERIOD]) == 0 ?
+ 1 : nla_get_u32(info->attrs[NL80211_ATTR_SHORT_BEACON_PERIOD]);

err = cfg80211_validate_beacon_int(rdev, dev->ieee80211_ptr->iftype,
params->beacon_interval);
--
2.34.1


2022-11-07 21:33:28

by Gilad Itzkovitch

[permalink] [raw]
Subject: [PATCH 2/4] wifi: mac80211: S1G beacon/short beacon support

From: Kieran Frewen <[email protected]>

If configured, use the S1G short beacon format. The S1G short beacon
format includes a limited set of information elements.

Signed-off-by: Kieran Frewen <[email protected]>
Co-developed-by: Gilad Itzkovitch <[email protected]>
Signed-off-by: Gilad Itzkovitch <[email protected]>
---
include/net/mac80211.h | 1 +
net/mac80211/cfg.c | 1 +
net/mac80211/ieee80211_i.h | 1 +
net/mac80211/tx.c | 14 +++++++++++++-
4 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/include/net/mac80211.h b/include/net/mac80211.h
index 721c450a9ccd..39faafde109a 100644
--- a/include/net/mac80211.h
+++ b/include/net/mac80211.h
@@ -674,6 +674,7 @@ struct ieee80211_bss_conf {
bool enable_beacon;
u8 dtim_period;
u16 beacon_int;
+ u8 short_beacon_period;
u16 assoc_capability;
u64 sync_tsf;
u32 sync_device_ts;
diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
index c848fe04dd44..a42abaa25273 100644
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
@@ -1308,6 +1308,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;
diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
index 63ff0d2524b6..2e1d829c548a 100644
--- a/net/mac80211/ieee80211_i.h
+++ b/net/mac80211/ieee80211_i.h
@@ -268,6 +268,7 @@ struct beacon_data {
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 rcu_head rcu_head;
};
diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c
index 383e0242e95f..ff5ea7ab271b 100644
--- a/net/mac80211/tx.c
+++ b/net/mac80211/tx.c
@@ -5121,6 +5121,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)
@@ -5158,7 +5170,7 @@ ieee80211_beacon_get_ap(struct ieee80211_hw *hw,
csa_off_base = skb->len;
}

- if (beacon->tail)
+ if (beacon->tail && !is_short)
skb_put_data(skb, beacon->tail, beacon->tail_len);

if (ieee80211_beacon_protect(skb, local, sdata, link) < 0)
--
2.34.1


2022-11-07 21:33:31

by Gilad Itzkovitch

[permalink] [raw]
Subject: [PATCH 4/4] wifi: mac80211: support setting S1G short beacon period and tail

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.
It also adds the support for distinguish short beacon tail.

Signed-off-by: Kieran Frewen <[email protected]>
Co-developed-by: Gilad Itzkovitch <[email protected]>
Signed-off-by: Gilad Itzkovitch <[email protected]>
---
net/mac80211/cfg.c | 24 ++++++++++++++++++++----
net/mac80211/ieee80211_i.h | 4 ++--
net/mac80211/tx.c | 4 +++-
3 files changed, 25 insertions(+), 7 deletions(-)

diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
index a42abaa25273..acc8c881bd7b 100644
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
@@ -1091,8 +1091,8 @@ static int ieee80211_assign_beacon(struct ieee80211_sub_if_data *sdata,
{
struct cfg80211_mbssid_elems *mbssid = NULL;
struct beacon_data *new, *old;
- int new_head_len, new_tail_len;
- int size, err;
+ int new_head_len, new_tail_len, new_short_tail_len;
+ int size, size_short, err;
u32 changed = BSS_CHANGED_BEACON;
struct ieee80211_bss_conf *link_conf = link->conf;

@@ -1115,7 +1115,13 @@ 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->tail_len will be zero for !params->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_tail_len;

/* new or old multiple BSSID elements? */
if (params->mbssid_ies) {
@@ -1142,9 +1148,12 @@ static int ieee80211_assign_beacon(struct ieee80211_sub_if_data *sdata,
new->tail = new->head + new_head_len;
new->head_len = new_head_len;
new->tail_len = new_tail_len;
+ new->short_tail = new->tail + new->tail_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);
@@ -1177,6 +1186,13 @@ 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) {
diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
index 2e1d829c548a..ef58e6f74b52 100644
--- a/net/mac80211/ieee80211_i.h
+++ b/net/mac80211/ieee80211_i.h
@@ -263,8 +263,8 @@ struct ieee80211_color_change_settings {
};

struct beacon_data {
- u8 *head, *tail;
- int head_len, tail_len;
+ u8 *head, *tail, *short_tail;
+ int head_len, tail_len, short_tail_len;
struct ieee80211_meshconf_ie *meshconf;
u16 cntdwn_counter_offsets[IEEE80211_MAX_CNTDWN_COUNTERS_NUM];
u8 cntdwn_current_counter;
diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c
index ff5ea7ab271b..f33e62d24151 100644
--- a/net/mac80211/tx.c
+++ b/net/mac80211/tx.c
@@ -5170,7 +5170,9 @@ ieee80211_beacon_get_ap(struct ieee80211_hw *hw,
csa_off_base = skb->len;
}

- if (beacon->tail && !is_short)
+ 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)
--
2.34.1


2022-11-08 10:13:20

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH 4/4] wifi: mac80211: support setting S1G short beacon period and tail

Hi Gilad,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on wireless-next/main]
[also build test WARNING on next-20221108]
[cannot apply to wireless/main linus/master v6.1-rc4]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url: https://github.com/intel-lab-lkp/linux/commits/Gilad-Itzkovitch/wifi-cfg80211-Add-long_beacon_interval-and-short_beacon_tail/20221108-052643
base: https://git.kernel.org/pub/scm/linux/kernel/git/wireless/wireless-next.git main
patch link: https://lore.kernel.org/r/20221107212358.272070-4-gilad.itzkovitch%40morsemicro.com
patch subject: [PATCH 4/4] wifi: mac80211: support setting S1G short beacon period and tail
config: x86_64-rhel-8.3-kvm
compiler: gcc-11 (Debian 11.3.0-8) 11.3.0
reproduce (this is a W=1 build):
# https://github.com/intel-lab-lkp/linux/commit/37bed728d5f225d3728bddc7bea70156db88f5e8
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Gilad-Itzkovitch/wifi-cfg80211-Add-long_beacon_interval-and-short_beacon_tail/20221108-052643
git checkout 37bed728d5f225d3728bddc7bea70156db88f5e8
# save the config file
mkdir build_dir && cp config build_dir/.config
make W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash kernel/bpf/ net/mac80211/ net/mptcp/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <[email protected]>

All warnings (new ones prefixed by >>):

net/mac80211/cfg.c: In function 'ieee80211_assign_beacon':
>> net/mac80211/cfg.c:1095:19: warning: unused variable 'size_short' [-Wunused-variable]
1095 | int size, size_short, err;
| ^~~~~~~~~~


vim +/size_short +1095 net/mac80211/cfg.c

1085
1086 static int ieee80211_assign_beacon(struct ieee80211_sub_if_data *sdata,
1087 struct ieee80211_link_data *link,
1088 struct cfg80211_beacon_data *params,
1089 const struct ieee80211_csa_settings *csa,
1090 const struct ieee80211_color_change_settings *cca)
1091 {
1092 struct cfg80211_mbssid_elems *mbssid = NULL;
1093 struct beacon_data *new, *old;
1094 int new_head_len, new_tail_len, new_short_tail_len;
> 1095 int size, size_short, err;
1096 u32 changed = BSS_CHANGED_BEACON;
1097 struct ieee80211_bss_conf *link_conf = link->conf;
1098
1099 old = sdata_dereference(link->u.ap.beacon, sdata);
1100
1101 /* Need to have a beacon head if we don't have one yet */
1102 if (!params->head && !old)
1103 return -EINVAL;
1104
1105 /* new or old head? */
1106 if (params->head)
1107 new_head_len = params->head_len;
1108 else
1109 new_head_len = old->head_len;
1110
1111 /* new or old tail? */
1112 if (params->tail || !old)
1113 /* params->tail_len will be zero for !params->tail */
1114 new_tail_len = params->tail_len;
1115 else
1116 new_tail_len = old->tail_len;
1117
1118 if (params->short_tail || !old)
1119 /* params->tail_len will be zero for !params->tail */
1120 new_short_tail_len = params->short_tail_len;
1121 else
1122 new_short_tail_len = old->short_tail_len;
1123
1124 size = sizeof(*new) + new_head_len + new_tail_len + new_short_tail_len;
1125
1126 /* new or old multiple BSSID elements? */
1127 if (params->mbssid_ies) {
1128 mbssid = params->mbssid_ies;
1129 size += struct_size(new->mbssid_ies, elem, mbssid->cnt);
1130 size += ieee80211_get_mbssid_beacon_len(mbssid);
1131 } else if (old && old->mbssid_ies) {
1132 mbssid = old->mbssid_ies;
1133 size += struct_size(new->mbssid_ies, elem, mbssid->cnt);
1134 size += ieee80211_get_mbssid_beacon_len(mbssid);
1135 }
1136
1137 new = kzalloc(size, GFP_KERNEL);
1138 if (!new)
1139 return -ENOMEM;
1140
1141 /* start filling the new info now */
1142
1143 /*
1144 * pointers go into the block we allocated,
1145 * memory is | beacon_data | head | tail | mbssid_ies
1146 */
1147 new->head = ((u8 *) new) + sizeof(*new);
1148 new->tail = new->head + new_head_len;
1149 new->head_len = new_head_len;
1150 new->tail_len = new_tail_len;
1151 new->short_tail = new->tail + new->tail_len;
1152 new->short_tail_len = new_short_tail_len;
1153
1154 /* copy in optional mbssid_ies */
1155 if (mbssid) {
1156 u8 *pos = new->short_tail + new->short_tail_len;
1157
1158 new->mbssid_ies = (void *)pos;
1159 pos += struct_size(new->mbssid_ies, elem, mbssid->cnt);
1160 ieee80211_copy_mbssid_beacon(pos, new->mbssid_ies, mbssid);
1161 /* update bssid_indicator */
1162 link_conf->bssid_indicator =
1163 ilog2(__roundup_pow_of_two(mbssid->cnt + 1));
1164 }
1165
1166 if (csa) {
1167 new->cntdwn_current_counter = csa->count;
1168 memcpy(new->cntdwn_counter_offsets, csa->counter_offsets_beacon,
1169 csa->n_counter_offsets_beacon *
1170 sizeof(new->cntdwn_counter_offsets[0]));
1171 } else if (cca) {
1172 new->cntdwn_current_counter = cca->count;
1173 new->cntdwn_counter_offsets[0] = cca->counter_offset_beacon;
1174 }
1175
1176 /* copy in head */
1177 if (params->head)
1178 memcpy(new->head, params->head, new_head_len);
1179 else
1180 memcpy(new->head, old->head, new_head_len);
1181
1182 /* copy in optional tail */
1183 if (params->tail)
1184 memcpy(new->tail, params->tail, new_tail_len);
1185 else
1186 if (old)
1187 memcpy(new->tail, old->tail, new_tail_len);
1188
1189 /* copy in optional short tail */
1190 if (params->short_tail)
1191 memcpy(new->short_tail, params->short_tail, new_short_tail_len);
1192 else
1193 if (old)
1194 memcpy(new->short_tail, old->short_tail, new_short_tail_len);
1195
1196 err = ieee80211_set_probe_resp(sdata, params->probe_resp,
1197 params->probe_resp_len, csa, cca, link);
1198 if (err < 0) {
1199 kfree(new);
1200 return err;
1201 }
1202 if (err == 0)
1203 changed |= BSS_CHANGED_AP_PROBE_RESP;
1204
1205 if (params->ftm_responder != -1) {
1206 link_conf->ftm_responder = params->ftm_responder;
1207 err = ieee80211_set_ftm_responder_params(sdata,
1208 params->lci,
1209 params->lci_len,
1210 params->civicloc,
1211 params->civicloc_len,
1212 link_conf);
1213
1214 if (err < 0) {
1215 kfree(new);
1216 return err;
1217 }
1218
1219 changed |= BSS_CHANGED_FTM_RESPONDER;
1220 }
1221
1222 rcu_assign_pointer(link->u.ap.beacon, new);
1223 sdata->u.ap.active = true;
1224
1225 if (old)
1226 kfree_rcu(old, rcu_head);
1227
1228 return changed;
1229 }
1230

--
0-DAY CI Kernel Test Service
https://01.org/lkp


Attachments:
(No filename) (7.04 kB)
config (168.36 kB)
Download all attachments