From patchwork Fri Dec 16 17:25:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13075239 Received: from mail-pj1-f52.google.com (mail-pj1-f52.google.com [209.85.216.52]) (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 2DF332119 for ; Fri, 16 Dec 2022 17:26:20 +0000 (UTC) Received: by mail-pj1-f52.google.com with SMTP id u15-20020a17090a3fcf00b002191825cf02so3043280pjm.2 for ; Fri, 16 Dec 2022 09:26:20 -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=z8mQvfW4UcUupWINqwg26ZM0G6ITKW3l9EMP7M/v7XQ=; b=O9jXDzhn08fQuvw5vNmhSp9w/gHiGlaGgSyZAxMYSlG5UqWtIG9EU4sS6XtSub1Yu6 T12DmQAuWd51BuoSyAtkWKnZF/VU0dag/zYIXW23ZDr9DR/+kwin8TXILvPXF5xyVvd2 44B2dd1s1/tcKyKbPlOqfPobOufY4IeMIXiE7VLbKKPPkFpDm4dhkEZiUraCzPCRgWIW HafBI/Z62PlLsUVIfz/27+fpUQM4ETjund84i6/ZNgZN2FE4aff0aL7MHRnSu0wuxjNL ++bfG1vyM09pK6iF8xcNR3ny8luUmLXyLxGyJyxVJ3jwGkar8D5ZlIOchaJMTjCvGxr0 8c1w== 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=z8mQvfW4UcUupWINqwg26ZM0G6ITKW3l9EMP7M/v7XQ=; b=Xbo7YXT4fHgPr+JHyH7VHG/YQeth9n5ipdwhHkjAzM+kyq+mu3oCSAis7LM54/SB95 jDSsrvOErptU2OlJ1A6uCy0PCQuGU5IlOBBTG0YUVTuARt4cJb7bFfPSVXn33wVQ2pt1 o0Gp9beu+Ef3n/8XBN5pbNPmjlOCPNO74TC+IJiX1k8/QZmRheKmkTTOuW4MoOTF1smn TTIlRJUzRJqlkJdxCltJ9dCBb1AgovVqZa6Sz3QxW5oY2acmC0jo+FjYvem5QehH1cHn UxxyHypgSH2jnqAXt2xbROHkB4AqCP8LChiJ8ghqJ+CwagvxFXcPTKS55Mk4dgkIyfQb s8NQ== X-Gm-Message-State: ANoB5pknbQARncoD3dBQrxmzSC1+wd4TuSs3BltNavQrxKIQ+dDOH7dO xdKUzIYj+6AtbtoRILs90fQtBYsVe8I= X-Google-Smtp-Source: AA0mqf4VzQgbsGjpFcMfhXPuABx6n1qsXZqGI9EUqHfr2hnMqrSaBGAgmqkSnw+7RqdhaxBGHpkVQw== X-Received: by 2002:a17:902:74c5:b0:187:dc9:ef64 with SMTP id f5-20020a17090274c500b001870dc9ef64mr35485481plt.60.1671211579316; Fri, 16 Dec 2022 09:26:19 -0800 (PST) Received: from jprestwo-xps.none ([50.39.160.234]) by smtp.gmail.com with ESMTPSA id j5-20020a170902da8500b00188fdae6e0esm1913636plx.44.2022.12.16.09.26.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Dec 2022 09:26:18 -0800 (PST) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH v2 1/8] band: introduce new method of tracking frequencies Date: Fri, 16 Dec 2022 09:25:59 -0800 Message-Id: <20221216172606.1799396-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 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]; From patchwork Fri Dec 16 17:26:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13075240 Received: from mail-pl1-f171.google.com (mail-pl1-f171.google.com [209.85.214.171]) (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 1AFE723B8 for ; Fri, 16 Dec 2022 17:26:20 +0000 (UTC) Received: by mail-pl1-f171.google.com with SMTP id d15so2972385pls.6 for ; Fri, 16 Dec 2022 09:26:20 -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=7jQMzcO0uR64xROqAzCyXdPXu0ZvqOvLqo/eTOcf2oo=; b=BsMM8U1T0m8wfJGVm2k9zyGq/yA0FKNVspKHOEpI+GCVUl7Laya5IC/FqAlbGEJogb B7qjicCfYu6K19aleKKrjIPUp8HKNtqPXmubuTCGVwm1peF9s0pSOLeKklWV8bQYqsqL 9I12/F+vnrWcao2pyOOD9fxKBujtLUqdWm8gUpaHJVX4EP+Uh9ATLKGug6vj7jn3fRDQ c9NUjNb+G8AsOhsx9Qb/vUtAhP4cYRKeP6pWiXWaAp13bT05xtdlqfxxoYYlQP3/2lcJ pgJC2YpWJ1laivCmQyQQ8DIUkcgP/HODd1pABsmF+EoK6kUPP6hkcKp6myaqNrjBZhCN QRtg== 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=7jQMzcO0uR64xROqAzCyXdPXu0ZvqOvLqo/eTOcf2oo=; b=vScw005V39xTa1ZXH6P757+6RvZqTq4N6KFpw1zcE47E4g73/fbT4oYwGCy/JoZOlE R31UsLQa+sIkJ+nIxv8kJDhv9FUjpVC7oLdDXakSjpeZmSjsR2mKh2Db4YUmVtG+vwcq 45F6MJ/PC9AZwyxYhrXr1aBQVNMmYm5MgGpmbmslXZwVdCevT/ZdodTgMbsHFoOqctWv O0ojP5I3bZE3slrN9VPddRzNPlsQltmkjJgd4jDOk5v3YqeI1liOldlOe2ecVCCZ+jby kaHW+I7kNgVSCNSyYAIV73eu24+0JIPpJBr8tO6fylxqIzJi5yo/B/XOhqFyRl5fvfx7 /AuA== X-Gm-Message-State: ANoB5pniSjdzLuBlo0r1QR7qRLBp4mGxtUKtIm4Zdv+eTG+JOc8ATVRG qEVw0xp6LKtfqYrq2for2NCjrixswiE= X-Google-Smtp-Source: AA0mqf7efOg04LBHyVBQPv3hkotMqYPOnghLRhfzmFaIhEktgm21lCcEKE0OwocBI41HF44paT1+EA== X-Received: by 2002:a05:6a20:42a2:b0:a3:c099:3a7a with SMTP id o34-20020a056a2042a200b000a3c0993a7amr47576636pzj.22.1671211580273; Fri, 16 Dec 2022 09:26:20 -0800 (PST) Received: from jprestwo-xps.none ([50.39.160.234]) by smtp.gmail.com with ESMTPSA id j5-20020a170902da8500b00188fdae6e0esm1913636plx.44.2022.12.16.09.26.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Dec 2022 09:26:19 -0800 (PST) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH v2 2/8] wiphy: parse/store frequency info in band object Date: Fri, 16 Dec 2022 09:26:00 -0800 Message-Id: <20221216172606.1799396-2-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.3 In-Reply-To: <20221216172606.1799396-1-prestwoj@gmail.com> References: <20221216172606.1799396-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 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); From patchwork Fri Dec 16 17:26:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13075241 Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.180]) (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 EDE2D259D for ; Fri, 16 Dec 2022 17:26:21 +0000 (UTC) Received: by mail-pl1-f180.google.com with SMTP id n4so2999165plp.1 for ; Fri, 16 Dec 2022 09:26:21 -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=N+UuGXs7Kl6zzo4tjOaDH/TtKM7ac5Puc+p1Vnfy258=; b=Y3RBtprFEWamEoj2dOJ2kWPB5kFN6LSoe+OrJzUw2PKgpDx3VaGPnP5bbvCGMJ1SWJ r8q5XHseQjXY+F3bf2VkWwhvYXka9tkFCb2OjjQUb6nNCXFKV6ZLnEs2pxeOOHsQPixL Kp/dJ0+B9NYm1xCOhf1QcNAE9LxPcx+k8OLFKT+cn2jVGjXVeCK5WNU+wdnlVgyf4DCp n3HPYQwSo4tar9et7iKt/wb8DrMG8wwBAbydrpm08H+zQpJITNtPk/J6jVGluPfRQjUa 1C5T+68IAzW/5qIReipsx3aVN1x4fVUQkKpcBrxAMVxPmNuy7de3IKWLYzoYpniuZUVf 6NMA== 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=N+UuGXs7Kl6zzo4tjOaDH/TtKM7ac5Puc+p1Vnfy258=; b=o/9d5w4C4dAsTlI60sR8TtK4LLEZfshTBvkvzHoQc2IsuHj63IdTkUbSDrANUDhnq3 TkV1BzhiZE7auuqCZrHPQLdeFfnShEACFqRdkJlyDMtJ5JnHdXm3nLwlE3JpEXBnaWXR OcsK3dBUqzTxBqNUI5w70CqIieh3suE2Zw9WQkv6n+C3UdlrUngY4oBK9u/zLoJNjYxv rItMv9+WdaEWlpNri715ygQbVtcfGga/CSICO5rPJk66Bm83nigF5AhhEGx17TsJFMXv 22gI0d3ASB15656uz1Il7RkB1u+vXIBocnfuRg5/ufFJ2bTX2iL8nlBxeh/mfE0v1g/P Pk4w== X-Gm-Message-State: ANoB5plJX8//jA0DPy/FGldTux8l/eCTt4GsXvEM3IcvRjqrBefoZggI +Gel+btpc8CxZH4ycAr2xi9Gx1RHLXs= X-Google-Smtp-Source: AA0mqf5dW/xCi2MFQ3ZG19SphwA2nvsVr3ZNItbk4FOWxKAWweP52ZQnk+g80CZrMXDPK/U2w5FaWA== X-Received: by 2002:a05:6a21:3a44:b0:9d:efbe:2082 with SMTP id zu4-20020a056a213a4400b0009defbe2082mr46307916pzb.56.1671211581094; Fri, 16 Dec 2022 09:26:21 -0800 (PST) Received: from jprestwo-xps.none ([50.39.160.234]) by smtp.gmail.com with ESMTPSA id j5-20020a170902da8500b00188fdae6e0esm1913636plx.44.2022.12.16.09.26.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Dec 2022 09:26:20 -0800 (PST) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH v2 3/8] wiphy: remove pending_freqs from wiphy_regdom_is_updating Date: Fri, 16 Dec 2022 09:26:01 -0800 Message-Id: <20221216172606.1799396-3-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.3 In-Reply-To: <20221216172606.1799396-1-prestwoj@gmail.com> References: <20221216172606.1799396-1-prestwoj@gmail.com> Precedence: bulk X-Mailing-List: iwd@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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, From patchwork Fri Dec 16 17:26:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13075242 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 6493128F3 for ; Fri, 16 Dec 2022 17:26:22 +0000 (UTC) Received: by mail-pj1-f45.google.com with SMTP id w4-20020a17090ac98400b002186f5d7a4cso6815714pjt.0 for ; Fri, 16 Dec 2022 09:26:22 -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=xTDdI4aYLss09n2Vx+1DB4AKeW+kEyCe6GmYOQFENm4=; b=NEsF+ipdZsSTEj3U9XMlDBeCzzPjJZpyIhIPNfnqpTuQW/NQdSL2/QjKqG2w79nDPv wYnCVyXa0OyQ3hOAbTVCX76xoCChEnhwzkVnnTgnnD7zgTzm5GsgjUlGzPXkmng/O6m/ Ulo/yd6W5HqPds3KzTGRvL097EIJrIfhVA1osYorgc4ikFZcv1C4OhGOflcURII/goSO IeO1YinlNoEXoDdln4zt+LCmz5UNs0ytoI5n0IGiCskCDYE2fliDvidYaTcoRn2Qy3P3 0EN7CyV7gx4za/l42KuxY+Ui8u46JKxRJuzsoLvC61pkg6F7IlAGwumUTF8Fro003erq GGBQ== 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=xTDdI4aYLss09n2Vx+1DB4AKeW+kEyCe6GmYOQFENm4=; b=Fy9hA2x3MhIGQhq5sFvPOgdaPwwDL8dd8V8Xoqscf6AfvtdWDgA1eG+vgAH26N7M06 OqcIEDTyO3kgQpGIiU7mNacdDzgGsaj6oP7RTHypdNTGmVEM5Y9mWs9hWhV+TZEdampi FSXM2vNRE8GqPRrAEA9frumyTLTwZlQWJgsLgxE3oaFf0oC9P14OXBfzXV1suCuweOzB /XiHdeBGHkxcRb29DlQLfprNXY1J5caRN6Gq5H5Yp7SdHj2eA5jwW94MryHhicu8lCwW iV27Cw/AbY1hBKmwHk3V3FGF0lETLCOe32UsCEiNxcY9HykDrGEcCsuipoj11kDZDz2N 1yvA== X-Gm-Message-State: ANoB5pkfo5YMOYctJbuVSqQme9RvJ67xOstWYBXWJUbRv3m2WmkX4eTJ AhYlx0feDxP2YO8WSFTYXt1mu2ZRjds= X-Google-Smtp-Source: AA0mqf6Q3NQJbWuHOL2IitODN5lfYKbquFJxz1muMmvTa8UyWoWXiVSqEvX20/8TVSGBvPzhCOBZaA== X-Received: by 2002:a17:902:9b84:b0:189:38a1:8c04 with SMTP id y4-20020a1709029b8400b0018938a18c04mr32436597plp.50.1671211581666; Fri, 16 Dec 2022 09:26:21 -0800 (PST) Received: from jprestwo-xps.none ([50.39.160.234]) by smtp.gmail.com with ESMTPSA id j5-20020a170902da8500b00188fdae6e0esm1913636plx.44.2022.12.16.09.26.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Dec 2022 09:26:21 -0800 (PST) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH v2 4/8] wiphy: don't parse dumps from unregistered wiphy's Date: Fri, 16 Dec 2022 09:26:02 -0800 Message-Id: <20221216172606.1799396-4-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.3 In-Reply-To: <20221216172606.1799396-1-prestwoj@gmail.com> References: <20221216172606.1799396-1-prestwoj@gmail.com> Precedence: bulk X-Mailing-List: iwd@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: From patchwork Fri Dec 16 17:26:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13075243 Received: from mail-pj1-f52.google.com (mail-pj1-f52.google.com [209.85.216.52]) (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 59DD6259D for ; Fri, 16 Dec 2022 17:26:23 +0000 (UTC) Received: by mail-pj1-f52.google.com with SMTP id hd14-20020a17090b458e00b0021909875bccso8871623pjb.1 for ; Fri, 16 Dec 2022 09:26:23 -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=A/OFUxs3WFoYK/4fYOXedIy+x4+CIpQqbONqf+WaA2E=; b=gZaib1NBuKmKm0nkuTbrnZkIgzARfdOknvM85oU7x4nYfPsLVP0zE6pvt2z4a3qWml pWYva+3cl0FoaC5ubLAq/DlvVf+MB+cQaVSnDG+Et3kLLff/70O0YaLf58oVe9LytmJF C1ViVhoj/NDBOAPw43IDraipgkMWCzJUV/zGnG5FmpsdmyhGqk2V626gnvZ+aJdejkpm dEIND3C1Y5uelvkqsxuqDJ01PToy+pVwsXyUiP3FZZn+hC/+3at6D0ktf+whDjzkFC/+ 1/LahjHAcq9pM8Q9tebByd/536nBzJirgNNzIfN0ea/L5hrw5E3WcOUz3j9XVZT0txLy 8o8Q== 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=A/OFUxs3WFoYK/4fYOXedIy+x4+CIpQqbONqf+WaA2E=; b=04sjLc7KPk89cQDHY3/oBcrc1ivJBhz1BeRhgb9lQFK75bKKCpPM6GsGfaJR9+pjel dSnU1ckeOF1hhqEjj+lCjcIDLSotdH4b9z21kHNdByRMPWCqjrWZwya45ujk639P2gOd KAYyyKcxE/kHISbqcUqJe0KzDClfufg86yNiFM2MA/7cZGiQcEz/oeHdU0H9JZHAeC7E lto52cctwopZh2YTFRTmTR+H0qGbbYc9+/msSyD37o0OvMZCWd/+Vd8KtE8wTitnjtLy HiEDSibcM7/ClYsXOf3P4O8s0RyLE+Xwpf8PG0Yr3HvWkq/p4lg3SZTsJf+4GYPS/142 17Fg== X-Gm-Message-State: ANoB5pkhaj9zOKMIbsuZMy9oyyfdl6akxOxwD4XelUVG+oD02diMgsF8 kMQKq2H5gyBhFLrM9Crq9UbiGL8lJHk= X-Google-Smtp-Source: AA0mqf7422I76HKY+ffUiTVJEPgTOn7aL4GqZnLEaxAhuoQcFf/C7Vii0hpH+dPJhwsjo6z0I6T+qQ== X-Received: by 2002:a17:902:a416:b0:189:3fcc:f996 with SMTP id p22-20020a170902a41600b001893fccf996mr33108049plq.21.1671211582570; Fri, 16 Dec 2022 09:26:22 -0800 (PST) Received: from jprestwo-xps.none ([50.39.160.234]) by smtp.gmail.com with ESMTPSA id j5-20020a170902da8500b00188fdae6e0esm1913636plx.44.2022.12.16.09.26.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Dec 2022 09:26:21 -0800 (PST) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH v2 5/8] wiphy: add getter for frequency/band info Date: Fri, 16 Dec 2022 09:26:03 -0800 Message-Id: <20221216172606.1799396-5-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.3 In-Reply-To: <20221216172606.1799396-1-prestwoj@gmail.com> References: <20221216172606.1799396-1-prestwoj@gmail.com> Precedence: bulk X-Mailing-List: iwd@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 This adds two new APIs: wiphy_get_frequency_info(): Used to get additional information about a given frequency such as disabled/no-IR. This can also be used to check if the frequency is supported. 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 | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++++ src/wiphy.h | 4 ++++ 2 files changed, 67 insertions(+) diff --git a/src/wiphy.c b/src/wiphy.c index f3a2a039..7b72b6be 100644 --- a/src/wiphy.c +++ b/src/wiphy.c @@ -496,6 +496,69 @@ 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_get_frequency_info(const struct wiphy *wiphy, uint32_t freq, + struct band_freq_attrs *attr_out) +{ + 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 false; + + bandp = wiphy_get_band(wiphy, band); + if (!bandp) + return false; + + attr = bandp->freq_attrs[channel]; + if (!attr.supported) + return false; + + if (attr_out) + *attr_out = attr; + + return true; +} + +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 false; + + 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; diff --git a/src/wiphy.h b/src/wiphy.h index 09dc4530..8411318a 100644 --- a/src/wiphy.h +++ b/src/wiphy.h @@ -102,6 +102,10 @@ 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_get_frequency_info(const struct wiphy *wiphy, uint32_t freq, + struct band_freq_attrs *attr_out); +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); From patchwork Fri Dec 16 17:26:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13075244 Received: from mail-pj1-f51.google.com (mail-pj1-f51.google.com [209.85.216.51]) (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 0516629AC for ; Fri, 16 Dec 2022 17:26:23 +0000 (UTC) Received: by mail-pj1-f51.google.com with SMTP id fy4so3197225pjb.0 for ; Fri, 16 Dec 2022 09:26:23 -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=GuPBJi48/NXmWMwJ7cSQ2UAaxfRxFhYvrJvv52ilXIk=; b=TNdYI3aRRyT47KCvlZCJTOMeGaNmBKbxCDfqp+BemV3h0DfrheoNgOj3R3gqcffrXu n9HYKCQWOSXFEh3vxZd2oMBrJpxB+9WWKuuijRv3HoTzMy/lYG+8aZa0FyvpX1CNOdDA j7gmOdy1Z8CHXtfdZfAHPCsf8eVJJIj1moWkfIzGFzvr9IYmoaz/3Kv9N33Qs6PqQ+ME 9yR3p+4uXzW5RLOQETsQA0W2JYKAiQz/a+ttB+Ny6VbhJyCW109fFeCh/+zNGZXar/qE 8wr1enKiV7EoICzsGO8rNVWtLJeG6aKIqH6fMp/HdCF0QstsblWlqE5OJyULwzK5kM+K bf6g== 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=GuPBJi48/NXmWMwJ7cSQ2UAaxfRxFhYvrJvv52ilXIk=; b=o49M9Y2perMsaWLL3FKD0zASjMJEYxQMcTzmNhW3R8+jTeJA7casx64f6bYhEsU4e4 EVWcGFOjhnSIfDosnIPHKNU3PPBVC2nItlPDJF8+mtanlHyYF6aZPa66crttIIocIied MRkiKbnGm0DTfZ8Ngi+/5QwBh6xXVwGw01GWfIxRC9iQJiSYQjsd3jqPXFIbsBMJpJ+p SH/eWFwXch2X90fzv/qyC0qa7L/uC+1LJ9LGrqEWo0ALpj2o2Ujop/CCeBbtrK5TLGVG Sq52hhWQqW74d+yv6k3oKmAe3Wv8AJqtZdhD2lib9OBcpqEqgWMvHw1XBSugTuzxw1iE QT8w== X-Gm-Message-State: ANoB5pmLscuKiAQWnUArIRX9oc5O8yqrHN/UWYjiQcOABewdVadxQqSR O/zE4OXbVH4X5B9jgcFMP6dfgoZJdwY= X-Google-Smtp-Source: AA0mqf6hJwCT9kA3T3j2tfIOr0mTSdiGHXuRIz6fZAyhuU7xeDzkKHVMToBnv1L4NIzGvYw/RhU46Q== X-Received: by 2002:a05:6a21:32a8:b0:9d:efbf:813b with SMTP id yt40-20020a056a2132a800b0009defbf813bmr50587360pzb.4.1671211583293; Fri, 16 Dec 2022 09:26:23 -0800 (PST) Received: from jprestwo-xps.none ([50.39.160.234]) by smtp.gmail.com with ESMTPSA id j5-20020a170902da8500b00188fdae6e0esm1913636plx.44.2022.12.16.09.26.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Dec 2022 09:26:22 -0800 (PST) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH v2 6/8] station: use wiphy_get_frequency_info Date: Fri, 16 Dec 2022 09:26:04 -0800 Message-Id: <20221216172606.1799396-6-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.3 In-Reply-To: <20221216172606.1799396-1-prestwoj@gmail.com> References: <20221216172606.1799396-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_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..28d6793a 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; + 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)) + if (!wiphy_get_frequency_info(station->wiphy, freq, &attr) || + attr.disabled) continue; if (!memcmp(info.addr, From patchwork Fri Dec 16 17:26:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13075245 Received: from mail-pj1-f54.google.com (mail-pj1-f54.google.com [209.85.216.54]) (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 C27D029AD for ; Fri, 16 Dec 2022 17:26:24 +0000 (UTC) Received: by mail-pj1-f54.google.com with SMTP id t11-20020a17090a024b00b0021932afece4so6741478pje.5 for ; Fri, 16 Dec 2022 09:26:24 -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=8hsmg+06NmeQovY9R3GIuEUIniH2y9nsyPGfA0hIb9k=; b=VS//l9BnhhTYbSZRKiwAGUew/UHCC2aHcfi/e6iGyMLa9+sDRxsQD7ywIQJ/BFrMDS CUbzMijfXFgjL1E49UfOF1bCz6rJRMKZMw/zsNnzC585Belk59koX1pw7pMcAHhURGy3 uRh8URkusrsuPtCix7wE41IirONDOHxV+n0Gx4kNkfT48LyrdfbJLi7iaNAGicJrtwxC MNOO5CXAzNaWZeSUHt+ExvAlBXMgbA5WFGwqBHXB69qK1BO+9kArAfZkiasq/6smOs0s aNWIGBG4naXYuY+cFO5RHSlLM7sz59EgzuXtZC2W3b6qczliiPqhnbZYVmWwfS2A5OUI by0g== 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=8hsmg+06NmeQovY9R3GIuEUIniH2y9nsyPGfA0hIb9k=; b=wmojqcKKTC65b5k1ZvacUSPfKi0a/k1Etbz6Y2FeoEZJSDyZfVpjzF/byWQF/3WImL IqHgB/fiD81G3/MbDQKNSrbaDqRAqrUgbXwBa3sEuER/i8DldcS8V2B1WAPQiAX//Mcy q1PQX6cNUr2Mtseu+WRzLSVOh91BIB+ctd4L5jAALXSPSLXYdLMBbyE3siGoIPpDRby4 jlEBH1n+Ir8V+lOh1117oHku7xDsJ7hX8fS/tfhHxkuzNzbg1rGzFEDv+aZKgzUM9U8U 8kpdDEv4XfgklHq/abZG6zE+ahY1UcLoS1axPmsq/HE/Z5segq5l90ImlvF7y4y+0Puu +gxw== X-Gm-Message-State: ANoB5pmhfYeDg6lyIYMyGsi/f8j+1clQ4PL/Iq99ACbPPEFDs6b5sTy6 Jvf9aMBmhWo269rPE0/Fkxui/Bjdp5g= X-Google-Smtp-Source: AA0mqf4fk1fLRIAHXORtcZtdZ6/MKrzL3E5xSJsgrYFTbB9p3YsynmuTJBxs/qRkcU9xElE1TI1ChA== X-Received: by 2002:a17:902:ce04:b0:189:323d:df17 with SMTP id k4-20020a170902ce0400b00189323ddf17mr37254798plg.67.1671211584110; Fri, 16 Dec 2022 09:26:24 -0800 (PST) Received: from jprestwo-xps.none ([50.39.160.234]) by smtp.gmail.com with ESMTPSA id j5-20020a170902da8500b00188fdae6e0esm1913636plx.44.2022.12.16.09.26.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Dec 2022 09:26:23 -0800 (PST) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH v2 7/8] ap: use wiphy_get_frequency_info Date: Fri, 16 Dec 2022 09:26:05 -0800 Message-Id: <20221216172606.1799396-7-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.3 In-Reply-To: <20221216172606.1799396-1-prestwoj@gmail.com> References: <20221216172606.1799396-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_get_frequency_info() --- src/ap.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/ap.c b/src/ap.c index 32d9e1c4..7ba1974f 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; + struct band_freq_attrs attr; if (!(wiphy_get_supported_bands(wiphy) & ap->band)) { l_error("AP hardware does not support band"); @@ -3191,15 +3190,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_get_frequency_info(wiphy, freq, &attr)) { l_error("AP hardware does not support frequency %u", freq); return false; } - if (scan_freq_set_contains(disabled, freq)) { + if (attr.disabled) { l_error("AP hardware has frequency %u disabled", freq); return false; } From patchwork Fri Dec 16 17:26:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13075246 Received: from mail-pl1-f182.google.com (mail-pl1-f182.google.com [209.85.214.182]) (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 806DB29AC for ; Fri, 16 Dec 2022 17:26:25 +0000 (UTC) Received: by mail-pl1-f182.google.com with SMTP id d3so2945877plr.10 for ; Fri, 16 Dec 2022 09:26:25 -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=Uw/LXTkmcEjIn6ij5JNOYm+9X54kyb4McOKnjUJGnK4=; b=loIFxNFsQOOt3Q+T5oEJFPHw6e0PlNMta+icRbG+ufRAHPvo3awpbj0LPC068FRjXB MSrPOBiBXRErl4ekruBXD+BjZgZfzannGtJJdkBIg/JlCmVzIcGpS7n8DHT6JdxL4tnU Bt7zvGgJYujHQl7SffQeXHZ/r2l072/NKabr1eMybf3Ly/6rKWcotc5xVVMN+T9KTSGb C7QoxGtceyqn/SWwVw8WfpXFpTcKlfBYfoSn418snBMi2fZKptnaXKWiNr9kX0c+nDLz 7Z1cyUZccE4pAHB0+F3rKQa4DLYlKJPQeEVU00w0sWQj9seOVydwRVLt2YS8hUr45Vkm q1EQ== 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=Uw/LXTkmcEjIn6ij5JNOYm+9X54kyb4McOKnjUJGnK4=; b=M6COdqLoQhsGfmZLCcEdPcmBN49ci1P+NuXeb59iqkK364BU6fjgUU0RGgLL7tlWcw O6jHiY5tmoiaMFRHvCq4NRDCpH1ruqSr82SIYjrnmHnhKbxYj9O5WInREeR1/412n/Hc 1mA6E6SmyTpZGi4ZmPHSIYEd7po6kTyReetc6+AUE0gPyt3k9w3hcvMEd0Gt0h830tkK PtcaZye8UrQDf6nHR5YRo3CJQd5VdM4lcavTMz+JbD2zT6F+hoq1g2kKtXnXQZ2/3wOr GgqCNV5fRFnNnzOiRsgeLWD5BlaRs4IgPbyuNwczafyF3zXeaa/AtTeK19JMUmafyb+f l5tQ== X-Gm-Message-State: ANoB5pk5P3+MrYNhVGxp9iDOUT0SxIkLs86A/D6c2etXunM7wqOx1QVx 7U/PIn/YTF7Bd5ew03MWZ/RfOMNUk+M= X-Google-Smtp-Source: AA0mqf5hVTYx8kC6yVadKJXmgsXEiGoyLm+n1OzqUq9DvPCz/lIfFzqCrHlE00/A2Vz0GoENdCfV5Q== X-Received: by 2002:a17:902:768b:b0:186:865c:ea17 with SMTP id m11-20020a170902768b00b00186865cea17mr31637139pll.38.1671211584811; Fri, 16 Dec 2022 09:26:24 -0800 (PST) Received: from jprestwo-xps.none ([50.39.160.234]) by smtp.gmail.com with ESMTPSA id j5-20020a170902da8500b00188fdae6e0esm1913636plx.44.2022.12.16.09.26.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Dec 2022 09:26:24 -0800 (PST) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH v2 8/8] wiphy: remove disabled_freqs and related dump code Date: Fri, 16 Dec 2022 09:26:06 -0800 Message-Id: <20221216172606.1799396-8-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.3 In-Reply-To: <20221216172606.1799396-1-prestwoj@gmail.com> References: <20221216172606.1799396-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 7b72b6be..7d06aa3f 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) { @@ -2029,9 +2020,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, @@ -2045,13 +2033,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); @@ -2121,33 +2105,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) { @@ -2192,7 +2161,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; @@ -2212,8 +2180,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 8411318a..27f4b7f3 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); bool wiphy_get_frequency_info(const struct wiphy *wiphy, uint32_t freq, struct band_freq_attrs *attr_out);