From patchwork Fri Jul 22 16:34:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 12926598 Received: from mail-pj1-f43.google.com (mail-pj1-f43.google.com [209.85.216.43]) (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 7EF0515BA for ; Fri, 22 Jul 2022 16:37:12 +0000 (UTC) Received: by mail-pj1-f43.google.com with SMTP id v16-20020a17090abb9000b001f25244c65dso1254434pjr.2 for ; Fri, 22 Jul 2022 09:37:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=RCFO7wruesz0nYBxQHkS7ZnaRMC+O+2nQM8zZtTBnzQ=; b=Jj/LtKWULwmveC99uu/mkjxSjURwZag0TNNoUC69w3fn2BxDjgXDYbbhGR0DuAhOQR 2al+qTPnjjek0NcCs03n81fG5frYa1CsE8XHQ1fl9Z0Gzt+QnS4KybY69dNfxkscHfFo 8IWjVb4eepQyIvpqQkCBvRh8wMw/t3lZ+pn0V7+FKTMbmUsVKJMxGS25xL2eFsTmbO1q 1Za35Te+txiyc0HqJFKNE2/ifkVJxTlMk4TwPTlq3DEq4RkCS2KTLPcICtwK4qORrdJf Q+yHzIe859OhtvwaRhEKtutksg9UbWrnmsouoxUMYsj3NEKnxyhaSfkICtnXxwMyVdh2 RqSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=RCFO7wruesz0nYBxQHkS7ZnaRMC+O+2nQM8zZtTBnzQ=; b=S/ZINI9b195i+zESS6B9UWBmw/OnnN63L6Tv9ZQF1aT7o7N8abG+D/NXkVX7Bw6I+p XEHLEz3wCGf16BB2uyTxdQCqcI83UoR/lW0sBkuTD489VsptBhi6KF3j3CXj0g0RMuBd U5SGGSOKxRSIzjRVHz9DuZxn/PpXG685ZEgwaUrXZGfj7hYrfo1387EyDcJ9iUXkGuTq n57Ul8ZjdZjUE8WXibTbAMrs/Ozyb1pWAWB7rX0067hCLnlsBWzN8zPPedseDXH4aQ80 vSsUSEhH9eUqu4lkTg1CZJ1lc/yAyUM2fz5j5bY9wxYyiaX3QnoQZyO2oKP2hKa2UZL3 atuA== X-Gm-Message-State: AJIora9i0aC1qxAWsKB/L7HzAA2G7qfcLSX7kfPeHZ9xaRg2uOOOpZAA YxQXnvGJEBzzpUJs4thfN3aqZsQLDLo= X-Google-Smtp-Source: AGRyM1sQx7OjmOMtw+KF/pR12lj36H4ol1aSemhGl4YnN+FpdCiDqcr/bEPgzDoKZOCKW97VsBzXhw== X-Received: by 2002:a17:90a:4402:b0:1f2:3507:5f96 with SMTP id s2-20020a17090a440200b001f235075f96mr513787pjg.22.1658507831561; Fri, 22 Jul 2022 09:37:11 -0700 (PDT) Received: from localhost.localdomain ([50.45.187.22]) by smtp.gmail.com with ESMTPSA id p18-20020a170902e75200b0016a109c7606sm4013887plf.259.2022.07.22.09.37.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Jul 2022 09:37:11 -0700 (PDT) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH 1/7] wiphy: fix runtime error from bit shift Date: Fri, 22 Jul 2022 09:34:11 -0700 Message-Id: <20220722163417.1119334-1-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: iwd@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The compiler treated the '1' as an int type which was not big enough to hold a bit shift of 31. Change this to 1ULL to fix the error: runtime error: left shift of 1 by 31 places cannot be represented in type 'int' --- src/wiphy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wiphy.c b/src/wiphy.c index 09b99fb2..4b9e130a 100644 --- a/src/wiphy.c +++ b/src/wiphy.c @@ -957,7 +957,7 @@ static void wiphy_print_he_capabilities(struct band *band, uint8_t width_set = bit_field(he_cap->he_phy_capa[0], 1, 7); for (i = 0; i < 32; i++) { - if (!(he_cap->iftypes & (1 << i))) + if (!(he_cap->iftypes & (1ULL << i))) continue; if (L_WARN_ON(s >= type_buf + sizeof(type_buf))) From patchwork Fri Jul 22 16:34:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 12926599 Received: from mail-pj1-f42.google.com (mail-pj1-f42.google.com [209.85.216.42]) (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 090074A1A for ; Fri, 22 Jul 2022 16:37:12 +0000 (UTC) Received: by mail-pj1-f42.google.com with SMTP id go3so4865870pjb.0 for ; Fri, 22 Jul 2022 09:37:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=gv0Gc6Eh6Spxe9fTHZB0uG90pjO05o2p3SJiOIb9gX4=; b=p8zw+GQSDlvyPeN814OGiOv23Ut8zZhsWt7JyOLvHsAddJBFw7W6s5AgiV6kaD/6Cz RsCwLdo7t4At3wpqQLiR1TdssLPCSqgK79+z1v63JGh9tGwvCJy4x48nGWT2yyt3UpUT 0sZIP5kAf1FXh9oaD1UkyLoPaw1GWtfpM8rYW6CXeTMi03yl2fvdpYL8eze4NjsZrMB8 ocsJDONngvAcSjds6ucq054ekvJUzQjGi7Bp/el35IaQavKg0/ht1ikSnclnFR/Ag45n p7t9ePJqYoZMJ7z4pn/XwlqYnUPWvZJkgfLTdd9+l7xCXiefAv1124CABiHTVSuoengt fZXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=gv0Gc6Eh6Spxe9fTHZB0uG90pjO05o2p3SJiOIb9gX4=; b=lSJIbdzM5TFsGyuJOjOPKNNCx2lwjwi38VTFXuq1YcajBqdq0PSUJWh+3xL3KrUuxp v08Q8jJAeEV5mtnuowYkXbfJFTgEIDft4PtwyO8FwLfthGlvhe4NpkudghdazTDTR6+q lfLOj3UAW3yUZ5xhgtbqU3pbPqrry3zTCRfwE9Z2trlFXrDtDdKEDe0CFdGA0UGHCdxC pKzAUXd6JaenOyeSeja0fj9rDjWtH6AHg/Yezhcu6+YH0gpdO5QIubUj6EyEEpC+5AlO vSx/ogZ58bHzb4mlvd8w6NJB7/ixbEYqKppBqF6844dgr7slVigaeC8vldcm0Jp/1PEW aKjw== X-Gm-Message-State: AJIora8dduZtLpB44yQbKPOtR5c+S/6aFphFq/3iWzaVI1GJ6VCuVG1e WPnt7fcCXtwdrsFcsQffdoZinZJSAlI= X-Google-Smtp-Source: AGRyM1tai/uhXNF/vymVXXkh4Iq+zC9flMoydoSEsI+xHcaQdIO3+JBKLcB3Ovxw0rde4kLk4IW6+g== X-Received: by 2002:a17:902:d5cf:b0:16c:e0ce:dbd8 with SMTP id g15-20020a170902d5cf00b0016ce0cedbd8mr373006plh.55.1658507832102; Fri, 22 Jul 2022 09:37:12 -0700 (PDT) Received: from localhost.localdomain ([50.45.187.22]) by smtp.gmail.com with ESMTPSA id p18-20020a170902e75200b0016a109c7606sm4013887plf.259.2022.07.22.09.37.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Jul 2022 09:37:11 -0700 (PDT) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH 2/7] scan: make scan_freq_set const in scan_passive Date: Fri, 22 Jul 2022 09:34:12 -0700 Message-Id: <20220722163417.1119334-2-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220722163417.1119334-1-prestwoj@gmail.com> References: <20220722163417.1119334-1-prestwoj@gmail.com> Precedence: bulk X-Mailing-List: iwd@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The scan_passive API wasn't using a const struct scan_freq_set as it should be since it's not modifying the contents. Changing this to const did require some additional changes like making the scan_parameters 'freqs' member const as well. After changing scan_parameters, p2p needed updating since it was using scan_parameters.freqs directly. This was changed to using a separate scan_freq_set pointer, then setting to scan_parameters.freqs when needed. --- src/p2p.c | 21 +++++++++++++-------- src/scan.c | 4 ++-- src/scan.h | 4 ++-- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/src/p2p.c b/src/p2p.c index a7207c30..ff3b8e45 100644 --- a/src/p2p.c +++ b/src/p2p.c @@ -1977,6 +1977,7 @@ static bool p2p_provision_scan_notify(int err, struct l_queue *bss_list, static void p2p_provision_scan_start(struct p2p_device *dev) { struct scan_parameters params = {}; + struct scan_freq_set *freqs = NULL; uint8_t buf[256]; params.flush = true; @@ -2005,16 +2006,17 @@ static void p2p_provision_scan_start(struct p2p_device *dev) * contain all of the 2.4 and 5G channels. */ if (dev->conn_go_scan_retry < 12) { - params.freqs = scan_freq_set_new(); - scan_freq_set_add(params.freqs, dev->conn_go_oper_freq); + freqs = scan_freq_set_new(); + scan_freq_set_add(freqs, dev->conn_go_oper_freq); + params.freqs = freqs; } dev->scan_id = scan_active_full(dev->wdev_id, ¶ms, NULL, p2p_provision_scan_notify, dev, p2p_scan_destroy); - if (params.freqs) - scan_freq_set_free(params.freqs); + if (freqs) + scan_freq_set_free(freqs); } static void p2p_start_client_provision(struct p2p_device *dev) @@ -3777,6 +3779,7 @@ schedule: static bool p2p_device_scan_start(struct p2p_device *dev) { struct scan_parameters params = {}; + struct scan_freq_set *freqs; uint8_t buf[256]; unsigned int i; @@ -3812,13 +3815,13 @@ static bool p2p_device_scan_start(struct p2p_device *dev) * Request frames intended for both P2P Devices and non-P2P Devices." */ params.no_cck_rates = true; - params.freqs = scan_freq_set_new(); + freqs = scan_freq_set_new(); for (i = 0; i < L_ARRAY_SIZE(channels_social); i++) { int chan = channels_social[i]; uint32_t freq = band_channel_to_freq(chan, BAND_FREQ_2_4_GHZ); - scan_freq_set_add(params.freqs, freq); + scan_freq_set_add(freqs, freq); } /* @@ -3845,12 +3848,14 @@ static bool p2p_device_scan_start(struct p2p_device *dev) dev->chans_per_scan = CHANS_PER_SCAN; } - scan_freq_set_add(params.freqs, freq); + scan_freq_set_add(freqs, freq); } + params.freqs = freqs; + dev->scan_id = scan_active_full(dev->wdev_id, ¶ms, NULL, p2p_scan_notify, dev, p2p_scan_destroy); - scan_freq_set_free(params.freqs); + scan_freq_set_free(freqs); return dev->scan_id != 0; } diff --git a/src/scan.c b/src/scan.c index 39aef625..03e5b8d9 100644 --- a/src/scan.c +++ b/src/scan.c @@ -279,7 +279,7 @@ static void scan_freq_append(uint32_t freq, void *user_data) } static void scan_build_attr_scan_frequencies(struct l_genl_msg *msg, - struct scan_freq_set *freqs) + const struct scan_freq_set *freqs) { struct scan_freq_append_data append_data = { msg, 0 }; @@ -654,7 +654,7 @@ static uint32_t scan_common(uint64_t wdev_id, bool passive, priority, &work_ops); } -uint32_t scan_passive(uint64_t wdev_id, struct scan_freq_set *freqs, +uint32_t scan_passive(uint64_t wdev_id, const struct scan_freq_set *freqs, scan_trigger_func_t trigger, scan_notify_func_t notify, void *userdata, scan_destroy_func_t destroy) { diff --git a/src/scan.h b/src/scan.h index 79bec605..58b8332b 100644 --- a/src/scan.h +++ b/src/scan.h @@ -93,7 +93,7 @@ struct scan_bss { struct scan_parameters { const uint8_t *extra_ie; size_t extra_ie_size; - struct scan_freq_set *freqs; + const struct scan_freq_set *freqs; uint16_t duration; bool flush : 1; bool randomize_mac_addr_hint : 1; @@ -130,7 +130,7 @@ struct l_genl_msg *scan_build_trigger_scan_bss(uint32_t ifindex, const uint8_t *ssid, uint32_t ssid_len); -uint32_t scan_passive(uint64_t wdev_id, struct scan_freq_set *freqs, +uint32_t scan_passive(uint64_t wdev_id, const struct scan_freq_set *freqs, scan_trigger_func_t trigger, scan_notify_func_t notify, void *userdata, scan_destroy_func_t destroy); uint32_t scan_passive_full(uint64_t wdev_id, From patchwork Fri Jul 22 16:34:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 12926600 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 8F9BB4A1C for ; Fri, 22 Jul 2022 16:37:13 +0000 (UTC) Received: by mail-pj1-f45.google.com with SMTP id b7-20020a17090a12c700b001f20eb82a08so8627188pjg.3 for ; Fri, 22 Jul 2022 09:37:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Yj+1eaEHRmtoibFMSIJoeabrx2THZ9kZemIQ0R1cgDk=; b=E9V34BJsFbaYFrvXx+H1+9liNiEbPWnLdh4445dprelsBas4UgLYOO5fqgWA6hZowL 3gBG0KMxW4lS2sK6F8gBkbU3NznCHreu/FXJyZLppyJMJESGXTX+QswUVA2QRBsoGRwt ezqlVqhdnW6iYploVi1mDZzbZnVPVgNrjQ7IY7nBDI2SZlULMxezz1Cklp1rsMbCU8l/ tZuVlPj/DofFIKh4NquDhW+hkNPN3DMXngTjoaTy/CMtgtCpxXqpRCdVW2LGhs6ShSQV x+imFrU5MQLgiRc9YArdxcYCenjgG5QqWyRWKH98W8gQXdQqyMJll9jzsTSOHEFcHgO1 JM1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Yj+1eaEHRmtoibFMSIJoeabrx2THZ9kZemIQ0R1cgDk=; b=AWM6AR0O6VJysJfPqak/89TMEcnbRj8QCejgweVBZvm1FhxqDD3U3stlc7PlWtWDIW Sl1lgrn9NjQU0tijLisja9c5etamaRmeyYRvy+uWLvJYUzM6Ea1SntvZSbJikwFoLCAR k1QiLg+nx0wIyGPraZWUgN5InQDyEGq/422BXvMK5I27CQc+J/+QYtWQVruYTtrz+Bdm 3adBf8k1sP9YOXsdmh04qn2nPqMaLCmOaWSz9BHUOWGuS0wxRhCH0QJp1Z/N3wO1mwAC n3++nokmtn0p1XI9zJqgJRlkj3yig4xwuOWJNiIMweQIp/up70e6PhQ4f/Q762wm2cLz gRcA== X-Gm-Message-State: AJIora8O8SpIgSoEOW4d8pJQ5VSuzWI/9xSGbBAqJ+3T11wrlKW2l80K tKPk1KfayKJjEDqLIf8x5ujbmPjAqvc= X-Google-Smtp-Source: AGRyM1towwAUHbVvWdwsfyfRvKH1nUJfnq6WK29oqHgM7LqV7WAeQ1rK43ZfpZqqdZN4YYd9vmUgBw== X-Received: by 2002:a17:902:bcc3:b0:16d:b62:bc6f with SMTP id o3-20020a170902bcc300b0016d0b62bc6fmr678681pls.25.1658507832612; Fri, 22 Jul 2022 09:37:12 -0700 (PDT) Received: from localhost.localdomain ([50.45.187.22]) by smtp.gmail.com with ESMTPSA id p18-20020a170902e75200b0016a109c7606sm4013887plf.259.2022.07.22.09.37.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Jul 2022 09:37:12 -0700 (PDT) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH 3/7] util: add scan_freq_set_remove Date: Fri, 22 Jul 2022 09:34:13 -0700 Message-Id: <20220722163417.1119334-3-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220722163417.1119334-1-prestwoj@gmail.com> References: <20220722163417.1119334-1-prestwoj@gmail.com> Precedence: bulk X-Mailing-List: iwd@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 --- src/util.c | 22 ++++++++++++++++++++++ src/util.h | 1 + 2 files changed, 23 insertions(+) diff --git a/src/util.c b/src/util.c index 2832486d..8fdb7f17 100644 --- a/src/util.c +++ b/src/util.c @@ -357,6 +357,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 75c29039..ff5211ed 100644 --- a/src/util.h +++ b/src/util.h @@ -110,6 +110,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(struct scan_freq_set *freqs); void scan_freq_set_foreach(const struct scan_freq_set *freqs, From patchwork Fri Jul 22 16:34:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 12926601 Received: from mail-pf1-f176.google.com (mail-pf1-f176.google.com [209.85.210.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 23BCA4A2E for ; Fri, 22 Jul 2022 16:37:14 +0000 (UTC) Received: by mail-pf1-f176.google.com with SMTP id d10so4878480pfd.9 for ; Fri, 22 Jul 2022 09:37:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=TnSQiZunjwkwihk4s4Mew9IVpaoXRgbw7DAEaraw7ow=; b=cKlYX+KGTvkJf+Ug00gViioF0RaKnsqBMr0+/j9gP3TBk87o77xa7QJ2Oqr28Br5MD XVo612ws+xbw8KMVl8wyjdK6y4kioMDDWjk8Uh57GYD/tUh2u32QsM7P3/uY4KARjOxr CtoQ0Z1iLDTT8SrnXryG28HBOBTqXoNjzDzYcpV5gAZaPTz3f+Aes4DoMf3nBf/LV19O 9YsckbrkokZH4OsDfPvFy6yUoieXrnPAM04WdIauPcv9qtz7q0ovnP3vvA43PI/ioocn Cjp3Ctr7WxnEpWBaOeUmlW0gId/e8R+6oPUY23DrWtMvv0A5DrI31iT0Ntk1Fmwq/6cU cecQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=TnSQiZunjwkwihk4s4Mew9IVpaoXRgbw7DAEaraw7ow=; b=s7oItZyKBBGxwZufnqIKHq7rMp4/E7taVyPd960VJXNkpcRUBaBSykULK3qhYyXuaQ etVDQCAjp/1IifegD2EpruEWNurKuuPcRuVaUwXFuPuMAS7Q0Onbu12MOF9tliCmevyY 352jYHYzLfslo69gqL01jo3NeiKJPTuOE0mrXywxiYKZzmw90Kjj5pRYjvHNJYXzFudW l/YTbLDHp5vj4Y6ww8hSCBrxhhc81JsqSnxGa48iEhSAoA3BzPI32KC+eiU/uyScuhrX ztbhX8/LX5H+CJLtIw07o8pDizYctIjoc0e5h8uNcb/HGmaOTvgTj221h38yi3tvY0/A qH3g== X-Gm-Message-State: AJIora8K1bhfRuMZNu+nMwz+eYAStEW7JjIagLuUbPiLlwyJg5skhVPS FDg5eMntaqsXoec/lz6G0lnNnw0h8y4= X-Google-Smtp-Source: AGRyM1tp5uqBqV5HnoS2emW+CqbptwM3zS4XmDgx4xM6VX/o7pBnYZTG6dJM9q1RcohLbyheglchsg== X-Received: by 2002:a63:6902:0:b0:41a:3743:c768 with SMTP id e2-20020a636902000000b0041a3743c768mr538140pgc.512.1658507833396; Fri, 22 Jul 2022 09:37:13 -0700 (PDT) Received: from localhost.localdomain ([50.45.187.22]) by smtp.gmail.com with ESMTPSA id p18-20020a170902e75200b0016a109c7606sm4013887plf.259.2022.07.22.09.37.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Jul 2022 09:37:13 -0700 (PDT) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH 4/7] util: add scan_freq_set_max Date: Fri, 22 Jul 2022 09:34:14 -0700 Message-Id: <20220722163417.1119334-4-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220722163417.1119334-1-prestwoj@gmail.com> References: <20220722163417.1119334-1-prestwoj@gmail.com> Precedence: bulk X-Mailing-List: iwd@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Finds the maximum frequency in the set --- src/util.c | 19 +++++++++++++++++++ src/util.h | 1 + 2 files changed, 20 insertions(+) diff --git a/src/util.c b/src/util.c index 8fdb7f17..2563184e 100644 --- a/src/util.c +++ b/src/util.c @@ -379,6 +379,25 @@ bool scan_freq_set_remove(struct scan_freq_set *freqs, uint32_t freq) return false; } +uint32_t scan_freq_set_max(struct scan_freq_set *freqs) +{ + uint32_t channel; + + if (!l_uintset_isempty(freqs->channels_6ghz)) { + channel = l_uintset_find_max(freqs->channels_6ghz); + return band_channel_to_freq(channel, BAND_FREQ_6_GHZ); + } + + if (!l_uintset_isempty(freqs->channels_5ghz)) { + channel = l_uintset_find_max(freqs->channels_5ghz); + return band_channel_to_freq(channel, BAND_FREQ_5_GHZ); + } + + channel = __builtin_popcount(freqs->channels_2ghz); + + return band_channel_to_freq(channel, BAND_FREQ_2_4_GHZ); +} + 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 ff5211ed..964f6500 100644 --- a/src/util.h +++ b/src/util.h @@ -122,5 +122,6 @@ void scan_freq_set_constrain(struct scan_freq_set *set, bool scan_freq_set_isempty(const struct scan_freq_set *set); uint32_t *scan_freq_set_to_fixed_array(const struct scan_freq_set *set, size_t *len_out); +uint32_t scan_freq_set_max(struct scan_freq_set *freqs); #endif /* __UTIL_H */ From patchwork Fri Jul 22 16:34:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 12926602 Received: from mail-pj1-f42.google.com (mail-pj1-f42.google.com [209.85.216.42]) (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 DFDD04A1C for ; Fri, 22 Jul 2022 16:37:14 +0000 (UTC) Received: by mail-pj1-f42.google.com with SMTP id pc13so4825600pjb.4 for ; Fri, 22 Jul 2022 09:37:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=CICC3Nf5vdpG6NJQqXxcqaOgIhBZf5Ux4gTr6OIhLh4=; b=JnJ3YRoGi7xztuWKbfhZoDHh3PfywlCc/vy+hUfxpOJOpwAyHZL9FIdh/PgJK177jj lk95D3LcC9jh3MushFWWecPM8Smo9hKnG38ys8Wn2NlS6pWjxugPIEtfHS7M0szElnND GQeLlbPPCbdYTlDbBSI6vkDaXORLkEOoXggBobs4/97iWiYUVMqPMSW+H7MTglW4H256 ip22yQlHD9w0MFX4Bwe5MGBVrXyIAMyHgCRYbKE9n0WNtOW/6OQSUhCoMvIC6cCZ318p tWxtr+Jac8xyXJNASgjA9qjeQWW/LTOatf2sYLbpEAA00D4z9EOEcvrMWgf09X+WYt/k 66PA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=CICC3Nf5vdpG6NJQqXxcqaOgIhBZf5Ux4gTr6OIhLh4=; b=qk+OBZpmoxl88ULfKYwYGfk2giaV26veo5UvPkQhW9kFUjM+kpLvZ85po//Yqdul4Q dHHrgL57N9U2580Vax95w2ARt/f8dQn4GHf4pfgceLaDLg4ngo/4w1UYifpSt6RDeQpA TYjqyVgjI00lym/cpXxnvDgqtHm9Enli+WgD5dIUufwt4K6X+STCHx9/971yNSV9DD7a ZCJ7XKnIKN2cir9jK+61/nPwILUvkXEVWC1ESlmfPC3kXIhAgpygJJ8rF0s6Jw+ow6XF kWNcNDTqqlh95YscuiaSwpXZ1vcSc5NKthvddVgWfAG/pH08jzyo6ragr2qlHVdTshho 81Vw== X-Gm-Message-State: AJIora+76tYLpOedbp7P+6HBzmzm34IfVg1gz1I15gogJMp5VmNC5amV Brf8G/9gyd0fQZYc7EIwsUfRxV0WAkA= X-Google-Smtp-Source: AGRyM1tvTbMXbaDBsn7r3eii08QaQXRMC9pg91vTvMLl6KntlpZcSMlk8O90y0x2HS37Eiiu8Hwuig== X-Received: by 2002:a17:90b:3ec4:b0:1f0:5aab:48db with SMTP id rm4-20020a17090b3ec400b001f05aab48dbmr18490368pjb.117.1658507834063; Fri, 22 Jul 2022 09:37:14 -0700 (PDT) Received: from localhost.localdomain ([50.45.187.22]) by smtp.gmail.com with ESMTPSA id p18-20020a170902e75200b0016a109c7606sm4013887plf.259.2022.07.22.09.37.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Jul 2022 09:37:13 -0700 (PDT) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH 5/7] manager: re-dump wiphy on regulatory change Date: Fri, 22 Jul 2022 09:34:15 -0700 Message-Id: <20220722163417.1119334-5-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220722163417.1119334-1-prestwoj@gmail.com> References: <20220722163417.1119334-1-prestwoj@gmail.com> Precedence: bulk X-Mailing-List: iwd@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 This is required due to the kernel not waiting for regulatory updates before sending the wiphy dump. The initial dump usually contains all supported frequencies, none of which are disabled. Later, the regulatory subsystem populates the frequency list which can significantly limit allowed frequencies. Even disregarding this problem, any regulatory update will modify the allowed frequencies so re-dumping wiphy should still be done on a regulatory change. --- src/manager.c | 58 ++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 48 insertions(+), 10 deletions(-) diff --git a/src/manager.c b/src/manager.c index ca29e110..c8d56a99 100644 --- a/src/manager.c +++ b/src/manager.c @@ -666,6 +666,29 @@ static int manager_wiphy_filtered_dump(uint32_t wiphy_id, return 0; } +static unsigned int manager_dump_wiphy(uint32_t wiphy_id) +{ + struct l_genl_msg *msg; + unsigned int wiphy_dump; + + msg = l_genl_msg_new_sized(NL80211_CMD_GET_WIPHY, 128); + + if (wiphy_id) + l_genl_msg_append_attr(msg, NL80211_ATTR_WIPHY, 4, &wiphy_id); + + l_genl_msg_append_attr(msg, NL80211_ATTR_SPLIT_WIPHY_DUMP, 0, NULL); + wiphy_dump = l_genl_family_dump(nl80211, msg, + manager_wiphy_dump_callback, + NULL, + manager_wiphy_dump_done); + if (!wiphy_dump) { + l_error("Wiphy information dump failed"); + l_genl_msg_unref(msg); + } + + return wiphy_dump; +} + static void manager_config_notify(struct l_genl_msg *msg, void *user_data) { uint8_t cmd; @@ -799,6 +822,25 @@ static void manager_config_notify(struct l_genl_msg *msg, void *user_data) } } +static void manager_reg_notify(struct l_genl_msg *msg, void *user_data) +{ + uint32_t wiphy_id; + uint8_t cmd = l_genl_msg_get_command(msg); + + switch (cmd) { + case NL80211_CMD_REG_CHANGE: + manager_dump_wiphy(0); + break; + case NL80211_CMD_WIPHY_REG_CHANGE: + if (nl80211_parse_attrs(msg, NL80211_ATTR_WIPHY, &wiphy_id, + NL80211_ATTR_UNSPEC) < 0) + break; + + manager_dump_wiphy(wiphy_id); + break; + } +} + static int manager_init(void) { struct l_genl *genl = iwd_get_genl(); @@ -826,17 +868,13 @@ static int manager_init(void) goto error; } - msg = l_genl_msg_new_sized(NL80211_CMD_GET_WIPHY, 128); - l_genl_msg_append_attr(msg, NL80211_ATTR_SPLIT_WIPHY_DUMP, 0, NULL); - wiphy_dump = l_genl_family_dump(nl80211, msg, - manager_wiphy_dump_callback, - NULL, - manager_wiphy_dump_done); - if (!wiphy_dump) { - l_error("Initial wiphy information dump failed"); - l_genl_msg_unref(msg); + if (!l_genl_family_register(nl80211, NL80211_MULTICAST_GROUP_REG, + manager_reg_notify, NULL, NULL)) + l_error("Registering for regulatory notifications failed"); + + wiphy_dump = manager_dump_wiphy(0); + if (!wiphy_dump) goto error; - } msg = l_genl_msg_new(NL80211_CMD_GET_INTERFACE); interface_dump = l_genl_family_dump(nl80211, msg, From patchwork Fri Jul 22 16:34:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 12926603 Received: from mail-pj1-f43.google.com (mail-pj1-f43.google.com [209.85.216.43]) (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 0EED44A2C for ; Fri, 22 Jul 2022 16:37:15 +0000 (UTC) Received: by mail-pj1-f43.google.com with SMTP id v16-20020a17090abb9000b001f25244c65dso1254523pjr.2 for ; Fri, 22 Jul 2022 09:37:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=qKhcnbNdSwvhA7rR0O08Kw3sCNSNtux7PL2RgOPbCKM=; b=OZeYF6CnQWXe8b15xAXRNVSKqAYnzsttgLd27b99fhMxQ1l8oehoobVtBUE7ouHsht 30Cmc5gGa3k0HCKwivJyTHyACiTTaiTCCYn9ceR4Md2bF+0WhzzXuN0SKB8RPoImjcGB Hjx3MZuQa5LcZoPfgFjItcaANrEmomFsPmzm5o5XrSX/9/0tWWgpxQwEMUYI4mKF9d6j JDYXz9mDGYFpR2eaYGuVlFPKR/KWVhCiHmPWzsrTOEgoLEem3AnuuOPDd5hPwlbc+mpV eUqx1MvpRPHIm/fQccVexvL/YnaxGrEhXZ3k2c64cMqxrdBslE/nzF3zmXnXsA9WlrGs +bnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=qKhcnbNdSwvhA7rR0O08Kw3sCNSNtux7PL2RgOPbCKM=; b=dm6aT078lGdF+WuwZIW16sjErK5sTMXMKsZ8Q3r8BwML89UDjm7RhS3xhwFJZpdVE7 IROyU0dQbh1C0QMzCLM2FPUXFGUZcjIdli6wHczvPZRBCpRSM762n9LZcTQ8W11wHewu 1775l7bR0pEaWt7Fka649ItAkAU0ldfj8FIFo7FxH+uY46gtis6QT9OCk7084DKPsKTC OPGpy65N81skS6G+uyNtwORtRypqZ0o731Cg8mqdw6pegUscEA9L2n81sJAQ8VxYRrBV tQ0XXARF6LI/cVZwewMRzd+W+iGh1BocgOiHDXKBJ8YaqDNWYZVUFV9uIBbvD/GNZc8x wxtg== X-Gm-Message-State: AJIora9V1bK6+lMLhnwzw0sMY27hbdtZ9GyQ2smaDLnyI1DLxQ+cVzTe Eg1DsRxnIQX2txhZI8mGwFApn7UCP60= X-Google-Smtp-Source: AGRyM1vOUJY0qUmuxCCfxp8xpvJ1ZcGYaBGDXlsLkZb/vcIfK0x946QmHTimmtPzgONm1BEdMa8cgQ== X-Received: by 2002:a17:902:cf06:b0:16b:cc33:5bce with SMTP id i6-20020a170902cf0600b0016bcc335bcemr689713plg.152.1658507834555; Fri, 22 Jul 2022 09:37:14 -0700 (PDT) Received: from localhost.localdomain ([50.45.187.22]) by smtp.gmail.com with ESMTPSA id p18-20020a170902e75200b0016a109c7606sm4013887plf.259.2022.07.22.09.37.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Jul 2022 09:37:14 -0700 (PDT) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH 6/7] wiphy: track disabled frequencies on multiple dumps Date: Fri, 22 Jul 2022 09:34:16 -0700 Message-Id: <20220722163417.1119334-6-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220722163417.1119334-1-prestwoj@gmail.com> References: <20220722163417.1119334-1-prestwoj@gmail.com> Precedence: bulk X-Mailing-List: iwd@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 If a frequency is disabled, it should not be added to the supported list which it previously was. In this case its added to the (new) disabled_freqs list. Now that wiphy's are dumped on regulatory changes frequencies may be added or removed from either the supported or disabled frequency list. These changes are now tracked to keep the lists accurate. --- src/wiphy.c | 35 ++++++++++++++++++++++++++++++++--- src/wiphy.h | 1 + 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/src/wiphy.c b/src/wiphy.c index 4b9e130a..7d123e0c 100644 --- a/src/wiphy.c +++ b/src/wiphy.c @@ -104,6 +104,7 @@ struct wiphy { uint16_t supported_iftypes; uint16_t supported_ciphers; struct scan_freq_set *supported_freqs; + struct scan_freq_set *disabled_freqs; struct band *band_2g; struct band *band_5g; struct band *band_6g; @@ -316,6 +317,7 @@ 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; @@ -357,6 +359,7 @@ 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); @@ -454,6 +457,11 @@ 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; +} + bool wiphy_can_transition_disable(struct wiphy *wiphy) { /* @@ -1208,19 +1216,40 @@ static void parse_supported_frequencies(struct wiphy *wiphy, struct l_genl_attr attr; while (l_genl_attr_next(freqs, NULL, NULL, NULL)) { + uint32_t freq = 0; + bool disabled = false; + if (!l_genl_attr_recurse(freqs, &attr)) continue; while (l_genl_attr_next(&attr, &type, &len, &data)) { - uint32_t u32; switch (type) { case NL80211_FREQUENCY_ATTR_FREQ: - u32 = *((uint32_t *) data); - scan_freq_set_add(wiphy->supported_freqs, u32); + freq = *((uint32_t *) data); + break; + case NL80211_FREQUENCY_ATTR_DISABLED: + disabled = true; break; } } + + if (!freq) + continue; + + /* + * Wiphy is dumped again on every regulatory domain change which + * may contain disabled frequencies which were previously + * allowed. If disabled, remove from supported. If supported, + * remove from disabled. + */ + if (disabled) { + scan_freq_set_add(wiphy->disabled_freqs, freq); + scan_freq_set_remove(wiphy->supported_freqs, freq); + } else { + scan_freq_set_add(wiphy->supported_freqs, freq); + scan_freq_set_remove(wiphy->disabled_freqs, freq); + } } } diff --git a/src/wiphy.h b/src/wiphy.h index acc64193..9a3b96f9 100644 --- a/src/wiphy.h +++ b/src/wiphy.h @@ -93,6 +93,7 @@ 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_can_transition_disable(struct wiphy *wiphy); bool wiphy_can_offload(struct wiphy *wiphy); bool wiphy_supports_cmds_auth_assoc(struct wiphy *wiphy); From patchwork Fri Jul 22 16:34:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 12926604 Received: from mail-pj1-f42.google.com (mail-pj1-f42.google.com [209.85.216.42]) (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 28C724A2C for ; Fri, 22 Jul 2022 16:37:16 +0000 (UTC) Received: by mail-pj1-f42.google.com with SMTP id p6-20020a17090a680600b001f2267a1c84so6949037pjj.5 for ; Fri, 22 Jul 2022 09:37:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=svzd3PF6k8MkSduQuJ28bOzWlvPKhFyicr0L1IYzjLI=; b=VIgHy8cfNpHo+Bl4jQITwQUVmEfaEXkFjvuF7olyLO27ykNvigIOPZzV3okjHOlMna lbLs37kTGbIOiT2NVylDPUc9ABuTIUpaWWB+y1JKeXr7Zu/734H98Au4mcGgEvSL3/Hb D9PY7qhsV6E7mkcu0ZCDJmtJXjvMQ+hpH0WeIBbdRogB3uV5O2wqp5+nKGNM4BGVo2W+ UgEVQhj9MA5ZviMKxu0JkaMtfuPpftcswdv7MV4scZ9F3NQbesDsaav6MgU8Bwi1R+7b sMPs62ppgi5k7ClJw3Gzw5DNsbjcwZA2wUokpd+Q3ebO+Tl8vI+mvNtYgOlY80FFc0Yj bEag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=svzd3PF6k8MkSduQuJ28bOzWlvPKhFyicr0L1IYzjLI=; b=S5xBHXg86pZ5078qf7yCoK+sQ19Cx2WoiCP4b5kFNOVHVHz54w/4nENVwE0q55l6tM eaH42DfvzbY4hCVLg0Nuq48lcuoskYJfzckcwPFWiame96SUcZj8c49q72W61LulM81t OhZmiajGVXGqerIctpxjJL1mX9qWkJxS4v/R2KaqX6WWpZzZCog5HYkLIQ1ZjRErpOqH e+v7l3iJJPVK5iX7kyqdkJdh3Oafz+mKJqmYt/4Ht5KM3zR4c5OxXwyy0bzjAi0dGZGK dO8mU3L4Ow9wQFKuoZigqsyzmTjPVqJlwXMNwfuQdQHiZnFv2ytExt5Sblh5h3/JKRBx V5pw== X-Gm-Message-State: AJIora/zfXdXRf4AZFM4B1HtsPZg1GVP+AU0sJHNG39VSJlT0hOkO+5h c6pCa/ljqZDsR+KG18zSFqQacImA9T8= X-Google-Smtp-Source: AGRyM1tKmURBlaeTYmKRaF1dzXGAiRGYXas9kDbr+nyOPmoIqpY0kPlj/gzCHMqySEoo9J+fQMQmBQ== X-Received: by 2002:a17:90b:4b4d:b0:1ef:a2c2:6bcc with SMTP id mi13-20020a17090b4b4d00b001efa2c26bccmr507358pjb.186.1658507835325; Fri, 22 Jul 2022 09:37:15 -0700 (PDT) Received: from localhost.localdomain ([50.45.187.22]) by smtp.gmail.com with ESMTPSA id p18-20020a170902e75200b0016a109c7606sm4013887plf.259.2022.07.22.09.37.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Jul 2022 09:37:15 -0700 (PDT) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH 7/7] station: do full passive scan if 6GHz is supported but disabled. Date: Fri, 22 Jul 2022 09:34:17 -0700 Message-Id: <20220722163417.1119334-7-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220722163417.1119334-1-prestwoj@gmail.com> References: <20220722163417.1119334-1-prestwoj@gmail.com> Precedence: bulk X-Mailing-List: iwd@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The kernel handles setting the regulatory domain by receiving beacons which set the country IE. Presumably since most regulatory domains disallow 6GHz the default (world) domain also disables it. This means until the country is set, 6GHz is disabled. This poses a problem for IWD's quick scanning since it only scans a few frequencies and this likely isn't enough beacons for the firmware to update the country, leaving 6Ghz inaccessable to the user without manual intervention (e.g. iw scan passive, or periodic scans by IWD). To try and work around this limitation the quick scan logic has been updated to check if a 6GHz AP has been connected to before and if that frequency is disabled (but supported). If this is the case IWD will opt for a full passive scan rather than scanning a limited set of frequencies. --- src/station.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/station.c b/src/station.c index 02f21c76..373bd1c3 100644 --- a/src/station.c +++ b/src/station.c @@ -1352,12 +1352,35 @@ static void station_quick_scan_destroy(void *userdata) static int station_quick_scan_trigger(struct station *station) { + uint32_t max_freq; struct scan_freq_set *known_freq_set; + const struct scan_freq_set *supported = wiphy_get_supported_freqs( + station->wiphy); + const struct scan_freq_set *disabled = wiphy_get_disabled_freqs( + station->wiphy); known_freq_set = known_networks_get_recent_frequencies(5); if (!known_freq_set) return -ENODATA; + /* + * This means IWD has previously connected to a 6GHz AP before, but now + * the regulatory domain disallows 6GHz likely caused by a reboot or + * the firmware going down. The only way to re-enable 6GHz is to get + * enough beacons via scanning for the firmware to set the regulatory + * domain and open up the frequencies. + */ + max_freq = scan_freq_set_max(known_freq_set); + if (max_freq > 6000 && scan_freq_set_contains(disabled, max_freq)) { + l_debug("6GHz may be available, doing full passive scan"); + station->quick_scan_id = scan_passive( + netdev_get_wdev_id(station->netdev), + supported, station_quick_scan_triggered, + station_quick_scan_results, station, + station_quick_scan_destroy); + goto done; + } + if (!wiphy_constrain_freq_set(station->wiphy, known_freq_set)) { scan_freq_set_free(known_freq_set); return -ENOTSUP; @@ -1368,6 +1391,7 @@ static int station_quick_scan_trigger(struct station *station) station_quick_scan_triggered, station_quick_scan_results, station_quick_scan_destroy); +done: scan_freq_set_free(known_freq_set); if (!station->quick_scan_id)