Skip to contentSkip to conversation

band: add operating clases for 802.11ax

PATCH In review James Prestwood 2 participants 14 messages Feb 25, 2022

lore
Share & tools
lore

James Prestwood

author
#0 lore raw

PATCH 1/11 band: add operating clases for 802.11ax

Obtained from the IEEE 802.11ax amendment, Table E-4

---
 src/band.c | 63 +++++++++++++++++++++++++++++++++++++++++++++++-------
 1 file changed, 55 insertions(+), 8 deletions(-)
src/band.c +55 -8
index 9024d186..28ba6a62 100644
@@ -489,8 +489,8 @@ static int band_channel_info_get_bandwidth(const struct band_chandef *info)
 struct operating_class_info {
 	uint32_t starting_frequency;
 	uint32_t flags;
-	uint8_t channel_set[20];
-	uint8_t center_frequencies[8];
+	uint8_t channel_set[60];
+	uint8_t center_frequencies[30];
 	uint16_t channel_spacing;
 	uint8_t operating_class;
 };
@@ -598,20 +598,20 @@ static const struct operating_class_info e4_operating_classes[] = {
 	{
 		.operating_class = 125,
 		.starting_frequency = 5000,
-		.channel_set = { 149, 153, 157, 161, 165, 169, 173},
+		.channel_set = { 149, 153, 157, 161, 165, 169, 173, 177 },
 		.channel_spacing = 20,
 	},
 	{
 		.operating_class = 126,
 		.starting_frequency = 5000,
-		.channel_set = { 149, 157, 165},
+		.channel_set = { 149, 157, 165, 173 },
 		.channel_spacing = 40,
 		.flags = PRIMARY_CHANNEL_LOWER,
 	},
 	{
 		.operating_class = 127,
 		.starting_frequency = 5000,
-		.channel_set = { 153, 161, 169 },
+		.channel_set = { 153, 161, 169, 177 },
 		.channel_spacing = 40,
 		.flags = PRIMARY_CHANNEL_UPPER,
 	},
@@ -619,21 +619,68 @@ static const struct operating_class_info e4_operating_classes[] = {
 		.operating_class = 128,
 		.starting_frequency = 5000,
 		.channel_spacing = 80,
-		.center_frequencies = { 42, 58, 106, 122, 138, 155 },
+		.center_frequencies = { 42, 58, 106, 122, 138, 155, 171 },
 	},
 	{
 		.operating_class = 129,
 		.starting_frequency = 5000,
 		.channel_spacing = 160,
-		.center_frequencies = { 50, 114 },
+		.center_frequencies = { 50, 114, 163 },
 	},
 	{
 		.operating_class = 130,
 		.starting_frequency = 5000,
 		.channel_spacing = 80,
-		.center_frequencies = { 42, 58, 106, 122, 138, 155 },
+		.center_frequencies = { 42, 58, 106, 122, 138, 155, 171 },
 		.flags = PLUS80,
 	},
+	{
+		.operating_class = 131,
+		.starting_frequency = 5950,
+		.channel_spacing = 20,
+		.channel_set = { 1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45,
+				49, 53, 57, 61, 65, 69, 73, 77, 81, 85, 89, 93,
+				97, 101, 105, 109, 113, 117, 121, 125, 129, 133,
+				137, 141, 145, 149, 153, 157, 161, 165, 169,
+				173, 177, 181, 185, 189, 193, 197, 201, 205,
+				209, 213, 217, 221, 225, 229, 233 },
+	},
+	{
+		.operating_class = 132,
+		.starting_frequency = 5950,
+		.channel_spacing = 40,
+		.center_frequencies = { 3, 11, 19, 27, 35, 43, 51, 59, 67, 75,
+					83, 91, 99, 107, 115, 123, 131, 139,
+					147, 155, 163, 171, 179, 187, 195, 203,
+					211, 219, 227 },
+	},
+	{
+		.operating_class = 133,
+		.starting_frequency = 5950,
+		.channel_spacing = 80,
+		.center_frequencies = { 7, 23, 39, 55, 71, 87, 103, 119, 135,
+					151, 167, 183, 199, 215 },
+	},
+	{
+		.operating_class = 134,
+		.starting_frequency = 5950,
+		.channel_spacing = 160,
+		.center_frequencies = { 15, 47, 79, 111, 143, 175, 207 },
+	},
+	{
+		.operating_class = 135,
+		.starting_frequency = 5950,
+		.channel_spacing = 80,
+		.center_frequencies = { 7, 23, 39, 55, 71, 87, 102, 119, 135,
+					151, 167, 183, 199, 215 },
+		.flags = PLUS80,
+	},
+	{
+		.operating_class = 136,
+		.starting_frequency = 5950,
+		.channel_spacing = 20,
+		.center_frequencies = { 2 },
+	}
 };
 
 static const struct operating_class_info *e4_find_opclass(uint32_t opclass)
Signature · 1 line
2.34.1
author
#1 lore raw

PATCH 2/11 band: remove unneeded line break

This fits within 80 characters

---
 src/band.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
