From patchwork Mon Sep 25 18:54:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13398273 Received: from mail-yw1-f176.google.com (mail-yw1-f176.google.com [209.85.128.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 440CBD304 for ; Mon, 25 Sep 2023 18:54:41 +0000 (UTC) Received: by mail-yw1-f176.google.com with SMTP id 00721157ae682-59bc956b029so86759727b3.2 for ; Mon, 25 Sep 2023 11:54:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1695668080; x=1696272880; darn=lists.linux.dev; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=uxDJG92KL3Fmh2baF9X4/Or/RbQCCbW5E6lHabmhxdU=; b=VWm8ixxtXTE0JL8BEASNxXMpDkCCiZ8kAEibJgSbCZrAJ30Xbcy4I+3OAhiAViwdG6 wRbjGlD92ZaGmkFA1R/pJdtno3qIhMXowkP+jEo9mMWf3nh33nPYZ4NeT2HF222Jzevb ZipkZIBZ5yP7iit9JTn4KBXBt+FSqzho3lG2Xwp40MZNS9k/YQWH0FAm8WNm57RJitS2 m9/LJ1mJxHh66vcmU5Rx1P5IgF5krMdDMU942C2RY1gKTv/e7L6JtFM5N1DxesCd8o7G 3SBc2QSKobA9RhKfYmUAJHBWkiY8+adV6LimeMOmLiPHeQeATiDDiHET+wrO/zwc5buo Mutw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695668080; x=1696272880; 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=uxDJG92KL3Fmh2baF9X4/Or/RbQCCbW5E6lHabmhxdU=; b=fAIQ/3kLAPyKF0KuVmNIDUeqoixXSM4BEtkABhW7fPJDwwikXEZgKC/3m+RR299/oQ OzjUutPa0iTts/c8hbbixq19c8XNmI2MgsQUI0a1MwOGPSDLcCSegcYpzvbdTbkcQcXo LkPjStQFBv6ejjGPEES3wr5dXHVCb4jJl04szxaGZLqErTsg6M1dM2sj7/tKMHhVG1gP 9lMkRAbxppulWOgXh6mU/rlT63SVN66aFpihztPJZteY7TLalktVjzSj1mhUT85mkfYX hrz+vQ3L9ZAKefKsEGKoEKQ8XL8YOZ/oDcxP/1XW6WYYbB3A1ZYzvwE6++D/URMJgMwt 5TVQ== X-Gm-Message-State: AOJu0Yw/G7uzCgCtXoZF10uefSYM7zXz/EZKLbFlNYywl5B0NZk0Dfo4 6vLYUTnOlPGz8MZGWcfqPnc4nUt/y7Y= X-Google-Smtp-Source: AGHT+IEt2JCqsF2aHMpfrv9mnxPt9IkZe+tVqUogL8kI8kK8ArMOFb7lklX4hfaJWUJMux33mY1miA== X-Received: by 2002:a81:b665:0:b0:59f:63fb:2261 with SMTP id h37-20020a81b665000000b0059f63fb2261mr5604630ywk.19.1695668080046; Mon, 25 Sep 2023 11:54:40 -0700 (PDT) Received: from LOCLAP699.rst-01.locus (50-78-19-50-static.hfc.comcastbusiness.net. [50.78.19.50]) by smtp.gmail.com with ESMTPSA id v134-20020a81488c000000b00570253fc3e5sm2518920ywa.105.2023.09.25.11.54.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Sep 2023 11:54:39 -0700 (PDT) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH 1/8] scan: add [Rank].BandModifier2_4Ghz Date: Mon, 25 Sep 2023 11:54:15 -0700 Message-Id: <20230925185422.2242494-1-prestwoj@gmail.com> X-Mailer: git-send-email 2.25.1 Precedence: bulk X-Mailing-List: iwd@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Similar to the 5/6Ghz options, allow modifying the rank for 2.4Ghz scan results. --- src/scan.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/scan.c b/src/scan.c index 5a972efb..3979dc03 100644 --- a/src/scan.c +++ b/src/scan.c @@ -53,6 +53,7 @@ #include "src/scan.h" /* User configurable options */ +static double RANK_2G_FACTOR; static double RANK_5G_FACTOR; static double RANK_6G_FACTOR; static uint32_t SCAN_MAX_INTERVAL; @@ -1634,6 +1635,9 @@ static void scan_bss_compute_rank(struct scan_bss *bss) rank = (double)bss->data_rate / max_rate * USHRT_MAX; + if (bss->frequency < 3000) + rank *= RANK_2G_FACTOR; + /* Prefer 5G networks over 2.4G and 6G */ if (bss->frequency >= 4900 && bss->frequency < 5900) rank *= RANK_5G_FACTOR; @@ -2355,6 +2359,10 @@ static int scan_init(void) scan_contexts = l_queue_new(); + if (!l_settings_get_double(config, "Rank", "BandModifier2_4Ghz", + &RANK_2G_FACTOR)) + RANK_2G_FACTOR = 1.0; + if (!l_settings_get_double(config, "Rank", "BandModifier5Ghz", &RANK_5G_FACTOR)) RANK_5G_FACTOR = 1.0; From patchwork Mon Sep 25 18:54:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13398274 Received: from mail-yw1-f175.google.com (mail-yw1-f175.google.com [209.85.128.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 61A321C29A for ; Mon, 25 Sep 2023 18:54:42 +0000 (UTC) Received: by mail-yw1-f175.google.com with SMTP id 00721157ae682-59c00b5c8b2so86408497b3.1 for ; Mon, 25 Sep 2023 11:54:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1695668081; x=1696272881; darn=lists.linux.dev; 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=WzJaXNVHDuRL31ALX0/rwQRbkfJJ08kUBSnb+4iHJjk=; b=J/F5CaJ9AIhbYGxVk6rm6/r5mQYSmX3+3OASRC9qcqvrshfGoW2UJ6PtoATqgxxzE9 Z+KhzskbHXtdt4YEKm67PIUwC+swkT24uaGwE+ZKoDmu2lMxw75GZvQl09ThzvoO8hur NVpAs4mU1oFucMAVPVZjCUtvHI6frsYqlpmSfb1hcGlRFxbF/CYjmnX2zOww7kDhbDL7 5od5Fr6qVldDf/DWDK1PMLIq1W6zjblUyB6BM5WPx8mfPeGHH9PVTdM2s06db+ouQUES 68CFfhFTcXsqdjtOTHsNdUd7A/TaNf5iin7kGMpzKy9yu5jCG6C1/Oh+jDhXgXLsS6Ag o09w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695668081; x=1696272881; 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=WzJaXNVHDuRL31ALX0/rwQRbkfJJ08kUBSnb+4iHJjk=; b=EDKu1VxfvzZQQ9dj9ft2A6WziOQ38EVH1tBWzI+r6NYXIK08mOnCBFp5y+UNOuOYdx FxPQlufE1g1CTLMVY0cHqbOlQQSC54Cz52Dz7U3f5IQxHEQefFGCsRqGzZBKFZS+ebwG fNDKOc9rJNHmR/Dgz04i3A9KWyCbaBdHBABtioU09wVCJ7OdaY/fOs9Pdudujm19UwzA KSlXfXaF2jO5QMTJeh4PZVnF2KKNVXog0pqR+cvEAt1CDhEjc7nT5crFpaNnsvjKGULu H03LEhTE2s9Y+TsHE00D3HyiZSmMUXE7xskD4SiGeiHcvCRzVGg9us0icis39Sf7Opc5 5nrA== X-Gm-Message-State: AOJu0Ywrpz/hT+GvZs5ZqrIq7bCyYiMrkZXGd4wk/D21ezEA7P61Eits VCIqOGvRgkBHqdviXzOKo2Kqd0yQMpw= X-Google-Smtp-Source: AGHT+IG1A6OK1jNfmG8DdZ8hpHftk+Bv5wRwLTklqlxykwLK1lXWITovJDxTotYrQupJRu0lY7BJpA== X-Received: by 2002:a81:8506:0:b0:598:9df6:1a4f with SMTP id v6-20020a818506000000b005989df61a4fmr7518948ywf.39.1695668081162; Mon, 25 Sep 2023 11:54:41 -0700 (PDT) Received: from LOCLAP699.rst-01.locus (50-78-19-50-static.hfc.comcastbusiness.net. [50.78.19.50]) by smtp.gmail.com with ESMTPSA id v134-20020a81488c000000b00570253fc3e5sm2518920ywa.105.2023.09.25.11.54.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Sep 2023 11:54:40 -0700 (PDT) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH 2/8] doc: document [Rank].BandModifier2_4Ghz Date: Mon, 25 Sep 2023 11:54:16 -0700 Message-Id: <20230925185422.2242494-2-prestwoj@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230925185422.2242494-1-prestwoj@gmail.com> References: <20230925185422.2242494-1-prestwoj@gmail.com> Precedence: bulk X-Mailing-List: iwd@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 --- src/iwd.config.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/iwd.config.rst b/src/iwd.config.rst index ea366a83..294e4c7b 100644 --- a/src/iwd.config.rst +++ b/src/iwd.config.rst @@ -291,6 +291,12 @@ autoconnect purposes. :widths: 20 80 :align: left + * - BandModifier2_4Ghz + - Values: floating point value (default: **1.0**) + + Increase or decrease the preference for 2.4GHz access points by + increasing or decreasing the value of this modifier. + * - BandModifier5Ghz - Values: floating point value (default: **1.0**) From patchwork Mon Sep 25 18:54:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13398275 Received: from mail-yw1-f175.google.com (mail-yw1-f175.google.com [209.85.128.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 8576ED304 for ; Mon, 25 Sep 2023 18:54:43 +0000 (UTC) Received: by mail-yw1-f175.google.com with SMTP id 00721157ae682-59c04237bf2so91257157b3.0 for ; Mon, 25 Sep 2023 11:54:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1695668082; x=1696272882; darn=lists.linux.dev; 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=KDJU7SYD0amvWzwOGqGm/wTZR2ZpJVaE47M/yoVuMJk=; b=CDfdC9HiMtyVYjde7/GejwOv4u/m9/nAQkzNROx3Lz+xN+ZEhezzs4P1pXpd3XMi9c ZLE8s4b0p5hnT2/5gTGgoICE6uNqAD0wzC5ruYN7llHO6lQZ3na+P8Y3dCL5EsdMrS6R NwA4TNxGTX63AJJRx39HedcYfW5YnnuiKjisFc71N3iFnSZbYTG9Y7hBu/hPyNfgMpVQ ePSlfbcNWSynooaBp33lBmINxwuNUzXmO1LAl0rhHmTxbQHtkSs8pEBtB1SmVDftSU9o xWqbk0I5KoR4IpxUAADjEROHohw6R6SOATb9Qp0Qc+XAPOQSRKBMr4zeRNW5IGq9kA0U i1VA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695668082; x=1696272882; 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=KDJU7SYD0amvWzwOGqGm/wTZR2ZpJVaE47M/yoVuMJk=; b=QoSeGqWP0KxlKn9shooAzjFrsvRdjIVjFyBMIge2o4kX9wfDade/7omZEwutYKjhcV Viej+snPYG9hww03jTsoVsvKyXpt24pUUTOP/uMPenGnHtrzeyQnmUyWbOBGgKMCeyuV 3mJw1eAfOlsa9ihFOgYBAec1WP5I5OFIVlB19UKVLj+CYE+s67b9tUKcbwklahAT9+5l y1e7m0sDX6vrGgLLZJt9HwjHPyfSzjx/7cUya/9811BDt/8Byok2ffQ/Y35gCxQ2B5Bw YuaxUPZJiGq5QSMJuWuWbB3Y/lZweiM5utsZHfkJakosPj+z9avUIC5ODm0h5gYDO77i iqwQ== X-Gm-Message-State: AOJu0YygGST58qA9HmvEbA/kDFXGFvMXzT6lSNPiQzTV5S3d/XTTyQdm uGwLuURLqQl8xpvCojDHXPebnPPuGWQ= X-Google-Smtp-Source: AGHT+IH1Ov4/AHCtUMT6sJsN7JxJZDGDcPUNufhRmwAHmOhp8JUos6SO/p4qQqV86F2LhSiWJgzo+A== X-Received: by 2002:a0d:d4c6:0:b0:589:ca07:c963 with SMTP id w189-20020a0dd4c6000000b00589ca07c963mr7400187ywd.42.1695668082244; Mon, 25 Sep 2023 11:54:42 -0700 (PDT) Received: from LOCLAP699.rst-01.locus (50-78-19-50-static.hfc.comcastbusiness.net. [50.78.19.50]) by smtp.gmail.com with ESMTPSA id v134-20020a81488c000000b00570253fc3e5sm2518920ywa.105.2023.09.25.11.54.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Sep 2023 11:54:42 -0700 (PDT) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH 3/8] scan: add scan_get_band_rank_modifier Date: Mon, 25 Sep 2023 11:54:17 -0700 Message-Id: <20230925185422.2242494-3-prestwoj@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230925185422.2242494-1-prestwoj@gmail.com> References: <20230925185422.2242494-1-prestwoj@gmail.com> Precedence: bulk X-Mailing-List: iwd@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 This exposes the [Rank].BandModifier* settings so other modules can use then. Doing this will allow user-disabling of certain bands by setting these modifier values to 0.0. --- src/scan.c | 41 ++++++++++++++++++++++++++++++----------- src/scan.h | 3 +++ 2 files changed, 33 insertions(+), 11 deletions(-) diff --git a/src/scan.c b/src/scan.c index 3979dc03..915e2875 100644 --- a/src/scan.c +++ b/src/scan.c @@ -2310,6 +2310,33 @@ bool scan_get_firmware_scan(uint64_t wdev_id, scan_notify_func_t notify, return true; } +double scan_get_band_rank_modifier(enum band_freq band) +{ + const struct l_settings *config = iwd_get_config(); + double modifier; + char *str; + + switch (band) { + case BAND_FREQ_2_4_GHZ: + str = "BandModifier2_4Ghz"; + break; + case BAND_FREQ_5_GHZ: + str = "BandModifier5Ghz"; + break; + case BAND_FREQ_6_GHZ: + str = "BandModifier6Ghz"; + break; + default: + l_warn("Unhandled band %u", band); + return 0.0; + } + + if (!l_settings_get_double(config, "Rank", str, &modifier)) + modifier = 1.0; + + return modifier; +} + bool scan_wdev_add(uint64_t wdev_id) { struct scan_context *sc; @@ -2359,17 +2386,9 @@ static int scan_init(void) scan_contexts = l_queue_new(); - if (!l_settings_get_double(config, "Rank", "BandModifier2_4Ghz", - &RANK_2G_FACTOR)) - RANK_2G_FACTOR = 1.0; - - if (!l_settings_get_double(config, "Rank", "BandModifier5Ghz", - &RANK_5G_FACTOR)) - RANK_5G_FACTOR = 1.0; - - if (!l_settings_get_double(config, "Rank", "BandModifier6Ghz", - &RANK_6G_FACTOR)) - RANK_6G_FACTOR = 1.0; + RANK_2G_FACTOR = scan_get_band_rank_modifier(BAND_FREQ_2_4_GHZ); + RANK_5G_FACTOR = scan_get_band_rank_modifier(BAND_FREQ_5_GHZ); + RANK_6G_FACTOR = scan_get_band_rank_modifier(BAND_FREQ_6_GHZ); if (!l_settings_get_uint(config, "Scan", "InitialPeriodicScanInterval", &SCAN_INIT_INTERVAL)) diff --git a/src/scan.h b/src/scan.h index 0e06dabe..0db7752d 100644 --- a/src/scan.h +++ b/src/scan.h @@ -29,6 +29,7 @@ struct p2p_beacon; struct mmpdu_header; struct wiphy; enum security; +enum band_freq; enum scan_state { SCAN_STATE_NOT_RUNNING, @@ -170,5 +171,7 @@ struct scan_bss *scan_bss_new_from_probe_req(const struct mmpdu_header *mpdu, size_t body_len, uint32_t frequency, int rssi); +double scan_get_band_rank_modifier(enum band_freq band); + bool scan_wdev_add(uint64_t wdev_id); bool scan_wdev_remove(uint64_t wdev_id); From patchwork Mon Sep 25 18:54:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13398276 Received: from mail-yw1-f182.google.com (mail-yw1-f182.google.com [209.85.128.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 81BC01C29A for ; Mon, 25 Sep 2023 18:54:44 +0000 (UTC) Received: by mail-yw1-f182.google.com with SMTP id 00721157ae682-59bf1dde73fso90727247b3.3 for ; Mon, 25 Sep 2023 11:54:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1695668083; x=1696272883; darn=lists.linux.dev; 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=gznMpBSuIGSoPLrozDk4KrZiUfnRaSfloj5Jc7inXDY=; b=ZUVQPHJcuxTp3vWhxNydhCT/SCoLtVnF17JLYaT5wwZo0zhICbfjEw2xvEjOplhHUH fSot6YjGXrAG/5XFZv0MUBc2i4UtMEC5pUOgOD9RNDFJaUovgc+H4z5ygoZESwPy6r5g jRBXoHqOzlAZzgbz51vIcHwyLbWH7DnP/wgISIMuMZrD1b03JMJjMnpc335vxYlXf54U F6GZ1axwnSTqMbf6tgrNe9P4cLY7yaSzozDZLf2LL8cq+4oJXZDde1cXBWtyNmEqjU0v +Wz6iUIf0ajeW84BAplItz0b9H6BswOlttRtV8xyuTVPzwmFUM24GuKrMFqJBJkqWG3S GL1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695668083; x=1696272883; 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=gznMpBSuIGSoPLrozDk4KrZiUfnRaSfloj5Jc7inXDY=; b=El0Fhfu0kegOkbOVERZgPNs8TlxmzZmp4UGuX5MTOaPY+cYOehjcCBA68UaUXI/tz3 dnioWO10PdErzWJfUyofIm0e6X8ePzQ8TH7p9BUjyHYZAdbmmHtiZ9Em3fEgzScvY053 RfFRFJ0APaxhvk1kLS5O1b0+UvQUcaT0lDi2xnVp30Ra4CTJjZipn671fh91sSNkGeTZ lZoD6wwGOsfpbLkA5gLGSp6TljjaELzTGIvOdJDLKYgO83wjZdji+atbOulz+8+x40hd nH9PWYG/0cTAh1p65uU/P4oLTJNf7WuiOyJDFjrZFUuLsoC7ey7/Qb2jpMIejOKM2lpO 6bog== X-Gm-Message-State: AOJu0YwtLBKNjuq0b3TAhuVGCILss10azH+XXKahG3Zxt77HDYnZUKZJ 4pcPmlJ/WhyfwqUMm3AUiTWCYsmo2SQ= X-Google-Smtp-Source: AGHT+IGpNtDgpKBdKnku5zFb8/I0ybCona2ocXLuTKSiZrU99rjM90E1dIijpEtrj0QjV40TgMnl/w== X-Received: by 2002:a81:6dc2:0:b0:599:da80:e1eb with SMTP id i185-20020a816dc2000000b00599da80e1ebmr7993095ywc.24.1695668083337; Mon, 25 Sep 2023 11:54:43 -0700 (PDT) Received: from LOCLAP699.rst-01.locus (50-78-19-50-static.hfc.comcastbusiness.net. [50.78.19.50]) by smtp.gmail.com with ESMTPSA id v134-20020a81488c000000b00570253fc3e5sm2518920ywa.105.2023.09.25.11.54.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Sep 2023 11:54:43 -0700 (PDT) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH 4/8] wiphy: add wiphy_get_allowed_freqs Date: Mon, 25 Sep 2023 11:54:18 -0700 Message-Id: <20230925185422.2242494-4-prestwoj@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230925185422.2242494-1-prestwoj@gmail.com> References: <20230925185422.2242494-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 more or less copied from scan_get_allowed_freqs but is going to be needed by station (basically just saves the need for station to do the same clone/constrain sequence itself). One slight alteration is now a band mask can be passed in which provides more flexibility for additional filtering. --- src/wiphy.c | 15 +++++++++++++++ src/wiphy.h | 2 ++ 2 files changed, 17 insertions(+) diff --git a/src/wiphy.c b/src/wiphy.c index ccff701e..dcd9e210 100644 --- a/src/wiphy.c +++ b/src/wiphy.c @@ -500,6 +500,21 @@ const struct scan_freq_set *wiphy_get_supported_freqs( return wiphy->supported_freqs; } +struct scan_freq_set *wiphy_get_allowed_freqs(const struct wiphy *wiphy, + uint32_t band_mask) +{ + struct scan_freq_set *allowed = scan_freq_set_clone( + wiphy->supported_freqs, + band_mask); + + if (!wiphy_constrain_freq_set(wiphy, allowed)) { + scan_freq_set_free(allowed); + allowed = NULL; + } + + return allowed; +} + static struct band *wiphy_get_band(const struct wiphy *wiphy, enum band_freq band) { switch (band) { diff --git a/src/wiphy.h b/src/wiphy.h index 9f24d171..cabb21c4 100644 --- a/src/wiphy.h +++ b/src/wiphy.h @@ -100,6 +100,8 @@ 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); +struct scan_freq_set *wiphy_get_allowed_freqs(const struct wiphy *wiphy, + uint32_t band_mask); const struct band_freq_attrs *wiphy_get_frequency_info( const struct wiphy *wiphy, From patchwork Mon Sep 25 18:54:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13398277 Received: from mail-yw1-f181.google.com (mail-yw1-f181.google.com [209.85.128.181]) (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 BBBE4D304 for ; Mon, 25 Sep 2023 18:54:45 +0000 (UTC) Received: by mail-yw1-f181.google.com with SMTP id 00721157ae682-59c07cf02ebso86741017b3.1 for ; Mon, 25 Sep 2023 11:54:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1695668084; x=1696272884; darn=lists.linux.dev; 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=vo9GvVGIYyDfs3W76IdQbrCPVd2t4pioZMSVx3WvBmo=; b=PVPqgEKuwkSbVxehecIigMdksr/Md+bHiEcZBxzsYX9LUWsoPG+1uceEb9HiJpX+45 2gIKcCdaTwuWwZnOVCYh8wKv4k3g8HL7YN9GxbV+mKAZheu30OcqIscmKFfaCNDxsE5n SNyq21cM+UNbbqnI8NRLSzQOr8D1gPTRB1wu9NxBohiKl9c/sr8k8sL7zJs2/Yyh8+SP 30qXJHiqv3xujesfRQM+UCwE6aCFpz1utx6jpAi8+cbAYE93bFq8fS46yY2J5sChWXwt 8n3yeunt9caMnCiFsg1sSHKNBQb/y7YBJ41kB9qbWS/52MP5efkr8b73v09drEeOczSe h9ng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695668084; x=1696272884; 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=vo9GvVGIYyDfs3W76IdQbrCPVd2t4pioZMSVx3WvBmo=; b=AL+KvSIlpgcmMq/ad21eZ0BOJfYzwyi++ebcpX6+mNtcM0SqJ4fYH5s0sddYLVUzDH WvJQpPZEL5IH0Ewn6iu1cYRPbChMDVtNSHdLUuGhowWgwrTvXIDU6MIBxSwpowUZul1e vzt0VWrwzsrAdZwz5Ok0O6ATYRpT678hcLWkjfYB6LzB42oFz5AAiuD83PfWqpSKGz/+ CCoWXSsLYCmPog5IzSgwM4X+mamrISnF72j5z3Q3MN6Cwzweqiy0Vlw1IeSTRF7cTCRj b5F/p2RhyWTDn/L+kznIZ3+ZQzet8DxcMm2PxLTXLO9Mb0k1zzbvDpV9m70ax5bfH4Ns ORxg== X-Gm-Message-State: AOJu0Yzimx3dGGWLN/Wj4Mbl1+bkTZXyLYZZMr98yAiAE8v0UNlNSNOm C4GU5I6GoW+gi2PNHqdzkCSNeyw7KOk= X-Google-Smtp-Source: AGHT+IHYANLH7xVsNMNU9UOSOvu20K9QusgAStegmK2b3ELZLL2lVKiQWlgiF97T0M8U3ibAhSoG2w== X-Received: by 2002:a81:5b0a:0:b0:56c:e70b:b741 with SMTP id p10-20020a815b0a000000b0056ce70bb741mr8337768ywb.20.1695668084480; Mon, 25 Sep 2023 11:54:44 -0700 (PDT) Received: from LOCLAP699.rst-01.locus (50-78-19-50-static.hfc.comcastbusiness.net. [50.78.19.50]) by smtp.gmail.com with ESMTPSA id v134-20020a81488c000000b00570253fc3e5sm2518920ywa.105.2023.09.25.11.54.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Sep 2023 11:54:44 -0700 (PDT) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH 5/8] scan: allow splitting of scans with defined frequencies Date: Mon, 25 Sep 2023 11:54:19 -0700 Message-Id: <20230925185422.2242494-5-prestwoj@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230925185422.2242494-1-prestwoj@gmail.com> References: <20230925185422.2242494-1-prestwoj@gmail.com> Precedence: bulk X-Mailing-List: iwd@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Currently the only way a scan can be split is if the request does not specify any frequencies, implying the request should scan the entire spectrum. This allows the scan logic to issue an extra request if 6GHz becomes available during the 2.4 or 5GHz scans. This restriction was somewhat arbitrary and done to let periodic scans pick up 6GHz APs through a single scan request. But now with the addition of allowing user-disabled bands periodic scans will need to specify a frequency list in case a given band has been disabled. This will break the scan splitting code which is why this prep work is being done. The main difference now is the original scan frequencies are tracked with the scan request. The reason for this is so if a request comes in with a limited set of 6GHz frequences IWD won't end up scanning the full 6GHz spectrum later on. --- src/scan.c | 53 ++++++++++++++++++++++------------------------------- 1 file changed, 22 insertions(+), 31 deletions(-) diff --git a/src/scan.c b/src/scan.c index 915e2875..9b1cc30a 100644 --- a/src/scan.c +++ b/src/scan.c @@ -107,6 +107,8 @@ struct scan_request { * and save these since there may be additional scan commands to run. */ struct scan_freq_set *freqs_scanned; + /* Entire list of frequencies to scan */ + struct scan_freq_set *scan_freqs; }; struct scan_context { @@ -170,6 +172,7 @@ static void scan_request_free(struct wiphy_radio_work_item *item) l_queue_destroy(sr->cmds, (l_queue_destroy_func_t) l_genl_msg_unref); scan_freq_set_free(sr->freqs_scanned); + scan_freq_set_free(sr->scan_freqs); l_free(sr); } @@ -341,20 +344,6 @@ static bool scan_mac_address_randomization_is_disabled(void) return disabled; } -static struct scan_freq_set *scan_get_allowed_freqs(struct scan_context *sc) -{ - struct scan_freq_set *allowed = scan_freq_set_new(); - - scan_freq_set_merge(allowed, wiphy_get_supported_freqs(sc->wiphy)); - - if (!wiphy_constrain_freq_set(sc->wiphy, allowed)) { - scan_freq_set_free(allowed); - allowed = NULL; - } - - return allowed; -} - static struct l_genl_msg *scan_build_cmd(struct scan_context *sc, bool ignore_flush_flag, bool is_passive, const struct scan_parameters *params, @@ -582,22 +571,29 @@ static void scan_cmds_add(struct scan_request *sr, struct scan_context *sc, bool passive, const struct scan_parameters *params) { + uint32_t bands = BAND_FREQ_2_4_GHZ | BAND_FREQ_5_GHZ | BAND_FREQ_6_GHZ; unsigned int i; struct scan_freq_set *subsets[2] = { 0 }; - struct scan_freq_set *allowed = scan_get_allowed_freqs(sc); + struct scan_freq_set *allowed = wiphy_get_allowed_freqs(sc->wiphy, + bands); const struct scan_freq_set *supported = wiphy_get_supported_freqs(sc->wiphy); /* - * If 6GHz is not possible, or already allowed, or the frequencies are - * explicit don't break up the request. + * No frequencies, just include the entire supported list and let the + * kernel filter out any disabled frequencies */ + if (!params->freqs) + sr->scan_freqs = scan_freq_set_clone(supported, bands); + else + sr->scan_freqs = scan_freq_set_clone(params->freqs, bands); + + /* If 6GHz is not possible or already allowed don't split the request */ if (!(scan_freq_set_get_bands(supported) & BAND_FREQ_6_GHZ) || - (scan_freq_set_get_bands(allowed) & BAND_FREQ_6_GHZ) || - params->freqs) { + (scan_freq_set_get_bands(allowed) & BAND_FREQ_6_GHZ)) { scan_freq_set_free(allowed); scan_build_next_cmd(sr->cmds, sc, passive, - params, params->freqs); + params, sr->scan_freqs); return; } @@ -613,8 +609,8 @@ static void scan_cmds_add(struct scan_request *sr, struct scan_context *sc, * extra 6GHz-only passive scan can be appended to this request * at that time. */ - subsets[0] = scan_freq_set_clone(allowed, BAND_FREQ_2_4_GHZ); - subsets[1] = scan_freq_set_clone(allowed, BAND_FREQ_5_GHZ); + subsets[0] = scan_freq_set_clone(sr->scan_freqs, BAND_FREQ_2_4_GHZ); + subsets[1] = scan_freq_set_clone(sr->scan_freqs, BAND_FREQ_5_GHZ); scan_freq_set_free(allowed); @@ -1918,9 +1914,8 @@ static void scan_wiphy_watch(struct wiphy *wiphy, struct scan_request *sr = NULL; struct l_genl_msg *msg = NULL; struct scan_parameters params = { 0 }; - struct scan_freq_set *freqs_6ghz; struct scan_freq_set *allowed; - bool allow_6g; + _auto_(scan_freq_set_free) struct scan_freq_set *freqs_6ghz = NULL; /* Only care about completed regulatory dumps */ if (event != WIPHY_STATE_WATCH_EVENT_REGDOM_DONE) @@ -1934,14 +1929,14 @@ static void scan_wiphy_watch(struct wiphy *wiphy, if (!sr) return; - allowed = scan_get_allowed_freqs(sc); - allow_6g = scan_freq_set_get_bands(allowed) & BAND_FREQ_6_GHZ; + allowed = wiphy_get_allowed_freqs(sc->wiphy, BAND_FREQ_6_GHZ); + freqs_6ghz = scan_freq_set_clone(sr->scan_freqs, BAND_FREQ_6_GHZ); /* * This update did not allow 6GHz, or the original request was * not expecting 6GHz. The periodic scan should now be ended. */ - if (!allow_6g || !sr->split) { + if (!allowed || scan_freq_set_isempty(freqs_6ghz) || !sr->split) { scan_get_results(sc, sr, sr->freqs_scanned); goto free_allowed; } @@ -1951,13 +1946,9 @@ static void scan_wiphy_watch(struct wiphy *wiphy, * Create a new 6GHz passive scan request and append to the * command list */ - freqs_6ghz = scan_freq_set_clone(allowed, BAND_FREQ_6_GHZ); - msg = scan_build_cmd(sc, false, true, ¶ms, freqs_6ghz); l_queue_push_tail(sr->cmds, msg); - scan_freq_set_free(freqs_6ghz); - /* * If this periodic scan is at the top of the queue, continue * running it. From patchwork Mon Sep 25 18:54:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13398278 Received: from mail-yw1-f172.google.com (mail-yw1-f172.google.com [209.85.128.172]) (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 A4C6B1C29A for ; Mon, 25 Sep 2023 18:54:46 +0000 (UTC) Received: by mail-yw1-f172.google.com with SMTP id 00721157ae682-59f7cc71e2eso31628907b3.0 for ; Mon, 25 Sep 2023 11:54:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1695668085; x=1696272885; darn=lists.linux.dev; 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=wCnx4kc9nA54IsbuiKqcciAI0MXgs/shVFtiXk52sx4=; b=j7agyiZxhOAj/73bSB2ZY1uS0oU4o19zpeqpu1kqz/M+/Vh97/MLMpzP3kRMSklXfB LG55fKOjZlIj2Z2u04kZ+60A2VIN7/hE4qvGZ5hZmh/AzRehU6+1ItKmgZHPY5ecepys efpR5/LYC6UDgRGxj1Vgmg+KRchAGn+ANW8nyUWZjGht6OsQBNGOLLlhhQysyDnHkrno 1JjiPeVf75fnW0E65rIqdWecL/eJ3qkf0sc6dw39LTxBf9a4dk4Qk2kvUD7ZWyc2pM3K P3Iax9ZogPqScMk+BdEpwGd4t4u6czmtihF+6w+1UbGeajEZo+RNBLPh8EDZTNjtH4tp YNOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695668085; x=1696272885; 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=wCnx4kc9nA54IsbuiKqcciAI0MXgs/shVFtiXk52sx4=; b=TnWRqaf7cHMdKOsT6fp652rCgQSoSCnOVNEWRiyA1y8x7DxXegcmFXfHvAOWeaaZXF 909DSW9pcgLkTYJWXySIKN6hRwyXiDvl5GU2KlxOjcMp7ikEFGV7NoAwiwsz9A0Pj/5c s4wxbHtuXPYm0ZHMS6IRC3ei4DUEtlIdXZu95wkjqfaRpcqs9MDZ7wlURm5BFogtToMv 7LIvBBUo6A+F1/LnRc2yUoKRMuMKai1NZRd/o6dl24mG6/wFcGZQFUMui6X4uSOzc5R9 Fta4Kso3GkXX68FwSziksVAqS/bZ3QsSl00qQ+DnFrA7OcpQI/rsM4N4jN8GY3+iXrMf WS3Q== X-Gm-Message-State: AOJu0YwZOtY/msmFXVVXYbFjGiBsxNOER/ZLI7bm3y5GyQm1e70onrT2 tT/zWot5mUeSEsPHVQsqEJB4LPViMMI= X-Google-Smtp-Source: AGHT+IHu6i7acTpw5I0y4FxwRoP/wrSeIm6W8szuj4Mn6d9pCKFwqN/Qh/VoF77NhYy4l89ohq9SSA== X-Received: by 2002:a05:690c:2a0b:b0:59f:4c52:2f51 with SMTP id ei11-20020a05690c2a0b00b0059f4c522f51mr7737494ywb.17.1695668085576; Mon, 25 Sep 2023 11:54:45 -0700 (PDT) Received: from LOCLAP699.rst-01.locus (50-78-19-50-static.hfc.comcastbusiness.net. [50.78.19.50]) by smtp.gmail.com with ESMTPSA id v134-20020a81488c000000b00570253fc3e5sm2518920ywa.105.2023.09.25.11.54.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Sep 2023 11:54:45 -0700 (PDT) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH 6/8] scan: filter user-disabled bands for periodic scans. Date: Mon, 25 Sep 2023 11:54:20 -0700 Message-Id: <20230925185422.2242494-6-prestwoj@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230925185422.2242494-1-prestwoj@gmail.com> References: <20230925185422.2242494-1-prestwoj@gmail.com> Precedence: bulk X-Mailing-List: iwd@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 To support user-disabled bands periodic scans need to specify a frequency list filtered by any bands that are disabled. This was needed in scan.c since periodic scans don't provide a frequency list in the scan request. If no bands are disabled the allowed freqs API should still result in the same scan behavior as if a frequency list is left out i.e. IWD just filters the frequencies as opposed to the kernel. --- src/scan.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/src/scan.c b/src/scan.c index 9b1cc30a..84cf0f38 100644 --- a/src/scan.c +++ b/src/scan.c @@ -990,9 +990,53 @@ static void scan_periodic_destroy(void *user_data) sc->sp.id = 0; } +static struct scan_freq_set *scan_periodic_get_freqs(struct scan_context *sc) +{ + struct scan_freq_set *allowed; + struct scan_freq_set *band_6g; + const struct scan_freq_set *supported = + wiphy_get_supported_freqs(sc->wiphy); + uint32_t band_mask = 0; + + if (RANK_2G_FACTOR) + band_mask |= BAND_FREQ_2_4_GHZ; + if (RANK_5G_FACTOR) + band_mask |= BAND_FREQ_5_GHZ; + + allowed = wiphy_get_allowed_freqs(sc->wiphy, band_mask); + if (!RANK_6G_FACTOR) + return allowed; + + /* 2.4 and 5Ghz are disabled, this is not a workable configuration */ + if (!allowed) + return NULL; + + /* + * 6GHz is special because initially its disabled until the regdom is + * established so (unless user disabled) we should always include those + * frequencies for periodic scans. + */ + band_6g = scan_freq_set_clone(supported, BAND_FREQ_6_GHZ); + scan_freq_set_merge(allowed, band_6g); + scan_freq_set_free(band_6g); + + return allowed; +} + static bool scan_periodic_queue(struct scan_context *sc) { struct scan_parameters params = {}; + struct scan_freq_set *freqs = scan_periodic_get_freqs(sc); + + /* + * If this happens its due to the user disabling all bands. This will + * cause IWD to never issue another periodic scan so warn the user of + * this. + */ + if (L_WARN_ON(!freqs)) + return false; + + params.freqs = freqs; if (sc->sp.needs_active_scan && known_networks_has_hidden()) { params.randomize_mac_addr_hint = true; @@ -1010,6 +1054,8 @@ static bool scan_periodic_queue(struct scan_context *sc) scan_periodic_notify, sc, scan_periodic_destroy); + scan_freq_set_free(freqs); + return sc->sp.id != 0; } From patchwork Mon Sep 25 18:54:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13398279 Received: from mail-yw1-f175.google.com (mail-yw1-f175.google.com [209.85.128.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 B64F4D304 for ; Mon, 25 Sep 2023 18:54:47 +0000 (UTC) Received: by mail-yw1-f175.google.com with SMTP id 00721157ae682-59f4bc88f9fso58197227b3.2 for ; Mon, 25 Sep 2023 11:54:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1695668087; x=1696272887; darn=lists.linux.dev; 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=iDy28uXZrbGTpOP0KLpU8nD9DUXgLGSe8pMEDTV5SB4=; b=ZqhqYfd6izfmWoYVWFFNKJ81MpOmZJP7Kc+/C04Ax8HNluPDX/r4Dogr3t1MQEPoea CGk+JNKiKFO6sJFhgZIGW3cGjvwCMLpwbLesVncQ+MbKGXKVlFgKqA7vqW/nixOj+I51 jnaZdgNkOTpR1ajjwi11dKKpel1/hRXxv/vywp+qxRtptQdo8lPlzIUQaoq97eK+o5da 6mNRrcoGWNFaawMlmksG2cvKv+McktkA8vzIx55XLkReu+vcb3zKLCle5O5zOoH7XEQI FdiXiEEbtnii81NjijR9xuBTTCqY5MrVV4c2Ra8rOCm5oFdvtZ69JjzJMGcRqHwGiUHW XwbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695668087; x=1696272887; 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=iDy28uXZrbGTpOP0KLpU8nD9DUXgLGSe8pMEDTV5SB4=; b=fR9z9Ny0DqGtOyj9NhtfUdt2CT9Qsf1NFRKicp17KwYMOkjdCgn3gR1nY/WQdYhQmT vjE2qxot1imSlSKCaWs4DbA1caCw6wgibiojnkf7cCSqxhAv3IoxDMAofri12undQHDN vLoALxyKNCHmC6ti6um5BmsEpw9yx+9SZ8lWPWaeK1JbY3bx3fJFIvHm0W/t/BOqjeW6 IJpE/d4oc2P2ss0XlVKyxgiExcy3aGHKZHj+WlDtP1QdNpl9RgQN9IzaGnFVJTEGsWow ciALtu3rS7kw0NyVM/rZ5ea2A8g/j94YYbAd0i3oxG9ktsXyftkkkPKgpnvC2RFwzAdB J2Zw== X-Gm-Message-State: AOJu0YzxcTr/jVK2JheVHljWuBj9KMnv0Zl6e/+hUvGE3ekhF8DcqpYL cdiVgC7aIu6wiQ0NqaJlXTjG1H7muCs= X-Google-Smtp-Source: AGHT+IHQCiAOqxVceCwICydKYNAaDRS//P9jRS5muf5Ch2eIVCH4Lds9dWpH9SK57nfWiZEcRkoUyg== X-Received: by 2002:a0d:f2c1:0:b0:586:9c7a:d9ec with SMTP id b184-20020a0df2c1000000b005869c7ad9ecmr6939316ywf.9.1695668086672; Mon, 25 Sep 2023 11:54:46 -0700 (PDT) Received: from LOCLAP699.rst-01.locus (50-78-19-50-static.hfc.comcastbusiness.net. [50.78.19.50]) by smtp.gmail.com with ESMTPSA id v134-20020a81488c000000b00570253fc3e5sm2518920ywa.105.2023.09.25.11.54.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Sep 2023 11:54:46 -0700 (PDT) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH 7/8] station: support user-disabled bands Date: Mon, 25 Sep 2023 11:54:21 -0700 Message-Id: <20230925185422.2242494-7-prestwoj@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230925185422.2242494-1-prestwoj@gmail.com> References: <20230925185422.2242494-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 support to allow users to disable entire bands, preventing scanning and connecting on those frequencies. If the [Rank].BandModifier* options are set to 0.0 it will imply those bands should not be used for scanning, connecting or roaming. This now applies to autoconnect, quick, hidden, roam, and dbus scans. This is a station only feature meaning other modules like RRM, DPP, WSC or P2P may still utilize those bands. Trying to limit bands in those modules may sometimes conflict with the spec which is why it was not added there. In addition modules like DPP/WSC are only used in limited capacity for connecting so there is little benefit gained to disallowing those bands. --- src/station.c | 134 +++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 110 insertions(+), 24 deletions(-) diff --git a/src/station.c b/src/station.c index 9e4ee69a..8e552f84 100644 --- a/src/station.c +++ b/src/station.c @@ -73,6 +73,9 @@ static bool supports_arp_evict_nocarrier; static bool supports_ndisc_evict_nocarrier; static struct watchlist event_watches; static uint32_t known_networks_watch; +static bool band_2_4ghz_disabled; +static bool band_5ghz_disabled; +static bool band_6ghz_disabled; struct station { enum station_state state; @@ -1326,6 +1329,20 @@ static bool station_needs_hidden_network_scan(struct station *station) return !l_queue_isempty(station->hidden_bss_list_sorted); } +static struct scan_freq_set *station_get_allowed_freqs(struct station *station) +{ + uint32_t band_mask = 0; + + if (!band_2_4ghz_disabled) + band_mask |= BAND_FREQ_2_4_GHZ; + if (!band_5ghz_disabled) + band_mask |= BAND_FREQ_5_GHZ; + if (!band_6ghz_disabled) + band_mask |= BAND_FREQ_6_GHZ; + + return wiphy_get_allowed_freqs(station->wiphy, band_mask); +} + static uint32_t station_scan_trigger(struct station *station, struct scan_freq_set *freqs, scan_trigger_func_t triggered, @@ -1411,6 +1428,7 @@ static void station_quick_scan_destroy(void *userdata) static int station_quick_scan_trigger(struct station *station) { _auto_(scan_freq_set_free) struct scan_freq_set *known_freq_set = NULL; + _auto_(scan_freq_set_free) struct scan_freq_set *allowed = NULL; bool known_6ghz; if (wiphy_regdom_is_updating(station->wiphy)) { @@ -1440,9 +1458,14 @@ static int station_quick_scan_trigger(struct station *station) known_6ghz) return -ENOTSUP; - if (!wiphy_constrain_freq_set(station->wiphy, known_freq_set)) { + allowed = station_get_allowed_freqs(station); + if (L_WARN_ON(!allowed)) + return -ENOTSUP; + + scan_freq_set_constrain(known_freq_set, allowed); + + if (scan_freq_set_isempty(known_freq_set)) return -ENOTSUP; - } station->quick_scan_id = station_scan_trigger(station, known_freq_set, @@ -2656,6 +2679,11 @@ static int station_roam_scan(struct station *station, struct scan_freq_set *freq_set) { struct scan_parameters params = { .freqs = freq_set, .flush = true }; + _auto_(scan_freq_set_free) struct scan_freq_set *allowed = + station_get_allowed_freqs(station); + + if (L_WARN_ON(!allowed)) + return -ENOTSUP; l_debug("ifindex: %u", netdev_get_ifindex(station->netdev)); @@ -2666,8 +2694,14 @@ static int station_roam_scan(struct station *station, params.ssid_len = strlen(ssid); } - if (!freq_set) + if (!freq_set) { station->roam_scan_full = true; + params.freqs = allowed; + } else + scan_freq_set_constrain(freq_set, allowed); + + if (L_WARN_ON(scan_freq_set_isempty(params.freqs))) + return -ENOTSUP; station->roam_scan_id = scan_active_full(netdev_get_wdev_id(station->netdev), ¶ms, @@ -3597,6 +3631,7 @@ static struct l_dbus_message *station_dbus_connect_hidden_network( }; const char *ssid; struct network *network; + _auto_(scan_freq_set_free) struct scan_freq_set *allowed = NULL; l_debug(""); @@ -3647,6 +3682,11 @@ not_hidden: return dbus_error_not_hidden(message); } + allowed = station_get_allowed_freqs(station); + if (L_WARN_ON(!allowed)) + return dbus_error_not_supported(message); + + params.freqs = allowed; params.ssid = (const uint8_t *)ssid; params.ssid_len = strlen(ssid); @@ -4268,38 +4308,77 @@ int station_hide_network(struct station *station, struct network *network) return 0; } -static void station_add_one_freq(uint32_t freq, void *user_data) +static void station_add_6ghz_freq(uint32_t freq, void *user_data) { - struct station *station = user_data; + struct scan_freq_set *set = user_data; - if (freq > 3000) - scan_freq_set_add(station->scan_freqs_order[1], freq); - else if (!scan_freq_set_contains(station->scan_freqs_order[0], freq)) - scan_freq_set_add(station->scan_freqs_order[2], freq); + if (freq > 5935) + scan_freq_set_add(set, freq); +} + +static void station_add_5ghz_freq(uint32_t freq, void *user_data) +{ + struct scan_freq_set *set = user_data; + + if (freq > 3000 && freq < 5935) + scan_freq_set_add(set, freq); +} + +static void station_add_2_4ghz_freq(uint32_t freq, void *user_data) +{ + struct scan_freq_set *set = user_data; + + /* exclude social channels added in initial scan request */ + if (freq < 3000 && freq != 2412 && freq != 2437 && freq != 2462) + scan_freq_set_add(set, freq); } static void station_fill_scan_freq_subsets(struct station *station) { - const struct scan_freq_set *supported = - wiphy_get_supported_freqs(station->wiphy); + _auto_(scan_freq_set_free) struct scan_freq_set *allowed = + station_get_allowed_freqs(station); + unsigned int subset_idx = 0; + if (L_WARN_ON(!allowed)) + return; /* * Scan the 2.4GHz "social channels" first, 5GHz second, if supported, * all other 2.4GHz channels last. To be refined as needed. */ - station->scan_freqs_order[0] = scan_freq_set_new(); - scan_freq_set_add(station->scan_freqs_order[0], 2412); - scan_freq_set_add(station->scan_freqs_order[0], 2437); - scan_freq_set_add(station->scan_freqs_order[0], 2462); - - station->scan_freqs_order[1] = scan_freq_set_new(); - station->scan_freqs_order[2] = scan_freq_set_new(); - scan_freq_set_foreach(supported, station_add_one_freq, station); - - if (scan_freq_set_isempty(station->scan_freqs_order[1])) { - scan_freq_set_free(station->scan_freqs_order[1]); - station->scan_freqs_order[1] = station->scan_freqs_order[2]; - station->scan_freqs_order[2] = NULL; + if (!band_2_4ghz_disabled) { + station->scan_freqs_order[subset_idx] = scan_freq_set_new(); + scan_freq_set_add(station->scan_freqs_order[subset_idx], 2412); + scan_freq_set_add(station->scan_freqs_order[subset_idx], 2437); + scan_freq_set_add(station->scan_freqs_order[subset_idx], 2462); + subset_idx++; + } + + /* + * TODO: It may might sense to split up 5 and 6ghz into separate subsets + * since the channel set is so large. + */ + if (!band_5ghz_disabled || !band_6ghz_disabled) { + struct scan_freq_set *set = scan_freq_set_new(); + + if (!band_5ghz_disabled) + scan_freq_set_foreach(allowed, + station_add_5ghz_freq, set); + if (!band_6ghz_disabled) + scan_freq_set_foreach(allowed, + station_add_6ghz_freq, set); + + /* 5/6ghz didn't add any frequencies */ + if (scan_freq_set_isempty(set)) { + scan_freq_set_free(set); + } else + station->scan_freqs_order[subset_idx++] = set; + } + + /* Add remaining 2.4ghz channels to subset */ + if (!band_2_4ghz_disabled) { + station->scan_freqs_order[subset_idx] = scan_freq_set_new(); + scan_freq_set_foreach(allowed, station_add_2_4ghz_freq, + station->scan_freqs_order[subset_idx]); } } @@ -5194,6 +5273,13 @@ static int station_init(void) station_known_networks_changed, NULL, NULL); + band_2_4ghz_disabled = + scan_get_band_rank_modifier(BAND_FREQ_2_4_GHZ) == 0.0; + band_5ghz_disabled = + scan_get_band_rank_modifier(BAND_FREQ_5_GHZ) == 0.0; + band_6ghz_disabled = + scan_get_band_rank_modifier(BAND_FREQ_6_GHZ) == 0.0; + return 0; } From patchwork Mon Sep 25 18:54:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13398280 Received: from mail-yw1-f179.google.com (mail-yw1-f179.google.com [209.85.128.179]) (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 1502F1C29A for ; Mon, 25 Sep 2023 18:54:48 +0000 (UTC) Received: by mail-yw1-f179.google.com with SMTP id 00721157ae682-59f6492b415so45490217b3.0 for ; Mon, 25 Sep 2023 11:54:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1695668088; x=1696272888; darn=lists.linux.dev; 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=tCP5OJlr9budLtvEit5bo/WYeTF14cXms+AeuPeOOXE=; b=jppUDEPUzmXSHhODG7WtFvUYekqIx/v+qx+5/HDCuPoxKTluEWgRPXtZFAM4LPu7rG w8KqSHNQzUpeGpXYZD1F9lw+21nIJUnU6u4d0YNzM+vkxumaNO8GVozPdIJHtUtaDA0h QwtkCSHHnazv7bslkqeV+KGpy2YaSJ0iQjEOR5qkk6w+fw7YofPoK2lF3rddR2F5y9zB 5nCmPlCwdUabvVJwd1RERVbpC52X35SFsgf4XgRtk7MbQgbgXqQUd22NTqRUdOfMPQTK Trc/r4/iIeU7g1DTMHYRBGfi7vARaWzBMS3P2nqmYJyqMy4ru20Txar5VrNTsxAOdnfg Dksw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695668088; x=1696272888; 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=tCP5OJlr9budLtvEit5bo/WYeTF14cXms+AeuPeOOXE=; b=FHN42js3GKFBUw2y3rQH9kcYhZfc0adDbNX8p5IMj4fcvP8OFAsgHSyS1hCqc2P9jS 6EDw430K/v9nlJQkY2a7cXGtVEWrgWGICM3aMH5Jp5ss6Yfm3ASzH0MWLP2AJfxVqBk6 WUMZKDa/YA6OV7Kh29tG4Ha/G0zRcMmQa2WlCld8Tm3zS/nyYIesWY3CqCl5vaDCMyJ6 1NNgQ8ztDQgOoeoag0qO2mPYL9xPQ1TqdfEJIPs0GegqLY4nVnrk6zs/nvSOEnZKR9yU yzafOgzRP3aljhcuNGfUN1mnxWWvXxNoVJuPwac5PBT7BORvYClxBJDLB43qw5BppiXf cOJQ== X-Gm-Message-State: AOJu0YwX2WqP9Bdwr/Fn3XNJZiBWdDPacroxGgR8bhK+sDqvx3FDF1c4 ul5WopG8u2QE7KVxPaCKf8hGNSaNNt4= X-Google-Smtp-Source: AGHT+IHps3i+hNQCQVltMVmAjL8e9NHh2KzutYoYK6Dx2oLIc/1QrQwEpVIxCasfVJ0dh9S49V/Ubg== X-Received: by 2002:a81:6c55:0:b0:59b:e9d5:a41c with SMTP id h82-20020a816c55000000b0059be9d5a41cmr356379ywc.22.1695668087844; Mon, 25 Sep 2023 11:54:47 -0700 (PDT) Received: from LOCLAP699.rst-01.locus (50-78-19-50-static.hfc.comcastbusiness.net. [50.78.19.50]) by smtp.gmail.com with ESMTPSA id v134-20020a81488c000000b00570253fc3e5sm2518920ywa.105.2023.09.25.11.54.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Sep 2023 11:54:47 -0700 (PDT) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH 8/8] doc: document disabling bands with a 0.0 modifier Date: Mon, 25 Sep 2023 11:54:22 -0700 Message-Id: <20230925185422.2242494-8-prestwoj@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230925185422.2242494-1-prestwoj@gmail.com> References: <20230925185422.2242494-1-prestwoj@gmail.com> Precedence: bulk X-Mailing-List: iwd@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 --- src/iwd.config.rst | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/iwd.config.rst b/src/iwd.config.rst index 294e4c7b..be2fd18c 100644 --- a/src/iwd.config.rst +++ b/src/iwd.config.rst @@ -297,6 +297,9 @@ autoconnect purposes. Increase or decrease the preference for 2.4GHz access points by increasing or decreasing the value of this modifier. + A value of 0.0 will disable the 2.4GHz band and prevent scanning or + connecting on those frequencies. + * - BandModifier5Ghz - Values: floating point value (default: **1.0**) @@ -306,6 +309,9 @@ autoconnect purposes. networks are highly RSSI sensitive, so it is still possible for IWD to prefer 2.4Ghz APs in certain circumstances. + A value of 0.0 will disable the 5GHz band and prevent scanning or + connecting on those frequencies. + * - BandModifier6Ghz - Values: floating point value (default: **1.0**) @@ -313,6 +319,9 @@ autoconnect purposes. or decreasing the value of this modifier. Since 6GHz networks are highly RSSI sensitive, this gives an option to prefer 6GHz APs over 5GHz APs. + A value of 0.0 will disable the 6GHz band and prevent scanning or + connecting on those frequencies. + Scan ----