diff mbox series

[3/6] nl80211: add support to send EHT capabilities from userspace

Message ID 1640163883-12696-4-git-send-email-quic_vjakkam@quicinc.com (mailing list archive)
State Superseded
Delegated to: Johannes Berg
Headers show
Series cfg80211/nl80211: add support for EHT | expand

Commit Message

Veerendranath Jakkam Dec. 22, 2021, 9:04 a.m. UTC
From: Vikram Kandukuri <quic_vikram@quicinc.com>

Add support to process EHT capabilities element passed by the userspace
in beacon template and store the pointer in struct cfg80211_ap_settings.

Add new attribute NL80211_ATTR_EHT_CAPABILITY to be used by the
userspace to pass EHT capabilities of a station trying to associate.

Signed-off-by: Vikram Kandukuri <quic_vikram@quicinc.com>
Co-authored-by: Aloka Dixit <quic_alokad@quicinc.com>
Signed-off-by: Aloka Dixit <quic_alokad@quicinc.com>
Co-authored-by: Veerendranath Jakkam <quic_vjakkam@quicinc.com>
Signed-off-by: Veerendranath Jakkam <quic_vjakkam@quicinc.com>
---
 include/net/cfg80211.h       |  6 ++++++
 include/uapi/linux/nl80211.h |  7 +++++++
 net/wireless/nl80211.c       | 29 ++++++++++++++++++++++++++---
 3 files changed, 39 insertions(+), 3 deletions(-)

Comments

Johannes Berg Feb. 3, 2022, 12:45 p.m. UTC | #1
On Wed, 2021-12-22 at 14:34 +0530, Veerendranath Jakkam wrote:
>  
> +#define NL80211_EHT_MIN_CAPABILITY_LEN           10
> +#define NL80211_EHT_MAX_CAPABILITY_LEN           81
> 

How did you get to 81?

I calculate only 51, based on the assumption that we can only have
NSS==8. Even if you think NSS==16 (which I doubt), I get to 80 only?

johannes
Johannes Berg Feb. 3, 2022, 12:47 p.m. UTC | #2
On Wed, 2021-12-22 at 14:34 +0530, Veerendranath Jakkam wrote:
> 
> +#define NL80211_EHT_MIN_CAPABILITY_LEN           10
> 

And that's 13, no? You have to support 80 MHz.

johannes
Veerendranath Jakkam Feb. 4, 2022, 7:12 a.m. UTC | #3
On 2/3/22 6:15 PM, Johannes Berg wrote:
> On Wed, 2021-12-22 at 14:34 +0530, Veerendranath Jakkam wrote:
>>   
>> +#define NL80211_EHT_MIN_CAPABILITY_LEN           10
>> +#define NL80211_EHT_MAX_CAPABILITY_LEN           81
>>
> How did you get to 81?
>
> I calculate only 51, based on the assumption that we can only have
> NSS==8. Even if you think NSS==16 (which I doubt), I get to 80 only?
>
> johannes

I considered max values for NSS and RU Index Bitmask sub-fields in PPE 
threshold field.

i.e. NSS=16, RU Index Bitmask = 0x11111 with this max PPE threshold info 
sub-field length is 60 bytes


Max PPE thresholds field length = 4 bits (for NSS) + 5 bits (for RU 
Index Bitmask) +  480 bits (PPE info) + 7 bits (PPE pad)= 62 bytes

EHT fixed fields length = 10 bytes

Max MCS-NSS Set field length = 9 bytes

So total max length would be 81 bytes
Veerendranath Jakkam Feb. 4, 2022, 7:18 a.m. UTC | #4
On 2/3/22 6:17 PM, Johannes Berg wrote:
> On Wed, 2021-12-22 at 14:34 +0530, Veerendranath Jakkam wrote:
>> +#define NL80211_EHT_MIN_CAPABILITY_LEN           10
>>
> And that's 13, no? You have to support 80 MHz.
>
> johannes

I considered fixed fields lengths only for minimum length.

But I agree that we can include minimum possible length of MCS-NSS Set 
field also.
Johannes Berg Feb. 4, 2022, 8:11 a.m. UTC | #5
On Fri, 2022-02-04 at 12:42 +0530, Veerendranath Jakkam wrote:
> > 
> > I calculate only 51, based on the assumption that we can only have
> > NSS==8. Even if you think NSS==16 (which I doubt), I get to 80 only?
> 
> So total max length would be 81 bytes
> 

