From patchwork Tue Dec 13 20:36:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13072413 Received: from mail-pj1-f41.google.com (mail-pj1-f41.google.com [209.85.216.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 373D823A7 for ; Tue, 13 Dec 2022 20:36:31 +0000 (UTC) Received: by mail-pj1-f41.google.com with SMTP id js9so4643866pjb.2 for ; Tue, 13 Dec 2022 12:36:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=W1MBLcYioJ9cI9BSWf9OGFwTP7j5/zAAPm+IAYnB3xI=; b=kUauQvlpMLu35wR3uS55SbQErtjDqmVwi43eNzeuRykOpTutAriBe3djgqzv5i0p9b ocZi33iaJk7hq9wwvhKo3vLRnkvTYaEaZ5csK3U+xKpfvf8en7+qctDe4F8I6fBYkVKf w1dgLLoAre/1jf7YRlxXA8oJ5/qD9lx0ZfcEDwAbY+BISkuqWRhlh1xaDUsszwCGYfdr 0LfiAe0Ow1SnJ1qPQjvHJQzf902bn2bGqppa9XBXYsaoW11dTkdUgEfYI0/xYoSGA0Kc VO5XKF7HAogjuaJ6uZBg8GXii02hW5MqeFWGiPJ5zg5+cmhxV2jodP7Oxg7G893O8B70 rvng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=W1MBLcYioJ9cI9BSWf9OGFwTP7j5/zAAPm+IAYnB3xI=; b=tDzMBfxUDzn6TpAuWSepCN+MtvIS5boNjF8PcUqC6x9p2m7HKNeudauDKCTg44w+T9 2AY35YXlWlD9kQZIVeOAQzh3iQ0KyLfwlywAq0jEEooNDID16slGQwCzSV1iQ8JDEs0X dVZcXCE+LADeGkyjWfphAtCpeahF90VhIguHPusMsG1K4efECAoT+V57n8pzHrQPb0w/ VyFAKbtVwTL3gHtu16zhp+UIejLGFDKwiDKnoMFaMs558YyM+GK17wXeqPucdU83uv0p nTvMUnT3AyUq5pJn6UfZ/z8OmgN743sE/rjbug7sQISTSda1kjH80gR9G/S8fppYdIez 73tg== X-Gm-Message-State: ANoB5plyc6/vOexksO1TJ89ujxC1OO44DElvCxweP6rDPce7n/Wk8b8v jeswZ7hi2cjzOOrjbMjfqtG0g82X5cI= X-Google-Smtp-Source: AA0mqf6d8k+m66psoDyEmNRu+VGz9acRjiZjERkBcCMP6gOcejyT9yOuIfmbXLv8qTIISVNAakI0Yg== X-Received: by 2002:a17:902:6547:b0:189:5506:a7 with SMTP id d7-20020a170902654700b00189550600a7mr21789713pln.19.1670963790397; Tue, 13 Dec 2022 12:36:30 -0800 (PST) Received: from jprestwo-xps.none ([50.39.160.234]) by smtp.gmail.com with ESMTPSA id v23-20020a1709028d9700b00189f69c1aa0sm272113plo.270.2022.12.13.12.36.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Dec 2022 12:36:30 -0800 (PST) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH 1/7] band: introduce new method of tracking frequencies Date: Tue, 13 Dec 2022 12:36:18 -0800 Message-Id: <20221213203624.1423277-1-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.3 Precedence: bulk X-Mailing-List: iwd@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 uint16_t array where each index corresponds to a channel, and the value will contain various flags for that frequency. --- 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..82ffc13e 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->frequencies); + l_free(band); } diff --git a/src/band.h b/src/band.h index 9b307a77..06a8402a 100644 --- a/src/band.h +++ b/src/band.h @@ -55,8 +55,16 @@ struct band_he_capabilities { uint8_t he_mcs_set[12]; }; +enum band_freq_attribute { + BAND_FREQ_ATTR_SUPPORTED = 1 << 0, + BAND_FREQ_ATTR_DISABLED = 1 << 1, + BAND_FREQ_ATTR_NO_IR = 1 << 2, +}; + struct band { enum band_freq freq; + uint16_t *frequencies; + size_t freqs_len; /* Each entry is type struct band_he_capabilities */ struct l_queue *he_capabilities; uint8_t vht_mcs_set[8]; From patchwork Tue Dec 13 20:36:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13072414 Received: from mail-pl1-f175.google.com (mail-pl1-f175.google.com [209.85.214.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DEA9C79EB for ; Tue, 13 Dec 2022 20:36:31 +0000 (UTC) Received: by mail-pl1-f175.google.com with SMTP id s7so1086620plk.5 for ; Tue, 13 Dec 2022 12:36:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=IheFy7kkqr82G29RncS4ibHyCnlRV3IDMlH09rsqM0g=; b=AzXYj6ugyzET8ayneTrA4uT8TCaE6Lw84A4D6PX+m/pbQyXRBI6m/C7pVQZ9yCe363 KmpsUfO8bvGMmnTBkticGXBRTetjVl4QNF9FyAPR6mHCDPSQOOkwJB5FHm3ZuW/zj8Ju /N0vgVfsziw22ziTYy3XgBGYNXPWCd8/KV8VDyqMDuPZmzA0Teco+jMpIlB0/EPxqw3e F/H6sixL7BGMN0rk0bOCOnIOD0I6iL2qFnL+6vaqBAAxQ9pjE/cpK3FdzlEqtBE5h573 C6SVENXL2KFeu4zVXzvlcdf/vUw3tRwlb6jkCeWZS1tnNk7vkYRjLTP0M5q1E7bRTbQc 3Cuw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=IheFy7kkqr82G29RncS4ibHyCnlRV3IDMlH09rsqM0g=; b=3zNT+3p8M2qGgBDic0JEUcNiXr+mfiMNaDb5fyE6Zv4hx96M1mcKylaotxOE50nsuE 1Zg8Ujw/jU+dPSfwSt0/pBcqPi55z65+CGfi8/uakv9amlmmeNWJg6B06/A13NYY6JVC xU4Ih6kog3dLhAeVFQHqlry7Isw1nYiOH4Xc3XF4zIB3+MauL2CaaF+NzMtQjO2/kli0 dPmdGR5+8xeb8aTz08Q9rB37hTjECAWO/1B9Hx4M2QvN2nISpmx6Atxm/jnUTajmv64g 2iQtSFOip123KajibJXspfjWQus59MeiMF9Y270DnGvkLas8OzBgcdK4b7hdCYAiSFFY io1A== X-Gm-Message-State: ANoB5pnSvYD2Ly8OoXOfKyoOZF0upXsTVgK8wJjPUbEZ/WJl27f8g3b9 7l301v3OGZbjNqRcR7p9XuUgL97bsLc= X-Google-Smtp-Source: AA0mqf4dzlajD6vHgt+tbkPRO2y2RQR6wD1ZthZtUMlGsCjMEe7IizU8e6jnDtSalDBqf+vD62nTmA== X-Received: by 2002:a17:902:930a:b0:188:da5c:152b with SMTP id bc10-20020a170902930a00b00188da5c152bmr21407273plb.9.1670963791196; Tue, 13 Dec 2022 12:36:31 -0800 (PST) Received: from jprestwo-xps.none ([50.39.160.234]) by smtp.gmail.com with ESMTPSA id v23-20020a1709028d9700b00189f69c1aa0sm272113plo.270.2022.12.13.12.36.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Dec 2022 12:36:30 -0800 (PST) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH 2/7] util: add scan_freq_set_remove Date: Tue, 13 Dec 2022 12:36:19 -0800 Message-Id: <20221213203624.1423277-2-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.3 In-Reply-To: <20221213203624.1423277-1-prestwoj@gmail.com> References: <20221213203624.1423277-1-prestwoj@gmail.com> Precedence: bulk X-Mailing-List: iwd@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Removes one frequency from a scan_freq_set object. --- src/util.c | 22 ++++++++++++++++++++++ src/util.h | 1 + 2 files changed, 23 insertions(+) diff --git a/src/util.c b/src/util.c index d564ebc0..69019dc8 100644 --- a/src/util.c +++ b/src/util.c @@ -360,6 +360,28 @@ bool scan_freq_set_add(struct scan_freq_set *freqs, uint32_t freq) return false; } +bool scan_freq_set_remove(struct scan_freq_set *freqs, uint32_t freq) +{ + enum band_freq band; + uint8_t channel; + + channel = band_freq_to_channel(freq, &band); + if (!channel) + return false; + + switch (band) { + case BAND_FREQ_2_4_GHZ: + freqs->channels_2ghz &= ~(1 << (channel - 1)); + return true; + case BAND_FREQ_5_GHZ: + return l_uintset_take(freqs->channels_5ghz, channel); + case BAND_FREQ_6_GHZ: + return l_uintset_take(freqs->channels_6ghz, channel); + } + + return false; +} + bool scan_freq_set_contains(const struct scan_freq_set *freqs, uint32_t freq) { enum band_freq band; diff --git a/src/util.h b/src/util.h index cc45059f..dafa446d 100644 --- a/src/util.h +++ b/src/util.h @@ -111,6 +111,7 @@ typedef void (*scan_freq_set_func_t)(uint32_t freq, void *userdata); struct scan_freq_set *scan_freq_set_new(void); void scan_freq_set_free(struct scan_freq_set *freqs); bool scan_freq_set_add(struct scan_freq_set *freqs, uint32_t freq); +bool scan_freq_set_remove(struct scan_freq_set *freqs, uint32_t freq); bool scan_freq_set_contains(const struct scan_freq_set *freqs, uint32_t freq); uint32_t scan_freq_set_get_bands(const struct scan_freq_set *freqs); void scan_freq_set_foreach(const struct scan_freq_set *freqs, From patchwork Tue Dec 13 20:36:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13072415 Received: from mail-pj1-f45.google.com (mail-pj1-f45.google.com [209.85.216.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EB4AB23A7 for ; Tue, 13 Dec 2022 20:36:32 +0000 (UTC) Received: by mail-pj1-f45.google.com with SMTP id fy4so4683993pjb.0 for ; Tue, 13 Dec 2022 12:36:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=NFLHIlYMqpETMIkWpY5nQdiElLfdcu0YuZVEnntzEfM=; b=bk4ApI+uVadCbP2Sws3OirWjW0WR1GWRrOdyzetFhtGpAS+rYEggIdkfnCeI/pWM4O 7t1gjyeiUK4OUnl7wukZCNWwTtvQNDuNWRYldgmCtXjREgBvvG1VBLjOdqSmfQx1c0gt wpwQDtusrVYFYghg10BySsjA1FjfhdpcRGkVOVnutr+Fsd967hMo5V6tUSjH13AxjVRp f6K7abpSHe4/33vsY0I5FpuqCCiZOWWTbAlIXD7WGOMGG+Z/qIQ92I2zI9ZtzjmsY9mJ Egb/yhLcKMlmMDok4850x+ss5mjSTLcoQGr+AuPfOzkNsS4PZjJHAA+J8nglhxlg0whw zPnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=NFLHIlYMqpETMIkWpY5nQdiElLfdcu0YuZVEnntzEfM=; b=yMV4Qn1zXIeW0wiONiqxZ1TyfkEAbxvw8IMTp/0iWHWSWK4Y4KRsUIsMXIdBtmRMa5 B+6plkit0mjycFpoe3U5IETFpWWTgyeD3P/6pS1z0VlqVOYCHUXtM/B3caBQ7RJR/8GH AMWXBkOC/uPBeqqksxl5wvn8i4shfFMIPSUwqnxDUX+NIyAYNsxitwVIG4eqVXlAMoW3 Eqj8ubjtLC9u9RTqcqdTWJ85dJauKu3BavOQNUGftCS4T3ythD+v4S2ZcS0LtbUPx0cj poS+U92z8XxUC8FBdi77BYlzMkoONlrqNJddp4KdQpu/7J/qYR2LcGLBADL44I88oVNf 5fgw== X-Gm-Message-State: ANoB5pmAnz7pwDuxMxaSAVjbSzvW+4reGkVfVExVu6g/mrSfMTCTjHBa gn0GZ38lEjVaW5Oxj8bln1DYTjoHR7U= X-Google-Smtp-Source: AA0mqf6OAUDmtHN9zu4mMlMKsY0o9qHEsFzc+GE2zas9/3qEi8/9zD0z8a6HKuDo3YvxZ5937QouUQ== X-Received: by 2002:a17:902:9044:b0:186:daeb:bc0a with SMTP id w4-20020a170902904400b00186daebbc0amr20346880plz.67.1670963792161; Tue, 13 Dec 2022 12:36:32 -0800 (PST) Received: from jprestwo-xps.none ([50.39.160.234]) by smtp.gmail.com with ESMTPSA id v23-20020a1709028d9700b00189f69c1aa0sm272113plo.270.2022.12.13.12.36.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Dec 2022 12:36:31 -0800 (PST) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH 3/7] wiphy: parse/store frequency info in band object Date: Tue, 13 Dec 2022 12:36:20 -0800 Message-Id: <20221213203624.1423277-3-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.3 In-Reply-To: <20221213203624.1423277-1-prestwoj@gmail.com> References: <20221213203624.1423277-1-prestwoj@gmail.com> Precedence: bulk X-Mailing-List: iwd@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 uint16_t array 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 | 19 +++++---- src/nl80211util.h | 3 +- src/wiphy.c | 105 ++++++++++++++++++++++++++++++++++++++++++---- 3 files changed, 109 insertions(+), 18 deletions(-) diff --git a/src/nl80211util.c b/src/nl80211util.c index da36d936..a2cd882d 100644 --- a/src/nl80211util.c +++ b/src/nl80211util.c @@ -501,20 +501,20 @@ 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) + uint16_t *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; + uint16_t flags = BAND_FREQ_ATTR_SUPPORTED; if (!l_genl_attr_recurse(&nested, &attr)) continue; @@ -525,7 +525,10 @@ int nl80211_parse_supported_frequencies(struct l_genl_attr *band_freqs, freq = *((uint32_t *) data); break; case NL80211_FREQUENCY_ATTR_DISABLED: - disabled = true; + flags |= BAND_FREQ_ATTR_DISABLED; + break; + case NL80211_FREQUENCY_ATTR_NO_IR: + flags |= BAND_FREQ_ATTR_NO_IR; break; } } @@ -533,11 +536,11 @@ int nl80211_parse_supported_frequencies(struct l_genl_attr *band_freqs, if (!freq) continue; - if (supported_list) - scan_freq_set_add(supported_list, freq); + channel = band_freq_to_channel(freq, NULL); + if (!channel || channel > num_channels) + continue; - if (disabled && disabled_list) - scan_freq_set_add(disabled_list, freq); + list[channel] = flags; } return 0; diff --git a/src/nl80211util.h b/src/nl80211util.h index 44555a25..f12f4695 100644 --- a/src/nl80211util.h +++ b/src/nl80211util.h @@ -58,5 +58,4 @@ 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); + uint16_t *list, size_t num_channels); diff --git a/src/wiphy.c b/src/wiphy.c index 37e0cdb8..c8ef5937 100644 --- a/src/wiphy.c +++ b/src/wiphy.c @@ -745,8 +745,33 @@ 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->frequencies[i] & BAND_FREQ_ATTR_SUPPORTED)) + continue; + + freq = band_channel_to_freq(i, band->freq); + if (!freq) + continue; + + if (band->frequencies[i] & BAND_FREQ_ATTR_DISABLED) + scan_freq_set_remove(set, freq); + } + } if (!scan_freq_set_get_bands(set)) /* The set is empty. */ @@ -952,7 +977,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, @@ -1471,19 +1496,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 +1527,8 @@ static void parse_supported_bands(struct wiphy *wiphy, continue; band->freq = freq; + band->frequencies = l_new(uint16_t, num_channels); + band->freqs_len = num_channels; /* Reset iter to beginning */ if (!l_genl_attr_recurse(bands, &attr)) { @@ -1507,15 +1538,14 @@ 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; switch (type) { case NL80211_BAND_ATTR_FREQS: nl80211_parse_supported_frequencies(&attr, - wiphy->supported_freqs, - wiphy->disabled_freqs); + band->frequencies, + band->freqs_len); break; case NL80211_BAND_ATTR_RATES: @@ -1970,6 +2000,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 +2011,28 @@ 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)) { + /* 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: + 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; - nl80211_parse_supported_frequencies(&attr, NULL, - wiphy->pending_freqs); + /* + * 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, + band->frequencies, + band->freqs_len); } } } @@ -2178,6 +2236,36 @@ static void wiphy_get_reg_domain(struct wiphy *wiphy) } } +static void setup_supported_freqs(struct wiphy *wiphy) +{ + struct band *bands[3] = { wiphy->band_2g, + wiphy->band_5g, wiphy->band_6g }; + unsigned int b; + unsigned int i; + + wiphy->supported_freqs = scan_freq_set_new(); + + 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->frequencies[i] & BAND_FREQ_ATTR_SUPPORTED)) + continue; + + freq = band_channel_to_freq(i, band->freq); + if (!freq) + continue; + + scan_freq_set_add(wiphy->supported_freqs, freq); + } + } +} + void wiphy_create_complete(struct wiphy *wiphy) { wiphy_register(wiphy); @@ -2193,6 +2281,7 @@ void wiphy_create_complete(struct wiphy *wiphy) wiphy_set_station_capability_bits(wiphy); wiphy_setup_rm_enabled_capabilities(wiphy); wiphy_get_reg_domain(wiphy); + setup_supported_freqs(wiphy); wiphy_print_basic_info(wiphy); } From patchwork Tue Dec 13 20:36:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13072416 Received: from mail-pj1-f41.google.com (mail-pj1-f41.google.com [209.85.216.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C628A79EB for ; Tue, 13 Dec 2022 20:36:33 +0000 (UTC) Received: by mail-pj1-f41.google.com with SMTP id js9so4643985pjb.2 for ; Tue, 13 Dec 2022 12:36:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=VBAdwWe5NuYlVb+xBDRLsvk1NYaBjwtZ8dCwBoV0LTc=; b=e8TrbHuyNVtZk8NOiY8sUhSGhnOGtkq0YQLSP4AI/VCiC3GTBs9RelmsqRtZw6L494 N6Bo2T9t7QIOy7Mlpx69hEP93TC7JN6qx9/14CcLiescZKbtCZNmeiD5Luz1uA3dsiRA a+IQryZRoedLZVJAER1VuG4FPxEwDnh7weUAaUQomtWrei4/OTlX2oAsZXRFIWcSdCPc o1z54fNJl27yjgS1HWcibEQ7+hU8dPAjey4U5D9lLUdhxt5SUCE9Ig0aRXjPblwlzicW 6ljX3SrpoaDGXykqot5HwE62cXUWq4KmVOn0h2L8QLMTvdKi+aY7VNMDB8PI7vUIyoi9 D8MQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=VBAdwWe5NuYlVb+xBDRLsvk1NYaBjwtZ8dCwBoV0LTc=; b=C8NIh5qwGKf1XFKJIT1KHw/5Jtl5KB5N4BnwFznUPM+P98PHADqKtZEZuLZDsTpmkl 8lg2t6bcRG36IVu4sgULP5H/+9opAZETwdfIM6uLie5GhC0vCSaiPBEwHTw4Pk4HWCR0 q7rL84UGST0K96P6/DgdWQPR0U3q18Ky93QF9wyph8vRaHIqDOO78RKZFKANYvKvSwgA s/CRtpmNvY/dByVSbermOiuNCOv09zX40MDEK426bJvupL393rdxk+aRclTZ0FkWcA5J YY5EOJqlZahoSLGgjR6JZnEsByC6gyghvc43hGwmHdQ+rK96RHbL2Eujz9FnpmL33gbN 6KJA== X-Gm-Message-State: ANoB5pmR3foTuTIrMKJHkPKaJ6c0kKZMfjjrMzbF+jnS2k9H+XkGag9s edrA1ziCZsij5+cNL7kR7WQwLdsie5g= X-Google-Smtp-Source: AA0mqf6KVFbI2Xi36Mr6aoeUfSrmTgqOPI7eD54ounJjoWroj6AYhRmUbX7BK9GVb3GVfX0e8XO83w== X-Received: by 2002:a17:902:ee45:b0:189:894c:6b48 with SMTP id 5-20020a170902ee4500b00189894c6b48mr22744907plo.59.1670963793281; Tue, 13 Dec 2022 12:36:33 -0800 (PST) Received: from jprestwo-xps.none ([50.39.160.234]) by smtp.gmail.com with ESMTPSA id v23-20020a1709028d9700b00189f69c1aa0sm272113plo.270.2022.12.13.12.36.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Dec 2022 12:36:32 -0800 (PST) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH 4/7] wiphy: add wiphy_check_{frequency,band} Date: Tue, 13 Dec 2022 12:36:21 -0800 Message-Id: <20221213203624.1423277-4-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.3 In-Reply-To: <20221213203624.1423277-1-prestwoj@gmail.com> References: <20221213203624.1423277-1-prestwoj@gmail.com> Precedence: bulk X-Mailing-List: iwd@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Add two new APIs as a replacement for wiphy_get_disabled_freqs(). wiphy_check_frequency() serves as a way to check a single frequency for certain attributes, currently: supported, disabled, and no-IR. wiphy_check_band() similarly checks the entire band. This is mainly targeted at station which needs to check if a given band is disabled and is only meant to be used with the supported and disabled flags. --- src/wiphy.c | 89 +++++++++++++++++++++++++++++++++++++++++++++++++++++ src/wiphy.h | 4 +++ 2 files changed, 93 insertions(+) diff --git a/src/wiphy.c b/src/wiphy.c index c8ef5937..f5b7c05e 100644 --- a/src/wiphy.c +++ b/src/wiphy.c @@ -496,6 +496,95 @@ 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; + } +} + +bool wiphy_check_frequency(const struct wiphy *wiphy, uint32_t freq, + uint16_t flags) +{ + enum band_freq band; + struct band *bandp; + uint8_t channel; + uint16_t mask; + + channel = band_freq_to_channel(freq, &band); + if (!channel) + return false; + + bandp = wiphy_get_band(wiphy, band); + if (!bandp) + return false; + + if (L_WARN_ON(channel > bandp->freqs_len)) + return false; + + + mask = bandp->frequencies[channel]; + + if ((flags & mask) != flags) + return false; + + return true; +} + +bool wiphy_check_band(const struct wiphy *wiphy, enum band_freq band, + uint16_t flags) +{ + unsigned int i; + bool supported = false; + bool disabled = true; + bool ret = false; + struct band *bandp = wiphy_get_band(wiphy, band); + + /* + * Caller should either include the SUPPORTED flag, or verify support + * before calling otherwise this return could be misleading i.e. + * checking a band for only DISABLED that isn't supported would + * return false which could be interpreted that the band is enabled. + */ + if ((flags & BAND_FREQ_ATTR_SUPPORTED) && !bandp) + return false; + + if (L_WARN_ON(!bandp)) + return false; + + /* + * This should only be used with SUPPORTED/DISABLED flags. For supported + * only ONE frequency needs to be supported. And for DISABLED ALL + * frequencies must be disabled. + */ + for (i = 0; i < bandp->freqs_len; i++) { + uint16_t mask = bandp->frequencies[i]; + + if (!(mask & BAND_FREQ_ATTR_SUPPORTED)) + continue; + + supported = true; + + if (!(mask & BAND_FREQ_ATTR_DISABLED)) + disabled = false; + } + + if (supported && (flags & BAND_FREQ_ATTR_SUPPORTED)) + ret = true; + + if (disabled && (flags & BAND_FREQ_ATTR_DISABLED)) + ret &= true; + + return ret; +} + bool wiphy_supports_probe_resp_offload(struct wiphy *wiphy) { return wiphy->ap_probe_resp_offload; diff --git a/src/wiphy.h b/src/wiphy.h index 410105dd..469ccdc8 100644 --- a/src/wiphy.h +++ b/src/wiphy.h @@ -100,6 +100,10 @@ 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_check_frequency(const struct wiphy *wiphy, uint32_t freq, + uint16_t flags); +bool wiphy_check_band(const struct wiphy *wiphy, enum band_freq band, + uint16_t flags); bool wiphy_supports_probe_resp_offload(struct wiphy *wiphy); bool wiphy_can_transition_disable(struct wiphy *wiphy); bool wiphy_can_offload(struct wiphy *wiphy); From patchwork Tue Dec 13 20:36:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13072417 Received: from mail-pj1-f41.google.com (mail-pj1-f41.google.com [209.85.216.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AC77C23A7 for ; Tue, 13 Dec 2022 20:36:34 +0000 (UTC) Received: by mail-pj1-f41.google.com with SMTP id w4-20020a17090ac98400b002186f5d7a4cso4884763pjt.0 for ; Tue, 13 Dec 2022 12:36:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=+x8Pze7qqhT2t69iknSN63dntsXi7vMZnGb9bsmMiYk=; b=Vy+tCudZNAr4GXGw+6wkKunGcsurPhSsn9PXP3+eBSaTl4Xj1+HlaY/duAb1UbzKG9 pGFvAezJmraW6mLX3rwP5kvYavnpNUS2+ApmKoUpkm2uAKrrvisKoodCadUPTjRDFdzA Cf+0p86u/sEwth+3dPLeBHIrhxle+EcKKoekq+lCd3Yp9GC+4wqEfPZ+LDZLHPCViTmP oOZ5xaB69KKtruxZq2mmIIqzjtqGhkqKVpLJ+QzUXP4a2IA8lmOunEmtklpQT8Um0eI4 ik3aHqvNJey3hXuFL9vBnD+afKgbzmteqFuFtrkEPmWWwXnHQ2a0sdP6Xjp14daVwEGq tT+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+x8Pze7qqhT2t69iknSN63dntsXi7vMZnGb9bsmMiYk=; b=ONCRQ0UwUZSbPveT9DONH+evU4SmG455Lb/kmmJkkmLDemOY/y2bVLl4COkmT531Ap 8Q3JkcIC2+SmXthj/yIkW2cgpohu3osMtpD0QxjWdWhI/7RZW63P96ORdnrqzNGEPkdd G6WBHddDYkzDXzWUXZ+D+PRB+0qeEj0y7pnwqcp88TOQmXna+MZ0dcEgS6xOjKfODq6V 7qcdpw+Pw1yv1KwJ+JlD4AZtEgzjpOaeoojpW/b/h7KP3AefjVWrVdtQMzrrjG3PBcDa Bbmxc1ofsClOub98FizxG31mJD0CmuQ2vhGmr8qFd6P4YvH5ZH/NYKPXIZqGBHYypYMP XWfA== X-Gm-Message-State: ANoB5pnQoGhD87ER8tzuyZUONB65NGjr/yniV3bwc4LdGgXFih3cP6mP nm81mXz12PxfTEwdNEMZU0N+fanGm8k= X-Google-Smtp-Source: AA0mqf4+4siTZ1gWKoyFx1oOczYNhfH33z5vB2RIWvaROBStve0UmEQd4D7DjOQyqLqFOou2vDUk3w== X-Received: by 2002:a17:903:258c:b0:189:6a5a:7289 with SMTP id jb12-20020a170903258c00b001896a5a7289mr26403306plb.52.1670963793983; Tue, 13 Dec 2022 12:36:33 -0800 (PST) Received: from jprestwo-xps.none ([50.39.160.234]) by smtp.gmail.com with ESMTPSA id v23-20020a1709028d9700b00189f69c1aa0sm272113plo.270.2022.12.13.12.36.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Dec 2022 12:36:33 -0800 (PST) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH 5/7] station: use wiphy_check_{frequency,band} Date: Tue, 13 Dec 2022 12:36:22 -0800 Message-Id: <20221213203624.1423277-5-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.3 In-Reply-To: <20221213203624.1423277-1-prestwoj@gmail.com> References: <20221213203624.1423277-1-prestwoj@gmail.com> Precedence: bulk X-Mailing-List: iwd@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Remove uses of supported/disabled scan_freq_set's and replace with the equivalent calls to wiphy_check_frequency/band. --- src/station.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/src/station.c b/src/station.c index a467b4e9..95a6d830 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,10 @@ 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_check_band(station->wiphy, BAND_FREQ_6_GHZ, + BAND_FREQ_ATTR_SUPPORTED | BAND_FREQ_ATTR_DISABLED) && + wiphy_country_is_unknown(station->wiphy) && + known_6ghz) return -ENOTSUP; if (!wiphy_constrain_freq_set(station->wiphy, known_freq_set)) { @@ -1812,10 +1811,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(); @@ -1853,8 +1848,10 @@ 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)) + if (!wiphy_check_frequency(station->wiphy, freq, + BAND_FREQ_ATTR_SUPPORTED) || + wiphy_check_frequency(station->wiphy, freq, + BAND_FREQ_ATTR_DISABLED)) continue; if (!memcmp(info.addr, From patchwork Tue Dec 13 20:36:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13072418 Received: from mail-pl1-f176.google.com (mail-pl1-f176.google.com [209.85.214.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5484079F2 for ; Tue, 13 Dec 2022 20:36:35 +0000 (UTC) Received: by mail-pl1-f176.google.com with SMTP id jn7so1044734plb.13 for ; Tue, 13 Dec 2022 12:36:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=dTK4CnFF1tJOjUo4j3UDYWjurXfIsH8HMOlpTtb+EtQ=; b=dCemuh3KT+tcI2w4p44z87QoPVWa+mRCRtsOgODZGCbpXCa/StzA4SoNfxlAf5Ak1+ qe1Btq9bodz5cwC1gT3d8YqmwqllGG3w5ACArgmSWfVT91VWF485Uw9Ha/7WhwaXKO5b YV1dCNDnBkvk/uBlffkZNlviZhcpanPLu+Xu0i9yuuIV7yf7VXqbR26FvMWVs7V2dfe9 295vjl4h3oyarQ7sacC2tBw1kvVWuxTGCA3hzA5N5GO0TnJxF6OS78mql67Fqey4TOy+ bbJlJRGzT8BTxt2pQCcnB+9cXdb3lol1yisMYqcC6UEt5BCyBhNWvjRM3NP8MSjDd/Nn 69uA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=dTK4CnFF1tJOjUo4j3UDYWjurXfIsH8HMOlpTtb+EtQ=; b=c/j5KQU9aq1IBcoX1DGkZOiBuwpYQXMDyjg8+sX+Qh9b5zAU9VUcfG0GurHdwSc8L/ SMVrjjMYTpJ3HAVjEmpeqUM3ChJSIx/D417BkW4vS4K5hh+cibcY61/u7He36bp/Ezzd Yj0lz+M56hrWikrXjhEpLIPnAYlFKD/gYA+UzVDKHHZyInDIuO11hSf8JWkficBqnV4V SjC8MUPGRvRK90VxSiVMD05GnF+9Fqrz4YF9/EczfYUUIFYNJDF4LWPQ/Um8f9h1boyu /GuC5OIK63sfIFWAtlFIN6JmX2wwDt4i09n44D0Fr1OKOZC/fcUubnkkyI8+rbIXFdu6 /uJA== X-Gm-Message-State: ANoB5pl7e3XpRH4VeiNa5yWLgO3p19UsOSl+EEFn9crrCsHIRmAPEXjq J8xTRPEjtaVqZnrZnSiD2SO5mfvz/gc= X-Google-Smtp-Source: AA0mqf5oWkAQ5KKjQB/lXwDxtF1FjAVgZeQNqATkRx3jT6HdAixFB1oWBzzucOGNj2h8VE659jh26A== X-Received: by 2002:a17:902:ab92:b0:189:6076:ab95 with SMTP id f18-20020a170902ab9200b001896076ab95mr20585882plr.18.1670963794612; Tue, 13 Dec 2022 12:36:34 -0800 (PST) Received: from jprestwo-xps.none ([50.39.160.234]) by smtp.gmail.com with ESMTPSA id v23-20020a1709028d9700b00189f69c1aa0sm272113plo.270.2022.12.13.12.36.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Dec 2022 12:36:34 -0800 (PST) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH 6/7] ap: use wiphy_check_{frequency,band} Date: Tue, 13 Dec 2022 12:36:23 -0800 Message-Id: <20221213203624.1423277-6-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.3 In-Reply-To: <20221213203624.1423277-1-prestwoj@gmail.com> References: <20221213203624.1423277-1-prestwoj@gmail.com> Precedence: bulk X-Mailing-List: iwd@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Replace disabled/supported frequency list with the new wiphy_check_* equivalent APIs. --- src/ap.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/ap.c b/src/ap.c index 32d9e1c4..ed20d763 100644 --- a/src/ap.c +++ b/src/ap.c @@ -3174,8 +3174,6 @@ 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; if (!(wiphy_get_supported_bands(wiphy) & ap->band)) { @@ -3191,15 +3189,12 @@ 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)) { + if (!wiphy_check_frequency(wiphy, freq, BAND_FREQ_ATTR_SUPPORTED)) { l_error("AP hardware does not support frequency %u", freq); return false; } - if (scan_freq_set_contains(disabled, freq)) { + if (wiphy_check_frequency(wiphy, freq, BAND_FREQ_ATTR_DISABLED)) { l_error("AP hardware has frequency %u disabled", freq); return false; } From patchwork Tue Dec 13 20:36:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13072419 Received: from mail-pj1-f49.google.com (mail-pj1-f49.google.com [209.85.216.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DB86079EB for ; Tue, 13 Dec 2022 20:36:35 +0000 (UTC) Received: by mail-pj1-f49.google.com with SMTP id 3-20020a17090a098300b00219041dcbe9so4789020pjo.3 for ; Tue, 13 Dec 2022 12:36:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=KJXREFkvel0c4L4gtqez4v2nDnAVF4zkdtaZnt785yQ=; b=OM1XurCUfMo884TEtPUYK2RtjkvkEZmVlVhrg+bmatdxEIHUOX4iJNzcI+x2SF8AVO lVmO/wbpiuTnZduHHekspLD/r06a0gZDMaQ2F0I6+o31M+2KxwBNkStLYUWWHaPqUFGw G6fpOcBNF4frdoX5WxK1l8Kw0QdcgVf9Bbb6xjlf86jfynufZZ/B1miBg5vbgAbiCimC c/IR5FKcoqUpWbSdpH/sRS3QnxfZ+m+qlM9FeUApsSaNIxMT+3Gn1TDun99Vxa+k9xIc V5qgu0dyySnjAO+e24BkCpaNME6ign7lTK2C3BOI6N9nosHtCdgZmH2bv5a0S7/FgMch +pnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=KJXREFkvel0c4L4gtqez4v2nDnAVF4zkdtaZnt785yQ=; b=MaQzwoAAPOsucHq0uM7XYWcU1Ve/5I/7PxLWLSi3OhnyyLCqLM1VODv84xMkUHTuGy aMWwTE5xc325YWF1sNGHtkM35A1xEk2I+TkS0NqrjTgLEiNPNL5bKPLdVHG/ICk0HttH yW7h5ussm96vcJ7y7c/NogZY6/ntyfkNRluarsoa6mw4M1RYlBT0CTn1xj72S7Ws7kok Yw5oP9ZGVwa/wFdHjWHDR2GS0l9RPhAEouXZae9yy/Kh6ecPso6qUIietw/xKm3dktja LZIUSJLwbhBG7Bhk4IunoRHkLWIs6oZQ7/tZL4ZlMiNKJKPXhTLePUvMa7JFee3iWBHm Qslg== X-Gm-Message-State: ANoB5pkv6hgmW/nzk10KiXBIWzgg/yVxjSHeWY8lA65bDypaEN1WeJek CvflsMTelQPcLrKjVld07mLlYLRKtuQ= X-Google-Smtp-Source: AA0mqf7OCH7mu65azVkoh+cAchqyyld6EApR199bM1+NA2YNVUrRh1Yb8g9dSiGDuXWnFABm3dA6/g== X-Received: by 2002:a17:902:7fcc:b0:18f:15d2:308d with SMTP id t12-20020a1709027fcc00b0018f15d2308dmr12382262plb.42.1670963795195; Tue, 13 Dec 2022 12:36:35 -0800 (PST) Received: from jprestwo-xps.none ([50.39.160.234]) by smtp.gmail.com with ESMTPSA id v23-20020a1709028d9700b00189f69c1aa0sm272113plo.270.2022.12.13.12.36.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Dec 2022 12:36:34 -0800 (PST) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH 7/7] wiphy: remove disabled_freqs and related dump code Date: Tue, 13 Dec 2022 12:36:24 -0800 Message-Id: <20221213203624.1423277-7-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.3 In-Reply-To: <20221213203624.1423277-1-prestwoj@gmail.com> References: <20221213203624.1423277-1-prestwoj@gmail.com> Precedence: bulk X-Mailing-List: iwd@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 f5b7c05e..79dd2dff 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) { @@ -2051,9 +2042,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, @@ -2067,13 +2055,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); @@ -2143,33 +2127,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) { @@ -2214,7 +2183,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; @@ -2234,8 +2202,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 469ccdc8..09ddca65 100644 --- a/src/wiphy.h +++ b/src/wiphy.h @@ -99,7 +99,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); bool wiphy_check_frequency(const struct wiphy *wiphy, uint32_t freq, uint16_t flags); bool wiphy_check_band(const struct wiphy *wiphy, enum band_freq band,