From patchwork Thu Dec 8 23:48:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13069066 Received: from mail-pg1-f169.google.com (mail-pg1-f169.google.com [209.85.215.169]) (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 3C2912F36 for ; Thu, 8 Dec 2022 23:48:19 +0000 (UTC) Received: by mail-pg1-f169.google.com with SMTP id 82so2463218pgc.0 for ; Thu, 08 Dec 2022 15:48:19 -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=q0mxRbNDmIrYRHrsZ3PuQADH4hrk850BmhEjhwCS4ac=; b=UqojndcLMnCPOqwH1LxZN6zwtOoQo42jm7Zl/t7ScVR5xr1A92uN+dAK/VQ4FTSwb6 +KPGdtyRC62HEAFHrwNy5NrQE3X4tVvQuguUw3VMFa2r9MWO8v79IKAyg5z4dhB/rCF4 sZ7Y3ugSIGt/QdoSg6Z4v/az1cfr2TETE9zTuyn7OKzSPcOa7zto9z+mgBg7+QidCums sohpMJAjtaZ1Ekwzv2QlZ8MR7n459+0eTf+STJGkoeNcKjfnIkoM75CDT1B6wqcYjf8d 9rx/6bjhHd0/kUA44LsKnVnufksdQ5KTD0zOrNr4vfcSuaBNH8yQbK0G/Xb6q6vljLVL jTbA== 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=q0mxRbNDmIrYRHrsZ3PuQADH4hrk850BmhEjhwCS4ac=; b=KY83XpFI8C29bo0k6gTpwAP727NIuRac/JCSeWDJa/owMfyCSjMZnJwWhz6rbxwGVJ ZPlJ6JzclSAgdiHzfpXPDa9eGvYhTCPMIEFnyKH8kA7Foh3ANtbyCTi0BFTym3kRCHnz 4B4Qmt+Bq1qpjymWoQWLsGGR31IY6a2Aq2ZNxZdcB7JIGPBTTNa3G2fPywj+AXEOJI8k 85XxqyvabNdCt6CGhdayI0UwwZp0vOlzzE9Bz/pb/KozCQxDzDmS9agGUB36HF+usyhB /3zMTsZOztcjga5zNA6vhhv2q/SCbf71ifVH406d6Pd8zFyD3CizLxME085Xe7wq8YzI VxqQ== X-Gm-Message-State: ANoB5pmg0YtRD0WTTeVbVjuYwxnGy7lYo9CYACxq56a4TSB/gxluXY9O vizUEX71HwDkfaVVRBBwaqUDdupZIcw= X-Google-Smtp-Source: AA0mqf5BumJoLaS+gltFoiYR4YVhb7jZ8srNACw7xGUFSfZmwXxJhTl31ikMdLfAlthx21Qzfca71Q== X-Received: by 2002:aa7:804a:0:b0:566:94d0:8c83 with SMTP id y10-20020aa7804a000000b0056694d08c83mr3271589pfm.7.1670543298389; Thu, 08 Dec 2022 15:48:18 -0800 (PST) Received: from jprestwo-xps.none ([50.39.160.234]) by smtp.gmail.com with ESMTPSA id f67-20020a62db46000000b005767cb32fdasm41392pfg.188.2022.12.08.15.48.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Dec 2022 15:48:17 -0800 (PST) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH 1/5] nl80211util: populate no-IR list parsing frequencies Date: Thu, 8 Dec 2022 15:48:08 -0800 Message-Id: <20221208234812.778191-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 In AP mode no-IR channels need to be known since they are effectively disabled with respect to AP operation. Parse these channels into a separate list. --- src/nl80211util.c | 11 ++++++++++- src/nl80211util.h | 3 ++- src/wiphy.c | 6 ++++-- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/nl80211util.c b/src/nl80211util.c index da36d936..396c82c2 100644 --- a/src/nl80211util.c +++ b/src/nl80211util.c @@ -502,7 +502,8 @@ 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 scan_freq_set *disabled_list, + struct scan_freq_set *no_ir_list) { uint16_t type, len; const void *data; @@ -515,6 +516,7 @@ int nl80211_parse_supported_frequencies(struct l_genl_attr *band_freqs, while (l_genl_attr_next(&nested, NULL, NULL, NULL)) { uint32_t freq = 0; bool disabled = false; + bool no_ir = false; if (!l_genl_attr_recurse(&nested, &attr)) continue; @@ -527,6 +529,9 @@ int nl80211_parse_supported_frequencies(struct l_genl_attr *band_freqs, case NL80211_FREQUENCY_ATTR_DISABLED: disabled = true; break; + case NL80211_FREQUENCY_ATTR_NO_IR: + no_ir = true; + break; } } @@ -538,6 +543,10 @@ int nl80211_parse_supported_frequencies(struct l_genl_attr *band_freqs, if (disabled && disabled_list) scan_freq_set_add(disabled_list, freq); + + if (no_ir && no_ir_list) + scan_freq_set_add(no_ir_list, freq); + } return 0; diff --git a/src/nl80211util.h b/src/nl80211util.h index 44555a25..ce1df2cd 100644 --- a/src/nl80211util.h +++ b/src/nl80211util.h @@ -59,4 +59,5 @@ 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 *disabled, + struct scan_freq_set *no_ir); diff --git a/src/wiphy.c b/src/wiphy.c index 10514572..4744e7f4 100644 --- a/src/wiphy.c +++ b/src/wiphy.c @@ -1514,7 +1514,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); + wiphy->disabled_freqs, + NULL); break; case NL80211_BAND_ATTR_RATES: @@ -1988,7 +1989,8 @@ static void wiphy_dump_callback(struct l_genl_msg *msg, continue; nl80211_parse_supported_frequencies(&attr, NULL, - wiphy->pending_freqs); + wiphy->pending_freqs, + NULL); } } } From patchwork Thu Dec 8 23:48:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13069067 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 0BDC2A480 for ; Thu, 8 Dec 2022 23:48:19 +0000 (UTC) Received: by mail-pf1-f176.google.com with SMTP id 140so2514321pfz.6 for ; Thu, 08 Dec 2022 15:48:19 -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=AY27r6VV9EGnwsY3q7cRIeqts5AhXIbdJYB/93nKAco=; b=e2xeAZ+TBkytvRDVHI0PB2C4Qi/iq7wlpvVVxrL99DkMrgvDRw6yeXrodsO3NhhgIm VyPDqwAExJSHeA2BiVCacTv5drcp530HfQInKoUBPE6IzuhJ59HbKJX2ikuylsBIhBs1 RKMTEj981wSkVwz21ZQ9cU3csdX/XMJjUrtedm5V5YM+yvsp0vzgDeyp0L3/arEoRUuP Athjwndy2nPlOOrREITl8ppHo5I5pzIpntuPgE0v6cnVdPeZpJ/5qEmwL0pFMnDDPixr W1jQYN0S/+iZ6wyLS/XrO7VDogtcN8Pi8+jY4675jpSlT8pYa9VoFpPfU2juRrDgrN/b UFKA== 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=AY27r6VV9EGnwsY3q7cRIeqts5AhXIbdJYB/93nKAco=; b=GB/QAdbpFwMBXfjZU+nq0StnMgKnRTAqwkEoik9WsWqoY2c9eA+paWCIU0bGqzROXz RlosiuB4n+wcqdXQ+KfCZwkArHvx63w2+9J2Iin5v2YLuB7h4yp9Syb8vEiHzk95EHbP /u20aQswheEarIjdr/nuITb3+VrwhoOVouIMYPq49uTgnordnyh3jAI7yTtwQNbyO0eA ZhR86r5SPMLKRHrc0n9z7+lOBoJcXlb2C86iFor5qiG1vYpYNJhL+QDAfQ3IH9u0ra5i QTq/u0zgxxEa4loB2/wTq/xcjo7ZoF+N8c/M41+itoWpsmt+aZL2mr3cndKdTYWyzYQf Ucew== X-Gm-Message-State: ANoB5pkVcZ2huleeE47GSEcCpeJRFKxwu5+N8qot6rBycZi2L+ngjdLJ pvKFLvncXZoHhFLpVuscVtP1q/ziaeo= X-Google-Smtp-Source: AA0mqf44IBZwkcJWMNCo8+VySjuAzFBpqQjbM/GJZ4dhj/LMxhMold9oEKQl1ar/DudD63s82A9i9g== X-Received: by 2002:a62:3846:0:b0:577:7cfb:a896 with SMTP id f67-20020a623846000000b005777cfba896mr3994567pfa.31.1670543299282; Thu, 08 Dec 2022 15:48:19 -0800 (PST) Received: from jprestwo-xps.none ([50.39.160.234]) by smtp.gmail.com with ESMTPSA id f67-20020a62db46000000b005767cb32fdasm41392pfg.188.2022.12.08.15.48.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Dec 2022 15:48:18 -0800 (PST) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH 2/5] wiphy: track no-IR frequencies Date: Thu, 8 Dec 2022 15:48:09 -0800 Message-Id: <20221208234812.778191-2-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.3 In-Reply-To: <20221208234812.778191-1-prestwoj@gmail.com> References: <20221208234812.778191-1-prestwoj@gmail.com> Precedence: bulk X-Mailing-List: iwd@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Track these frequencies as is done with disabled frequencies, and update on regulatory changes. AP mode needs to know if any frequencies are marked no-IR since it cannot start on these. --- src/wiphy.c | 59 ++++++++++++++++++++++++++++++++++------------------- 1 file changed, 38 insertions(+), 21 deletions(-) diff --git a/src/wiphy.c b/src/wiphy.c index 4744e7f4..af0443bc 100644 --- a/src/wiphy.c +++ b/src/wiphy.c @@ -106,7 +106,9 @@ struct wiphy { uint16_t supported_ciphers; struct scan_freq_set *supported_freqs; struct scan_freq_set *disabled_freqs; - struct scan_freq_set *pending_freqs; + struct scan_freq_set *no_ir_freqs; + struct scan_freq_set *pending_disabled_freqs; + struct scan_freq_set *pending_no_ir_freqs; struct band *band_2g; struct band *band_5g; struct band *band_6g; @@ -346,6 +348,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(); + wiphy->no_ir_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; @@ -951,7 +954,7 @@ int wiphy_estimate_data_rate(struct wiphy *wiphy, bool wiphy_regdom_is_updating(struct wiphy *wiphy) { - return wiphy->pending_freqs != NULL; + return wiphy->pending_disabled_freqs != NULL; } uint32_t wiphy_state_watch_add(struct wiphy *wiphy, @@ -1515,7 +1518,7 @@ static void parse_supported_bands(struct wiphy *wiphy, nl80211_parse_supported_frequencies(&attr, wiphy->supported_freqs, wiphy->disabled_freqs, - NULL); + wiphy->no_ir_freqs); break; case NL80211_BAND_ATTR_RATES: @@ -1921,6 +1924,16 @@ static void wiphy_setup_rm_enabled_capabilities(struct wiphy *wiphy) */ } +static void wiphy_set_pending_freqs(struct wiphy *wiphy) +{ + scan_freq_set_free(wiphy->disabled_freqs); + scan_freq_set_free(wiphy->no_ir_freqs); + wiphy->disabled_freqs = wiphy->pending_disabled_freqs; + wiphy->no_ir_freqs = wiphy->pending_no_ir_freqs; + wiphy->pending_disabled_freqs = NULL; + wiphy->pending_no_ir_freqs = NULL; +} + static void wiphy_dump_done(void *user_data) { struct wiphy *wiphy = user_data; @@ -1932,9 +1945,8 @@ 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; + + wiphy_set_pending_freqs(wiphy); WATCHLIST_NOTIFY(&wiphy->state_watches, wiphy_state_watch_func_t, wiphy, @@ -1948,12 +1960,10 @@ 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->pending_disabled_freqs || wiphy->self_managed) continue; - scan_freq_set_free(wiphy->disabled_freqs); - wiphy->disabled_freqs = wiphy->pending_freqs; - wiphy->pending_freqs = NULL; + wiphy_set_pending_freqs(wiphy); WATCHLIST_NOTIFY(&wiphy->state_watches, wiphy_state_watch_func_t, wiphy, @@ -1989,8 +1999,8 @@ static void wiphy_dump_callback(struct l_genl_msg *msg, continue; nl80211_parse_supported_frequencies(&attr, NULL, - wiphy->pending_freqs, - NULL); + wiphy->pending_disabled_freqs, + wiphy->pending_no_ir_freqs); } } } @@ -2002,15 +2012,18 @@ static bool wiphy_cancel_last_dump(struct wiphy *wiphy) /* * 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. For a self-managed wiphy just free/NULL + * pending_disabled_freqs. For a global dump each wiphy needs to be + * checked and dealt with. */ if (wiphy && wiphy->dump_id) { id = wiphy->dump_id; wiphy->dump_id = 0; - scan_freq_set_free(wiphy->pending_freqs); - wiphy->pending_freqs = NULL; + scan_freq_set_free(wiphy->pending_disabled_freqs); + scan_freq_set_free(wiphy->pending_no_ir_freqs); + wiphy->pending_disabled_freqs = NULL; + wiphy->pending_no_ir_freqs = NULL; } else if (!wiphy && wiphy_dump_id) { id = wiphy_dump_id; wiphy_dump_id = 0; @@ -2018,11 +2031,13 @@ static bool wiphy_cancel_last_dump(struct wiphy *wiphy) for (e = l_queue_get_entries(wiphy_list); e; e = e->next) { struct wiphy *w = e->data; - if (!w->pending_freqs || w->self_managed) + if (!w->pending_disabled_freqs || w->self_managed) continue; - scan_freq_set_free(w->pending_freqs); - w->pending_freqs = NULL; + scan_freq_set_free(w->pending_disabled_freqs); + scan_freq_set_free(w->pending_no_ir_freqs); + w->pending_disabled_freqs = NULL; + w->pending_no_ir_freqs = NULL; } } @@ -2068,7 +2083,8 @@ 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(); + wiphy->pending_disabled_freqs = scan_freq_set_new(); + wiphy->pending_no_ir_freqs = scan_freq_set_new(); if (no_start_event) return; @@ -2088,7 +2104,8 @@ static void wiphy_dump_after_regdom(struct wiphy *wiphy) if (w->self_managed) continue; - w->pending_freqs = scan_freq_set_new(); + w->pending_disabled_freqs = scan_freq_set_new(); + w->pending_no_ir_freqs = scan_freq_set_new(); if (no_start_event) continue; From patchwork Thu Dec 8 23:48:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13069068 Received: from mail-pg1-f175.google.com (mail-pg1-f175.google.com [209.85.215.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 C5180A481 for ; Thu, 8 Dec 2022 23:48:20 +0000 (UTC) Received: by mail-pg1-f175.google.com with SMTP id q1so2414373pgl.11 for ; Thu, 08 Dec 2022 15:48: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=WwIPX9bbyRBJ9GAUhiMDkxeqX6k978DcUsJ7JFHVGdo=; b=ZKF+Xo14VsuR91UGC8vv7wAYBlYj6iAt3N17nhgBA2BgDHJxGr1AEV0jDbES7KUGc3 HY2xSJSSdGf8xFff+yJJuCUS5GToY3vwqV7Vs2NZAC88LXh66xfAma/6n1mmMK/CFp7Z X0VtqCgEnPb4DxfmNyvl7sSGeMvWe5y/SLKt4Cj6fD9NgYt96LUPFJ09OcPI5PFn0RHL v7vskYjnlYVDRc66cKal9+OhKJUynacbErl/UFy7ORJHC0P8WfXmfV+gr1+8O519/ByP WAK+BmGHG2GkaNl2+0DMaFiUNc5DribP6KK1ST8s9+quG/t/c8BqVSjzHrL/MD2ttfIA LNTg== 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=WwIPX9bbyRBJ9GAUhiMDkxeqX6k978DcUsJ7JFHVGdo=; b=np4qukEniMqXzEcPLG3vWL87EJ9hawIHzOM0c00/QYd4RqfPwMyrjlpPJNQa+qKRse k6SQvtOToTekza38nPxEB21uVBWDt06WoNd+pFGKrfobdA237iz1flGt5TdSSJjfZLdz 67uHYtr9dLiLcSDrhOP56roDujFVoc8/Wmp+KtKn7gR4GJgxIED4mV0Ke4ZGipPrcz7W u39p5E0RkpNGj0jQ1I/vKQT+Eb1bufljXTWiRfIZSUvRuKa1wYpvU1U84tR8RFcGvnwZ 3T+WJJXhMg0LgXRIUBJn5CMX7CXIGtGxNz4wIVzECpXP3N0EBSiCn8tOlJLBhH9E9uHr S6cQ== X-Gm-Message-State: ANoB5pk+PnTeQ0M17emu0JtCvpmvbPEvvCYYq+I0YNFbqS/QN5aXLmv6 9fT7r84TB1MmD8DfCVfeqsrsLZclAm4= X-Google-Smtp-Source: AA0mqf43Bc1NY3c+yBgIqbBYzoHEjhxH+DxMUt8evjz5XlCrK7OtOLJOszIvU9ao9W2pYdg9QWw15Q== X-Received: by 2002:a05:6a00:705:b0:566:900e:1023 with SMTP id 5-20020a056a00070500b00566900e1023mr3099181pfl.3.1670543300103; Thu, 08 Dec 2022 15:48:20 -0800 (PST) Received: from jprestwo-xps.none ([50.39.160.234]) by smtp.gmail.com with ESMTPSA id f67-20020a62db46000000b005767cb32fdasm41392pfg.188.2022.12.08.15.48.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Dec 2022 15:48:19 -0800 (PST) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH 3/5] wiphy: add wiphy_get_no_ir_freqs Date: Thu, 8 Dec 2022 15:48:10 -0800 Message-Id: <20221208234812.778191-3-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.3 In-Reply-To: <20221208234812.778191-1-prestwoj@gmail.com> References: <20221208234812.778191-1-prestwoj@gmail.com> Precedence: bulk X-Mailing-List: iwd@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Similar to supported/disabled, returns a list of frequencies which were flagged as no-IR. --- src/wiphy.c | 5 +++++ src/wiphy.h | 1 + 2 files changed, 6 insertions(+) diff --git a/src/wiphy.c b/src/wiphy.c index af0443bc..593679df 100644 --- a/src/wiphy.c +++ b/src/wiphy.c @@ -499,6 +499,11 @@ const struct scan_freq_set *wiphy_get_disabled_freqs(const struct wiphy *wiphy) return wiphy->disabled_freqs; } +const struct scan_freq_set *wiphy_get_no_ir_freqs(const struct wiphy *wiphy) +{ + return wiphy->no_ir_freqs; +} + 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 f8de7e0e..40aa75fa 100644 --- a/src/wiphy.h +++ b/src/wiphy.h @@ -99,6 +99,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); +const struct scan_freq_set *wiphy_get_no_ir_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 Thu Dec 8 23:48: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: 13069069 Received: from mail-pg1-f175.google.com (mail-pg1-f175.google.com [209.85.215.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 A3D1E2F36 for ; Thu, 8 Dec 2022 23:48:21 +0000 (UTC) Received: by mail-pg1-f175.google.com with SMTP id 142so2439688pga.1 for ; Thu, 08 Dec 2022 15:48: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=zuJ/j7yzCVtHI7ExfN8DgABz0kInSEgciLBQlbjZgTc=; b=XtPPVWl+vSSbR8czdY7SP0X3UgX7Vq5hrneLWTD1Lqsoit8uiQjB3WEWGdSUggQil0 W5Typxjw4NuhqmWMgSxhXGGpAq6w74vB507DXK2YrbK1xTqgz2HgYkliXOIRmasdoqHv RP2AZzBXR6j+Rob/AxOpwzaPlxHZuh+C2M8JhIwOlygoKOIJM9GITnYVH7eA2Jj7Y5Ev ifIBEDymbaYJrpyeZlS/LyAoren71X+Z3feOCEJFaSTWfls5dZ4AAjmY0soye+a+TCKY I2S00HYJj2ZC9D2gRnmyhgYzIEL9k27SpU3Iai0066oLvolhkO8q0KRhRbDk/4WahLd8 GCxg== 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=zuJ/j7yzCVtHI7ExfN8DgABz0kInSEgciLBQlbjZgTc=; b=sOZXE+QMIUZ2waV2ChY67CxMLNbkXETINLrmA3cnSXbnYPudlSaccIOT7B7P4oSX91 4TUCzgHoUOSa/lycs7cBsDr4SBDV8Dqp16jnZcUrlFyjXA8vC6sqoALuOImK0/L+8V8W 4uxwJoc8acUumZjtDkrDNaAkcgFNbc6g8RHZ3NSdthNcu744DUa/UR7pCeWSuFniNUbp nxFzV3rzB7xrK9LzrfXt0cDnOTgYVL0WkPpU182xeaRUYHLRKHSTcknAbz1APw2d63Pk um/p6RyhNeKfL+EMTIWGT7YDTRy55D3E7UnW/Q16zK1z3u+hLC1oF2ICJhqtUAobpcey kpAA== X-Gm-Message-State: ANoB5pmf6gHfOkJUYutCK/9WR4yYq8QIIja3mLFCE/CY9laNDCKPrhQa w2Yp7njPANaTUGP1aIQNzEHhsVuMzh0= X-Google-Smtp-Source: AA0mqf7VPk/CEz7P01NN49N38ex0zFO/0gGwnp6FasYQYYMHWOUlWFmWQKwYA4h9xL+0Lw8RCCC8bw== X-Received: by 2002:a62:e812:0:b0:576:ddd4:6a02 with SMTP id c18-20020a62e812000000b00576ddd46a02mr4047766pfi.22.1670543300928; Thu, 08 Dec 2022 15:48:20 -0800 (PST) Received: from jprestwo-xps.none ([50.39.160.234]) by smtp.gmail.com with ESMTPSA id f67-20020a62db46000000b005767cb32fdasm41392pfg.188.2022.12.08.15.48.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Dec 2022 15:48:20 -0800 (PST) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH 4/5] ap: add support for 5GHz frequencies in AP mode Date: Thu, 8 Dec 2022 15:48:11 -0800 Message-Id: <20221208234812.778191-4-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.3 In-Reply-To: <20221208234812.778191-1-prestwoj@gmail.com> References: <20221208234812.778191-1-prestwoj@gmail.com> Precedence: bulk X-Mailing-List: iwd@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 This enables IWD to use 5GHz frequencies in AP mode. Only profile based AP's can use this feature since additional information is needed. A new profile key [General].Band was added which is optional and expects a string, either "2.4GHz" or "5GHz". The existing Channel key can then be used to specify any 5GHz channel. It should be noted that the system will probably need a regulatory domain set in order for 5GHz to be allowed in AP mode. This is due to world roaming (00) restricting any/all 5GHz frequencies. This can be accomplished by setting main.conf [General].Country=CC to the country this AP will operate in. --- src/ap.c | 91 +++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 83 insertions(+), 8 deletions(-) diff --git a/src/ap.c b/src/ap.c index 69412174..7608ab23 100644 --- a/src/ap.c +++ b/src/ap.c @@ -70,6 +70,7 @@ struct ap_state { char ssid[33]; char passphrase[64]; uint8_t psk[32]; + enum band_freq band; uint8_t channel; uint8_t *authorized_macs; unsigned int authorized_macs_num; @@ -985,7 +986,7 @@ static uint32_t ap_send_mgmt_frame(struct ap_state *ap, frame_xchg_cb_t callback, void *user_data) { - uint32_t ch_freq = band_channel_to_freq(ap->channel, BAND_FREQ_2_4_GHZ); + uint32_t ch_freq = band_channel_to_freq(ap->channel, ap->band); uint64_t wdev_id = netdev_get_wdev_id(ap->netdev); struct iovec iov[2]; @@ -2408,7 +2409,7 @@ static struct l_genl_msg *ap_build_cmd_start_ap(struct ap_state *ap) uint32_t nl_akm = CRYPTO_AKM_PSK; uint32_t wpa_version = NL80211_WPA_VERSION_2; uint32_t auth_type = NL80211_AUTHTYPE_OPEN_SYSTEM; - uint32_t ch_freq = band_channel_to_freq(ap->channel, BAND_FREQ_2_4_GHZ); + uint32_t ch_freq = band_channel_to_freq(ap->channel, ap->band); uint32_t ch_width = NL80211_CHAN_WIDTH_20; unsigned int i; @@ -3170,6 +3171,45 @@ static char **ap_ciphers_to_strv(uint16_t ciphers) return list; } +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; + const struct scan_freq_set *no_ir; + uint32_t freq; + + if (!(wiphy_get_supported_bands(wiphy) & ap->band)) { + l_error("AP hardware does not support band"); + return -EINVAL; + } + + freq = band_channel_to_freq(ap->channel, ap->band); + if (!freq) { + l_error("AP invalid band (%s) and channel (%u) combination", + (ap->band & BAND_FREQ_5_GHZ) ? "5Ghz" : "2.4GHz", + ap->channel); + return false; + } + + supported = wiphy_get_supported_freqs(wiphy); + disabled = wiphy_get_disabled_freqs(wiphy); + no_ir = wiphy_get_no_ir_freqs(wiphy); + + if (!scan_freq_set_contains(supported, freq)) { + l_error("AP hardware does not support frequency %u", freq); + return false; + } + + if (scan_freq_set_contains(disabled, freq) || + scan_freq_set_contains(no_ir, freq)) { + l_error("AP hardware has frequency %u disabled or no-IR", freq); + return false; + } + + return true; +} + static int ap_load_config(struct ap_state *ap, const struct l_settings *config, bool *out_cck_rates) { @@ -3210,13 +3250,26 @@ static int ap_load_config(struct ap_state *ap, const struct l_settings *config, if (err) return err; + strval = l_settings_get_string(config, "General", "Band"); + if (strval) { + if (!strcmp(strval, "2.4GHz")) + ap->band = BAND_FREQ_2_4_GHZ; + else if (!strcmp(strval, "5GHz")) + ap->band = BAND_FREQ_5_GHZ; + else { + l_error("AP Band value unsupported: %s", strval); + return -EINVAL; + } + + l_free(l_steal_ptr(strval)); + } else + ap->band = BAND_FREQ_2_4_GHZ; + if (l_settings_has_key(config, "General", "Channel")) { unsigned int uintval; if (!l_settings_get_uint(config, "General", "Channel", - &uintval) || - !band_channel_to_freq(uintval, - BAND_FREQ_2_4_GHZ)) { + &uintval)) { l_error("AP Channel value unsupported"); return -EINVAL; } @@ -3224,7 +3277,12 @@ static int ap_load_config(struct ap_state *ap, const struct l_settings *config, ap->channel = uintval; } else /* TODO: Start a Get Survey to decide the channel */ - ap->channel = 6; + ap->channel = (ap->band & BAND_FREQ_2_4_GHZ) ? 6 : 36; + + if (!ap_validate_band_channel(ap)) { + l_error("AP Band and Channel combination invalid"); + return -EINVAL; + } strval = l_settings_get_string(config, "WSC", "DeviceName"); if (strval) { @@ -3300,9 +3358,26 @@ static int ap_load_config(struct ap_state *ap, const struct l_settings *config, return -EINVAL; } + /* + * If CCK Rates are used with 5GHz the AP will start but any + * linux-based (maybe others?) station will reject + * authentications and log: + * + * "No legacy rates in association response" + * + * This isn't outlined in 802.11, and a proper fix is to use + * the rates the hardware supports as noted by the TODO in + * ap_start(). For now don't allow CCK rates with 5GHz. + */ + if (!boolval && (ap->band & BAND_FREQ_5_GHZ)) { + l_error("AP [General].NoCCKRates must be true for 5GHz " + " band"); + return -EINVAL; + } + *out_cck_rates = !boolval; } else - *out_cck_rates = true; + *out_cck_rates = (ap->band & BAND_FREQ_2_4_GHZ); cipher_mask = wiphy_get_supported_ciphers(wiphy, IE_GROUP_CIPHERS); @@ -4080,7 +4155,7 @@ static bool ap_dbus_property_get_freq(struct l_dbus *dbus, if (!ap_if->ap || !ap_if->ap->started) return false; - freq = band_channel_to_freq(ap_if->ap->channel, BAND_FREQ_2_4_GHZ); + freq = band_channel_to_freq(ap_if->ap->channel, ap_if->ap->band); l_dbus_message_builder_append_basic(builder, 'u', &freq); From patchwork Thu Dec 8 23:48: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: 13069070 Received: from mail-pf1-f172.google.com (mail-pf1-f172.google.com [209.85.210.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 91C6EA481 for ; Thu, 8 Dec 2022 23:48:22 +0000 (UTC) Received: by mail-pf1-f172.google.com with SMTP id 21so2519017pfw.4 for ; Thu, 08 Dec 2022 15:48: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=MkWXHL9QpRN0P17qHhHjwOyYSxwizyQuhCSmiEKlic8=; b=WIq0VtzNUtIvVPkmV7BO93UcyQLZPJtbtOcdnUDb6K7Qsd/NrJvRfUQURcMVuMkE0L HuxIm9L8r+X4j8fgOBwnmjX0J13b3jfmmIqMba/S54ZQzykoAu4j0nfEpXYNpuEqQTnE PF097UQroYeu6LqzVwe/nw6mwZ/0yeq1rnlB2S/vY4L+CW9KpE4S3taM3Wv9mXnsMxEl FU3ibehUPNrtC5uTuGqt90bSy3aSjDR/ETarWy+86CXkXjnRG7HIVUs+U2sATZ+09BlJ 5JrJaxgHJ4figOuMPcMofp3LAZx7NfV5vK1BCPDWhsPEGbTvz3If12qdN3VEaMmGUU+U 7zNg== 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=MkWXHL9QpRN0P17qHhHjwOyYSxwizyQuhCSmiEKlic8=; b=XSlLLUx2MAkBQp1MQS5vlsUdK3Z/K/DCcSkPYRhfvbpjO9FphAzfkt7oNJwvV0dq+a eGaQKB3gqdAtgmh6moTLC1O5Aeuptct6ubg+plryPkVb2XjwQWyX3a5Nh3iQu752Ss9X +MTe5390iOU2m7sODVSztS4CeTv/L8zG6WVRoQPeDFLkZgmLdtfaWudmIfNioq9a0XWH KeN1OZ52cqID0Aixr1krkykniDJLbxkihq5PVS1Al9ShyHuKtf/rGbNnUzLa25N+lrH9 UIVc8Q6K0LCokzvNmo1MZ41mcdL8sY5NxWu/8FumAqqwAOizMdui547CLunIutzS9yOP y9iQ== X-Gm-Message-State: ANoB5plExfvDaa9fUObX4+S1CPmogV6AXKEfyocZr6Oywg89hnrbPDcL tGjmK3ZTqZqpPAriHG13NTXlLtd62Bs= X-Google-Smtp-Source: AA0mqf7R+XDaU6loTHJYJAt2BNvyMrP8K6imm184I2AFm0RrW/CL5QYT7rwlhvkDQpHjBIGY82A87Q== X-Received: by 2002:a62:ee14:0:b0:566:900d:6073 with SMTP id e20-20020a62ee14000000b00566900d6073mr3067726pfi.24.1670543301879; Thu, 08 Dec 2022 15:48:21 -0800 (PST) Received: from jprestwo-xps.none ([50.39.160.234]) by smtp.gmail.com with ESMTPSA id f67-20020a62db46000000b005767cb32fdasm41392pfg.188.2022.12.08.15.48.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Dec 2022 15:48:21 -0800 (PST) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH 5/5] doc: document new AP profile key: [General].Band Date: Thu, 8 Dec 2022 15:48:12 -0800 Message-Id: <20221208234812.778191-5-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.3 In-Reply-To: <20221208234812.778191-1-prestwoj@gmail.com> References: <20221208234812.778191-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.ap.rst | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/iwd.ap.rst b/src/iwd.ap.rst index 7b8844e7..22d307e1 100644 --- a/src/iwd.ap.rst +++ b/src/iwd.ap.rst @@ -52,11 +52,23 @@ The group ``[General]`` contains general AP configuration. :widths: 20 80 :align: left + * - Band + - Frequency band + + Band the access point will operate on. This is optional and if omitted + the 2.4GHz band will be used. Value should be "2.4GHz" or "5GHz". + + Note: Due to regulatory requirements the linux kernel does not allow or + strictly limits 5GHz use in AP mode while in world roaming. These + frequencies become available once the country is set, either via IWD's + main.conf option ``[General].Country`` (see ``man iwd.config``) or + externally (e.g. iw reg set ). + * - Channel - Channel number - Optional channel number for the access point to operate on. Only the - 2.4GHz-band channels are currently allowed. + Optional channel number for the access point to operate on. If omitted + the channel will be chosen automatically. Network Authentication Settings -------------------------------