src/band.c +1 -2
index 28ba6a62..053f85d6 100644
@@ -325,8 +325,7 @@ static bool find_best_mcs_vht(uint8_t max_index, enum ofdm_channel_width width,
 	 */
 
 	for (i = max_index; i >= 0; i--)
-		if (band_ofdm_rate(i, width, rssi,
-						nss, sgi, out_data_rate))
+		if (band_ofdm_rate(i, width, rssi, nss, sgi, out_data_rate))
 			return true;
 
 	return false;
Signature · 1 line
2.34.1
author
#2 lore raw

PATCH 3/11 band: add BAND_FREQ_6_GHZ

In reply to James Prestwood

This is a new band defined in the WiFi 6E (ax) amendment. A completely new value is needed due to channel reuse between 2.4/5 and 6GHz.

util.c needed minimal updating to prevent compile errors which will be fixed later to actually handle this band. WSC also needed a case added for 6GHz but the spec does not outline any RF Band value for 6GHz so the 5GHz value will be returned in this case.

---
 src/band.c | 3 ++-
 src/band.h | 1 +
 src/util.c | 4 ++++
 src/wsc.c  | 1 +
 4 files changed, 8 insertions(+), 1 deletion(-)
src/band.c +2 -1
index 053f85d6..1eb94586 100644
@@ -1092,10 +1092,11 @@ static const uint8_t oper_class_jp_to_global[] = {
 	/* 128 - 130 is a 1 to 1 mapping */
 };
 
-/* Annex E, table E-4 (only 2.4GHz and 4.9 / 5GHz bands) */
+/* Annex E, table E-4 (only 2.4GHz, 4.9 / 5GHz, and 6GHz bands) */
 static const enum band_freq oper_class_to_band_global[] = {
 	[81 ... 84]   = BAND_FREQ_2_4_GHZ,
 	[104 ... 130] = BAND_FREQ_5_GHZ,
+	[131 ... 136] = BAND_FREQ_6_GHZ,
 };
 
 /* Annex E, table E-5 */
src/band.h +1 -0
index 2320bbcf..7b9e901f 100644
@@ -39,6 +39,7 @@ enum band_chandef_width {
 enum band_freq {
 	BAND_FREQ_2_4_GHZ = 0x1,
 	BAND_FREQ_5_GHZ = 0x2,
+	BAND_FREQ_6_GHZ = 0x4,
 };
 
 struct band_chandef {
src/util.c +4 -0
index 20e179a6..16df59ac 100644
@@ -347,6 +347,8 @@ bool scan_freq_set_add(struct scan_freq_set *freqs, uint32_t freq)
 		return true;
 	case BAND_FREQ_5_GHZ:
 		return l_uintset_put(freqs->channels_5ghz, channel);
+	case BAND_FREQ_6_GHZ:
+		return false;
 	}
 
 	return false;
@@ -366,6 +368,8 @@ bool scan_freq_set_contains(const struct scan_freq_set *freqs, uint32_t freq)
 		return freqs->channels_2ghz & (1 << (channel - 1));
 	case BAND_FREQ_5_GHZ:
 		return l_uintset_contains(freqs->channels_5ghz, channel);
+	case BAND_FREQ_6_GHZ:
+		return false;
 	}
 
 	return false;
src/wsc.c +1 -0
index 0457ebf7..bb9f663b 100644
@@ -308,6 +308,7 @@ static inline enum wsc_rf_band freq_to_rf_band(uint32_t freq)
 	case BAND_FREQ_2_4_GHZ:
 		return WSC_RF_BAND_2_4_GHZ;
 	case BAND_FREQ_5_GHZ:
+	case BAND_FREQ_6_GHZ:
 		return WSC_RF_BAND_5_0_GHZ;
 	}
 
Signature · 1 line
2.34.1
author
#3 lore raw

PATCH 4/11 band: add 6GHz support to {channel, freq}_to_{freq, channel}

In reply to James Prestwood

Adds support for the channels and frequencies defined in the 802.11ax spec.

---
 src/band.c | 35 +++++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)
src/band.c +35 -0
index 1eb94586..87b70d42 100644
@@ -1016,6 +1016,25 @@ uint8_t band_freq_to_channel(uint32_t freq, enum band_freq *out_band)
 		return channel;
 	}
 
+	if (freq > 5950 && freq <= 7115) {
+		if (freq % 5)
+			return 0;
+
+		channel = (freq - 5950) / 5;
+
+		if (out_band)
+			*out_band = BAND_FREQ_6_GHZ;
+
+		return channel;
+	}
+
+	if (freq == 5935) {
+		if (out_band)
+			*out_band = BAND_FREQ_6_GHZ;
+
+		return 2;
+	}
+
 	return 0;
 }
 
@@ -1037,6 +1056,22 @@ uint32_t band_channel_to_freq(uint8_t channel, enum band_freq band)
 			return 4000 + 5 * channel;
 	}
 
+	if (band == BAND_FREQ_6_GHZ) {
+		/* operating class 136 */
+		if (channel == 2)
+			return 5935;
+
+		/* Channels increment by 4, starting with 1 */
+		if (channel % 4 != 1)
+			return 0;
+
+		if (channel < 1 || channel > 233)
+			return 0;
+
+		/* operating classes 131, 132, 133, 134, 135 */
+		return 5950 + 5 * channel;
+	}
+
 	return 0;
 }
 
Signature · 1 line
2.34.1
author
#4 lore raw

PATCH 5/11 util: add 6GHz support to scan_freq_set* APIs

In reply to James Prestwood

The 6GHz channels are stored and accessed identically to 5GHz, just using a separate uintset object.

---
 src/util.c | 53 +++++++++++++++++++++++++++++++++++++++--------------
 1 file changed, 39 insertions(+), 14 deletions(-)
