From patchwork Thu Mar 24 14:19:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Escande X-Patchwork-Id: 1609071 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=DGJBxVol; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=gZOvQ0Cu; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KPS8k31yNz9s1l for ; Fri, 25 Mar 2022 01:21:58 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=b73fB5Y8aLWKPPKabMmbOhv5rpz+lqnNTvJOoXx+JYg=; b=DGJBxVoltNaA/f L5ErQRFhvgGNI86zjfftW5Tfg9m264fAq/RJyB5QRTPcbI/6LYhmCsKLIkGZe++WEyNSLuaMmVztC fOEFuk97FGi213Re8FAi5kWJPK/bTkmVquUPwk7jACJS1Iyc+Ylt3bbMb+ASMTzziwREatCB6gTgS GR0azzXIIRuVRdv00Lwl1T2TjNCRMutDXaoUS+WoM1vEPGPqSzcDWOIGsfOej7+cHJORNIetc9qCL PEySx2l8W8sKCnnRet0XcSKqY5PRxhFV5b7JFuYiV86hrMDKUDASqrKdiGHuXeAb7rFZnEJaPp4t3 OovvqKw2vu+GYvLfTzvQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nXOKh-00Gqj1-JW; Thu, 24 Mar 2022 14:20:59 +0000 Received: from mail-wr1-x42c.google.com ([2a00:1450:4864:20::42c]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nXOJX-00Gq7Y-F4 for hostap@lists.infradead.org; Thu, 24 Mar 2022 14:19:48 +0000 Received: by mail-wr1-x42c.google.com with SMTP id j18so6848257wrd.6 for ; Thu, 24 Mar 2022 07:19:46 -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=J5VYFbcgJxvmWWsnbqvsv7zcVXE1fuIi8lgMpHIn1HI=; b=gZOvQ0CuDA+EdKtQVj8JqqKX0uZON7FwmPxSb/FONen6UHEKGaUA2m9JwV+KXfhKx+ W9SFoofSbMaKzm1o1e65UHpfZmmbzil/3QjfQ0oV4Kre3dViUs14ZljD/phpBEKccYS8 s5c+/Tf9lxjrW01O6JjsL2GICvBNp1jG/DZfhur5D2S8wwak3XKPJBe9W/RE6BqNUBYs M50LUVJWJcloQ/LlISMgBAYhx+qjzneBJrevRC5SRmLZn5qtvg/o5p2PlojAUKCvz3tY LUhfYfQRRig4JbOuEfOc4dt22gXaPyWlpzChF+JZVBaZXX6PUfcIQkntEq25jrsB6nKg IBow== 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=J5VYFbcgJxvmWWsnbqvsv7zcVXE1fuIi8lgMpHIn1HI=; b=VmiqbKKzi+MpcQHReRlsk3s2IlJIPlAHUBxBKJWlro7QkvsGZuoNh2R9A8X55LdOlJ 6trq2jfI9r7wLRIzKvUMvjR29Df1bmb/7GC8fFCIz5t+69Rswu7runvOKBVBFfk3kG/q zVLxP2sjTKGDqcpvD2JliGReGqH6MoG2t+A6lmfLHiDyCVw9bd6DavvWR+wy2NoaK5pa q6ZJ9oxFWDuwfb9UV8uKDSCiMOyylSp7o3TV40ZTZYSgAw27wisXb7xpon2NEZlrwHbt 69jSj90a/4KJZ9YiaYtrU2codNoBTcFJ7JraGjP5soWCC6AtJBT3Vg3tBj/dkqwzz60y Voqg== X-Gm-Message-State: AOAM531sebjPEko8ulQunN9IjCc21+ue/TkBlrWiK+9MIy79aksJ91d9 z3RsyMlTfne7sUjD6oGi+NDdAKDl4Pg= X-Google-Smtp-Source: ABdhPJwGsu66H7eLk5LCjmsAz62/MUvm/HS3l45g+2XmOrSe8Ev3IE3rQS0GD9iveuX+AdqmbbsDsw== X-Received: by 2002:a5d:4887:0:b0:203:dde4:c770 with SMTP id g7-20020a5d4887000000b00203dde4c770mr4819347wrq.20.1648131585507; Thu, 24 Mar 2022 07:19:45 -0700 (PDT) Received: from syracuse.iliad.local (freebox.vlq16.iliad.fr. [213.36.7.13]) by smtp.gmail.com with ESMTPSA id n65-20020a1c2744000000b003862bfb509bsm6776422wmn.46.2022.03.24.07.19.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Mar 2022 07:19:45 -0700 (PDT) From: Nicolas Escande To: hostap@lists.infradead.org Cc: Nicolas Escande Subject: [RFC PATCH 2/4] ACS: introduce acs_get_bwXXX_center_chan Date: Thu, 24 Mar 2022 15:19:18 +0100 Message-Id: <20220324141920.317515-3-nico.escande@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220324141920.317515-1-nico.escande@gmail.com> References: <20220324141920.317515-1-nico.escande@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220324_071947_548550_53548D7A X-CRM114-Status: GOOD ( 16.07 ) X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: When using 40/80/160MHz, instead of computing the segment center freq based on the selected channel, lets look it up in the bwXXX_seg table. This is preparative work to allow selecting a primary channel which is not the first of the segment. Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:42c listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [nico.escande[at]gmail.com] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: hostap@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Hostap" Errors-To: hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org When using 40/80/160MHz, instead of computing the segment center freq based on the selected channel, lets look it up in the bwXXX_seg table. This is preparative work to allow selecting a primary channel which is not the first of the segment. Signed-off-by: Nicolas Escande --- src/ap/acs.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 46 insertions(+), 6 deletions(-) diff --git a/src/ap/acs.c b/src/ap/acs.c index 40df377f0..30f2e8d08 100644 --- a/src/ap/acs.c +++ b/src/ap/acs.c @@ -403,6 +403,19 @@ static int acs_usable_bw40_chan(const struct hostapd_channel_data *chan) } +static int acs_get_bw40_center_chan(int freq) +{ + unsigned int i; + + for (i = 0; i < ARRAY_SIZE(bw40_seg); i++) + if (freq >= bw40_seg[i].first && + freq < bw40_seg[i].last + 1) + return bw40_seg[i].center_chan; + + return 0; +} + + const struct { int first; int last; @@ -429,6 +442,19 @@ static int acs_usable_bw80_chan(const struct hostapd_channel_data *chan) } +static int acs_get_bw80_center_chan(int freq) +{ + unsigned int i; + + for (i = 0; i < ARRAY_SIZE(bw80_seg); i++) + if (freq >= bw80_seg[i].first && + freq < bw80_seg[i].last + 1) + return bw80_seg[i].center_chan; + + return 0; +} + + const struct { int first; int last; @@ -451,6 +477,19 @@ static int acs_usable_bw160_chan(const struct hostapd_channel_data *chan) } +static int acs_get_bw160_center_chan(int freq) +{ + unsigned int i; + + for (i = 0; i < ARRAY_SIZE(bw160_seg); i++) + if (freq >= bw160_seg[i].first && + freq < bw160_seg[i].last + 1) + return bw160_seg[i].center_chan; + + return 0; +} + + static int acs_survey_is_sufficient(struct freq_survey *survey) { if (!(survey->filled & SURVEY_HAS_NF)) { @@ -944,19 +983,21 @@ bw_selected: static void acs_adjust_center_freq(struct hostapd_iface *iface) { - int offset; + int center; wpa_printf(MSG_DEBUG, "ACS: Adjusting VHT center frequency"); switch (hostapd_get_oper_chwidth(iface->conf)) { case CHANWIDTH_USE_HT: - offset = 2 * iface->conf->secondary_channel; + center = (iface->conf->secondary_channel) ? + acs_get_bw40_center_chan(iface->freq): + iface->conf->channel; break; case CHANWIDTH_80MHZ: - offset = 6; + center = acs_get_bw80_center_chan(iface->freq); break; case CHANWIDTH_160MHZ: - offset = 14; + center = acs_get_bw160_center_chan(iface->freq); break; default: /* TODO: How can this be calculated? Adjust @@ -966,8 +1007,7 @@ static void acs_adjust_center_freq(struct hostapd_iface *iface) return; } - hostapd_set_oper_centr_freq_seg0_idx(iface->conf, - iface->conf->channel + offset); + hostapd_set_oper_centr_freq_seg0_idx(iface->conf, center); }