From: Denis Kenzior <denkenz at gmail.com>
To: iwd at lists.01.org
Subject: Re: [PATCH 3/6] scan: add scan_freq_set_serialize
Date: Mon, 29 Nov 2021 17:37:28 -0600 [thread overview]
Message-ID: <f5b9b2d3-7582-dc09-36ca-d67dcf906309@gmail.com> (raw)
In-Reply-To: 20211129231300.108873-3-prestwoj@gmail.com
[-- Attachment #1: Type: text/plain, Size: 2405 bytes --]
Hi James,
On 11/29/21 5:12 PM, James Prestwood wrote:
> This serializes a scan_freq_set into a uint32_t array.
> ---
> src/scan.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
> src/scan.h | 3 +++
> 2 files changed, 48 insertions(+)
>
> diff --git a/src/scan.c b/src/scan.c
> index b602c8be..1c80dd65 100644
> --- a/src/scan.c
> +++ b/src/scan.c
> @@ -2370,6 +2370,51 @@ void scan_freq_set_constrain(struct scan_freq_set *set,
> set->channels_2ghz &= constraint->channels_2ghz;
> }
>
> +struct scan_freq_get_index_data {
> + unsigned int target;
> + unsigned int current;
> + uint32_t found;
> +};
Whats this for?
> +
> +static void count_foreach(uint32_t freq, void *user_data)
> +{
> + uint8_t *count = user_data;
> +
> + l_put_u8(*count + 1, count);
> +}
Hmm, I wonder if you can either calculate this directly or book-keep the count
in scan_freq_set itself. In theory the 2g freqs (if not zero) are just
__builtin_popcount(). For the uintset it is essentially the same.
> +
> +static void add_foreach(uint32_t freq, void *user_data)
> +{
> + uint32_t **list = user_data;
> +
> + **list = freq;
> +
> + *list = *list + 1;
> +}
> +
> +uint32_t *scan_freq_set_serialize(const struct scan_freq_set *set,
> + size_t *len_out)
> +{
> + uint8_t count = 0;
> + uint32_t *freqs;
> +
> + scan_freq_set_foreach(set, count_foreach, &count);
> +
> + if (!count)
> + return NULL;
> +
> + freqs = l_new(uint32_t, count);
> +
> + scan_freq_set_foreach(set, add_foreach, &freqs);
> +
> + /* Move pointer back to start of list */
> + freqs -= count;
> +
> + *len_out = count;
> +
> + return freqs;
> +}
> +
> bool scan_wdev_add(uint64_t wdev_id)
> {
> struct scan_context *sc;
> diff --git a/src/scan.h b/src/scan.h
> index 66e38410..e6eea1c5 100644
> --- a/src/scan.h
> +++ b/src/scan.h
> @@ -191,5 +191,8 @@ void scan_freq_set_constrain(struct scan_freq_set *set,
> const struct scan_freq_set *constraint);
> bool scan_freq_set_isempty(const struct scan_freq_set *set);
>
> +uint32_t *scan_freq_set_serialize(const struct scan_freq_set *set,
> + size_t *len_out);
> +
Can we call this scan_freq_set_to_fixed_array, similar to how l_dbus_message
names this.
> bool scan_wdev_add(uint64_t wdev_id);
> bool scan_wdev_remove(uint64_t wdev_id);
>
Regards,
-Denis
next reply other threads:[~2021-11-29 23:37 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-29 23:37 Denis Kenzior [this message]
-- strict thread matches above, loose matches on Subject: below --
2021-11-29 23:12 [PATCH 3/6] scan: add scan_freq_set_serialize James Prestwood
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=f5b9b2d3-7582-dc09-36ca-d67dcf906309@gmail.com \
--to=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