Right. Now I don't know how I got to 80...

Regardless, I don't think NSS>8 is actually valid, the PHY spec always
says it's max of 8, so I think we can safely limit to 51?

johannes
Veerendranath Jakkam Feb. 4, 2022, 2:37 p.m. UTC | #6
On 2/4/22 1:41 PM, Johannes Berg wrote:
> On Fri, 2022-02-04 at 12:42 +0530, Veerendranath Jakkam wrote:
>>> I calculate only 51, based on the assumption that we can only have
>>> NSS==8. Even if you think NSS==16 (which I doubt), I get to 80 only?
>> So total max length would be 81 bytes
>>
> Right. Now I don't know how I got to 80...
>
> Regardless, I don't think NSS>8 is actually valid, the PHY spec always
> says it's max of 8, so I think we can safely limit to 51?
>
> johannes


There are some references for NSS > 8, ex: Table 9-33a, P802.11be_D1.3 
hence I used 81.

Please let me know if you would like this to be changed to 51
Johannes Berg Feb. 4, 2022, 2:43 p.m. UTC | #7
On Fri, 2022-02-04 at 20:07 +0530, Veerendranath Jakkam wrote:
> 
> There are some references for NSS > 8, ex: Table 9-33a, P802.11be_D1.3 
> hence I used 81.

Right, the spec confuses me. In a lot of places it reserves enough space
for 8 < NSS <= 16, but then it has e.g. Table 36-40 with 4 bits, but
saying "for up to 8 spatial streams" (MU-MIMO). And even for OFDMA it
states in a lot of places that the maximum is only 8.

> Please let me know if you would like this to be changed to 51
> 
Nah, don't worry. I think it probably doesn't even really *matter*, we
can safely leave it at 81 anyway (I had evidently miscalculated as 80
before, so I was confused).

We also already had some patches in this area, and I'm just working on a
combination - e.g. in your first patch I don't like the use of FIELD_GET
so much, preferring uXX_get_bits(), but Ilan already had patches here
that deal with that.

For many of the other patches, Ilan and you arrived at a literally bit-
identical version of things!

So I think I'm going to pick a couple of things from him and a couple of
things from you, and send out a combined series. Perhaps later today, if
I manage to get it done.

Also in your later nl80211 patch I'm thinking we should combine the
HE/EHT GI settings etc., there's no point duplicating all the enums,
though we might want to do some renaming.

Sounds OK?

johannes
Veerendranath Jakkam Feb. 4, 2022, 5:43 p.m. UTC | #8
On 2/4/22 8:13 PM, Johannes Berg wrote:
> On Fri, 2022-02-04 at 20:07 +0530, Veerendranath Jakkam wrote:
>> There are some references for NSS > 8, ex: Table 9-33a, P802.11be_D1.3
>> hence I used 81.
> Right, the spec confuses me. In a lot of places it reserves enough space
> for 8 < NSS <= 16, but then it has e.g. Table 36-40 with 4 bits, but
> saying "for up to 8 spatial streams" (MU-MIMO). And even for OFDMA it
> states in a lot of places that the maximum is only 8.
>
>> Please let me know if you would like this to be changed to 51
>>
> Nah, don't worry. I think it probably doesn't even really *matter*, we
> can safely leave it at 81 anyway (I had evidently miscalculated as 80
> before, so I was confused).
>
> We also already had some patches in this area, and I'm just working on a
> combination - e.g. in your first patch I don't like the use of FIELD_GET
> so much, preferring uXX_get_bits(), but Ilan already had patches here
> that deal with that.
>
> For many of the other patches, Ilan and you arrived at a literally bit-
> identical version of things!
>
> So I think I'm going to pick a couple of things from him and a couple of
> things from you, and send out a combined series. Perhaps later today, if
> I manage to get it done.


Sure, Thanks for the update.

> Also in your later nl80211 patch I'm thinking we should combine the
> HE/EHT GI settings etc., there's no point duplicating all the enums,
> though we might want to do some renaming.
>
> Sounds OK?
>
> johannes


Yeah, This looks fine for me.

meanwhile I will upload new patch set with the suggested changes in last 
patch.
Johannes Berg Feb. 4, 2022, 5:45 p.m. UTC | #9
On Fri, 2022-02-04 at 23:13 +0530, Veerendranath Jakkam wrote:
> 
> 
> > Also in your later nl80211 patch I'm thinking we should combine the
> > HE/EHT GI settings etc., there's no point duplicating all the enums,
> > though we might want to do some renaming.

