From patchwork Mon Oct 26 12:31:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?0JzQsNGA0LrQvtCyINCc0LjRhdCw0LjQuyDQkNC70LXQutGB0LDQvdC00YDQvtCy0LjRhw==?= X-Patchwork-Id: 1388355 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=205.233.59.134; helo=merlin.infradead.org; envelope-from=hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=itmh.ru Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=merlin.20170209 header.b=wsb/Uic6; dkim-atps=neutral Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (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 ozlabs.org (Postfix) with ESMTPS id 4CL5df0tt6z9sSs for ; Tue, 27 Oct 2020 20:15:18 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:To:From: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=/toDlqbYf3RLEtloBinJ67Bcgqiatj+/4sre9bEWcrQ=; b=wsb/Uic6lt9tH1mIzxs99uYzKi z4mx/RUEB9p7xUg9VsLLOX0h5Umh0O9oHzNTWFCvYZuyLF5bnG0KLmah8utnOe74LNFd4iqzDcfcb wL2MOJdMWXXtJB30LaKrzhEZirIDWMTCN5TkeUw1XtHmFjjcHMJdqgBtjthof7SrNkPvlPTAfEPZj zNQqBonjiDyMJBqY0brLKhOcMPj3w3MOCVeXoEMzeEGHqnoYwE6nmqySUUR73lBJb4g532ShEUl7V aEP3P6FK8b/Uoo1b2t8kN1ba2a7yzMa0PD8H4IMkHCDi4yhs/IoyeFNYBoBgA3Ce/fwG+RAzGvZLN iPjsFFSQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kXL1n-0008HV-1q; Tue, 27 Oct 2020 09:12:27 +0000 Received: from pechkin.mail.miralogic.ru ([212.49.119.90]) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kX1fK-00075m-QY for hostap@lists.infradead.org; Mon, 26 Oct 2020 12:31:59 +0000 Received: from mail.itmh.ru (unknown [IPv6:2a02:17d0:810a:100::2]) by pechkin.mail.miralogic.ru (Postfix) with ESMTP id 1C8B442F55; Mon, 26 Oct 2020 17:31:58 +0500 (YEKT) Received: from arden.corp.itmh.ru (2a02:17d0:810a:100::2) by arden.corp.itmh.ru (2a02:17d0:810a:100::2) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Mon, 26 Oct 2020 17:31:59 +0500 Received: from arden.corp.itmh.ru ([fe80::a5a9:460a:d0d8:f5cb]) by arden.corp.itmh.ru ([fe80::a5a9:460a:d0d8:f5cb%12]) with mapi id 15.00.1497.000; Mon, 26 Oct 2020 17:31:59 +0500 From: =?koi8-r?b?7cHSy8/XIO3JyMHJzCDhzMXL08HOxNLP18ne?= To: "hostap@lists.infradead.org" Subject: [RFC AP: ACS: select primary channel for 5G-band based on interference factor Thread-Topic: [RFC AP: ACS: select primary channel for 5G-band based on interference factor Thread-Index: AQHWq5P/61Gx9sFTN0OVwXhfBxX9NA== Date: Mon, 26 Oct 2020 12:31:59 +0000 Message-ID: <1603715517413.92611@itmh.ru> Accept-Language: ru-RU, en-US Content-Language: ru-RU X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [2a02:17d0:8118:10a::2] MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201026_083159_173818_A37C3FF9 X-CRM114-Status: GOOD ( 12.37 ) X-Spam-Score: 0.0 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record X-Mailman-Approved-At: Tue, 27 Oct 2020 05:12:24 -0400 X-BeenThere: hostap@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "illumin@yandex.ru" Sender: "Hostap" Errors-To: hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Make ACS algorithm select the best channel within a bandwidth as primary channel instead of just picking the first one. The reason i had to add acs_adjust_sec_chan is because even if i use VHT80 ieee80211n_allowed_ht40_channel_pair -> allowed_ht40_channel_pair check fails and i get fallback to 20 MHz. Signed-off-by: Markov Mikhail --- src/ap/acs.c | 42 ++++++++++++++++++++++++++++++++++-------- src/ap/ap_config.h | 1 + 2 files changed, 35 insertions(+), 8 deletions(-) diff --git a/src/ap/acs.c b/src/ap/acs.c index aa2ceb0d1..1ac37271d 100644 --- a/src/ap/acs.c +++ b/src/ap/acs.c @@ -642,9 +642,10 @@ acs_find_ideal_chan_mode(struct hostapd_iface *iface, int n_chans, u32 bw, struct hostapd_channel_data **rand_chan, struct hostapd_channel_data **ideal_chan, + struct hostapd_channel_data **first_chan, long double *ideal_factor) { - struct hostapd_channel_data *chan, *adj_chan = NULL; + struct hostapd_channel_data *chan, *adj_chan = NULL, *pri_chan; long double factor; int i, j; unsigned int k; @@ -653,7 +654,7 @@ acs_find_ideal_chan_mode(struct hostapd_iface *iface, double total_weight; struct acs_bias *bias, tmp_bias; - chan = &mode->channels[i]; + pri_chan = chan = &mode->channels[i]; /* Since in the current ACS implementation the first channel is * always a primary channel, skip channels not available as @@ -727,6 +728,9 @@ acs_find_ideal_chan_mode(struct hostapd_iface *iface, if (acs_usable_chan(adj_chan)) { factor += adj_chan->interference_factor; total_weight += 1; + + if (adj_chan->interference_factor < pri_chan->interference_factor) + pri_chan = adj_chan; } } @@ -805,7 +809,8 @@ acs_find_ideal_chan_mode(struct hostapd_iface *iface, if (acs_usable_chan(chan) && (!*ideal_chan || factor < *ideal_factor)) { *ideal_factor = factor; - *ideal_chan = chan; + *ideal_chan = pri_chan; + *first_chan = chan; } /* This channel would at least be usable */ @@ -825,7 +830,7 @@ static struct hostapd_channel_data * acs_find_ideal_chan(struct hostapd_iface *iface) { struct hostapd_channel_data *ideal_chan = NULL, - *rand_chan = NULL; + *rand_chan = NULL, *first_chan = NULL; long double ideal_factor = 0; int i; int n_chans = 1; @@ -866,14 +871,16 @@ acs_find_ideal_chan(struct hostapd_iface *iface) mode = &iface->hw_features[i]; if (!hostapd_hw_skip_mode(iface, mode)) acs_find_ideal_chan_mode(iface, mode, n_chans, bw, - &rand_chan, &ideal_chan, + &rand_chan, &ideal_chan, &first_chan, &ideal_factor); } if (ideal_chan) { wpa_printf(MSG_DEBUG, "ACS: Ideal channel is %d (%d MHz) with total interference factor of %Lg", ideal_chan->chan, ideal_chan->freq, ideal_factor); - return ideal_chan; + iface->conf->bw_first_chan = first_chan->chan; + /* Primary channel selection belongs only to 5G band. */ + return is_24ghz_mode(iface->current_mode->mode)? first_chan : ideal_chan; } return rand_chan; @@ -905,7 +912,24 @@ static void acs_adjust_center_freq(struct hostapd_iface *iface) } hostapd_set_oper_centr_freq_seg0_idx(iface->conf, - iface->conf->channel + offset); + iface->conf->bw_first_chan + offset); +} + + +static void acs_adjust_sec_chan(struct hostapd_config *conf) +{ + const int ht40_plus_channels[] = { 36, 44, 52, 60, 100, 108, 116, 124, 132, 140, + 149, 157, 165, 184, 192 }; + int i, sec_chan = -1; + + for (i = 0; i < ARRAY_SIZE(ht40_plus_channels); i++) { + if (conf->channel == ht40_plus_channels[i]) { + sec_chan = 1; + break; + } + } + + conf->secondary_channel = sec_chan; } @@ -961,8 +985,10 @@ static void acs_study(struct hostapd_iface *iface) iface->conf->channel = ideal_chan->chan; iface->freq = ideal_chan->freq; - if (iface->conf->ieee80211ac || iface->conf->ieee80211ax) + if (iface->conf->ieee80211ac || iface->conf->ieee80211ax) { acs_adjust_center_freq(iface); + acs_adjust_sec_chan(iface->conf); + } err = 0; fail: diff --git a/src/ap/ap_config.h b/src/ap/ap_config.h index bada04c3e..18d662c6e 100644 --- a/src/ap/ap_config.h +++ b/src/ap/ap_config.h @@ -909,6 +909,7 @@ struct hostapd_config { int fragm_threshold; u8 op_class; u8 channel; + u8 bw_first_chan; int enable_edmg; u8 edmg_channel; u8 acs;