wiphy: make wiphy_band_is_disabled return more descriptive
PATCH 1/3 wiphy: make wiphy_band_is_disabled return more descriptive
The function wiphy_band_is_disabled() return was a bit misleading because if the band was not supported it would return true which could be misunderstood as the band is supported, but disabled. There was only one call site and because of this behavior wiphy_band_is_disabled needed to be paired with checking if the band was supported.
To be more descriptive to the called, wiphy_band_is_disabled() now returns an int and if the band isn't supported -ENOTSUP will be returned, otherwise true/false.
--- src/station.c | 4 +--- src/wiphy.c | 4 ++-- src/wiphy.h | 2 +- 3 files changed, 4 insertions(+), 6 deletions(-)
src/station.c +1 -3
@@ -1450,9 +1450,7 @@ 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 (wiphy_get_supported_bands (station->wiphy) &BAND_FREQ_6_GHZ && -wiphy_band_is_disabled (station->wiphy, -BAND_FREQ_6_GHZ ) && +if (wiphy_band_is_disabled (station->wiphy,BAND_FREQ_6_GHZ ) == true &&wiphy_country_is_unknown (station->wiphy) && known_6ghz)return -ENOTSUP ;
src/wiphy.c +2 -2
@@ -570,7 +570,7 @@ const struct band_freq_attrs *wiphy_get_frequency_info_list(return bandp->freq_attrs; } -bool wiphy_band_is_disabled (const struct wiphy *wiphy,enum band_freq band) +int wiphy_band_is_disabled (const struct wiphy *wiphy,enum band_freq band) {struct band_freq_attrs attr;unsigned int i;
@@ -578,7 +578,7 @@ bool wiphy_band_is_disabled(const struct wiphy *wiphy, enum band_freq band) bandp =wiphy_get_band (wiphy, band);if (!bandp) -return true; +return -ENOTSUP ;for (i =0 ; i < bandp->freqs_len; i++) { attr = bandp->freq_attrs[i];
src/wiphy.h +1 -1
@@ -111,7 +111,7 @@ const struct band_freq_attrs *wiphy_get_frequency_info_list(enum band_freq band, size_t *size); -bool wiphy_band_is_disabled (const struct wiphy *wiphy,enum band_freq band); +int 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);
Signature · 1 line
2.25.1
PATCH 2/3 scan: remove use of wiphy_get_allowed_freqs to optimize 6ghz path
wiphy_get_allowed_freqs was only being used to see if 6GHz was disabled or not. This is expensive and requires several allocations when there already exists wiphy_is_band_disabled(). The prior patch modified wiphy_is_band_disabled() to return -ENOTSUP which allows scan.c to completely remove the need for wiphy_get_allowed_freqs.
scan_wiphy_watch was also slightly re-ordered to avoid allocating freqs_6ghz if the scan request was being completed.
--- src/scan.c | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-)
src/scan.c +10 -13
@@ -574,10 +574,9 @@ static void scan_cmds_add(struct scan_request *sr, struct scan_context *sc,uint32_t bands =BAND_FREQ_2_4_GHZ |BAND_FREQ_5_GHZ |BAND_FREQ_6_GHZ ;unsigned int i;struct scan_freq_set *subsets[2 ] = {0 }; - _auto_(scan_freq_set_free) struct scan_freq_set *allowed = -wiphy_get_allowed_freqs (sc->wiphy, bands);const struct scan_freq_set *supported =wiphy_get_supported_freqs (sc->wiphy); +int disabled;/* * No frequencies, just include the entire supported list and let the
@@ -589,8 +588,8 @@ static void scan_cmds_add(struct scan_request *sr, struct scan_context *sc, sr->scan_freqs =scan_freq_set_clone (params->freqs, bands);/* If 6GHz is not possible or already allowed don't split the request */ -if (!(scan_freq_set_get_bands (supported) &BAND_FREQ_6_GHZ ) || - (scan_freq_set_get_bands (allowed) &BAND_FREQ_6_GHZ )) { + disabled =wiphy_band_is_disabled (sc->wiphy,BAND_FREQ_6_GHZ ); +if (disabled == -ENOTSUP || disabled == false) {scan_build_next_cmd (sr->cmds, sc, passive, params, sr->scan_freqs);return ;
@@ -1947,8 +1946,8 @@ static void scan_wiphy_watch(struct wiphy *wiphy,struct scan_request *sr =NULL ;struct l_genl_msg *msg =NULL ;struct scan_parameters params = {0 }; -struct scan_freq_set *allowed; _auto_(scan_freq_set_free) struct scan_freq_set *freqs_6ghz = NULL; +int disabled;/* Only care about completed regulatory dumps */ if (event !=WIPHY_STATE_WATCH_EVENT_REGDOM_DONE )
@@ -1962,18 +1961,19 @@ static void scan_wiphy_watch(struct wiphy *wiphy,if (!sr)return ; - allowed =wiphy_get_allowed_freqs (sc->wiphy,BAND_FREQ_6_GHZ ); - freqs_6ghz =scan_freq_set_clone (sr->scan_freqs,BAND_FREQ_6_GHZ ); -/* * This update did not allow 6GHz, or the original request was * not expecting 6GHz. The periodic scan should now be ended. */ -if (!allowed ||scan_freq_set_isempty (freqs_6ghz) || !sr->split) { + disabled =wiphy_band_is_disabled (wiphy,BAND_FREQ_6_GHZ ); +if (scan_freq_set_get_bands (sr->freqs_scanned) &BAND_FREQ_6_GHZ || + disabled == true || !sr->split) {scan_get_results (sc, sr, sr->freqs_scanned); - goto free_allowed; +return ; } + freqs_6ghz =scan_freq_set_clone (sr->scan_freqs,BAND_FREQ_6_GHZ ); +/* * At this point we know there is an ongoing periodic scan. * Create a new 6GHz passive scan request and append to the
@@ -1988,9 +1988,6 @@ static void scan_wiphy_watch(struct wiphy *wiphy,*/ if (l_queue_peek_head (sc->requests) == sr)start_next_scan_request (&sr->work); - -free_allowed: -scan_freq_set_free (allowed); }static struct scan_context *scan_context_new (uint64_t wdev_id)
Signature · 1 line
2.25.1
PATCH 3/3 wiphy: remove wiphy_get_allowed_freqs
In reply to James PrestwoodThis was recently added but with the modifications to wiphy_band_is_disabled() its no longer needed.
--- src/wiphy.c | 15 --------------- src/wiphy.h | 2 -- 2 files changed, 17 deletions(-)
src/wiphy.c +0 -15
@@ -500,21 +500,6 @@ const struct scan_freq_set *wiphy_get_supported_freqs(return wiphy->supported_freqs; } -struct scan_freq_set *wiphy_get_allowed_freqs (const struct wiphy *wiphy, -uint32_t band_mask) -{ -struct scan_freq_set *allowed =scan_freq_set_clone ( - wiphy->supported_freqs, - band_mask); - -if (!wiphy_constrain_freq_set (wiphy, allowed)) { -scan_freq_set_free (allowed); - allowed =NULL ; - } - -return allowed; -} -static struct band *wiphy_get_band (const struct wiphy *wiphy,enum band_freq band) {switch (band) {
src/wiphy.h +0 -2
@@ -100,8 +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); -struct scan_freq_set *wiphy_get_allowed_freqs (const struct wiphy *wiphy, -uint32_t band_mask); const struct band_freq_attrs *wiphy_get_frequency_info( const struct wiphy *wiphy,
Signature · 1 line
2.25.1
Hi James,
Quoted 10 lines · James Prestwood
The function
wiphy_band_is_disabled()return was a bit misleading because if the band was not supported it would return true which could be misunderstood as the band is supported, but disabled. There was only one call site and because of this behaviorwiphy_band_is_disabledneeded to be paired with checking if the band was supported.To be more descriptive to the called,
wiphy_band_is_disabled()now returns an int and if the band isn't supported-ENOTSUPwill be returned, otherwise true/false.
Returning true/false and -errno isn't a pattern we use. I changed this patch to return -errno on error, 1 if disabled, and 0 otherwise. Also fixed up patch 2 as a result. Please double check that I didn't screw anything up.
Quoted 6 lines
--- src/station.c | 4 +--- src/wiphy.c | 4 ++-- src/wiphy.h | 2 +- 3 files changed, 4 insertions(+), 6 deletions(-)
All applied, thanks.
Regards,
-Denis