src/util.c +39 -14
index 16df59ac..2832486d 100644
@@ -314,6 +314,7 @@ bool util_ip_prefix_tohl(const char *ip, uint8_t *prefix_out,
 struct scan_freq_set {
 	uint16_t channels_2ghz;
 	struct l_uintset *channels_5ghz;
+	struct l_uintset *channels_6ghz;
 };
 
 struct scan_freq_set *scan_freq_set_new(void)
@@ -322,6 +323,7 @@ struct scan_freq_set *scan_freq_set_new(void)
 
 	/* 802.11-2012, 8.4.2.10 hints that 200 is the largest channel number */
 	ret->channels_5ghz = l_uintset_new_from_range(1, 200);
+	ret->channels_6ghz = l_uintset_new_from_range(1, 233);
 
 	return ret;
 }
@@ -329,6 +331,7 @@ struct scan_freq_set *scan_freq_set_new(void)
 void scan_freq_set_free(struct scan_freq_set *freqs)
 {
 	l_uintset_free(freqs->channels_5ghz);
+	l_uintset_free(freqs->channels_6ghz);
 	l_free(freqs);
 }
 
@@ -348,7 +351,7 @@ bool scan_freq_set_add(struct scan_freq_set *freqs, uint32_t freq)
 	case BAND_FREQ_5_GHZ:
 		return l_uintset_put(freqs->channels_5ghz, channel);
 	case BAND_FREQ_6_GHZ:
-		return false;
+		return l_uintset_put(freqs->channels_6ghz, channel);
 	}
 
 	return false;
@@ -369,7 +372,7 @@ bool scan_freq_set_contains(const struct scan_freq_set *freqs, uint32_t freq)
 	case BAND_FREQ_5_GHZ:
 		return l_uintset_contains(freqs->channels_5ghz, channel);
 	case BAND_FREQ_6_GHZ:
-		return false;
+		return l_uintset_contains(freqs->channels_6ghz, channel);
 	}
 
 	return false;
@@ -388,10 +391,15 @@ uint32_t scan_freq_set_get_bands(struct scan_freq_set *freqs)
 	if (l_uintset_find_min(freqs->channels_5ghz) <= max)
 		bands |= BAND_FREQ_5_GHZ;
 
+	max = l_uintset_get_max(freqs->channels_6ghz);
+
+	if (l_uintset_find_min(freqs->channels_6ghz) <= max)
+		bands |= BAND_FREQ_6_GHZ;
+
 	return bands;
 }
 
