From patchwork Wed Jan 8 10:12:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neo Jou X-Patchwork-Id: 1219504 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=2607:7c80:54:e::133; helo=bombadil.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=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="YAfUwNND"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="hyh8Gllj"; dkim-atps=neutral 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 ozlabs.org (Postfix) with ESMTPS id 47t4nP54D0z9sPn for ; Wed, 8 Jan 2020 21:12:57 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: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=92OR6Vcc+Wid3Z3Eo3o6u905rmVOoNcET4EsYh5x6cw=; b=YAf UwNNDCY6TlquCuS6M4iEOGaq+fAmx2+Vf8VqpMnYVSYT+1pkQTKa/7Tqwkm5IHAeZTjHvsFoKtjdX 2nixTPldtN8ztG7Ak4jtCZVkMzE+h5o1gVb2qAmvAIiv1ZH0Ga8k+YD+hx4kWNpXYKnj5AGdHBf8s OiTlPAiDLmZEt+TquONuGrDdMaYaYqgvVOgYoMhHDjJZTLmOFmUQGQinbdzDleGJxwpBF+wqtq9OQ QYR4xD17+mAGxfkdJbKYv5Wur0Gql+H2LJypEv4hVO1p9UZJiGcVVOyMehwDQO+PRRGE0Ltaq0V7m QP9KSt4Es/+aMtvBCPhD8G4vZE2o+kg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ip8KU-0006uf-7I; Wed, 08 Jan 2020 10:12:46 +0000 Received: from mail-pf1-x442.google.com ([2607:f8b0:4864:20::442]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1ip8KM-0006no-H0 for hostap@lists.infradead.org; Wed, 08 Jan 2020 10:12:39 +0000 Received: by mail-pf1-x442.google.com with SMTP id x184so1392585pfb.3 for ; Wed, 08 Jan 2020 02:12:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=p8f8lirgt/Ntk2InK06WdCR1AroaMwiiNDd3UKofaPI=; b=hyh8GlljU3MclIgnrptAyHFxF3oYxDoOJXJ/VQR3e+TUm2j8ByRe6YklXXirwW7yOG 4ENSezqmRiNMkX5tPWvWCFG4ZlpgXeRpNgGYBulwVQz2o73rbrtZi/QqQ+yyvpifciYO Knu5y7Ekh17WL6D5YIkxVpN2agSvd6xFXNfCJivrHN4ElJiiqftZ6Oenkb27yAu7FvHo jNdKOMSpP99F9tPOpX+5UpFZgRkM4vQbFIoZ2awH5hInUTGnQYMycLBw113asTI26vJ8 twRfAo9Es75Byofyo77dqJJywFOAI4FdGwOUm8iMLDCmBvxmpW5Ln2b6juLY+ax0HaUu fi1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=p8f8lirgt/Ntk2InK06WdCR1AroaMwiiNDd3UKofaPI=; b=lC5eLSRikUKiAxPhkmjVx9V4xCGGUkBQSzBCwghniEJjIR3tuO4qkXeNT9tk6PmNFK NoNbkGE5vIR54nwkLlQIVf6xeXRRD/+dKEaC3QZdJbonHrdI+3iqXSqUH/V9vW1ri1Rs WjBi4vDmN6NK/Q6DxMr+TF+Dfp//nSKzBWCUnKNCIJBoBUXOUiyZDodMKjAwKp/Xgp3R 0s2LtNv9Wa4JuIKIE9Ui7GhygQUFrZBSyznNBm9+kKJof3sxQRa5cUd0tTiYZvlEirtU b5oKpBNZp/n5Q7rWDrcHnw9iFENSjJ8Rz/jsLCpi7DAsCs24d0N53kIMnheg06iQsFT1 US9w== X-Gm-Message-State: APjAAAWpAZhrtBOrlIzwKHwj6+PdoG06W0bvwtlNyUQ1g4hfHqg/b+Jr yydo72q4PhiyMY8T74uyGByKGOLXMjk= X-Google-Smtp-Source: APXvYqzrgIh2cTCkFsgNxrExFOaxrQJ4/wA2b6AR+Cab5C+G0n6Pq358k2srIzXthI8aPjaoH93IVQ== X-Received: by 2002:a63:5920:: with SMTP id n32mr4265475pgb.443.1578478357520; Wed, 08 Jan 2020 02:12:37 -0800 (PST) Received: from localhost ([115.82.163.104]) by smtp.gmail.com with ESMTPSA id d3sm2670157pfn.113.2020.01.08.02.12.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 08 Jan 2020 02:12:37 -0800 (PST) From: neojou@gmail.com To: hostap@lists.infradead.org Subject: [PATCH] ACS: cover not-offloaded-ACS with hw_mode=any Date: Wed, 8 Jan 2020 18:12:28 +0800 Message-Id: <1578478348-4095-1-git-send-email-neojou@gmail.com> X-Mailer: git-send-email 2.7.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200108_021238_562594_A53D0959 X-CRM114-Status: GOOD ( 14.09 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:442 listed in] [list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (neojou[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -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 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: neojou@gmail.com MIME-Version: 1.0 Sender: "Hostap" Errors-To: hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org From: Neo Jou This patch is to extend the existing hw_mode=any to cover the not-offloaded-ACS case. In wpa_driver_nl80211_postprocess_modes, the approach, similar to the one for 80211.b is used for the mode HOSTAPD_MODE_IEEE80211ANY. it is for hostapd_select_hw_mode() to get the support configured mode. And after ACS computed, the current_mode is changed back to B/G/A/AD, depends on the frequency ACS decided. By this way, "hw_mode=any" can be used for not-offloaded-ACS case. Signed-off-by: Neo Jou --- src/ap/hw_features.c | 35 +++++++++++++++++++++++++++++ src/drivers/driver_nl80211_capa.c | 47 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 82 insertions(+) diff --git a/src/ap/hw_features.c b/src/ap/hw_features.c index ba10752..2db65c5 100644 --- a/src/ap/hw_features.c +++ b/src/ap/hw_features.c @@ -963,6 +963,39 @@ int hostapd_acs_completed(struct hostapd_iface *iface, int err) wpa_msg(iface->bss[0]->msg_ctx, MSG_INFO, ACS_EVENT_COMPLETED "freq=%d channel=%d", iface->freq, iface->conf->channel); + + if (iface->current_mode->mode == HOSTAPD_MODE_IEEE80211ANY) { + int i; + enum hostapd_hw_mode target_mode; + + if (iface->freq < 4000) { + target_mode = HOSTAPD_MODE_IEEE80211B; + for (i = 0; i < iface->current_mode->num_rates; i++) { + if (iface->current_mode->rates[i] > 200) { + target_mode = HOSTAPD_MODE_IEEE80211G; + break; + } + } + } else if (iface->freq > 50000) + target_mode = HOSTAPD_MODE_IEEE80211AD; + else + target_mode = HOSTAPD_MODE_IEEE80211A; + + for (i = 0; i < iface->num_hw_features; i++) { + struct hostapd_hw_modes *mode = &iface->hw_features[i]; + if (mode->mode == target_mode) { + iface->current_mode = mode; + break; + } + } + + if (iface->current_mode->mode == HOSTAPD_MODE_IEEE80211ANY) { + wpa_printf(MSG_ERROR, "ACS error - cannot decide band"); + wpa_msg(iface->bss[0]->msg_ctx, MSG_INFO, ACS_EVENT_FAILED); + hostapd_notify_bad_chans(iface); + goto out; + } + } break; case HOSTAPD_CHAN_ACS: wpa_printf(MSG_ERROR, "ACS error - reported complete, but no result available"); @@ -1070,6 +1103,8 @@ const char * hostapd_hw_mode_txt(int mode) return "IEEE 802.11g"; case HOSTAPD_MODE_IEEE80211AD: return "IEEE 802.11ad"; + case HOSTAPD_MODE_IEEE80211ANY: + return "IEEE 802.11any"; default: return "UNKNOWN"; } diff --git a/src/drivers/driver_nl80211_capa.c b/src/drivers/driver_nl80211_capa.c index e1cf9f7..908d1fd 100644 --- a/src/drivers/driver_nl80211_capa.c +++ b/src/drivers/driver_nl80211_capa.c @@ -1808,6 +1808,53 @@ wpa_driver_nl80211_postprocess_modes(struct hostapd_hw_modes *modes, modes[m].mode = HOSTAPD_MODE_IEEE80211A; } + /* Add HOSTAPD_MODE_IEEE80211ANY */ + nmodes = os_realloc_array(modes, *num_modes + 1, sizeof(*nmodes)); + if (nmodes == NULL) + return modes; /* Could not add mode ANY */ + + mode = &nmodes[*num_modes]; + os_memset(mode, 0, sizeof(*mode)); + modes = nmodes; + mode->mode = HOSTAPD_MODE_IEEE80211ANY; + + for (m = 0; m < *num_modes; m++) { + struct hostapd_channel_data *m_channels; + int *m_rates; + + if (!modes[m].num_channels) + continue; + + /* add channels */ + m_channels = os_realloc_array(mode->channels, + mode->num_channels + modes[m].num_channels, + sizeof(struct hostapd_channel_data)); + if (m_channels == NULL) + return modes; + + mode->channels = m_channels; + + memcpy(&(mode->channels[mode->num_channels]), + modes[m].channels, + modes[m].num_channels * sizeof(struct hostapd_channel_data)); + + mode->num_channels += modes[m].num_channels; + + /* add rates */ + m_rates = os_realloc_array(mode->rates, + mode->num_rates + modes[m].num_rates, + sizeof(int)); + if (m_rates == NULL) + return modes; + mode->rates = m_rates; + memcpy(&(mode->rates[mode->num_rates]), + modes[m].rates, + modes[m].num_rates * sizeof(int)); + mode->num_rates += modes[m].num_rates; + } + + (*num_modes)++; + /* If only 802.11g mode is included, use it to construct matching * 802.11b mode data. */