iwd.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 1/8] band: introduce new method of tracking frequencies
@ 2022-12-16 21:27 James Prestwood
  2022-12-16 21:27 ` [PATCH v3 2/8] wiphy: parse/store frequency info in band object James Prestwood
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: James Prestwood @ 2022-12-16 21:27 UTC (permalink / raw)
  To: iwd; +Cc: James Prestwood

Currently the wiphy object keeps track of supported and disabled
frequencies as two separate scan_freq_set's. This is very expensive
and limiting since we have to add more sets in order to track
additional frequency flags (no-IR, no-HT, no-HE etc).

Instead we can refactor how frequencies are stored. They will now
be part of the band object and stored as a list of flag structures
where each index corresponds to a channel
---
 src/band.c | 2 ++
 src/band.h | 8 ++++++++
 2 files changed, 10 insertions(+)

diff --git a/src/band.c b/src/band.c
index 01166b62..d89b2a90 100644
--- a/src/band.c
+++ b/src/band.c
@@ -36,6 +36,8 @@ void band_free(struct band *band)
 	if (band->he_capabilities)
 		l_queue_destroy(band->he_capabilities, l_free);
 
+	l_free(band->freq_attrs);
+
 	l_free(band);
 }
 
diff --git a/src/band.h b/src/band.h
index 9b307a77..da4c0ae5 100644
--- a/src/band.h
+++ b/src/band.h
@@ -55,8 +55,16 @@ struct band_he_capabilities {
 	uint8_t he_mcs_set[12];
 };
 
+struct band_freq_attrs {
+	bool supported : 1;
+	bool disabled : 1;
+	bool no_ir : 1;
+} __attribute__ ((packed));
+
 struct band {
 	enum band_freq freq;
+	struct band_freq_attrs *freq_attrs;
+	size_t freqs_len;
 	/* Each entry is type struct band_he_capabilities */
 	struct l_queue *he_capabilities;
 	uint8_t vht_mcs_set[8];
-- 
2.34.3


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v3 2/8] wiphy: parse/store frequency info in band object
  2022-12-16 21:27 [PATCH v3 1/8] band: introduce new method of tracking frequencies James Prestwood
@ 2022-12-16 21:27 ` James Prestwood
  2022-12-16 21:27 ` [PATCH v3 3/8] wiphy: remove pending_freqs from wiphy_regdom_is_updating James Prestwood
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: James Prestwood @ 2022-12-16 21:27 UTC (permalink / raw)
  To: iwd; +Cc: James Prestwood

As additional frequency info is needed it doesn't make sense to
store a full list of frequencies for every attribute (i.e.
supported, disabled, no-IR, etc).

This changes nl80211_parse_supported_frequencies to take a list
of frequency attributes where each index corresponds to a channel,
and each value can be filled with flag bits to signal any
limitations on that frequency.

wiphy.c then had to be updated to use this rather than the existing
scan_freq_set lists. This, as-is, will break anything using
wiphy_get_disabled_freqs().
---
 src/nl80211util.c | 22 +++++++++++----
 src/nl80211util.h |  6 +++--
 src/wiphy.c       | 68 +++++++++++++++++++++++++++++++++++++++++++----
 src/wiphy.h       |  2 ++
 4 files changed, 86 insertions(+), 12 deletions(-)

diff --git a/src/nl80211util.c b/src/nl80211util.c
index da36d936..712cdec3 100644
--- a/src/nl80211util.c
+++ b/src/nl80211util.c
@@ -502,19 +502,21 @@ int nl80211_parse_chandef(struct l_genl_msg *msg, struct band_chandef *out)
 
 int nl80211_parse_supported_frequencies(struct l_genl_attr *band_freqs,
 					struct scan_freq_set *supported_list,
-					struct scan_freq_set *disabled_list)
+					struct band_freq_attrs *list,
+					size_t num_channels)
 {
 	uint16_t type, len;
 	const void *data;
 	struct l_genl_attr attr;
 	struct l_genl_attr nested;
+	uint8_t channel;
 
 	if (!l_genl_attr_recurse(band_freqs, &nested))
 		return -EBADMSG;
 
 	while (l_genl_attr_next(&nested, NULL, NULL, NULL)) {
 		uint32_t freq = 0;
-		bool disabled = false;
+		struct band_freq_attrs freq_attr = { 0 };
 
 		if (!l_genl_attr_recurse(&nested, &attr))
 			continue;
@@ -523,9 +525,13 @@ int nl80211_parse_supported_frequencies(struct l_genl_attr *band_freqs,
 			switch (type) {
 			case NL80211_FREQUENCY_ATTR_FREQ:
 				freq = *((uint32_t *) data);
+				freq_attr.supported = true;
 				break;
 			case NL80211_FREQUENCY_ATTR_DISABLED:
-				disabled = true;
+				freq_attr.disabled = true;
+				break;
+			case NL80211_FREQUENCY_ATTR_NO_IR:
+				freq_attr.no_ir = true;
 				break;
 			}
 		}
@@ -533,11 +539,17 @@ int nl80211_parse_supported_frequencies(struct l_genl_attr *band_freqs,
 		if (!freq)
 			continue;
 
+		channel = band_freq_to_channel(freq, NULL);
+		if (!channel)
+			continue;
+
+		if (L_WARN_ON(channel > num_channels))
+			continue;
+
 		if (supported_list)
 			scan_freq_set_add(supported_list, freq);
 
-		if (disabled && disabled_list)
-			scan_freq_set_add(disabled_list, freq);
+		list[channel] = freq_attr;
 	}
 
 	return 0;
diff --git a/src/nl80211util.h b/src/nl80211util.h
index 44555a25..d26d286f 100644
--- a/src/nl80211util.h
+++ b/src/nl80211util.h
@@ -24,6 +24,7 @@
 
 struct band_chandef;
 struct scan_freq_set;
+struct band_freq_attrs;
 
 int nl80211_parse_attrs(struct l_genl_msg *msg, int tag, ...);
 
@@ -58,5 +59,6 @@ struct l_genl_msg *nl80211_build_cmd_frame(uint32_t ifindex,
 
 int nl80211_parse_chandef(struct l_genl_msg *msg, struct band_chandef *out);
 int nl80211_parse_supported_frequencies(struct l_genl_attr *band_freqs,
-					struct scan_freq_set *supported,
-					struct scan_freq_set *disabled);
+					struct scan_freq_set *supported_list,
+					struct band_freq_attrs *list,
+					size_t num_channels);
diff --git a/src/wiphy.c b/src/wiphy.c
index 37e0cdb8..6b8f00a1 100644
--- a/src/wiphy.c
+++ b/src/wiphy.c
@@ -745,8 +745,35 @@ void wiphy_generate_address_from_ssid(struct wiphy *wiphy, const char *ssid,
 bool wiphy_constrain_freq_set(const struct wiphy *wiphy,
 						struct scan_freq_set *set)
 {
+	struct band *bands[3] = { wiphy->band_2g,
+					wiphy->band_5g, wiphy->band_6g };
+	unsigned int b;
+	unsigned int i;
+
 	scan_freq_set_constrain(set, wiphy->supported_freqs);
-	scan_freq_set_subtract(set, wiphy->disabled_freqs);
+
+	for (b = 0; b < L_ARRAY_SIZE(bands); b++) {
+		struct band *band = bands[b];
+
+		if (!band)
+			continue;
+
+		for (i = 0; i < band->freqs_len; i++) {
+			uint32_t freq;
+
+			if (!band->freq_attrs[i].supported)
+				continue;
+
+			if (!band->freq_attrs[i].disabled)
+				continue;
+
+			freq = band_channel_to_freq(i, band->freq);
+			if (!freq)
+				continue;
+
+			scan_freq_set_remove(set, freq);
+		}
+	}
 
 	if (!scan_freq_set_get_bands(set))
 		/* The set is empty. */
@@ -1471,19 +1498,23 @@ static void parse_supported_bands(struct wiphy *wiphy,
 		struct band **bandp;
 		struct band *band;
 		enum band_freq freq;
+		size_t num_channels;
 
 		switch (type) {
 		case NL80211_BAND_2GHZ:
 			bandp = &wiphy->band_2g;
 			freq = BAND_FREQ_2_4_GHZ;
+			num_channels = 14;
 			break;
 		case NL80211_BAND_5GHZ:
 			bandp = &wiphy->band_5g;
 			freq = BAND_FREQ_5_GHZ;
+			num_channels = 196;
 			break;
 		case NL80211_BAND_6GHZ:
 			bandp = &wiphy->band_6g;
 			freq = BAND_FREQ_6_GHZ;
+			num_channels = 233;
 			break;
 		default:
 			continue;
@@ -1498,6 +1529,9 @@ static void parse_supported_bands(struct wiphy *wiphy,
 				continue;
 
 			band->freq = freq;
+			band->freq_attrs = l_new(struct band_freq_attrs,
+							num_channels);
+			band->freqs_len = num_channels;
 
 			/* Reset iter to beginning */
 			if (!l_genl_attr_recurse(bands, &attr)) {
@@ -1507,7 +1541,6 @@ static void parse_supported_bands(struct wiphy *wiphy,
 		} else
 			band = *bandp;
 
-
 		while (l_genl_attr_next(&attr, &type, &len, &data)) {
 			struct l_genl_attr nested;
 
@@ -1515,7 +1548,8 @@ static void parse_supported_bands(struct wiphy *wiphy,
 			case NL80211_BAND_ATTR_FREQS:
 				nl80211_parse_supported_frequencies(&attr,
 							wiphy->supported_freqs,
-							wiphy->disabled_freqs);
+							band->freq_attrs,
+							band->freqs_len);
 				break;
 
 			case NL80211_BAND_ATTR_RATES:
@@ -1970,6 +2004,7 @@ static void wiphy_dump_callback(struct l_genl_msg *msg,
 	struct l_genl_attr bands;
 	struct l_genl_attr attr;
 	uint16_t type;
+	struct band *band;
 
 	if (nl80211_parse_attrs(msg, NL80211_ATTR_WIPHY, &id,
 					NL80211_ATTR_WIPHY_BANDS, &bands,
@@ -1980,7 +2015,24 @@ static void wiphy_dump_callback(struct l_genl_msg *msg,
 	if (L_WARN_ON(!wiphy))
 		return;
 
-	while (l_genl_attr_next(&bands, NULL, NULL, NULL)) {
+	while (l_genl_attr_next(&bands, &type, NULL, NULL)) {
+		switch (type) {
+		case NL80211_BAND_2GHZ:
+			band = wiphy->band_2g;
+			break;
+		case NL80211_BAND_5GHZ:
+			band = wiphy->band_5g;
+			break;
+		case NL80211_BAND_6GHZ:
+			band = wiphy->band_6g;
+			break;
+		default:
+			continue;
+		}
+
+		if (L_WARN_ON(!band))
+			continue;
+
 		if (!l_genl_attr_recurse(&bands, &attr))
 			return;
 
@@ -1988,8 +2040,14 @@ static void wiphy_dump_callback(struct l_genl_msg *msg,
 			if (type != NL80211_BAND_ATTR_FREQS)
 				continue;
 
+			/*
+			 * Just write over the old list for each frequency. In
+			 * theory no new frequencies should be added so there
+			 * should never be any stale values.
+			 */
 			nl80211_parse_supported_frequencies(&attr, NULL,
-							wiphy->pending_freqs);
+							band->freq_attrs,
+							band->freqs_len);
 		}
 	}
 }
diff --git a/src/wiphy.h b/src/wiphy.h
index 410105dd..09dc4530 100644
--- a/src/wiphy.h
+++ b/src/wiphy.h
@@ -28,6 +28,7 @@ struct scan_bss;
 struct scan_freq_set;
 struct wiphy_radio_work_item;
 struct ie_rsn_info;
+struct band_freq_attrs;
 enum security;
 enum band_freq;
 
@@ -100,6 +101,7 @@ uint32_t wiphy_get_supported_bands(struct wiphy *wiphy);
 const struct scan_freq_set *wiphy_get_supported_freqs(
 						const struct wiphy *wiphy);
 const struct scan_freq_set *wiphy_get_disabled_freqs(const struct wiphy *wiphy);
+
 bool wiphy_supports_probe_resp_offload(struct wiphy *wiphy);
 bool wiphy_can_transition_disable(struct wiphy *wiphy);
 bool wiphy_can_offload(struct wiphy *wiphy);
-- 
2.34.3


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v3 3/8] wiphy: remove pending_freqs from wiphy_regdom_is_updating
  2022-12-16 21:27 [PATCH v3 1/8] band: introduce new method of tracking frequencies James Prestwood
  2022-12-16 21:27 ` [PATCH v3 2/8] wiphy: parse/store frequency info in band object James Prestwood
