diff mbox series

[v3,07/12] mac80211: S1G capabilities information element in probe request

Message ID 20220906044812.7609-8-kieran.frewen@morsemicro.com (mailing list archive)
State Changes Requested
Delegated to: Johannes Berg
Headers show
Series Additional Support for 802.11ah (S1G) | expand

Commit Message

Kieran Frewen Sept. 6, 2022, 4:48 a.m. UTC
Add the missing S1G capabilities information element to probe requests.

Signed-off-by: Kieran Frewen <kieran.frewen@morsemicro.com>
---
 net/mac80211/ieee80211_i.h |  1 +
 net/mac80211/util.c        | 21 +++++++++++++++++++++
 2 files changed, 22 insertions(+)

Comments

Johannes Berg Sept. 6, 2022, 9:47 a.m. UTC | #1
Feels like somewhere in this patch you should consider the size of the
new element?
 
>  /* channel management */
>  bool ieee80211_chandef_ht_oper(const struct ieee80211_ht_operation *ht_oper,
> diff --git a/net/mac80211/util.c b/net/mac80211/util.c
> index 53826c663723..78e8c286011e 100644
> --- a/net/mac80211/util.c
> +++ b/net/mac80211/util.c
> @@ -1857,6 +1857,12 @@ static int ieee80211_build_preq_ies_band(struct ieee80211_sub_if_data *sdata,
>  	rate_flags = ieee80211_chandef_rate_flags(chandef);
>  	shift = ieee80211_chandef_get_shift(chandef);
>  
> +	/* For direct mac80211 scan (probe request), add S1G IE and consider its override bits */
> +	if (band == NL80211_BAND_S1GHZ) {
> +		pos = ieee80211_ie_build_s1g_cap(pos, &sband->s1g_cap);
> +		goto done;
> +	}
> 

Though off the top of my head I'm not really sure how it works for the
other bits.

johannes
diff mbox series

Patch

diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
index cd8879998739..e8ff4af9fc03 100644
--- a/net/mac80211/ieee80211_i.h
+++ b/net/mac80211/ieee80211_i.h
@@ -2400,6 +2400,7 @@  void ieee80211_add_s1g_capab_ie(struct ieee80211_sub_if_data *sdata,
 				struct sk_buff *skb);
 void ieee80211_add_aid_request_ie(struct ieee80211_sub_if_data *sdata,
 				  struct sk_buff *skb);
+u8 *ieee80211_ie_build_s1g_cap(u8 *pos, struct ieee80211_sta_s1g_cap *s1g_cap);
 
 /* channel management */
 bool ieee80211_chandef_ht_oper(const struct ieee80211_ht_operation *ht_oper,
diff --git a/net/mac80211/util.c b/net/mac80211/util.c
index 53826c663723..78e8c286011e 100644
--- a/net/mac80211/util.c
+++ b/net/mac80211/util.c
@@ -1857,6 +1857,12 @@  static int ieee80211_build_preq_ies_band(struct ieee80211_sub_if_data *sdata,
 	rate_flags = ieee80211_chandef_rate_flags(chandef);
 	shift = ieee80211_chandef_get_shift(chandef);
 
+	/* For direct mac80211 scan (probe request), add S1G IE and consider its override bits */
+	if (band == NL80211_BAND_S1GHZ) {
+		pos = ieee80211_ie_build_s1g_cap(pos, &sband->s1g_cap);
+		goto done;
+	}
+
 	num_rates = 0;
 	for (i = 0; i < sband->n_bitrates; i++) {
 		if ((BIT(i) & rate_mask) == 0)
@@ -2919,6 +2925,21 @@  size_t ieee80211_ie_split_vendor(const u8 *ies, size_t ielen, size_t offset)
 	return pos;
 }
 
+u8 *ieee80211_ie_build_s1g_cap(u8 *pos, struct ieee80211_sta_s1g_cap *s1g_cap)
+{
+	*pos++ = WLAN_EID_S1G_CAPABILITIES;
+	*pos++ = sizeof(struct ieee80211_s1g_cap);
+	memset(pos, 0, sizeof(struct ieee80211_s1g_cap));
+
+	memcpy(pos, &s1g_cap->cap, sizeof(s1g_cap->cap));
+	pos += sizeof(s1g_cap->cap);
+
+	memcpy(pos, &s1g_cap->nss_mcs, sizeof(s1g_cap->nss_mcs));
+	pos += sizeof(s1g_cap->nss_mcs);
+
+	return pos;
+}
+
 u8 *ieee80211_ie_build_ht_cap(u8 *pos, struct ieee80211_sta_ht_cap *ht_cap,
 			      u16 cap)
 {