mac80211: HE: add SPR/OBSSPD support
Subsystems (2)
v3 cover mac80211: HE: add SPR/OBSSPD support
This series adds support for propagating the OBSS PD information from assocs to a wireless driver.
Changes in V2
* always use bss_conf as per request from Johannes
Changes in V3
* remove reference to mac80211 inside comment
John Crispin (2):
mac80211: HE: add Spatial Reuse IE parsing support
mac80211: allow setting spatial reuse parameters from bss_conf
include/linux/ieee80211.h | 49 ++++++++++++++++++++++++++++++++++++ include/net/cfg80211.h | 15 +++++++++++ include/net/mac80211.h | 4 +++ include/uapi/linux/nl80211.h | 27 ++++++++++++++++++++ net/mac80211/cfg.c | 5 +++- net/mac80211/he.c | 24 ++++++++++++++++++ net/mac80211/ieee80211_i.h | 4 +++ net/mac80211/mlme.c | 1 + net/mac80211/util.c | 4 +++ net/wireless/nl80211.c | 43 +++++++++++++++++++++++++++++++ 10 files changed, 175 insertions(+), 1 deletion(-)
Signature · 1 line
2.20.1
PATCH v3 1/2 mac80211: HE: add Spatial Reuse IE parsing support
Add support to mac80211 for parsing SPR IEs as per P802.11ax_D4.0 section 9.4.2.241.
--- include/linux/ieee80211.h | 49 ++++++++++++++++++++++++++++++++++++++ net/mac80211/ieee80211_i.h | 1 + net/mac80211/util.c | 4 ++++ 3 files changed, 54 insertions(+)
include/linux/ieee80211.h +49 -0
@@ -1628,6 +1628,18 @@ struct ieee80211_he_operation {u8 optional[0 ]; } __packed; +/** +* struct ieee80211_he_spr - HE spatial reuse element +* +* This structure is the "HE spatial reuse element" element as +* described in P802.11ax_D4.0 section 9.4.2.241 +*/ +struct ieee80211_he_spr { +u8 he_sr_control; +/* Optional 0 to 19 bytes: depends on @he_sr_control */ +u8 optional[0 ]; +} __packed; +/** * struct ieee80211_he_mu_edca_param_ac_rec - MU AC Parameter Record field *
@@ -2066,6 +2078,42 @@ ieee80211_he_oper_size(const u8 *he_oper_ie)return oper_len; } +/* HE Spatial Reuse defines */ +#define IEEE80211_HE_SPR_NON_SRG_OFFSET_PRESENT 0x4 +#define IEEE80211_HE_SPR_SRG_INFORMATION_PRESENT 0x8 + +/* +* ieee80211_he_spr_size - calculate 802.11ax HE Spatial Reuse IE size +* @he_spr_ie: byte data of the He Spatial Reuse IE, stating from the the byte +* after the ext ID byte. It is assumed that he_spr_ie has at least +* sizeof(struct ieee80211_he_spr) bytes, the caller must have validated +* this +* @return the actual size of the IE data (not including header), or 0 on error +*/ +static inline u8 +ieee80211_he_spr_size (const u8 *he_spr_ie) +{ +struct ieee80211_he_spr *he_spr = (void *)he_spr_ie; +u8 spr_len =sizeof (struct ieee80211_he_spr ); +u32 he_spr_params; + +/* Make sure the input is not NULL */ +if (!he_spr_ie) +return 0 ; + +/* Calc required length */ + he_spr_params =le32_to_cpu (he_spr->he_sr_control); +if (he_spr_params &IEEE80211_HE_SPR_NON_SRG_OFFSET_PRESENT ) + spr_len++; +if (he_spr_params &IEEE80211_HE_SPR_SRG_INFORMATION_PRESENT ) + spr_len +=18 ; + +/* Add the first byte (extension ID) to the total length */ + spr_len++; + +return spr_len; +} +/* Authentication algorithms */ #define WLAN_AUTH_OPEN 0#define WLAN_AUTH_SHARED_KEY 1
@@ -2488,6 +2536,7 @@ enum ieee80211_eid_ext {WLAN_EID_EXT_HE_OPERATION =36 ,WLAN_EID_EXT_UORA =37 ,WLAN_EID_EXT_HE_MU_EDCA =38 , +WLAN_EID_EXT_HE_SPR =39 ,WLAN_EID_EXT_MAX_CHANNEL_SWITCH_TIME =52 ,WLAN_EID_EXT_MULTIPLE_BSSID_CONFIGURATION =55 , WLAN_EID_EXT_NON_INHERITANCE = 56,
net/mac80211/ieee80211_i.h +1 -0
@@ -1483,6 +1483,7 @@ struct ieee802_11_elems {const struct ieee80211_meshconf_ie *mesh_config;const u8 *he_cap;const struct ieee80211_he_operation *he_operation; +const struct ieee80211_he_spr *he_spr;const struct ieee80211_mu_edca_param_set *mu_edca_param_set;const u8 *uora_element;const u8 *mesh_id;
net/mac80211/util.c +4 -0
@@ -1236,6 +1236,10 @@ _ieee802_11_parse_elems_crc(const u8 *start, size_t len, bool action, WLAN_EID_EXT_MULTIPLE_BSSID_CONFIGURATION && elen == 3) { elems->mbssid_config_ie = (void *)&pos[1 ]; + } else if (pos[0] == WLAN_EID_EXT_HE_SPR && + elen >= sizeof(*elems->he_spr) && + elen >= ieee80211_he_spr_size(&pos[1])) { + elems->he_spr = (void *)&pos[1 ]; }break ;default :
Signature · 1 line
2.20.1
PATCH v3 2/2 mac80211: allow setting spatial reuse parameters from bss_conf
In reply to John CrispinStore the OBSS PD parameters inside bss_conf when bringing up an AP and/or when a station connects to an AP. This allows the driver to configure the HW accordingly.
--- include/net/cfg80211.h | 15 +++++++++++++ include/net/mac80211.h | 4 ++++ include/uapi/linux/nl80211.h | 27 ++++++++++++++++++++++ net/mac80211/cfg.c | 5 ++++- net/mac80211/he.c | 24 ++++++++++++++++++++ net/mac80211/ieee80211_i.h | 3 +++ net/mac80211/mlme.c | 1 + net/wireless/nl80211.c | 43 ++++++++++++++++++++++++++++++++++++ 8 files changed, 121 insertions(+), 1 deletion(-)
include/net/cfg80211.h +15 -0
@@ -249,6 +249,19 @@ struct ieee80211_rate {u16 hw_value, hw_value_short; }; +/** +* struct ieee80211_he_obss_pd - AP settings for spatial reuse +* +* @enable: is the feature enabled. +* @min_offset: minimal tx power offset an associated station shall use +* @max_offset: maximum tx power offset an associated station shall use +*/ +struct ieee80211_he_obss_pd { +bool enable; +u32 min_offset; +u32 max_offset; +}; +/** * struct ieee80211_sta_ht_cap - STA's HT capabilities *
@@ -899,6 +912,7 @@ enum cfg80211_ap_settings_flags {* @vht_required: stations must support VHT * @twt_responder: Enable Target Wait Time * @flags: flags, as defined in enum cfg80211_ap_settings_flags +* @he_obss_pd: OBSS Packet Detection settings */ struct cfg80211_ap_settings {struct cfg80211_chan_def chandef;
@@ -926,6 +940,7 @@ struct cfg80211_ap_settings {bool ht_required, vht_required;bool twt_responder;u32 flags; +struct ieee80211_he_obss_pd he_obss_pd; };/**
include/net/mac80211.h +4 -0
@@ -318,6 +318,7 @@ struct ieee80211_vif_chanctx_switch {* @BSS_CHANGED_FTM_RESPONDER: fime timing reasurement request responder * functionality changed for this BSS (AP mode). * @BSS_CHANGED_TWT: TWT status changed +* @BSS_CHANGED_HE_OBSS_PD: OBSS Packet Detection status changed. * */ enum ieee80211_bss_change {
@@ -349,6 +350,7 @@ enum ieee80211_bss_change {BSS_CHANGED_MCAST_RATE =1 <<25 ,BSS_CHANGED_FTM_RESPONDER =1 <<26 ,BSS_CHANGED_TWT =1 <<27 , + BSS_CHANGED_HE_OBSS_PD = 1<<28, /* when adding here, make sure to change ieee80211_reconfig */ };
@@ -603,6 +605,7 @@ struct ieee80211_ftm_responder_params {* nontransmitted BSSIDs * @profile_periodicity: the least number of beacon frames need to be received * in order to discover all the nontransmitted BSSIDs in the set. +* @he_obss_pd: OBSS Packet Detection parameters. */ struct ieee80211_bss_conf {const u8 *bssid;
@@ -664,6 +667,7 @@ struct ieee80211_bss_conf {u8 bssid_indicator;bool ema_ap;u8 profile_periodicity; +struct ieee80211_he_obss_pd he_obss_pd; };/**
include/uapi/linux/nl80211.h +27 -0
@@ -2356,6 +2356,9 @@ enum nl80211_commands {* * @NL80211_ATTR_TWT_RESPONDER: Enable target wait time responder support. * +* @NL80211_ATTR_HE_OBSS_PD: nested attribute for OBSS Packet Detection +* functionality. +* * @NUM_NL80211_ATTR: total number of nl80211_attrs available * @NL80211_ATTR_MAX: highest attribute number currently defined * @__NL80211_ATTR_AFTER_LAST: internal use
@@ -2813,6 +2816,8 @@ enum nl80211_attrs {NL80211_ATTR_TWT_RESPONDER , +NL80211_ATTR_HE_OBSS_PD , +/* add attributes here, update the policy in nl80211.c */ __NL80211_ATTR_AFTER_LAST,
@@ -6488,4 +6493,26 @@ enum nl80211_peer_measurement_ftm_resp {NL80211_PMSR_FTM_RESP_ATTR_MAX =NUM_NL80211_PMSR_FTM_RESP_ATTR -1 }; +/** +* enum nl80211_he_spr - spatial reuse attributes +* @__NL80211_HE_OBSS_PD_ATTR_INVALID: Invalid +* +* @NL80211_ATTR_HE_OBSS_PD_MIN_OFFSET: the OBSS PD minimum tx power offset. +* @NL80211_ATTR_HE_OBSS_PD_MAX_OFFSET: the OBSS PD maximum tx power offset. +* +* @__NL80211_HE_OBSS_PD_ATTR_LAST: Internal +* @NL80211_HE_OBSS_PD_ATTR_MAX: highest spiatl reuse attribute. +*/ +enum nl80211_he_spr_attributes { + __NL80211_HE_OBSS_PD_ATTR_INVALID, + +NL80211_ATTR_HE_OBSS_PD_MIN_OFFSET , +NL80211_ATTR_HE_OBSS_PD_MAX_OFFSET , + +/* keep last */ + __NL80211_ATTR_HE_OBSS_PD_LAST, +NL80211_HE_OBSS_PD_ATTR_MAX = __NL80211_ATTR_HE_OBSS_PD_LAST -1 , +}; + +#endif /* __LINUX_NL80211_H */
net/mac80211/cfg.c +4 -1
@@ -976,7 +976,8 @@ static int ieee80211_start_ap(struct wiphy *wiphy, struct net_device *dev,BSS_CHANGED_SSID |BSS_CHANGED_P2P_PS |BSS_CHANGED_TXPOWER | -BSS_CHANGED_TWT ; +BSS_CHANGED_TWT | +BSS_CHANGED_HE_OBSS_PD ;int err;int prev_beacon_int;
@@ -1047,6 +1048,8 @@ static int ieee80211_start_ap(struct wiphy *wiphy, struct net_device *dev, sdata->vif.bss_conf.enable_beacon = true; sdata->vif.bss_conf.allow_p2p_go_ps = sdata->vif.p2p; sdata->vif.bss_conf.twt_responder = params->twt_responder; +memcpy (&sdata->vif.bss_conf.he_obss_pd, ¶ms->he_obss_pd, +sizeof (struct ieee80211_he_obss_pd )); sdata->vif.bss_conf.ssid_len = params->ssid_len;if (params->ssid_len)
net/mac80211/he.c +24 -0
@@ -53,3 +53,27 @@ ieee80211_he_cap_ie_to_sta_he_cap(struct ieee80211_sub_if_data *sdata, he_cap->has_he = true; } + +void +ieee80211_he_spr_ie_to_bss_conf (struct ieee80211_vif *vif, +const struct ieee80211_he_spr *he_spr_ie_elem) +{ +struct ieee80211_he_obss_pd *he_obss_pd = + &vif->bss_conf.he_obss_pd; +const u8 *data = he_spr_ie_elem->optional; + +memset (he_obss_pd,0 ,sizeof (*he_obss_pd)); + +if (!he_spr_ie_elem) +return ; + +if (he_spr_ie_elem->he_sr_control & +IEEE80211_HE_SPR_NON_SRG_OFFSET_PRESENT ) + data++; +if (he_spr_ie_elem->he_sr_control & +IEEE80211_HE_SPR_SRG_INFORMATION_PRESENT ) { + he_obss_pd->max_offset = *data++; + he_obss_pd->min_offset = *data++; + he_obss_pd->enable = true; + } +}
net/mac80211/ieee80211_i.h +3 -0
@@ -1873,6 +1873,9 @@ ieee80211_he_cap_ie_to_sta_he_cap(struct ieee80211_sub_if_data *sdata,struct ieee80211_supported_band *sband, const u8 *he_cap_ie, u8 he_cap_len, struct sta_info *sta); +void +ieee80211_he_spr_ie_to_bss_conf (struct ieee80211_vif *vif, +const struct ieee80211_he_spr *he_spr_ie_elem);/* Spectrum management */ void ieee80211_process_measurement_req(struct ieee80211_sub_if_data *sdata,
net/mac80211/mlme.c +1 -0
@@ -3373,6 +3373,7 @@ static bool ieee80211_assoc_success(struct ieee80211_sub_if_data *sdata,if (elems.uora_element) bss_conf->uora_ocw_range = elems.uora_element[0 ]; +ieee80211_he_spr_ie_to_bss_conf (&sdata->vif, elems.he_spr);/* TODO: OPEN: what happens if BSS color disable is set? */ }
net/wireless/nl80211.c +43 -0
61 lines not on this page · raw message
Signature · 1 line
2.20.1
Johannes Berg
maintainerRe: [PATCH V3 2/2] mac80211: allow setting spatial reuse parameters from bss_conf
Quoted 6 lines · John Crispin
Store the OBSS PD parameters inside
bss_confwhen bringing up an AP and/or when a station connects to an AP. This allows the driver to configure the HW accordingly.Signed-off-by Shashidhar Lakkavalli <[email protected]>Signed-off-by John Crispin <[email protected]>
Quoted 10 lines
--- include/net/cfg80211.h | 15 +++++++++++++ include/net/mac80211.h | 4 ++++ include/uapi/linux/nl80211.h | 27 ++++++++++++++++++++++ net/mac80211/cfg.c | 5 ++++- net/mac80211/he.c | 24 ++++++++++++++++++++ net/mac80211/ieee80211_i.h | 3 +++ net/mac80211/mlme.c | 1 + net/wireless/nl80211.c | 43 ++++++++++++++++++++++++++++++++++++ 8 files changed, 121 insertions(+), 1 deletion(-)
Not sure if I missed this before, but in any case please split between cfg80211 and mac80211 for all but the most trivial patches.
Quoted 2 lines
+/**
+ * enumnl80211_he_spr- spatial reuse attributes
bad copy/paste? :)
Quoted 7 lines
+ * @__NL80211_HE_OBSS_PD_ATTR_INVALID: Invalid
+ *
+ * @NL80211_ATTR_HE_OBSS_PD_MIN_OFFSET: the OBSS PD minimum tx power offset.
+ * @NL80211_ATTR_HE_OBSS_PD_MAX_OFFSET: the OBSS PD maximum tx power offset.
+ *
+ * @__NL80211_HE_OBSS_PD_ATTR_LAST: Internal
+ * @NL80211_HE_OBSS_PD_ATTR_MAX: highest spiatl reuse attribute.
typo & wrong anyway, OBSS PD not SPR
Quoted 1 line
+ */
Those prefixes are a bit confusing - IMHO they should all be NL80211_HE_OBSS_PD_ATTR_*, NL80211_ATTR_* is mostly (except for a few historical bugs) the top-level attributes.
Quoted 1 line
+enum
nl80211_he_spr_attributes{
here also
net/mac80211/cfg.c static int ieee80211_start_ap(struct wiphy *wiphy, struct net_device *dev, · line 1052
Quoted 2 lines
net/mac80211/cfg.c +2
-0+memcpy (&sdata->vif.bss_conf.he_obss_pd, ¶ms->he_obss_pd, +sizeof (struct ieee80211_he_obss_pd ));
just use struct assignment
blabla.he_obss_pd = params->he_obss_pd;
net/wireless/nl80211.c const struct nla_policy nl80211_policy[NUM_NL80211_ATTR] = { · line 577
Quoted 1 line
net/wireless/nl80211.c +1
-0+ [NL80211_ATTR_HE_OBSS_PD] = { .type = NLA_NESTED },
please use NLA_POLICY_NESTED() (requires putting the below policy above this point)
net/wireless/nl80211.c static int nl80211_parse_beacon(struct cfg80211_registered_device *rdev, · line 4353
Quoted 2 lines
net/wireless/nl80211.c +2
-0+static const struct nla_policy + he_spr_policy[NL80211_HE_OBSS_PD_ATTR_MAX +1 ] = {
I guess I'd lose all the tabs here but don't really care that much.
net/wireless/nl80211.c static int nl80211_parse_beacon(struct cfg80211_registered_device *rdev, · line 4355
Quoted 2 lines
net/wireless/nl80211.c +2
-0+ [NL80211_ATTR_HE_OBSS_PD_MIN_OFFSET] = { .type = NLA_U32 }, + [NL80211_ATTR_HE_OBSS_PD_MAX_OFFSET] = { .type = NLA_U32 },
That can't be right, they go into u8 eventually, no? Use NLA_U8 or maybe even NLA_POLICY_RANGE().
Also in the struct ieee80211_he_obss_pd you have u32 for no real reason?
In the element in the frame you only used a single u8.
net/wireless/nl80211.c static int nl80211_parse_beacon(struct cfg80211_registered_device *rdev, · line 4379
Quoted 6 lines
net/wireless/nl80211.c +5
-0+if (!tb[NL80211_ATTR_HE_OBSS_PD_MIN_OFFSET ] || + !tb[NL80211_ATTR_HE_OBSS_PD_MAX_OFFSET ]) +return -EINVAL ; +if (he_obss_pd->min_offset >= he_obss_pd->max_offset) +return -EINVAL ;
Maybe add some extack error messages for this.
johannes