I actually just decided against that ... it gets messy because we still
need the attributes, and the GI is the only one that's entirely the
same, so I think probably duplicating that is more understandable (all
the EHT stuff belongs together)...

> 
> meanwhile I will upload new patch set with the suggested changes in last 
> patch.

No need. I'm doing rework on this, and we also have mac80211 assoc
patches, STA capabilities, etc. I'll send it all out soon.

johannes
Veerendranath Jakkam Feb. 4, 2022, 6:28 p.m. UTC | #10
On 2/4/22 11:15 PM, Johannes Berg wrote:
> On Fri, 2022-02-04 at 23:13 +0530, Veerendranath Jakkam wrote:
>>
>>> Also in your later nl80211 patch I'm thinking we should combine the
>>> HE/EHT GI settings etc., there's no point duplicating all the enums,
>>> though we might want to do some renaming.
> I actually just decided against that ... it gets messy because we still
> need the attributes, and the GI is the only one that's entirely the
> same, so I think probably duplicating that is more understandable (all
> the EHT stuff belongs together)...
>
>> meanwhile I will upload new patch set with the suggested changes in last
>> patch.
> No need. I'm doing rework on this, and we also have mac80211 assoc
> patches, STA capabilities, etc. I'll send it all out soon.
>
> johannes


Thank a lot for your assistance. Looking forward to see your patches.. :)


veeru
diff mbox series

Patch

diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index df197c6..ce34dd7 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -1271,6 +1271,7 @@  struct cfg80211_unsol_bcast_probe_resp {
  * @ht_cap: HT capabilities (or %NULL if HT isn't enabled)
  * @vht_cap: VHT capabilities (or %NULL if VHT isn't enabled)
  * @he_cap: HE capabilities (or %NULL if HE isn't enabled)
+ * @eht_cap: EHT capabilities (or %NULL if EHT isn't enabled)
  * @ht_required: stations must support HT
  * @vht_required: stations must support VHT
  * @twt_responder: Enable Target Wait Time
@@ -1308,6 +1309,7 @@  struct cfg80211_ap_settings {
 	const struct ieee80211_vht_cap *vht_cap;
 	const struct ieee80211_he_cap_elem *he_cap;
 	const struct ieee80211_he_operation *he_oper;
+	const struct ieee80211_eht_cap_elem *eht_cap;
 	bool ht_required, vht_required, he_required, sae_h2e_required;
 	bool twt_responder;
 	u32 flags;
@@ -1473,6 +1475,8 @@  struct sta_txpwr {
  * @airtime_weight: airtime scheduler weight for this station
  * @txpwr: transmit power for an associated station
  * @he_6ghz_capa: HE 6 GHz Band capabilities of station
+ * @eht_capa: EHT capabilities of station
+ * @eht_capa_len: the length of the EHT capabilities
  */
 struct station_parameters {
 	const u8 *supported_rates;
@@ -1506,6 +1510,8 @@  struct station_parameters {
 	u16 airtime_weight;
 	struct sta_txpwr txpwr;
 	const struct ieee80211_he_6ghz_capa *he_6ghz_capa;
+	const struct ieee80211_eht_cap_elem *eht_capa;
+	u8 eht_capa_len;
 };
 
 /**
diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h
index a709f5c..c221322 100644
--- a/include/uapi/linux/nl80211.h
+++ b/include/uapi/linux/nl80211.h
@@ -2659,6 +2659,8 @@  enum nl80211_commands {
  *	enumerated in &enum nl80211_ap_settings_flags. This attribute shall be
  *	used with %NL80211_CMD_START_AP request.
  *
+ * @NL80211_ATTR_EHT_CAPABILITY: EHT Capability information element.
+ *
  * @NUM_NL80211_ATTR: total number of nl80211_attrs available
  * @NL80211_ATTR_MAX: highest attribute number currently defined
  * @__NL80211_ATTR_AFTER_LAST: internal use
@@ -3169,6 +3171,8 @@  enum nl80211_attrs {
 
 	NL80211_ATTR_AP_SETTINGS_FLAGS,
 
+	NL80211_ATTR_EHT_CAPABILITY,
+
 	/* add attributes here, update the policy in nl80211.c */
 
 	__NL80211_ATTR_AFTER_LAST,
@@ -3225,6 +3229,9 @@  enum nl80211_attrs {
 #define NL80211_MAX_NR_CIPHER_SUITES		5
 #define NL80211_MAX_NR_AKM_SUITES		2
 
+#define NL80211_EHT_MIN_CAPABILITY_LEN           10
+#define NL80211_EHT_MAX_CAPABILITY_LEN           81
+
 #define NL80211_MIN_REMAIN_ON_CHANNEL_TIME	10
 
 /* default RSSI threshold for scan results if none specified. */
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 0ece4d3..dba4002 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -778,6 +778,10 @@  static const struct nla_policy nl80211_policy[NUM_NL80211_ATTR] = {
 	[NL80211_ATTR_MBSSID_ELEMS] = { .type = NLA_NESTED },
 	[NL80211_ATTR_RADAR_BACKGROUND] = { .type = NLA_FLAG },
 	[NL80211_ATTR_AP_SETTINGS_FLAGS] = { .type = NLA_U32 },
+	[NL80211_ATTR_EHT_CAPABILITY] =
+		NLA_POLICY_RANGE(NLA_BINARY,
+				 NL80211_EHT_MIN_CAPABILITY_LEN,
+				 NL80211_EHT_MAX_CAPABILITY_LEN),
 };
 
 /* policy for the key attributes */
@@ -5414,6 +5418,9 @@  static void nl80211_calculate_ap_params(struct cfg80211_ap_settings *params)
 	cap = cfg80211_find_ext_elem(WLAN_EID_EXT_HE_OPERATION, ies, ies_len);
 	if (cap && cap->datalen >= sizeof(*params->he_oper) + 1)
 		params->he_oper = (void *)(cap->data + 1);
+	cap = cfg80211_find_ext_elem(WLAN_EID_EXT_EHT_CAPABILITY, ies, ies_len);
+	if (cap && cap->datalen >= sizeof(*params->eht_cap) + 1)
+		params->eht_cap = (void *)(cap->data + 1);
 }
 
 static bool nl80211_get_ap_channel(struct cfg80211_registered_device *rdev,
@@ -6382,7 +6389,7 @@  int cfg80211_check_station_change(struct wiphy *wiphy,
 		if (params->supported_rates)
 			return -EINVAL;
 		if (params->ext_capab || params->ht_capa || params->vht_capa ||
-		    params->he_capa)
+		    params->he_capa || params->eht_capa)
 			return -EINVAL;
 	}
 
@@ -6567,6 +6574,17 @@  static int nl80211_parse_sta_channel_info(struct genl_info *info,
 	return 0;
 }
 
+static void nl80211_parse_sta_eht_capa(struct genl_info *info,
+				       struct station_parameters *params)
+{
+	if (info->attrs[NL80211_ATTR_EHT_CAPABILITY]) {
+		params->eht_capa =
+			nla_data(info->attrs[NL80211_ATTR_EHT_CAPABILITY]);
+		params->eht_capa_len =
+			nla_len(info->attrs[NL80211_ATTR_EHT_CAPABILITY]);
+	}
+}
+
 static int nl80211_set_station_tdls(struct genl_info *info,
 				    struct station_parameters *params)
 {
@@ -6587,6 +6605,8 @@  static int nl80211_set_station_tdls(struct genl_info *info,
 			nla_len(info->attrs[NL80211_ATTR_HE_CAPABILITY]);
 	}
 
+	nl80211_parse_sta_eht_capa(info, params);
+
 	err = nl80211_parse_sta_channel_info(info, params);
 	if (err)
 		return err;
@@ -6848,6 +6868,8 @@  static int nl80211_new_station(struct sk_buff *skb, struct genl_info *info)
 		params.he_6ghz_capa =
 			nla_data(info->attrs[NL80211_ATTR_HE_6GHZ_CAPABILITY]);
 
+	nl80211_parse_sta_eht_capa(info, &params);
+
 	if (info->attrs[NL80211_ATTR_OPMODE_NOTIF]) {
 		params.opmode_notif_used = true;
 		params.opmode_notif =
@@ -6891,8 +6913,9 @@  static int nl80211_new_station(struct sk_buff *skb, struct genl_info *info)
 		params.ht_capa = NULL;
 		params.vht_capa = NULL;
 
-		/* HE requires WME */
-		if (params.he_capa_len || params.he_6ghz_capa)
+		/* HE and EHT requires WME */
+		if (params.he_capa_len || params.he_6ghz_capa ||
+		    params.eht_capa_len)
 			return -EINVAL;
 	}