-static void scan_channels_5ghz_add(uint32_t channel, void *user_data)
+static void scan_channels_add(uint32_t channel, void *user_data)
 {
 	struct l_uintset *to = user_data;
 
@@ -403,37 +411,41 @@ void scan_freq_set_merge(struct scan_freq_set *to,
 {
 	to->channels_2ghz |= from->channels_2ghz;
 
-	l_uintset_foreach(from->channels_5ghz, scan_channels_5ghz_add,
+	l_uintset_foreach(from->channels_5ghz, scan_channels_add,
 							to->channels_5ghz);
+	l_uintset_foreach(from->channels_6ghz, scan_channels_add,
+							to->channels_6ghz);
 }
 
 bool scan_freq_set_isempty(const struct scan_freq_set *set)
 {
-	if (set->channels_2ghz == 0 && l_uintset_isempty(set->channels_5ghz))
+	if (set->channels_2ghz == 0 && l_uintset_isempty(set->channels_5ghz) &&
+					l_uintset_isempty(set->channels_6ghz))
 		return true;
 
 	return false;
 }
 
-struct channels_5ghz_foreach_data {
+struct channels_foreach_data {
 	scan_freq_set_func_t func;
+	enum band_freq band;
 	void *user_data;
 };
 
-static void scan_channels_5ghz_frequency(uint32_t channel, void *user_data)
+static void scan_channels_foreach(uint32_t channel, void *user_data)
 {
-	const struct channels_5ghz_foreach_data *channels_5ghz_data = user_data;
+	const struct channels_foreach_data *channels_data = user_data;
 	uint32_t freq;
 
-	freq = band_channel_to_freq(channel, BAND_FREQ_5_GHZ);
+	freq = band_channel_to_freq(channel, channels_data->band);
 
-	channels_5ghz_data->func(freq, channels_5ghz_data->user_data);
+	channels_data->func(freq, channels_data->user_data);
 }
 
 void scan_freq_set_foreach(const struct scan_freq_set *freqs,
 				scan_freq_set_func_t func, void *user_data)
 {
-	struct channels_5ghz_foreach_data data = { };
+	struct channels_foreach_data data = { };
 	uint8_t channel;
 	uint32_t freq;
 
@@ -441,10 +453,14 @@ void scan_freq_set_foreach(const struct scan_freq_set *freqs,
 		return;
 
 	data.func = func;
+	data.band = BAND_FREQ_5_GHZ;
 	data.user_data = user_data;
 
-	l_uintset_foreach(freqs->channels_5ghz, scan_channels_5ghz_frequency,
-									&data);
+	l_uintset_foreach(freqs->channels_5ghz, scan_channels_foreach, &data);
+
+	data.band = BAND_FREQ_6_GHZ;
+
+	l_uintset_foreach(freqs->channels_6ghz, scan_channels_foreach, &data);
 
 	if (!freqs->channels_2ghz)
 		return;
@@ -472,6 +488,14 @@ void scan_freq_set_constrain(struct scan_freq_set *set,
 	l_uintset_free(set->channels_5ghz);
 	set->channels_5ghz = intersection;
 
+	intersection = l_uintset_intersect(constraint->channels_6ghz,
+							set->channels_6ghz);
+	if (!intersection)
+		return;
+
+	l_uintset_free(set->channels_6ghz);
+	set->channels_6ghz = intersection;
+
 	set->channels_2ghz &= constraint->channels_2ghz;
 }
 
@@ -491,7 +515,8 @@ uint32_t *scan_freq_set_to_fixed_array(const struct scan_freq_set *set,
 	uint32_t *freqs;
 
 	count = __builtin_popcount(set->channels_2ghz) +
-				l_uintset_size(set->channels_5ghz);
+				l_uintset_size(set->channels_5ghz) +
+				l_uintset_size(set->channels_6ghz);
 
 	if (!count)
 		return NULL;
Signature · 1 line
2.34.1
author
#5 lore raw

PATCH 6/11 wiphy: add 6Ghz support

In reply to James Prestwood
---
 src/wiphy.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
src/wiphy.c +21 -0
index b6b0f563..a52d0941 100644
@@ -106,6 +106,7 @@ struct wiphy {
 	struct scan_freq_set *supported_freqs;
 	struct band *band_2g;
 	struct band *band_5g;
+	struct band *band_6g;
 	char *model_str;
 	char *vendor_str;
 	char *driver_str;
@@ -350,6 +351,11 @@ static void wiphy_free(void *data)
 		wiphy->band_5g = NULL;
 	}
 
+	if (wiphy->band_6g) {
+		band_free(wiphy->band_6g);
+		wiphy->band_6g = NULL;
+	}
+
 	scan_freq_set_free(wiphy->supported_freqs);
 	watchlist_destroy(&wiphy->state_watches);
 	l_free(wiphy->model_str);
@@ -436,6 +442,9 @@ uint32_t wiphy_get_supported_bands(struct wiphy *wiphy)
 	if (wiphy->band_5g)
 		bands |= BAND_FREQ_5_GHZ;
 
+	if (wiphy->band_6g)
+		bands |= BAND_FREQ_6_GHZ;
+
 	return bands;
 }
 
@@ -739,6 +748,9 @@ const uint8_t *wiphy_get_supported_rates(struct wiphy *wiphy, unsigned int band,
 	case NL80211_BAND_5GHZ:
 		bandp = wiphy->band_5g;
 		break;
+	case NL80211_BAND_6GHZ:
+		bandp = wiphy->band_6g;
+		break;
 	default:
 		return NULL;
 	}
@@ -789,6 +801,9 @@ int wiphy_estimate_data_rate(struct wiphy *wiphy,
 	case BAND_FREQ_5_GHZ:
 		bandp = wiphy->band_5g;
 		break;
+	case BAND_FREQ_6_GHZ:
+		bandp = wiphy->band_6g;
+		break;
 	default:
 		return -ENOTSUP;
 	}
@@ -979,6 +994,9 @@ static void wiphy_print_basic_info(struct wiphy *wiphy)
 	if (wiphy->band_5g)
 		wiphy_print_band_info(wiphy->band_5g, "5Ghz Band");
 
+	if (wiphy->band_6g)
+		wiphy_print_band_info(wiphy->band_6g, "6GHz Band");
+
 	if (wiphy->supported_ciphers) {
 		int len = 0;
 
@@ -1193,6 +1211,9 @@ static void parse_supported_bands(struct wiphy *wiphy,
 		case NL80211_BAND_5GHZ:
 			bandp = &wiphy->band_5g;
 			break;
+		case NL80211_BAND_6GHZ:
+			bandp = &wiphy->band_6g;
+			break;
 		default:
 			continue;
 		}
Signature · 1 line
2.34.1
author
#6 lore raw

PATCH 7/11 network: add 6GHz restrictions to network_can_connect_bss

In reply to James Prestwood

The 802.11ax standards adds some restrictions for the 6GHz band. In short stations must use SAE, OWE, or 8021x on this band and frame protection is required.

---
 src/network.c | 37 +++++++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)
src/network.c +37 -0
index 4e7af27c..a970f81f 100644
@@ -55,6 +55,7 @@
 #include "src/util.h"
 #include "src/erp.h"
 #include "src/handshake.h"
+#include "src/band.h"
 
 #define SAE_PT_SETTING "SAE-PT-Group%u"
 
@@ -774,6 +775,7 @@ int network_can_connect_bss(struct network *network, const struct scan_bss *bss)
 	struct network_config *config = info ? &info->config : NULL;
 	bool can_transition_disable = wiphy_can_transition_disable(wiphy);
 	struct ie_rsn_info rsn;
+	enum band_freq band;
 	int ret;
 
 	switch (security) {
@@ -785,6 +787,9 @@ int network_can_connect_bss(struct network *network, const struct scan_bss *bss)
 		return -ENOSYS;
 	}
 
+	if (!band_freq_to_channel(bss->frequency, &band))
+		return -ENOTSUP;
+
 	memset(&rsn, 0, sizeof(rsn));
 	ret = scan_bss_get_rsn_info(bss, &rsn);
 	if (ret < 0) {
@@ -797,6 +802,13 @@ int network_can_connect_bss(struct network *network, const struct scan_bss *bss)
 		 * We assume the spec means us to check bit 3 here
 		 */
 		if (ret == -ENOENT && security == SECURITY_NONE) {
+			/*
+			 * 802.11ax 12.12.2 - STA shall not use Open System
+			 * authentication without encryption
+			 */
+			if (band == BAND_FREQ_6_GHZ)
+				return -EPERM;
+
 			if (!config)
 				return 0;
 
@@ -852,6 +864,31 @@ int network_can_connect_bss(struct network *network, const struct scan_bss *bss)
 	}
 
 no_transition_disable:
+	/* 802.11ax Section 12.12.2 */
+	if (band == BAND_FREQ_6_GHZ) {
+		/* STA shall not use the following cipher suite selectors */
+		rsn.pairwise_ciphers &= ~IE_RSN_CIPHER_SUITE_USE_GROUP_CIPHER;
+		rsn.pairwise_ciphers &= ~IE_RSN_CIPHER_SUITE_TKIP;
+
+		/* STA shall not use the following AKM suite selectors */
+		rsn.akm_suites &= ~IE_RSN_AKM_SUITE_PSK;
+		rsn.akm_suites &= ~IE_RSN_AKM_SUITE_PSK_SHA256;
+		rsn.akm_suites &= ~IE_RSN_AKM_SUITE_FT_USING_PSK;
+
+		/* Basically the STA must use OWE, SAE, or 8021x */
+		if (!(rsn.akm_suites & (IE_RSN_AKM_SUITE_8021X |
+					IE_RSN_AKM_SUITE_FT_OVER_8021X |
+					IE_RSN_AKM_SUITE_8021X_SHA256 |
+					IE_RSN_AKM_SUITE_SAE_SHA256 |
+					IE_RSN_AKM_SUITE_FT_OVER_SAE_SHA256 |
+					IE_RSN_AKM_SUITE_FT_OVER_8021X_SHA384 |
+					IE_RSN_AKM_SUITE_OWE)))
+			return -EPERM;
+
+		/* STA shall use management frame protection */
+		rsn.mfpr = true;
+	}
+
 	if (!wiphy_select_cipher(wiphy, rsn.pairwise_ciphers))
 		return -ENOTSUP;
 
Signature · 1 line
2.34.1
#7 lore raw

Re: [PATCH 07/11] network: add 6GHz restrictions to network_can_connect_bss

Hi James,

Quoted 7 lines · James Prestwood

The 802.11ax standards adds some restrictions for the 6GHz band. In short stations must use SAE, OWE, or 8021x on this band and frame protection is required.

---
  src/network.c | 37 +++++++++++++++++++++++++++++++++++++
  1 file changed, 37 insertions(+)

<snip>

Quoted 13 lines
src/network.c +9 -0
@@ -852,6 +864,31 @@ int network_can_connect_bss(struct network *network, const struct scan_bss *bss)
  	}
 
  no_transition_disable:
+	/* 802.11ax Section 12.12.2 */
+	if (band == BAND_FREQ_6_GHZ) {
+		/* STA shall not use the following cipher suite selectors */
+		rsn.pairwise_ciphers &= ~IE_RSN_CIPHER_SUITE_USE_GROUP_CIPHER;
+		rsn.pairwise_ciphers &= ~IE_RSN_CIPHER_SUITE_TKIP;
+
+		/* STA shall not use the following AKM suite selectors */
+		rsn.akm_suites &= ~IE_RSN_AKM_SUITE_PSK;
+		rsn.akm_suites &= ~IE_RSN_AKM_SUITE_PSK_SHA256;

src/network.c int network_can_connect_bss(struct network *network, const struct scan_bss *bss) · line 885

Quoted 10 lines
src/network.c +10 -0
+		rsn.akm_suites &= ~IE_RSN_AKM_SUITE_FT_USING_PSK;
+
+		/* Basically the STA must use OWE, SAE, or 8021x */
+		if (!(rsn.akm_suites & (IE_RSN_AKM_SUITE_8021X |
+					IE_RSN_AKM_SUITE_FT_OVER_8021X |
+					IE_RSN_AKM_SUITE_8021X_SHA256 |
+					IE_RSN_AKM_SUITE_SAE_SHA256 |
+					IE_RSN_AKM_SUITE_FT_OVER_SAE_SHA256 |
+					IE_RSN_AKM_SUITE_FT_OVER_8021X_SHA384 |
+					IE_RSN_AKM_SUITE_OWE)))

I wonder if it is better to use IE_AKM_IS_SAE, IE_AKM_IS_FILS(8021x) and IE_AKM_IS_OWE instead.

src/network.c int network_can_connect_bss(struct network *network, const struct scan_bss *bss) · line 889

Quoted 4 lines
src/network.c +4 -0
+			return -EPERM;
+
+		/* STA shall use management frame protection */
+		rsn.mfpr = true;

This isn't actually how we enforce MFP. Not sure we ever set MFPR to true unless it is for testing purposes.

src/network.c int network_can_connect_bss(struct network *network, const struct scan_bss *bss) · line 894

Quoted 6 lines
src/network.c +2 -0
+	}
+
  	if (!wiphy_select_cipher(wiphy, rsn.pairwise_ciphers))
  		return -ENOTSUP;
 

Regards,
-Denis

author
#8 lore raw

Re: [PATCH 07/11] network: add 6GHz restrictions to network_can_connect_bss

Quoted 43 lines · Denis Kenzior

Hi James,

Quoted 9 lines · James Prestwood

The 802.11ax standards adds some restrictions for the 6GHz band. In short
stations must use SAE, OWE, or 8021x on this band and frame protection is
required.
---
  src/network.c | 37 +++++++++++++++++++++++++++++++++++++

  1 file changed, 37 insertions(+)

<snip>

Quoted 28 lines
(quoted diff) +0 -0
@@ -852,6 +864,31 @@ int network_can_connect_bss(struct network
 *network, const struct scan_bss *bss)
         }


  no_transition_disable:
+       /* 802.11ax Section 12.12.2 */
+       if (band == BAND_FREQ_6_GHZ) {
+               /* STA shall not use the following cipher suite selectors */
+               rsn.pairwise_ciphers &= ~IE_RSN_CIPHER_SUITE_USE_GROUP_CIPHER;
+               rsn.pairwise_ciphers &= ~IE_RSN_CIPHER_SUITE_TKIP; +
+               /* STA shall not use the following AKM suite selectors */
+               rsn.akm_suites &= ~IE_RSN_AKM_SUITE_PSK; +               rsn.akm_suites &= ~IE_RSN_AKM_SUITE_PSK_SHA256; +               rsn.akm_suites &= ~IE_RSN_AKM_SUITE_FT_USING_PSK; +
+               /* Basically the STA must use OWE, SAE, or 8021x */ +               if (!(rsn.akm_suites & (IE_RSN_AKM_SUITE_8021X | +                                       IE_RSN_AKM_SUITE_FT_OVER_80 21X |
+                                       IE_RSN_AKM_SUITE_8021X_SHA2 56 |
+                                       IE_RSN_AKM_SUITE_SAE_SHA256 |
+                                       IE_RSN_AKM_SUITE_FT_OVER_SA

Quoted 8 lines
Quoted 4 lines

E_SHA256 |
+                                       IE_RSN_AKM_SUITE_FT_OVER_80 21X_SHA384 |
+                                       IE_RSN_AKM_SUITE_OWE)))

I wonder if it is better to use IE_AKM_IS_SAE, IE_AKM_IS_FILS(8021x) and
IE_AKM_IS_OWE instead.

I avoided this because they all check for only a single AKM, which I guess we could modify, or add IE_AKM_HAS_* variants.

Quoted 9 lines
Quoted 5 lines

+                       return -EPERM;
+
+               /* STA shall use management frame protection */ +               rsn.mfpr = true;

This isn't actually how we enforce MFP.  Not sure we ever set MFPR to true
unless it is for testing purposes.

Yes, I saw earlier in the function it was set but it looks like this was just for the group management cipher check at the bottom. I'll add something in station.c.

Quoted 10 lines
Quoted 7 lines

+       }
+
        if (!wiphy_select_cipher(wiphy, rsn.pairwise_ciphers)) return -ENOTSUP;

Regards,
-Denis

author
#9 lore raw

PATCH 8/11 band: keep 6GHz frequencies out of 40mhz special case

In reply to James Prestwood

There is no 40MHz upper/lower concept for 6GHz so avoid this special handling.

---
 src/band.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
src/band.c +5 -1
index 87b70d42..984bc15d 100644
@@ -902,8 +902,12 @@ int oci_verify(const uint8_t oci[static 3], const struct band_chandef *own)
 	 * on 40 Mhz channels.  If the STA is operating on 40 Mhz while the
 	 * peer is operating on 80 or 160 Mhz wide channels, then only the
 	 * primary channel validation is performed
+	 *
+	 * With 6GHz operating classes there is no concept of upper/lower 40mhz
+	 * channels, therefore this special handling list not needed.
 	 */
-	if (own_bandwidth == 40 && oci_bandwidth == 40) {
+	if (own_bandwidth == 40 && oci_bandwidth == 40 &&
+						info->operating_class < 131) {
 		uint32_t behavior;
 
 		/*
Signature · 1 line
2.34.1
author
#10 lore raw

PATCH 9/11 unit: add band tests for 6GHz

In reply to James Prestwood

Tests that all valid channels/frequencies can be computed as well as oci_verify maps each new operating class to the correct chandef.

---
 unit/test-band.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 60 insertions(+)
unit/test-band.c +60 -0
index 0de1fdee..757db377 100644
@@ -331,6 +331,33 @@ static const struct band_chandef cd_4 = {
 	.center1_frequency = 2427,
 };
 
+static const struct band_chandef cd_5 = {
+	.frequency = 6235,
+	.channel_width = BAND_CHANDEF_WIDTH_20,
+};
+
+static const struct band_chandef cd_6 = {
+	.frequency = 6235,
+	.channel_width =  BAND_CHANDEF_WIDTH_40,
+};
+
+static const struct band_chandef cd_7 = {
+	.frequency = 6235,
+	.channel_width =  BAND_CHANDEF_WIDTH_80,
+};
+
+static const struct band_chandef cd_8 = {
+	.frequency = 6235,
+	.channel_width =  BAND_CHANDEF_WIDTH_160,
+};
+
+static const struct band_chandef cd_9 = {
+	.frequency = 6235,
+	.channel_width =  BAND_CHANDEF_WIDTH_80P80,
+	.center1_frequency = 6145,
+	.center2_frequency = 6225,
+};
+
 struct oci_data {
 	const struct band_chandef *cd;
 	uint8_t oci[3];
@@ -341,6 +368,11 @@ static const struct oci_data oci_data_1 = { &cd_1, { 129, 108, 0 } };
 static const struct oci_data oci_data_2 = { &cd_2, { 130, 36, 155 } };
 static const struct oci_data oci_data_3 = { &cd_3, { 81, 6, 0 } };
 static const struct oci_data oci_data_4 = { &cd_4, { 84, 6, 0 } };
+static const struct oci_data oci_data_5 = { &cd_5, { 131, 57, 0 } };
+static const struct oci_data oci_data_6 = { &cd_6, { 132, 57, 0 } };
+static const struct oci_data oci_data_7 = { &cd_7, { 133, 57, 0 } };
+static const struct oci_data oci_data_8 = { &cd_8, { 134, 57, 0 } };
+static const struct oci_data oci_data_9 = { &cd_9, { 135, 57, 55 } };
 
 static const struct oci_data oci_err_1 = { &cd_1, { 129, 36, 0 }, -EPERM };
 static const struct oci_data oci_err_2 = { &cd_1, { 121, 108, 0 }, -EPERM };
@@ -372,6 +404,26 @@ static void test_oci_from_chandef(const void *data)
 	assert(!memcmp(oci, test->oci, sizeof(oci)));
 }
 
+static void test_6ghz_channels(const void *data)
+{
+	unsigned int i;
+
+	/* Test all channels for 6GHz */
+	for (i = 1; i <= 233; i += 4)
+		assert(band_channel_to_freq(i, BAND_FREQ_6_GHZ) != 0);
+}
+
+static void test_6ghz_freqs(const void *data)
+{
+	uint32_t i;
+	enum band_freq band;
+
+	for (i = 5955; i < 7115; i += 5) {
+		assert(band_freq_to_channel(i, &band) != 0);
+		assert(band == BAND_FREQ_6_GHZ);
+	}
+}
+
 int main(int argc, char *argv[])
 {
 	l_test_init(&argc, &argv);
@@ -395,6 +447,11 @@ int main(int argc, char *argv[])
 	l_test_add("/band/oci/verify 2", test_oci_verify, &oci_data_2);
 	l_test_add("/band/oci/verify 3", test_oci_verify, &oci_data_3);
 	l_test_add("/band/oci/verify 4", test_oci_verify, &oci_data_4);
+	l_test_add("/band/oci/verify 5", test_oci_verify, &oci_data_5);
+	l_test_add("/band/oci/verify 6", test_oci_verify, &oci_data_6);
+	l_test_add("/band/oci/verify 7", test_oci_verify, &oci_data_7);
+	l_test_add("/band/oci/verify 8", test_oci_verify, &oci_data_8);
+	l_test_add("/band/oci/verify 9", test_oci_verify, &oci_data_9);
 
 	l_test_add("/band/oci/noverify 1", test_oci_verify, &oci_err_1);
 	l_test_add("/band/oci/noverify 2", test_oci_verify, &oci_err_2);
@@ -410,5 +467,8 @@ int main(int argc, char *argv[])
 	l_test_add("/band/oci/chandef 3", test_oci_from_chandef, &oci_data_3);
 	l_test_add("/band/oci/chandef 4", test_oci_from_chandef, &oci_data_4);
 
+	l_test_add("/band/6ghz/channels", test_6ghz_channels, NULL);
+	l_test_add("/band/6ghz/freq", test_6ghz_freqs, NULL);
+
 	return l_test_run();
 }
Signature · 1 line
2.34.1
author
#11 lore raw

PATCH 10/11 iwmon: parse ATTR_REG_RULES

In reply to James Prestwood

This parses out the regulatory rules and prints them.

---
 monitor/nlmon.c | 90 ++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 89 insertions(+), 1 deletion(-)
monitor/nlmon.c +89 -1
index 6ded9aa2..fe967922 100644
@@ -5455,6 +5455,93 @@ static void print_wiphy_bands(unsigned int level, const char *label,
 	}
 }
 
+static void print_reg_rule_flags(unsigned int level, const char *label,
+					const void *data, uint16_t size)
+{
+	uint32_t flag;
+
+	flag = l_get_u32(data);
+
+	if (!flag)
+		return;
+
+	print_attr(level, "%s: len %u", label, size);
+
+	if (flag & NL80211_RRF_NO_OFDM)
+		print_attr(level + 1, "No ODFM");
+	if (flag & NL80211_RRF_NO_CCK)
+		print_attr(level + 1, "No CCK");
+	if (flag & NL80211_RRF_NO_INDOOR)
+		print_attr(level + 1, "No Indoor");
+	if (flag & NL80211_RRF_NO_OUTDOOR)
+		print_attr(level + 1, "No Outdoor");
+	if (flag & NL80211_RRF_DFS)
+		print_attr(level + 1, "DFS");
+	if (flag & NL80211_RRF_PTP_ONLY)
+		print_attr(level + 1, "PTP Only");
+	if (flag & NL80211_RRF_PTMP_ONLY)
+		print_attr(level + 1, "PTMP Only");
+	if (flag & NL80211_RRF_NO_IR)
+		print_attr(level + 1, "No IR");
+	if (flag & __NL80211_RRF_NO_IBSS)
+		print_attr(level + 1, "No IBSS");
+	if (flag & NL80211_RRF_AUTO_BW)
+		print_attr(level + 1, "Auto BW");
+	if (flag & NL80211_RRF_IR_CONCURRENT)
+		print_attr(level + 1, "IR Concurrent");
+	if (flag & NL80211_RRF_NO_HT40MINUS)
+		print_attr(level + 1, "No HT40-");
+	if (flag & NL80211_RRF_NO_HT40PLUS)
+		print_attr(level + 1, "No HT40+");
+	if (flag & NL80211_RRF_NO_80MHZ)
+		print_attr(level + 1, "No 80MHz");
+	if (flag & NL80211_RRF_NO_160MHZ)
+		print_attr(level + 1, "No 160MHz");
+	if (flag & NL80211_RRF_NO_HE)
+		print_attr(level + 1, "No HE");
+}
+
+static void print_u32_div_1000(unsigned int level, const char *label,
+					const void *data, uint16_t size)
+{
+	uint32_t val = l_get_u32(data) / 1000;
+
+	print_attr(level, "%s: %u MHz", label, val);
+}
+
+static const struct attr_entry reg_rule_table[] = {
+	{ NL80211_ATTR_REG_RULE_FLAGS, "Flags", ATTR_CUSTOM,
+					{ .function = print_reg_rule_flags } },
+	{ NL80211_ATTR_FREQ_RANGE_START, "Frequency Start", ATTR_CUSTOM,
+					{ .function = print_u32_div_1000 } },
+	{ NL80211_ATTR_FREQ_RANGE_END, "Frequency End", ATTR_CUSTOM,
+					{ .function = print_u32_div_1000 } },
+	{ NL80211_ATTR_FREQ_RANGE_MAX_BW, "Frequency Range Max BW", ATTR_CUSTOM,
+					{ .function = print_u32_div_1000 } },
+	{ NL80211_ATTR_POWER_RULE_MAX_ANT_GAIN, "Max Antenna Gain", ATTR_U32 },
+	{ NL80211_ATTR_POWER_RULE_MAX_EIRP, "Max EIRP", ATTR_U32 },
+	{ NL80211_ATTR_DFS_CAC_TIME, "DFS CAC Time", ATTR_U32 },
+	{ }
+};
+
+static void print_reg_rules(unsigned int level, const char *label,
+					const void *data, uint16_t size)
+{
+	const struct nlattr *nla;
+	uint16_t nla_type;
+
+	print_attr(level, "%s: len %u", label, size);
+
+	for (nla = data; NLA_OK(nla, size); nla = NLA_NEXT(nla, size)) {
+		nla_type = nla->nla_type & NLA_TYPE_MASK;
+		print_attr(level + 1, "Rule %u: len %u", nla_type,
+							NLA_PAYLOAD(nla));
+
+		print_attributes(level + 2, reg_rule_table,
+					NLA_DATA(nla), NLA_PAYLOAD(nla));
+	}
+}
+
 static void print_eapol_key(unsigned int level, const void *data, uint32_t size)
 {
 	const struct eapol_key *ek = (struct eapol_key *)data;
@@ -6004,7 +6091,8 @@ static const struct attr_entry attr_table[] = {
 	{ NL80211_ATTR_REG_ALPHA2,
 			"Regulatory Alpha2", ATTR_STRING },
 	{ NL80211_ATTR_REG_RULES,
-			"Regulatory Rules" },
+			"Regulatory Rules", ATTR_CUSTOM,
+				{ .function = print_reg_rules } },
 	{ NL80211_ATTR_MESH_CONFIG,
 			"Mesh Configuration" },
 	{ NL80211_ATTR_BSS_BASIC_RATES,
Signature · 1 line
2.34.1
author
#12 lore raw

PATCH 11/11 test-runner: start iwmon first

In reply to James Prestwood

This aids in debugging if iwd/hostapd/etc fail to start correctly.

---
 tools/test-runner | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
tools/test-runner +5 -5
index 64407a41..0b749238 100755
@@ -1327,6 +1327,11 @@ def pre_test(ctx, test, copied):
 
 		subtests = pruned
 
+	if ctx.args.log:
+		ctx.start_process(['iwmon', '--nowiphy'])
+	elif ctx.args.monitor:
+		ctx.start_process(['iwmon'], outfile=ctx.args.monitor)
+
 	ctx.start_dbus()
 	ctx.start_haveged()
 	ctx.start_dbus_monitor()
@@ -1336,11 +1341,6 @@ def pre_test(ctx, test, copied):
 	ctx.start_wpas_interfaces()
 	ctx.start_ofono()
 
-	if ctx.args.log:
-		ctx.start_process(['iwmon', '--nowiphy'])
-	elif ctx.args.monitor:
-		ctx.start_process(['iwmon', '--nowiphy'], outfile=ctx.args.monitor)
-
 	if ctx.hw_config.has_option('SETUP', 'start_iwd'):
 		start = ctx.hw_config.getboolean('SETUP', 'start_iwd')
 	else:
Signature · 1 line
2.34.1
#13 lore raw
In reply to James Prestwood

Hi James,

Quoted 5 lines · James Prestwood

Obtained from the IEEE 802.11ax amendment, Table E-4

---
  src/band.c | 63 +++++++++++++++++++++++++++++++++++++++++++++++-------
  1 file changed, 55 insertions(+), 8 deletions(-)

patches 1-6 and 8-11 applied, thanks.

Regards,
-Denis