Received: by 2002:a05:7412:d1aa:b0:fc:a2b0:25d7 with SMTP id ba42csp572103rdb; Mon, 29 Jan 2024 10:49:31 -0800 (PST) X-Google-Smtp-Source: AGHT+IHi3GfOUJ639yh9PtrxvIV7rig8GR7rUSMobtsAsEcOpQMo+F3Z0iAmofzH/a3L7sBZ5jBO X-Received: by 2002:ae9:f50c:0:b0:783:bcc9:cd84 with SMTP id o12-20020ae9f50c000000b00783bcc9cd84mr5980640qkg.49.1706554171698; Mon, 29 Jan 2024 10:49:31 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706554171; cv=pass; d=google.com; s=arc-20160816; b=fGxp74tYDOqgwX+Dvu5KuHWl6NXNfZke8gzxzPZyDZ96gUuqJdYUviu1N3b+fElYBh OoYWFpzKft3lb4flqrNGGtX7SOzSkFeE/XycXH52LRP8WjenmRF6MLXI8qooxTCKc1+c 9+V6Ok+4Bt5nHfpfrDarH6pJC6NDplgdTpO/DjqcHDH4fKV+7A99y+Jp6pEyGeqk5r7B 65VNCUHr13Tqi08VfxGo2geq611fTUlQZFL8JYEThKE7L5BHQgRv7lRJ2OpVFu2pI3ox G3GMnv0BsiEOmWUBEc1qfxS0da81yI/Cm1SU7KqNLak9NRHRUIeJg0qFACdyJhTMRAlp 3nvA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=7wWAy1oqsd71mYz/uh6Dprml+565Z99Zn8z9fpl/tXs=; fh=TiQfsz2ICsAFkd7LoDhzXPqwi+GI20uPk93zfrTjRPI=; b=ERE98Vk4MFfhvB4w2rP7h4G6h1QEI+gaONjoMvKUa4qRDoH3lGo97sG2eN+V0v+L2r erzvj2ad6B6Y8Q9XxS562wMjSM8B8dYun9Ic4ju3pMlP+WGhTMzRWAi7eI1R01D+73uQ hTLp8QXY6/qg7Ik/pDKbY8py/VxwbjFPMuCQPrm1QBSTqbIW6JEuS7M3XBNFyEI2lCbc MNMOV/E1uz1dDz1aEfz0no+ixGNYYdvIhjgvjKSPPM9OtQDjIjw3agFg7wbz0/ctEeaT GZ3REKD/CYdIDNwYarAds22zx2TIj8/H4XZKmL9GpuuDFiA57ZunBSjHzH75VPTvR+Ba GYLw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@sipsolutions.net header.s=mail header.b=R8yuVuiv; arc=pass (i=1 spf=pass spfdomain=sipsolutions.net dkim=pass dkdomain=sipsolutions.net dmarc=pass fromdomain=sipsolutions.net); spf=pass (google.com: domain of linux-wireless+bounces-2690-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-wireless+bounces-2690-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=REJECT dis=NONE) header.from=sipsolutions.net X-Forwarded-Encrypted: i=1; AJvYcCUmtxbeftWPZyes3QDpJOIglLoVwwGuRKSwemzBUtWy8WlskFjBBIPjdfmSSf5Oilzz8XYUdJH+4wXejCfPDrTcR/pOTsYM//+VnboogQ== Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id e24-20020a05620a209800b0078309bb963asi5839931qka.304.2024.01.29.10.49.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jan 2024 10:49:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-wireless+bounces-2690-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@sipsolutions.net header.s=mail header.b=R8yuVuiv; arc=pass (i=1 spf=pass spfdomain=sipsolutions.net dkim=pass dkdomain=sipsolutions.net dmarc=pass fromdomain=sipsolutions.net); spf=pass (google.com: domain of linux-wireless+bounces-2690-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-wireless+bounces-2690-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=REJECT dis=NONE) header.from=sipsolutions.net Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 6FFF91C23989 for ; Mon, 29 Jan 2024 18:49:31 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3F52015A4BF; Mon, 29 Jan 2024 18:41:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sipsolutions.net header.i=@sipsolutions.net header.b="R8yuVuiv" X-Original-To: linux-wireless@vger.kernel.org Received: from sipsolutions.net (s3.sipsolutions.net [168.119.38.16]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F1D3D158D6A for ; Mon, 29 Jan 2024 18:41:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=168.119.38.16 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706553687; cv=none; b=r51Na//F7LqNUeXm6YPoNF2jGgKP24gBn9ebYh8eheg6eNYwcwtFQWNW6VNU1TtNWU7rd80CiAxCjHcmpyUuv013bfIjlBLe8k4a3I7AejpGqTsoxhjXGvj0wqVaQ040mCKrDcFKsIKUkM9MOTzEGlW9filcy1IZ5b9hBaGCeIQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706553687; c=relaxed/simple; bh=vF1xHAkaL8sdbmL2/nzDPmaaepLG0nAZaacy/Y3dYLc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MUJ9zSogPdVWRnKQv9u+4/x7+W/A8kET0oEeJpyVpPLG8ytQfxDnaTQba/6dEDydonW4HYVk8fIcwwwUjoydQ6mj8ht/++olltRmq4bvajyMghjRO46R7cffb/Ig1wt27KqAPik10YQ+PunA9aBwI2x1VFKQAoFYhy6PoSE6tLI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sipsolutions.net; spf=pass smtp.mailfrom=sipsolutions.net; dkim=pass (2048-bit key) header.d=sipsolutions.net header.i=@sipsolutions.net header.b=R8yuVuiv; arc=none smtp.client-ip=168.119.38.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sipsolutions.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sipsolutions.net DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sipsolutions.net; s=mail; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Content-Type:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-To: Resent-Cc:Resent-Message-ID; bh=7wWAy1oqsd71mYz/uh6Dprml+565Z99Zn8z9fpl/tXs=; t=1706553685; x=1707763285; b=R8yuVuiv4L17DI53u/T9VLE0rJGbcDtMYgdGX0VsNkDEdOi zXHZ6SAoU90dtjc1CsRCs7FiRJL2xFpu2kmRSlwi/WXw8hVJ/VB8c6l7+vjMVKesWrxMV34kCNwH4 gq47u0v9G8xQ/XIGjOcsQwQANBI3QOUBvTdFcY0f08YU7eaKjqmG8NyvMOYrcjCTcku3e/xV5QFbD oZPVFZkXl+QfemYvyIDc/9YYxkM2NTyZEt2PatDRbVHyoMnDTptl2Lx0nu93sp1PG8fHOmrBNM9iz iqHqmZiaJmmJVRA02TXYUKgvYgLzR2GXal4NQsWZcVPwQ3oAOaJCZn6UmN0J/vTg==; Received: by sipsolutions.net with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.97) (envelope-from ) id 1rUWZO-00000004z9N-2WPh; Mon, 29 Jan 2024 19:41:22 +0100 From: Johannes Berg To: linux-wireless@vger.kernel.org Cc: Johannes Berg Subject: [PATCH 14/15] wifi: mac80211: use cfg80211_chandef_primary_freq() Date: Mon, 29 Jan 2024 19:34:48 +0100 Message-ID: <20240129194108.eb59d6433d18.I74b745f0d1a32e779fb25d50c56407be7c35b840@changeid> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240129184108.49639-17-johannes@sipsolutions.net> References: <20240129184108.49639-17-johannes@sipsolutions.net> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Johannes Berg Instead of calculating the new primary 40/80/160 MHz center frequency here, use the new helper function from cfg80211. Signed-off-by: Johannes Berg --- net/mac80211/util.c | 30 +++++++++++------------------- 1 file changed, 11 insertions(+), 19 deletions(-) diff --git a/net/mac80211/util.c b/net/mac80211/util.c index 49eef33b5e70..63a88169d53d 100644 --- a/net/mac80211/util.c +++ b/net/mac80211/util.c @@ -4365,8 +4365,9 @@ EXPORT_SYMBOL(ieee80211_radar_detected); void ieee80211_chandef_downgrade(struct cfg80211_chan_def *c, struct ieee80211_conn_settings *conn) { + /* no-HT indicates nothing to do */ + enum nl80211_chan_width new_primary_width = NL80211_CHAN_WIDTH_20_NOHT; struct ieee80211_conn_settings _ignored = {}; - int tmp; /* allow passing NULL if caller doesn't care */ if (!conn) @@ -4390,12 +4391,7 @@ void ieee80211_chandef_downgrade(struct cfg80211_chan_def *c, conn->bw_limit = IEEE80211_CONN_BW_LIMIT_20; break; case NL80211_CHAN_WIDTH_80: - tmp = (30 + c->chan->center_freq - c->center_freq1)/20; - /* n_P40 */ - tmp /= 2; - /* freq_P40 */ - c->center_freq1 = c->center_freq1 - 20 + 40 * tmp; - c->width = NL80211_CHAN_WIDTH_40; + new_primary_width = NL80211_CHAN_WIDTH_40; if (conn->mode == IEEE80211_CONN_MODE_VHT) conn->mode = IEEE80211_CONN_MODE_HT; conn->bw_limit = IEEE80211_CONN_BW_LIMIT_40; @@ -4406,21 +4402,11 @@ void ieee80211_chandef_downgrade(struct cfg80211_chan_def *c, conn->bw_limit = IEEE80211_CONN_BW_LIMIT_80; break; case NL80211_CHAN_WIDTH_160: - /* n_P20 */ - tmp = (70 + c->chan->center_freq - c->center_freq1)/20; - /* n_P80 */ - tmp /= 4; - c->center_freq1 = c->center_freq1 - 40 + 80 * tmp; - c->width = NL80211_CHAN_WIDTH_80; + new_primary_width = NL80211_CHAN_WIDTH_80; conn->bw_limit = IEEE80211_CONN_BW_LIMIT_80; break; case NL80211_CHAN_WIDTH_320: - /* n_P20 */ - tmp = (150 + c->chan->center_freq - c->center_freq1) / 20; - /* n_P160 */ - tmp /= 8; - c->center_freq1 = c->center_freq1 - 80 + 160 * tmp; - c->width = NL80211_CHAN_WIDTH_160; + new_primary_width = NL80211_CHAN_WIDTH_160; conn->bw_limit = IEEE80211_CONN_BW_LIMIT_160; break; case NL80211_CHAN_WIDTH_1: @@ -4442,6 +4428,12 @@ void ieee80211_chandef_downgrade(struct cfg80211_chan_def *c, break; } + if (new_primary_width != NL80211_CHAN_WIDTH_20_NOHT) { + c->center_freq1 = + cfg80211_chandef_primary_freq(c, new_primary_width); + c->width = new_primary_width; + } + WARN_ON_ONCE(!cfg80211_chandef_valid(c)); } -- 2.43.0