2021-05-19 03:37:42

by Wen Gong

[permalink] [raw]
Subject: [PATCH 0/9] cfg80211/mac80211: Add support for 6GHZ STA for various modes : LPI, SP and VLP

It introduced some new concept:
power type of AP(STANDARD_POWER_AP, INDOOR_AP, VERY_LOW_POWER_AP)
power type of STATION(DEFAULT_CLIENT, SUBORDINATE_CLIENT)
power spectral density(psd)

This patchset for cfg80211/mac80211 is to add the definition of new
concept of 6G and add basic parse of IE(transmit power envelope
element) in beacon and save power spectral density(psd) reported
by lower-driver for 6G channel, the info will be passed to lower
driver when connecting to 6G AP.

Wen Gong (9):
cfg80211: add power type definition for 6G Hz
mac80211: add definition of regulatory info in 6G Hz operation
information
mac80211: add parse regulatory info in 6G Hz operation information
cfg80211: add definition for 6G power spectral density(psd)
cfg80211: save power spectral density(psd) of regulatory rule
mac80211: add definition for transmit power envelope element
mac80211: add parse transmit power envelope element
mac80211: add transmit power envelope element and power constraint in
bss_conf
mac80211: save transmit power envelope element and power constraint

include/linux/ieee80211.h | 35 ++++++++++++++++++++++++++++++++++-
include/net/cfg80211.h | 7 +++++++
include/net/mac80211.h | 6 ++++++
include/net/regulatory.h | 1 +
include/uapi/linux/nl80211.h | 32 ++++++++++++++++++++++++++++++++
net/mac80211/ieee80211_i.h | 3 +++
net/mac80211/mlme.c | 21 +++++++++++++++++++++
net/mac80211/util.c | 18 ++++++++++++++++++
net/wireless/reg.c | 14 ++++++++++++++
9 files changed, 136 insertions(+), 1 deletion(-)

--
2.31.1



2021-05-19 03:37:42

by Wen Gong

[permalink] [raw]
Subject: [PATCH 7/9] mac80211: add parse transmit power envelope element

This patch is to add the transmit power envelope element parse in
_ieee802_11_parse_elems_crc(), it maybe have more than one transmit
power envelope element in a beacon.

Signed-off-by: Wen Gong <[email protected]>
---
net/mac80211/ieee80211_i.h | 3 +++
net/mac80211/util.c | 8 ++++++++
2 files changed, 11 insertions(+)

diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
index ecda126a7026..22220e8dfdc7 100644
--- a/net/mac80211/ieee80211_i.h
+++ b/net/mac80211/ieee80211_i.h
@@ -1507,6 +1507,7 @@ struct ieee802_11_elems {
const struct ieee80211_he_spr *he_spr;
const struct ieee80211_mu_edca_param_set *mu_edca_param_set;
const struct ieee80211_he_6ghz_capa *he_6ghz_capa;
+ const struct ieee80211_tx_pwr_env *tx_pwr_env[IEEE80211_TPE_MAX_IE_COUNT];
const u8 *uora_element;
const u8 *mesh_id;
const u8 *peering;
@@ -1557,6 +1558,8 @@ struct ieee802_11_elems {
u8 perr_len;
u8 country_elem_len;
u8 bssid_index_len;
+ u8 tx_pwr_env_len[IEEE80211_TPE_MAX_IE_COUNT];
+ u8 tx_pwr_env_num;

/* whether a parse error occurred while retrieving these elements */
bool parse_error;
diff --git a/net/mac80211/util.c b/net/mac80211/util.c
index f58136e844a7..585d2eeb4470 100644
--- a/net/mac80211/util.c
+++ b/net/mac80211/util.c
@@ -1344,6 +1344,14 @@ _ieee802_11_parse_elems_crc(const u8 *start, size_t len, bool action,
elems->rsnx = pos;
elems->rsnx_len = elen;
break;
+ case WLAN_EID_TX_POWER_ENVELOPE:
+ if (elems->tx_pwr_env_num >= ARRAY_SIZE(elems->tx_pwr_env))
+ break;
+
+ elems->tx_pwr_env[elems->tx_pwr_env_num] = (void *)pos;
+ elems->tx_pwr_env_len[elems->tx_pwr_env_num] = elen;
+ elems->tx_pwr_env_num++;
+ break;
case WLAN_EID_EXTENSION:
ieee80211_parse_extension_element(calc_crc ?
&crc : NULL,
--
2.31.1


2021-05-19 03:37:54

by Wen Gong

[permalink] [raw]
Subject: [PATCH 4/9] cfg80211: add definition for 6G power spectral density(psd)

6GHz regulatory domains introduces power spectral density(psd). This
patch is define the flags for psd.

Signed-off-by: Wen Gong <[email protected]>
---
include/net/cfg80211.h | 5 +++++
include/net/regulatory.h | 1 +
include/uapi/linux/nl80211.h | 2 ++
3 files changed, 8 insertions(+)

diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index 13d92c643794..2f1769412fd6 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -107,6 +107,8 @@ struct wiphy;
* on this channel.
* @IEEE80211_CHAN_16MHZ: 16 MHz bandwidth is permitted
* on this channel.
+ * @IEEE80211_CHAN_PSD: power spectral density (in dBm)
+ * on this channel.
*
*/
enum ieee80211_channel_flags {
@@ -129,6 +131,7 @@ enum ieee80211_channel_flags {
IEEE80211_CHAN_4MHZ = 1<<16,
IEEE80211_CHAN_8MHZ = 1<<17,
IEEE80211_CHAN_16MHZ = 1<<18,
+ IEEE80211_CHAN_PSD = 1<<19,
};

#define IEEE80211_CHAN_NO_HT40 \
@@ -162,6 +165,7 @@ enum ieee80211_channel_flags {
* on this channel.
* @dfs_state_entered: timestamp (jiffies) when the dfs state was entered.
* @dfs_cac_ms: DFS CAC time in milliseconds, this is valid for DFS channels.
+ * @psd: power spectral density (in dBm)
*/
struct ieee80211_channel {
enum nl80211_band band;
@@ -178,6 +182,7 @@ struct ieee80211_channel {
enum nl80211_dfs_state dfs_state;
unsigned long dfs_state_entered;
unsigned int dfs_cac_ms;
+ s8 psd;
};

/**
diff --git a/include/net/regulatory.h b/include/net/regulatory.h
index 47f06f6f5a67..ed20004fb6a9 100644
--- a/include/net/regulatory.h
+++ b/include/net/regulatory.h
@@ -221,6 +221,7 @@ struct ieee80211_reg_rule {
u32 flags;
u32 dfs_cac_ms;
bool has_wmm;
+ s8 psd;
};

struct ieee80211_regdomain {
diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h
index 9f8e9e49a16a..b843ba0afad2 100644
--- a/include/uapi/linux/nl80211.h
+++ b/include/uapi/linux/nl80211.h
@@ -4040,6 +4040,7 @@ enum nl80211_sched_scan_match_attr {
* @NL80211_RRF_NO_80MHZ: 80MHz operation not allowed
* @NL80211_RRF_NO_160MHZ: 160MHz operation not allowed
* @NL80211_RRF_NO_HE: HE operation not allowed
+ * @NL80211_RRF_PSD: channels has power spectral density value
*/
enum nl80211_reg_rule_flags {
NL80211_RRF_NO_OFDM = 1<<0,
@@ -4058,6 +4059,7 @@ enum nl80211_reg_rule_flags {
NL80211_RRF_NO_80MHZ = 1<<15,
NL80211_RRF_NO_160MHZ = 1<<16,
NL80211_RRF_NO_HE = 1<<17,
+ NL80211_RRF_PSD = 1<<18,
};

#define NL80211_RRF_PASSIVE_SCAN NL80211_RRF_NO_IR
--
2.31.1


2021-05-19 03:37:55

by Wen Gong

[permalink] [raw]
Subject: [PATCH 8/9] mac80211: add transmit power envelope element and power constraint in bss_conf

This patch is to add definition of transmit power envelope element and
power constraint in struct ieee80211_bss_conf for 6GHz.

Signed-off-by: Wen Gong <[email protected]>
---
include/net/mac80211.h | 6 ++++++
1 file changed, 6 insertions(+)

diff --git a/include/net/mac80211.h b/include/net/mac80211.h
index 2d1d629e5d14..1e9d3650fbc4 100644
--- a/include/net/mac80211.h
+++ b/include/net/mac80211.h
@@ -631,6 +631,9 @@ struct ieee80211_fils_discovery {
* @s1g: BSS is S1G BSS (affects Association Request format).
* @beacon_tx_rate: The configured beacon transmit rate that needs to be passed
* to driver when rate control is offloaded to firmware.
+ * @tx_pwr_env: transmit power envelope array of BSS.
+ * @tx_pwr_env_num: number of @tx_pwr_env.
+ * @pwr_reduction: power constraint of BSS.
*/
struct ieee80211_bss_conf {
const u8 *bssid;
@@ -700,6 +703,9 @@ struct ieee80211_bss_conf {
u32 unsol_bcast_probe_resp_interval;
bool s1g;
struct cfg80211_bitrate_mask beacon_tx_rate;
+ struct ieee80211_tx_pwr_env tx_pwr_env[IEEE80211_TPE_MAX_IE_COUNT];
+ u8 tx_pwr_env_num;
+ u8 pwr_reduction;
};

/**
--
2.31.1


2021-05-19 03:37:55

by Wen Gong

[permalink] [raw]
Subject: [PATCH 9/9] mac80211: save transmit power envelope element and power constraint

This patch is to save the transmit power envelope element and power
constraint in struct ieee80211_bss_conf for 6GHz.

Signed-off-by: Wen Gong <[email protected]>
---
net/mac80211/mlme.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)

diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c
index 2e33a1263518..5b02d78bd934 100644
--- a/net/mac80211/mlme.c
+++ b/net/mac80211/mlme.c
@@ -5076,6 +5076,27 @@ static int ieee80211_prep_channel(struct ieee80211_sub_if_data *sdata,
else
he_oper = NULL;

+ if (is_6ghz) {
+ struct ieee802_11_elems elems;
+ struct ieee80211_bss_conf *bss_conf;
+ u8 i, n;
+
+ ieee802_11_parse_elems(ies->data, ies->len, false, &elems,
+ NULL, NULL);
+ bss_conf = &sdata->vif.bss_conf;
+ bss_conf->pwr_reduction = 0;
+ if (elems.pwr_constr_elem)
+ bss_conf->pwr_reduction = *elems.pwr_constr_elem;
+
+ memset(bss_conf->tx_pwr_env, 0, sizeof(bss_conf->tx_pwr_env));
+ bss_conf->tx_pwr_env_num = elems.tx_pwr_env_num;
+ n = min_t(u8, elems.tx_pwr_env_num,
+ ARRAY_SIZE(elems.tx_pwr_env));
+ for (i = 0; i < n; i++)
+ memcpy(&bss_conf->tx_pwr_env[i], elems.tx_pwr_env[i],
+ elems.tx_pwr_env_len[i]);
+ }
+
if (!ieee80211_verify_sta_he_mcs_support(sband, he_oper))
ifmgd->flags |= IEEE80211_STA_DISABLE_HE;
}
--
2.31.1


2021-05-19 03:37:55

by Wen Gong

[permalink] [raw]
Subject: [PATCH 1/9] cfg80211: add power type definition for 6G Hz

6GHz regulatory domains introduces different modes for 6GHz AP
operations Low Power Indoor(LPI), Standard Power(SP) and Very Low
Power(VLP). 6GHz STAs could be operated as either Regular or
Subordinate clients. This patch is define the flags for power type
of AP and STATION mode.

Signed-off-by: Wen Gong <[email protected]>
---
include/net/cfg80211.h | 2 ++
include/uapi/linux/nl80211.h | 30 ++++++++++++++++++++++++++++++
2 files changed, 32 insertions(+)

diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index 911fae42b0c0..13d92c643794 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -675,6 +675,7 @@ struct key_params {
* chan will define the primary channel and all other
* parameters are ignored.
* @freq1_offset: offset from @center_freq1, in KHz
+ * @power_type: power type of BSS for 6G
*/
struct cfg80211_chan_def {
struct ieee80211_channel *chan;
@@ -683,6 +684,7 @@ struct cfg80211_chan_def {
u32 center_freq2;
struct ieee80211_edmg edmg;
u16 freq1_offset;
+ enum nl80211_ap_reg_power power_type;
};

/*
diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h
index ac78da99fccd..9f8e9e49a16a 100644
--- a/include/uapi/linux/nl80211.h
+++ b/include/uapi/linux/nl80211.h
@@ -4085,6 +4085,36 @@ enum nl80211_dfs_regions {
NL80211_DFS_JP = 3,
};

+/**
+ * enum nl80211_ap_reg_power - regulatory power for a Access Point
+ *
+ * @NL80211_REG_UNSET_AP: Access Point has no regulatory power mode
+ * @NL80211_REG_LPI: Indoor Access Point
+ * @NL80211_REG_SP: Standard power Access Point
+ * @NL80211_REG_VLP: Very low power Access Point
+ */
+enum nl80211_ap_reg_power {
+ NL80211_REG_UNSET_AP,
+ NL80211_REG_LPI_AP,
+ NL80211_REG_SP_AP,
+ NL80211_REG_VLP_AP,
+ NL80211_REG_MAX_AP_TYPE = 3,
+};
+
+/**
+ * enum nl80211_client_reg_power - regulatory power for a client
+ *
+ * @NL80211_REG_UNSET_CLIENT: Client has no regulatory power mode
+ * @NL80211_REG_DEFAULT_CLIENT: Default Client
+ * @NL80211_REG_SUBORDINATE_CLIENT: Subordinate Client
+ */
+enum nl80211_client_reg_power {
+ NL80211_REG_UNSET_CLIENT,
+ NL80211_REG_DEFAULT_CLIENT,
+ NL80211_REG_SUBORDINATE_CLIENT,
+ NL80211_REG_MAX_CLIENT_TYPE = 2,
+};
+
/**
* enum nl80211_user_reg_hint_type - type of user regulatory hint
*
--
2.31.1


2021-05-25 10:33:45

by Wen Gong

[permalink] [raw]
Subject: Re: [PATCH 0/9] cfg80211/mac80211: Add support for 6GHZ STA for various modes : LPI, SP and VLP

On 2021-05-18 04:19, Wen Gong wrote:
> It introduced some new concept:
> power type of AP(STANDARD_POWER_AP, INDOOR_AP, VERY_LOW_POWER_AP)
> power type of STATION(DEFAULT_CLIENT, SUBORDINATE_CLIENT)
> power spectral density(psd)
>
> This patchset for cfg80211/mac80211 is to add the definition of new
> concept of 6G and add basic parse of IE(transmit power envelope
> element) in beacon and save power spectral density(psd) reported
> by lower-driver for 6G channel, the info will be passed to lower
> driver when connecting to 6G AP.
>
> Wen Gong (9):
> cfg80211: add power type definition for 6G Hz
> mac80211: add definition of regulatory info in 6G Hz operation
> information
> mac80211: add parse regulatory info in 6G Hz operation information
> cfg80211: add definition for 6G power spectral density(psd)
> cfg80211: save power spectral density(psd) of regulatory rule
> mac80211: add definition for transmit power envelope element
> mac80211: add parse transmit power envelope element
> mac80211: add transmit power envelope element and power constraint in
> bss_conf
> mac80211: save transmit power envelope element and power constraint
>
...
Nobody have comments?

2021-06-15 08:53:52

by Wen Gong

[permalink] [raw]
Subject: Re: [PATCH 0/9] cfg80211/mac80211: Add support for 6GHZ STA for various modes : LPI, SP and VLP

On 2021-05-25 18:04, Wen Gong wrote:
> On 2021-05-18 04:19, Wen Gong wrote:
>> It introduced some new concept:
>> power type of AP(STANDARD_POWER_AP, INDOOR_AP, VERY_LOW_POWER_AP)
>> power type of STATION(DEFAULT_CLIENT, SUBORDINATE_CLIENT)
>> power spectral density(psd)
>>
>> This patchset for cfg80211/mac80211 is to add the definition of new
>> concept of 6G and add basic parse of IE(transmit power envelope
>> element) in beacon and save power spectral density(psd) reported
>> by lower-driver for 6G channel, the info will be passed to lower
>> driver when connecting to 6G AP.
>>
>> Wen Gong (9):
>> cfg80211: add power type definition for 6G Hz
>> mac80211: add definition of regulatory info in 6G Hz operation
>> information
>> mac80211: add parse regulatory info in 6G Hz operation information
>> cfg80211: add definition for 6G power spectral density(psd)
>> cfg80211: save power spectral density(psd) of regulatory rule
>> mac80211: add definition for transmit power envelope element
>> mac80211: add parse transmit power envelope element
>> mac80211: add transmit power envelope element and power constraint
>> in
>> bss_conf
>> mac80211: save transmit power envelope element and power constraint
>>
> ...
> Nobody have comments?
Hi Johannes Berg,

Do you have comments?

2021-07-23 09:23:05

by Johannes Berg

[permalink] [raw]
Subject: Re: [PATCH 1/9] cfg80211: add power type definition for 6G Hz

Hi,

Sorry it took me so long to look at this. I started earlier, but then
found some questions and then ... sorry.

>
> +/**
> + * enum nl80211_ap_reg_power - regulatory power for a Access Point
> + *
> + * @NL80211_REG_UNSET_AP: Access Point has no regulatory power mode
> + * @NL80211_REG_LPI: Indoor Access Point
> + * @NL80211_REG_SP: Standard power Access Point
> + * @NL80211_REG_VLP: Very low power Access Point
> + */
> +enum nl80211_ap_reg_power {
> + NL80211_REG_UNSET_AP,
> + NL80211_REG_LPI_AP,
> + NL80211_REG_SP_AP,
> + NL80211_REG_VLP_AP,
> + NL80211_REG_MAX_AP_TYPE = 3,

That last one is missing docs. Also, why should it be numbered
explicitly? Better add something like

NUM_NL80211_REG_POWER_TYPE,
NL80211_REG_MAX_TYPE = NUM_NL80211_REG_POWER_TYPE - 1

or something?


> +enum nl80211_client_reg_power {
> + NL80211_REG_UNSET_CLIENT,
> + NL80211_REG_DEFAULT_CLIENT,
> + NL80211_REG_SUBORDINATE_CLIENT,
> + NL80211_REG_MAX_CLIENT_TYPE = 2,

same here.

johannes

2021-07-23 09:25:37

by Johannes Berg

[permalink] [raw]
Subject: Re: [PATCH 4/9] cfg80211: add definition for 6G power spectral density(psd)

On Mon, 2021-05-17 at 16:19 -0400, Wen Gong wrote:
>
> + * @IEEE80211_CHAN_PSD: power spectral density (in dBm)
> + * on this channel.

Do we need that? Which really is just another way of asking

> + * @psd: power spectral density (in dBm)

whether or not 0 is a valid value for this?

> +++ b/include/uapi/linux/nl80211.h
> @@ -4040,6 +4040,7 @@ enum nl80211_sched_scan_match_attr {
>   * @NL80211_RRF_NO_80MHZ: 80MHz operation not allowed
>   * @NL80211_RRF_NO_160MHZ: 160MHz operation not allowed
>   * @NL80211_RRF_NO_HE: HE operation not allowed
> + * @NL80211_RRF_PSD: channels has power spectral density value

It doesn't seem like we need this, after all, there must be some kind of
attribute for the PSD, and then its presence/absence already indicates
this?

johannes

2021-07-23 09:34:20

by Johannes Berg

[permalink] [raw]
Subject: Re: [PATCH 7/9] mac80211: add parse transmit power envelope element

On Mon, 2021-05-17 at 16:19 -0400, Wen Gong wrote:
> This patch is to add the transmit power envelope element parse in
> _ieee802_11_parse_elems_crc(), it maybe have more than one transmit
> power envelope element in a beacon.

This is really hard to read.

I'm sure you're aware of
https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches#commit_messages

Also, FWIW, "This patch" language is pointless. We all know we're
talking about a patch. Or maybe even not, we may be reading the commit
later on.

> + case WLAN_EID_TX_POWER_ENVELOPE:
> + if (elems->tx_pwr_env_num >=
> ARRAY_SIZE(elems->tx_pwr_env))
> + break;
>

Seems to me this should do some validation on the actual element? It at
least has to have _one_ octet, afaict?

johannes

2021-07-23 09:36:00

by Johannes Berg

[permalink] [raw]
Subject: Re: [PATCH 8/9] mac80211: add transmit power envelope element and power constraint in bss_conf

On Mon, 2021-05-17 at 16:19 -0400, Wen Gong wrote:
> This patch is to add definition of transmit power envelope element and
> power constraint in struct ieee80211_bss_conf for 6GHz.

This does nothing, please squash with the next patch.

johannes

2021-07-23 09:38:45

by Johannes Berg

[permalink] [raw]
Subject: Re: [PATCH 9/9] mac80211: save transmit power envelope element and power constraint

On Mon, 2021-05-17 at 16:19 -0400, Wen Gong wrote:
>
> + if (is_6ghz) {
> + struct ieee802_11_elems elems;
> + struct ieee80211_bss_conf *bss_conf;
> + u8 i, n;
> +
> + ieee802_11_parse_elems(ies->data, ies->len, false, &elems,
> + NULL, NULL);
> + bss_conf = &sdata->vif.bss_conf;
> + bss_conf->pwr_reduction = 0;
> + if (elems.pwr_constr_elem)
> + bss_conf->pwr_reduction = *elems.pwr_constr_elem;
> +
> + memset(bss_conf->tx_pwr_env, 0, sizeof(bss_conf->tx_pwr_env));
> + bss_conf->tx_pwr_env_num = elems.tx_pwr_env_num;
> + n = min_t(u8, elems.tx_pwr_env_num,
> + ARRAY_SIZE(elems.tx_pwr_env));

If anything, that min_t would make sense only if you were actually using
ARRAY_SIZE(bss_conf->tx_pwr_env), but like this it's quite pointless,
just checking again if the element parsing was internally consistent?

I'd probably remove it and throw in a

BUILD_BUG_ON(ARRAY_SIZE(bss_conf->tx_pwr_env) !=
ARRAY_SIZE(elems.tx_pwr_env));

instead.

> + for (i = 0; i < n; i++)
> + memcpy(&bss_conf->tx_pwr_env[i], elems.tx_pwr_env[i],
> + elems.tx_pwr_env_len[i]);

You also never validated that the element wasn't too long!


If you connect to 6 Ghz with this, and then again to another AP that
doesn't, you'll have it stuck at the old values. You need to reset at
some point (during disconnect).

And then two more questions:

1) Could this information change? Should we track it in beacons?

2) Should we at least check it again from the protected beacon or such
after association, so we don't blindly trust the probe response or
beacon (received during scan, not validated) at least when BIGTK is in
use?

johannes