@ 2022-12-16 21:27 ` James Prestwood
  2022-12-16 21:27 ` [PATCH v3 4/8] wiphy: don't parse dumps from unregistered wiphy's James Prestwood
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: James Prestwood @ 2022-12-16 21:27 UTC (permalink / raw)
  To: iwd; +Cc: James Prestwood

We can determine this info based on the dump IDs.
---
 src/wiphy.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/wiphy.c b/src/wiphy.c
index 6b8f00a1..3777bd58 100644
--- a/src/wiphy.c
+++ b/src/wiphy.c
@@ -979,7 +979,7 @@ int wiphy_estimate_data_rate(struct wiphy *wiphy,
 
 bool wiphy_regdom_is_updating(struct wiphy *wiphy)
 {
-	return wiphy->pending_freqs != NULL;
+	return wiphy->dump_id || (!wiphy->self_managed && wiphy_dump_id);
 }
 
 uint32_t wiphy_state_watch_add(struct wiphy *wiphy,
-- 
2.34.3


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v3 4/8] wiphy: don't parse dumps from unregistered wiphy's
  2022-12-16 21:27 [PATCH v3 1/8] band: introduce new method of tracking frequencies James Prestwood
  2022-12-16 21:27 ` [PATCH v3 2/8] wiphy: parse/store frequency info in band object James Prestwood
  2022-12-16 21:27 ` [PATCH v3 3/8] wiphy: remove pending_freqs from wiphy_regdom_is_updating James Prestwood
@ 2022-12-16 21:27 ` James Prestwood
  2022-12-16 21:27 ` [PATCH v3 5/8] wiphy: add getter for frequency/band info James Prestwood
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: James Prestwood @ 2022-12-16 21:27 UTC (permalink / raw)
  To: iwd; +Cc: James Prestwood

There is no reason to parse these since IWD won't use them.
---
 src/wiphy.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/wiphy.c b/src/wiphy.c
index 3777bd58..f3a2a039 100644
--- a/src/wiphy.c
+++ b/src/wiphy.c
@@ -2015,6 +2015,10 @@ static void wiphy_dump_callback(struct l_genl_msg *msg,
 	if (L_WARN_ON(!wiphy))
 		return;
 
+	/* Unregistered means the wiphy is blacklisted, don't bother parsing */
+	if (!wiphy->registered)
+		return;
+
 	while (l_genl_attr_next(&bands, &type, NULL, NULL)) {
 		switch (type) {
 		case NL80211_BAND_2GHZ:
-- 
2.34.3


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v3 5/8] wiphy: add getter for frequency/band info
  2022-12-16 21:27 [PATCH v3 1/8] band: introduce new method of tracking frequencies James Prestwood
                   ` (2 preceding siblings ...)
  2022-12-16 21:27 ` [PATCH v3 4/8] wiphy: don't parse dumps from unregistered wiphy's James Prestwood
@ 2022-12-16 21:27 ` James Prestwood
  2022-12-16 21:27 ` [PATCH v3 6/8] station: use wiphy_get_frequency_info James Prestwood
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: James Prestwood @ 2022-12-16 21:27 UTC (permalink / raw)
  To: iwd; +Cc: James Prestwood

This adds two new APIs:

wiphy_get_frequency_info(): Used to get information about a given
frequency such as disabled/no-IR. This can also be used to check
if the frequency is supported (NULL return is unsupported).

wiphy_band_is_disabled(): Checks if a band is disabled. Note that
an unsupported band will also return true. Checking support should
be done with wiphy_get_supported_bands()
---
 src/wiphy.c | 91 +++++++++++++++++++++++++++++++++++++----------------
 src/wiphy.h |  5 +++
 2 files changed, 69 insertions(+), 27 deletions(-)

diff --git a/src/wiphy.c b/src/wiphy.c
index f3a2a039..714da9bc 100644
--- a/src/wiphy.c
+++ b/src/wiphy.c
@@ -496,6 +496,67 @@ const struct scan_freq_set *wiphy_get_disabled_freqs(const struct wiphy *wiphy)
 	return wiphy->disabled_freqs;
 }
 
+static struct band *wiphy_get_band(const struct wiphy *wiphy, enum band_freq band)
+{
+	switch (band) {
+	case BAND_FREQ_2_4_GHZ:
+		return wiphy->band_2g;
+	case BAND_FREQ_5_GHZ:
+		return wiphy->band_5g;
+	case BAND_FREQ_6_GHZ:
+		return wiphy->band_6g;
+	default:
+		return NULL;
+	}
+}
+
+const struct band_freq_attrs *wiphy_get_frequency_info(
+						const struct wiphy *wiphy,
+						uint32_t freq)
+{
+	struct band_freq_attrs *attr;
+	enum band_freq band;
+	uint8_t channel;
+	struct band *bandp;
+
+	channel = band_freq_to_channel(freq, &band);
+	if (!channel)
+		return NULL;
+
+	bandp = wiphy_get_band(wiphy, band);
+	if (!bandp)
+		return NULL;
+
+	attr = &bandp->freq_attrs[channel];
+	if (!attr->supported)
+		return NULL;
+
+	return attr;
+}
+
+bool wiphy_band_is_disabled(const struct wiphy *wiphy, enum band_freq band)
+{
+	struct band_freq_attrs attr;
+	unsigned int i;
+	struct band *bandp;
+
+	bandp = wiphy_get_band(wiphy, band);
+	if (!bandp)
+		return true;
+
+	for (i = 0; i < bandp->freqs_len; i++) {
+		attr = bandp->freq_attrs[i];
+
+		if (!attr.supported)
+			continue;
+
+		if (!attr.disabled)
+			return false;
+	}
+
+	return true;
+}
+
 bool wiphy_supports_probe_resp_offload(struct wiphy *wiphy)
 {
 	return wiphy->ap_probe_resp_offload;
@@ -819,21 +880,7 @@ const uint8_t *wiphy_get_supported_rates(struct wiphy *wiphy,
 						enum band_freq band,
 						unsigned int *out_num)
 {
-	struct band *bandp;
-
-	switch (band) {
-	case BAND_FREQ_2_4_GHZ:
-		bandp = wiphy->band_2g;
-		break;
-	case BAND_FREQ_5_GHZ:
-		bandp = wiphy->band_5g;
-		break;
-	case BAND_FREQ_6_GHZ:
-		bandp = wiphy->band_6g;
-		break;
-	default:
-		return NULL;
-	}
+	struct band *bandp = wiphy_get_band(wiphy, band);
 
 	if (!bandp)
 		return NULL;
@@ -891,19 +938,9 @@ int wiphy_estimate_data_rate(struct wiphy *wiphy,
 	if (band_freq_to_channel(bss->frequency, &band) == 0)
 		return -ENOTSUP;
 
-	switch (band) {
-	case BAND_FREQ_2_4_GHZ:
-		bandp = wiphy->band_2g;
-		break;
-	case BAND_FREQ_5_GHZ:
-		bandp = wiphy->band_5g;
-		break;
-	case BAND_FREQ_6_GHZ:
-		bandp = wiphy->band_6g;
-		break;
-	default:
+	bandp = wiphy_get_band(wiphy, band);
+	if (!bandp)
 		return -ENOTSUP;
-	}
 
 	ie_tlv_iter_init(&iter, ies, ies_len);
 
diff --git a/src/wiphy.h b/src/wiphy.h
index 09dc4530..c1919b4c 100644
--- a/src/wiphy.h
+++ b/src/wiphy.h
@@ -102,6 +102,11 @@ const struct scan_freq_set *wiphy_get_supported_freqs(
 						const struct wiphy *wiphy);
 const struct scan_freq_set *wiphy_get_disabled_freqs(const struct wiphy *wiphy);
 
+const struct band_freq_attrs *wiphy_get_frequency_info(
+						const struct wiphy *wiphy,
+						uint32_t freq);
+bool wiphy_band_is_disabled(const struct wiphy *wiphy, enum band_freq band);
+
 bool wiphy_supports_probe_resp_offload(struct wiphy *wiphy);
 bool wiphy_can_transition_disable(struct wiphy *wiphy);
 bool wiphy_can_offload(struct wiphy *wiphy);
-- 
2.34.3


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v3 6/8] station: use wiphy_get_frequency_info
  2022-12-16 21:27 [PATCH v3 1/8] band: introduce new method of tracking frequencies James Prestwood
                   ` (3 preceding siblings ...)
  2022-12-16 21:27 ` [PATCH v3 5/8] wiphy: add getter for frequency/band info James Prestwood
@ 2022-12-16 21:27 ` James Prestwood
  2022-12-16 21:27 ` [PATCH v3 7/8] ap: " James Prestwood
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: James Prestwood @ 2022-12-16 21:27 UTC (permalink / raw)
  To: iwd; +Cc: James Prestwood

Remove uses of supported/disabled scan_freq_set's and replace
with the equivalent calls to wiphy_get_frequency_info() and
wiphy_band_is_disabled().
---
 src/station.c | 19 ++++++++-----------
 1 file changed, 8 insertions(+), 11 deletions(-)

diff --git a/src/station.c b/src/station.c
index 9a646934..bad067c8 100644
--- a/src/station.c
+++ b/src/station.c
@@ -1407,8 +1407,6 @@ static int station_quick_scan_trigger(struct station *station)
 {
 	_auto_(scan_freq_set_free) struct scan_freq_set *known_freq_set = NULL;
 	bool known_6ghz;
-	const struct scan_freq_set *disabled = wiphy_get_disabled_freqs(
-								station->wiphy);
 
 	if (wiphy_regdom_is_updating(station->wiphy)) {
 		l_debug("regdom is updating, delaying quick scan");
@@ -1430,9 +1428,11 @@ static int station_quick_scan_trigger(struct station *station)
 	 * this since its so limited, so return an error which will fall back to
 	 * full autoconnect.
 	 */
-	if ((scan_freq_set_get_bands(disabled) & BAND_FREQ_6_GHZ) &&
-				wiphy_country_is_unknown(station->wiphy) &&
-				known_6ghz)
+	if (wiphy_get_supported_bands(station->wiphy) & BAND_FREQ_6_GHZ &&
+			wiphy_band_is_disabled(station->wiphy,
+						BAND_FREQ_6_GHZ) &&
+			wiphy_country_is_unknown(station->wiphy) &&
+			known_6ghz)
 		return -ENOTSUP;
 
 	if (!wiphy_constrain_freq_set(station->wiphy, known_freq_set)) {
@@ -1812,10 +1812,6 @@ static void parse_neighbor_report(struct station *station,
 	struct scan_freq_set *freq_set_md, *freq_set_no_md;
 	uint32_t current_freq = 0;
 	struct handshake_state *hs = netdev_get_handshake(station->netdev);
-	const struct scan_freq_set *supported =
-				wiphy_get_supported_freqs(station->wiphy);
-	const struct scan_freq_set *disabled =
-				wiphy_get_disabled_freqs(station->wiphy);
 
 	freq_set_md = scan_freq_set_new();
 	freq_set_no_md = scan_freq_set_new();
@@ -1828,6 +1824,7 @@ static void parse_neighbor_report(struct station *station,
 		uint32_t freq;
 		enum band_freq band;
 		const uint8_t *cc = NULL;
+		const struct band_freq_attrs *attr;
 
 		if (ie_tlv_iter_get_tag(&iter) != IE_TYPE_NEIGHBOR_REPORT)
 			continue;
@@ -1853,8 +1850,8 @@ static void parse_neighbor_report(struct station *station,
 			continue;
 
 		/* Skip if frequency is not supported or disabled */
-		if (!scan_freq_set_contains(supported, freq) ||
-				scan_freq_set_contains(disabled, freq))
+		attr = wiphy_get_frequency_info(station->wiphy, freq);
+		if (!attr || attr->disabled)
 			continue;
 
 		if (!memcmp(info.addr,
-- 
2.34.3


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v3 7/8] ap: use wiphy_get_frequency_info
  2022-12-16 21:27 [PATCH v3 1/8] band: introduce new method of tracking frequencies James Prestwood
                   ` (4 preceding siblings ...)
  2022-12-16 21:27 ` [PATCH v3 6/8] station: use wiphy_get_frequency_info James Prestwood
@ 2022-12-16 21:27 ` James Prestwood
  2022-12-16 21:27 ` [PATCH v3 8/8] wiphy: remove disabled_freqs and related dump code James Prestwood
  2022-12-16 22:37 ` [PATCH v3 1/8] band: introduce new method of tracking frequencies Denis Kenzior
  7 siblings, 0 replies; 9+ messages in thread
From: James Prestwood @ 2022-12-16 21:27 UTC (permalink / raw)
  To: iwd; +Cc: James Prestwood

Replace disabled/supported frequency list with the new
wiphy_get_frequency_info()
---
 src/ap.c | 17 ++++-------------
 1 file changed, 4 insertions(+), 13 deletions(-)

diff --git a/src/ap.c b/src/ap.c
index 32d9e1c4..a9027f79 100644
--- a/src/ap.c
+++ b/src/ap.c
@@ -3174,9 +3174,8 @@ static char **ap_ciphers_to_strv(uint16_t ciphers)
 static bool ap_validate_band_channel(struct ap_state *ap)
 {
 	struct wiphy *wiphy = netdev_get_wiphy(ap->netdev);
-	const struct scan_freq_set *supported;
-	const struct scan_freq_set *disabled;
 	uint32_t freq;
+	const struct band_freq_attrs *attr;
 
 	if (!(wiphy_get_supported_bands(wiphy) & ap->band)) {
 		l_error("AP hardware does not support band");
@@ -3191,19 +3190,11 @@ static bool ap_validate_band_channel(struct ap_state *ap)
 		return false;
 	}
 
-	supported = wiphy_get_supported_freqs(wiphy);
-	disabled = wiphy_get_disabled_freqs(wiphy);
-
-	if (!scan_freq_set_contains(supported, freq)) {
-		l_error("AP hardware does not support frequency %u", freq);
+	attr = wiphy_get_frequency_info(wiphy, freq);
+	if (!attr || attr->disabled) {
+		l_error("AP frequency %u disabled or unsupported", freq);
 		return false;
 	}
-
-	if (scan_freq_set_contains(disabled, freq)) {
-		l_error("AP hardware has frequency %u disabled", freq);
-		return false;
-	}
-
 	return true;
 }
 
-- 
2.34.3


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v3 8/8] wiphy: remove disabled_freqs and related dump code
  2022-12-16 21:27 [PATCH v3 1/8] band: introduce new method of tracking frequencies James Prestwood
                   ` (5 preceding siblings ...)
  2022-12-16 21:27 ` [PATCH v3 7/8] ap: " James Prestwood
@ 2022-12-16 21:27 ` James Prestwood
  2022-12-16 22:37 ` [PATCH v3 1/8] band: introduce new method of tracking frequencies Denis Kenzior
  7 siblings, 0 replies; 9+ messages in thread
From: James Prestwood @ 2022-12-16 21:27 UTC (permalink / raw)
  To: iwd; +Cc: James Prestwood

The disabled_freqs list is being removed and replaced with a new
list in the band object. This completely removes the need for
the pending_freqs list as well since any regdom related dumps
can just overwrite the existing frequency list.
---
 src/wiphy.c | 38 ++------------------------------------
 src/wiphy.h |  1 -
 2 files changed, 2 insertions(+), 37 deletions(-)

diff --git a/src/wiphy.c b/src/wiphy.c
index 714da9bc..4ea7c3f8 100644
--- a/src/wiphy.c
+++ b/src/wiphy.c
@@ -105,8 +105,6 @@ struct wiphy {
 	uint16_t supported_iftypes;
 	uint16_t supported_ciphers;
 	struct scan_freq_set *supported_freqs;
-	struct scan_freq_set *disabled_freqs;
-	struct scan_freq_set *pending_freqs;
 	struct band *band_2g;
 	struct band *band_5g;
 	struct band *band_6g;
@@ -345,7 +343,6 @@ static struct wiphy *wiphy_new(uint32_t id)
 
 	wiphy->id = id;
 	wiphy->supported_freqs = scan_freq_set_new();
-	wiphy->disabled_freqs = scan_freq_set_new();
 	watchlist_init(&wiphy->state_watches, NULL);
 	wiphy->extended_capabilities[0] = IE_TYPE_EXTENDED_CAPABILITIES;
 	wiphy->extended_capabilities[1] = EXT_CAP_LEN;
@@ -393,7 +390,6 @@ static void wiphy_free(void *data)
 	}
 
 	scan_freq_set_free(wiphy->supported_freqs);
-	scan_freq_set_free(wiphy->disabled_freqs);
 	watchlist_destroy(&wiphy->state_watches);
 	l_free(wiphy->model_str);
 	l_free(wiphy->vendor_str);
@@ -491,11 +487,6 @@ const struct scan_freq_set *wiphy_get_supported_freqs(
 	return wiphy->supported_freqs;
 }
 
-const struct scan_freq_set *wiphy_get_disabled_freqs(const struct wiphy *wiphy)
-{
-	return wiphy->disabled_freqs;
-}
-
 static struct band *wiphy_get_band(const struct wiphy *wiphy, enum band_freq band)
 {
 	switch (band) {
@@ -2003,9 +1994,6 @@ static void wiphy_dump_done(void *user_data)
 
 	if (wiphy) {
 		wiphy->dump_id = 0;
-		scan_freq_set_free(wiphy->disabled_freqs);
-		wiphy->disabled_freqs = wiphy->pending_freqs;
-		wiphy->pending_freqs = NULL;
 
 		WATCHLIST_NOTIFY(&wiphy->state_watches,
 				wiphy_state_watch_func_t, wiphy,
@@ -2019,13 +2007,9 @@ static void wiphy_dump_done(void *user_data)
 	for (e = l_queue_get_entries(wiphy_list); e; e = e->next) {
 		wiphy = e->data;
 
-		if (!wiphy->pending_freqs || wiphy->self_managed)
+		if (wiphy->self_managed)
 			continue;
 
-		scan_freq_set_free(wiphy->disabled_freqs);
-		wiphy->disabled_freqs = wiphy->pending_freqs;
-		wiphy->pending_freqs = NULL;
-
 		WATCHLIST_NOTIFY(&wiphy->state_watches,
 				wiphy_state_watch_func_t, wiphy,
 				WIPHY_STATE_WATCH_EVENT_REGDOM_DONE);
@@ -2095,33 +2079,18 @@ static void wiphy_dump_callback(struct l_genl_msg *msg,
 
 static bool wiphy_cancel_last_dump(struct wiphy *wiphy)
 {
-	const struct l_queue_entry *e;
 	unsigned int id = 0;
 
 	/*
 	 * Zero command ID to signal that wiphy_dump_done doesn't need to do
-	 * anything. For a self-managed wiphy just free/NULL pending_freqs. For
-	 * a global dump each wiphy needs to be checked and dealt with.
+	 * anything.
 	 */
 	if (wiphy && wiphy->dump_id) {
 		id = wiphy->dump_id;
 		wiphy->dump_id = 0;
-
-		scan_freq_set_free(wiphy->pending_freqs);
-		wiphy->pending_freqs = NULL;
 	} else if (!wiphy && wiphy_dump_id) {
 		id = wiphy_dump_id;
 		wiphy_dump_id = 0;
-
-		for (e = l_queue_get_entries(wiphy_list); e; e = e->next) {
-			struct wiphy *w = e->data;
-
-			if (!w->pending_freqs || w->self_managed)
-				continue;
-
-			scan_freq_set_free(w->pending_freqs);
-			w->pending_freqs = NULL;
-		}
 	}
 
 	if (id) {
@@ -2166,7 +2135,6 @@ static void wiphy_dump_after_regdom(struct wiphy *wiphy)
 	/* Limited dump so just emit the event for this wiphy */
 	if (wiphy) {
 		wiphy->dump_id = id;
-		wiphy->pending_freqs = scan_freq_set_new();
 
 		if (no_start_event)
 			return;
@@ -2186,8 +2154,6 @@ static void wiphy_dump_after_regdom(struct wiphy *wiphy)
 		if (w->self_managed)
 			continue;
 
-		w->pending_freqs = scan_freq_set_new();
-
 		if (no_start_event)
 			continue;
 
diff --git a/src/wiphy.h b/src/wiphy.h
index c1919b4c..6616da61 100644
--- a/src/wiphy.h
+++ b/src/wiphy.h
@@ -100,7 +100,6 @@ const char *wiphy_get_path(struct wiphy *wiphy);
 uint32_t wiphy_get_supported_bands(struct wiphy *wiphy);
 const struct scan_freq_set *wiphy_get_supported_freqs(
 						const struct wiphy *wiphy);
-const struct scan_freq_set *wiphy_get_disabled_freqs(const struct wiphy *wiphy);
 
 const struct band_freq_attrs *wiphy_get_frequency_info(
 						const struct wiphy *wiphy,
-- 
2.34.3


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH v3 1/8] band: introduce new method of tracking frequencies
  2022-12-16 21:27 [PATCH v3 1/8] band: introduce new method of tracking frequencies James Prestwood
                   ` (6 preceding siblings ...)
  2022-12-16 21:27 ` [PATCH v3 8/8] wiphy: remove disabled_freqs and related dump code James Prestwood
@ 2022-12-16 22:37 ` Denis Kenzior
  7 siblings, 0 replies; 9+ messages in thread
From: Denis Kenzior @ 2022-12-16 22:37 UTC (permalink / raw)
  To: James Prestwood, iwd

Hi James,

On 12/16/22 15:27, James Prestwood wrote:
> Currently the wiphy object keeps track of supported and disabled
> frequencies as two separate scan_freq_set's. This is very expensive
> and limiting since we have to add more sets in order to track
> additional frequency flags (no-IR, no-HT, no-HE etc).
> 
> Instead we can refactor how frequencies are stored. They will now
> be part of the band object and stored as a list of flag structures
> where each index corresponds to a channel
> ---
>   src/band.c | 2 ++
>   src/band.h | 8 ++++++++
>   2 files changed, 10 insertions(+)

All applied, thanks.

Regards,
-Denis


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2022-12-16 22:38 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-16 21:27 [PATCH v3 1/8] band: introduce new method of tracking frequencies James Prestwood
2022-12-16 21:27 ` [PATCH v3 2/8] wiphy: parse/store frequency info in band object James Prestwood
2022-12-16 21:27 ` [PATCH v3 3/8] wiphy: remove pending_freqs from wiphy_regdom_is_updating James Prestwood
2022-12-16 21:27 ` [PATCH v3 4/8] wiphy: don't parse dumps from unregistered wiphy's James Prestwood
2022-12-16 21:27 ` [PATCH v3 5/8] wiphy: add getter for frequency/band info James Prestwood
2022-12-16 21:27 ` [PATCH v3 6/8] station: use wiphy_get_frequency_info James Prestwood
2022-12-16 21:27 ` [PATCH v3 7/8] ap: " James Prestwood
2022-12-16 21:27 ` [PATCH v3 8/8] wiphy: remove disabled_freqs and related dump code James Prestwood
2022-12-16 22:37 ` [PATCH v3 1/8] band: introduce new method of tracking frequencies Denis Kenzior

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).