From: James Prestwood <prestwoj@gmail.com>
To: iwd@lists.linux.dev
Cc: James Prestwood <prestwoj@gmail.com>
Subject: [PATCH 2/3] scan: remove use of wiphy_get_allowed_freqs to optimize 6ghz path
Date: Fri, 29 Sep 2023 09:19:58 -0700 [thread overview]
Message-ID: <20230929161959.3840935-2-prestwoj@gmail.com> (raw)
In-Reply-To: <20230929161959.3840935-1-prestwoj@gmail.com>
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(-)
diff --git a/src/scan.c b/src/scan.c
index 93047a6b..57fcae6f 100644
--- a/src/scan.c
+++ b/src/scan.c
@@ -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)
--
2.25.1
next prev parent reply other threads:[~2023-09-29 16:20 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-29 16:19 [PATCH 1/3] wiphy: make wiphy_band_is_disabled return more descriptive James Prestwood
2023-09-29 16:19 ` James Prestwood [this message]
2023-09-29 16:19 ` [PATCH 3/3] wiphy: remove wiphy_get_allowed_freqs James Prestwood
2023-09-30 2:59 ` [PATCH 1/3] wiphy: make wiphy_band_is_disabled return more descriptive Denis Kenzior
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230929161959.3840935-2-prestwoj@gmail.com \
--to=prestwoj@gmail.com \
--cc=iwd@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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 read-only IMAP folder(s) and NNTP newsgroup(s).