From patchwork Thu Oct 22 11:00:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrei Otcheretianski X-Patchwork-Id: 1386154 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=2001:8b0:10b:1231::1; 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=intel.com 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=cAkgYgEq; dkim-atps=neutral Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:8b0:10b:1231::1]) (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 4CH4F03N17z9sVN for ; Thu, 22 Oct 2020 22:01:56 +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=TlAPO+iTFS00o7raNE1FjZAxP2t7oPR9CquSnWRctI4=; b=cAkgYgEqN8Uj3mfdopOhMGoCmL oqFHoSA56XfUlQyYX4Q6L9x7YMQyYe3LVXoB4kVNQ2nZnTv8FU3Ftma4LknZGx48MujyD42ZJle3P j0Eaw90KcZNdnJ3/B0fa6C53BB0kZqkG/yNOGDjHephv/YIuyz18aqBblbmutUP+WV2o/i6YnjakD gii2hP5UCFcvuv94vhP/0gWhvBMc9B0UJ9EdVVd85oQ9Q3W/qQadD5/SRc6/MbZk7yjDAW0FwwRE1 mOM3Y6PPDiBTWzVsWPn7O/CeVVLAxI95nGRQHbXG/LuCObGQjfIQp9fQwWrKNEpv0XaGStUfHF53H 77Xr68rQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kVYKt-0002Y6-DP; Thu, 22 Oct 2020 11:00:47 +0000 Received: from mga01.intel.com ([192.55.52.88]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kVYKq-0002WF-G4 for hostap@lists.infradead.org; Thu, 22 Oct 2020 11:00:45 +0000 IronPort-SDR: OxAGl1TbCPd8fdEbwKfaLvFM01k06nlT67oXTBB+ni1m9baEvgM2k35bwMk3c2kzqn9EB64+xY 4hWtyOzz8Otw== X-IronPort-AV: E=McAfee;i="6000,8403,9781"; a="185185954" X-IronPort-AV: E=Sophos;i="5.77,404,1596524400"; d="scan'208";a="185185954" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Oct 2020 04:00:39 -0700 IronPort-SDR: xpWncFccjIhXDu2lXV2PyIVgT8AyzUt8kZCK73PWUlAHmi3Kg1PTT1MMvMf5SQ5hzQoXSgsxAH JtqNWXqrlXFQ== X-IronPort-AV: E=Sophos;i="5.77,404,1596524400"; d="scan'208";a="533918592" Received: from ralon-mobl.ger.corp.intel.com (HELO localhost.localdomain) ([10.214.247.1]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Oct 2020 04:00:37 -0700 From: Andrei Otcheretianski To: hostap@lists.infradead.org Subject: [PATCH] hw_feature: Correctly select mode in case of 6GHz Date: Thu, 22 Oct 2020 14:00:25 +0300 Message-Id: <20201022110025.16987-1-andrei.otcheretianski@intel.com> X-Mailer: git-send-email 2.28.0 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201022_070044_760193_122A9E15 X-CRM114-Status: GOOD ( 19.96 ) X-Spam-Score: -5.0 (-----) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-5.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [192.55.52.88 listed in wl.mailspike.net] -5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at https://www.dnswl.org/, high trust [192.55.52.88 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 RCVD_IN_MSPIKE_WL Mailspike good senders 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: Andrei Otcheretianski , Ilan Peer Sender: "Hostap" Errors-To: hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org From: Ilan Peer There are 2 HW modes with IEEE80211_MODE_A: one for the 5GHz channels and one for 6GHz channels. Since hw_get_chan() checks all the compatible hw modes, eventually, an incorrect hw mode is selected. To fix this, add a function that checks if a specific mode supports the requested frequency and if so use it as the current mode. Signed-off-by: Ilan Peer Signed-off-by: Andrei Otcheretianski --- src/ap/hw_features.c | 7 +++--- src/common/hw_features_common.c | 38 ++++++++++++++++++++++----------- src/common/hw_features_common.h | 3 +++ 3 files changed, 32 insertions(+), 16 deletions(-) diff --git a/src/ap/hw_features.c b/src/ap/hw_features.c index f6e69030d7..ebcc60520b 100644 --- a/src/ap/hw_features.c +++ b/src/ap/hw_features.c @@ -1029,12 +1029,13 @@ int hostapd_select_hw_mode(struct hostapd_iface *iface) iface->current_mode = NULL; for (i = 0; i < iface->num_hw_features; i++) { struct hostapd_hw_modes *mode = &iface->hw_features[i]; + int chan; + if (mode->mode == iface->conf->hw_mode) { if (iface->freq > 0 && - !hw_get_chan(mode->mode, iface->freq, - iface->hw_features, - iface->num_hw_features)) + !hw_mode_get_channel(mode, iface->freq, &chan)) continue; + iface->current_mode = mode; break; } diff --git a/src/common/hw_features_common.c b/src/common/hw_features_common.c index 511e68f9ec..54da8eb301 100644 --- a/src/common/hw_features_common.c +++ b/src/common/hw_features_common.c @@ -39,12 +39,30 @@ struct hostapd_channel_data * hw_get_channel_chan(struct hostapd_hw_modes *mode, return NULL; } +struct hostapd_channel_data * +hw_mode_get_channel(struct hostapd_hw_modes *mode, int freq, int *chan) +{ + int i; + + for (i = 0; i < mode->num_channels; i++) { + struct hostapd_channel_data *ch = &mode->channels[i]; + + if (ch->freq == freq) { + if (chan) + *chan = ch->chan; + return ch; + } + } + + return NULL; +} struct hostapd_channel_data * hw_get_channel_freq(enum hostapd_hw_mode mode, int freq, int *chan, struct hostapd_hw_modes *hw_features, int num_hw_features) { - int i, j; + struct hostapd_channel_data *chan_data; + int i; if (chan) *chan = 0; @@ -52,21 +70,15 @@ hw_get_channel_freq(enum hostapd_hw_mode mode, int freq, int *chan, if (!hw_features) return NULL; - for (j = 0; j < num_hw_features; j++) { - struct hostapd_hw_modes *curr_mode = &hw_features[j]; + for (i = 0; i < num_hw_features; i++) { + struct hostapd_hw_modes *curr_mode = &hw_features[i]; if (curr_mode->mode != mode) continue; - for (i = 0; i < curr_mode->num_channels; i++) { - struct hostapd_channel_data *ch = - &curr_mode->channels[i]; - - if (ch->freq == freq) { - if (chan) - *chan = ch->chan; - return ch; - } - } + + chan_data = hw_mode_get_channel(curr_mode, freq, chan); + if (chan_data) + return chan_data; } return NULL; diff --git a/src/common/hw_features_common.h b/src/common/hw_features_common.h index e57a8d65cc..ddde36b992 100644 --- a/src/common/hw_features_common.h +++ b/src/common/hw_features_common.h @@ -14,6 +14,9 @@ struct hostapd_channel_data * hw_get_channel_chan(struct hostapd_hw_modes *mode, int chan, int *freq); +struct hostapd_channel_data * +hw_mode_get_channel(struct hostapd_hw_modes *mode, int freq, int *chan); + struct hostapd_channel_data * hw_get_channel_freq(enum hostapd_hw_mode mode, int freq, int *chan, struct hostapd_hw_modes *hw_features, int num_hw_features);