Received: by 2002:a05:7412:d1aa:b0:fc:a2b0:25d7 with SMTP id ba42csp572009rdb; Mon, 29 Jan 2024 10:49:20 -0800 (PST) X-Google-Smtp-Source: AGHT+IHZF1EbDrjr9DOxB4H9vgCX15S2piS15jZcHGkHTPIswwGtJR97vRtkYIWCwMnvgfRAtCEy X-Received: by 2002:a17:906:261a:b0:a35:fb27:2e38 with SMTP id h26-20020a170906261a00b00a35fb272e38mr1120047ejc.34.1706554160755; Mon, 29 Jan 2024 10:49:20 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706554160; cv=pass; d=google.com; s=arc-20160816; b=fREQJG+3X5MTD+XupBKzBwF0bVdQJwmIeXuscXuuwKjdo9CHWm88J/IpBhvmP051wd WFQykSO/yVu7R2e6FQmj2T8bmvwdZ4eXkwJuo+kYJMhcAmP0Pdrzsrx0oxhqqYWQtinf kocYnwANg169gi8T8VZRCTUQaoFC6+xRFv/kM8caQK53/r4xyUyq6wiA+vf6jesjGGr9 2aB8cGreKaY2AenzHMa7kGEi2t5wI3C0GjGG28vr2EnPu3IH/0g3MfLld2EJd5Dy1MGN dcLqP9xeoycR1KLGnUZcVoNqJuEDTeonu79IzRjneqMWPfTSkFwi5UBUokx5awtuHYKA N9rg== 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=ZLy2LnMoX4fyGybdH5A6/Eee87FXiJYJWeR4yXsBztU=; fh=buqv4mT8UXgPG9vBve5grjbLsFOun3QGKBNslXzdRBA=; b=y31ar+4Eald3EqEYls2G+GblcMEm9+26Wqm9C/zc9E5wEp66DQn46Rk3m/aZy/MluB 8pisLR1GWqkG4OFfxKheCsgS5yQgxH65hAYZ9ypvcPBYFRFg8eu16wf8mHGKmYTr9W7c bLg2weCzE7MLPmMOzeCsKWNdet0V0wSuMdU9UtNX00V5kWgJVcZeKveqLvBkYloWCXK7 J/l3Ui7WhWDxjcsRGuLy5eVrU944Tt6ZV/cl0FCbz/T6+HhN/I2K4XqF4z9iJ/8boVFd hCWDjp1qM9XFJAC0wTBe2iWi3iovyRSkSh+18kJTzu2DKLB3YdHcGWHT2zJFaFqDNerC MCDA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@sipsolutions.net header.s=mail header.b=mAtCiNvx; 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-2686-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-wireless+bounces-2686-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; AJvYcCXXD4MYdeC+UKJWAvWEAoR8mTJqR+454MDuAreHgb47el1bhxOv5KsArexfzafzofS2Nykvh8IBSbKrCAAz5Z4WgM7FhLHCRt8hsRhOVA== Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id y8-20020a170906070800b00a2fe96b97cesi3670616ejb.727.2024.01.29.10.49.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jan 2024 10:49:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-wireless+bounces-2686-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@sipsolutions.net header.s=mail header.b=mAtCiNvx; 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-2686-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-wireless+bounces-2686-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 7710B1F23C6E for ; Mon, 29 Jan 2024 18:49:12 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1F38515A480; Mon, 29 Jan 2024 18:41:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sipsolutions.net header.i=@sipsolutions.net header.b="mAtCiNvx" 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 AE03E159576 for ; Mon, 29 Jan 2024 18:41:22 +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=1706553685; cv=none; b=dxc91w1XBb7owBiw6Fn6LSHhapc8A/idLq+Wq2KZTUxirPmr3Wub1gTzMqh0pLP5GUZw88WdTkS+hW6fHcDxKkRW1FSW22HxtTGiUXSvF5xOBQgV8mIDF3raXYPoVcFWo+G3SZZsHRxiwsV2xwxuXwrYyVBe+9MFVOmappyCcFU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706553685; c=relaxed/simple; bh=5/bomvJ9EQtYk0rcQo2BG09UzsYsrmQTlHvsluZjqVc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=C28EuDzHTKksiyUruM9uF0alaHKhGhSKrKaI3bqPDb+nHzdHmLd2+6k6OhZIdJxecMCXn2+F5Dc9v0PUjkOwM4HP8jOBP2AaPFoUTaT64PXfY3jeZMN5yD7vuKhWbn7aTxUzOug1AcUS2ohr/ue+KPB/nqGwaD0pyATJTBjllXY= 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=mAtCiNvx; 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=ZLy2LnMoX4fyGybdH5A6/Eee87FXiJYJWeR4yXsBztU=; t=1706553682; x=1707763282; b=mAtCiNvxB94ktRVAmdEM9sRMrQZA3e+kA1sT1h0TrpQq2HV 275wA+FdZxccbmh7ziAFBThUIIYBney3M52hQBo+PP28OnbLmbk4gYSoCxVbpPPdOdGoIzwsdmySc AOQmuCTM/LjSk3wa7GjZQMAvzIVY1VS2vD7c7u3eU+K9vvsba9H5R8N6MaSYb5AwzQMbgBz8saPV6 mmZhxUR1iv0MiL1zHkgEawiMeT2fxBK+Appllo6FuRwLaYBExjTkH8Fsk49cQCvBS7bPDZ7Sh+0rz F+ZepcXR7D/DxH+BD6auW7HNatW2Z5FHdjd0c0XV37cF+tv52qY1iZEzj4wkWpKQ==; Received: by sipsolutions.net with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.97) (envelope-from ) id 1rUWZM-00000004z9N-0vP6; Mon, 29 Jan 2024 19:41:20 +0100 From: Johannes Berg To: linux-wireless@vger.kernel.org Cc: Johannes Berg Subject: [PATCH 11/15] wifi: mac80211: refactor puncturing bitmap extraction Date: Mon, 29 Jan 2024 19:34:45 +0100 Message-ID: <20240129194108.d9f50dcec8d0.I8b08cbc2490a734fafcce0fa0fc328211ba6f10b@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 Add a new inline helper function to ieee80211.h to extract the disabled subchannels bitmap from an EHT operation element, and use that in mac80211 where we do that. Signed-off-by: Johannes Berg --- include/linux/ieee80211.h | 16 +++++++++++++ net/mac80211/mlme.c | 50 +++++++++++++-------------------------- 2 files changed, 32 insertions(+), 34 deletions(-) diff --git a/include/linux/ieee80211.h b/include/linux/ieee80211.h index a70388ae3a7b..d9d2c1253157 100644 --- a/include/linux/ieee80211.h +++ b/include/linux/ieee80211.h @@ -3189,6 +3189,22 @@ ieee80211_eht_oper_size_ok(const u8 *data, u8 len) return len >= needed; } +/* must validate ieee80211_eht_oper_size_ok() first */ +static inline u16 +ieee80211_eht_oper_dis_subchan_bitmap(const struct ieee80211_eht_operation *eht_oper) +{ + const struct ieee80211_eht_operation_info *info = + (const void *)eht_oper->optional; + + if (!(eht_oper->params & IEEE80211_EHT_OPER_INFO_PRESENT)) + return 0; + + if (!(eht_oper->params & IEEE80211_EHT_OPER_DISABLED_SUBCHANNEL_BITMAP_PRESENT)) + return 0; + + return get_unaligned_le16(info->optional); +} + #define IEEE80211_BW_IND_DIS_SUBCH_PRESENT BIT(1) struct ieee80211_bandwidth_indication { diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c index ffa0909597cc..03919bb36e2d 100644 --- a/net/mac80211/mlme.c +++ b/net/mac80211/mlme.c @@ -813,36 +813,27 @@ ieee80211_determine_chan_mode(struct ieee80211_sub_if_data *sdata, } if (conn->mode >= IEEE80211_CONN_MODE_EHT) { - const struct ieee80211_eht_operation *eht_oper; + u16 bitmap; - eht_oper = elems->eht_operation; - - if (WARN_ON_ONCE(!eht_oper)) { + if (WARN_ON_ONCE(!elems->eht_operation)) { ret = -EINVAL; goto free; } - if (eht_oper->params & IEEE80211_EHT_OPER_INFO_PRESENT && - eht_oper->params & IEEE80211_EHT_OPER_DISABLED_SUBCHANNEL_BITMAP_PRESENT) { - const struct ieee80211_eht_operation_info *info = - (void *)eht_oper->optional; - const u8 *disable_subchannel_bitmap = info->optional; - u16 bitmap; + bitmap = ieee80211_eht_oper_dis_subchan_bitmap(elems->eht_operation); - bitmap = get_unaligned_le16(disable_subchannel_bitmap); - if (!cfg80211_valid_disable_subchannel_bitmap(&bitmap, - &ap_chandef) || - (bitmap && - ieee80211_hw_check(&local->hw, DISALLOW_PUNCTURING))) { - conn->mode = IEEE80211_CONN_MODE_HE; - conn->bw_limit = min_t(enum ieee80211_conn_bw_limit, - conn->bw_limit, - IEEE80211_CONN_BW_LIMIT_160); - sdata_info(sdata, - "AP has invalid/unsupported puncturing, disabling EHT\n"); - } - /* FIXME: store puncturing bitmap */ + if (!cfg80211_valid_disable_subchannel_bitmap(&bitmap, + &ap_chandef) || + (bitmap && + ieee80211_hw_check(&local->hw, DISALLOW_PUNCTURING))) { + conn->mode = IEEE80211_CONN_MODE_HE; + conn->bw_limit = min_t(enum ieee80211_conn_bw_limit, + conn->bw_limit, + IEEE80211_CONN_BW_LIMIT_160); + sdata_info(sdata, + "AP has invalid/unsupported puncturing, disabling EHT\n"); } + /* FIXME: store puncturing bitmap */ } /* the mode can only decrease, so this must terminate */ @@ -5881,18 +5872,9 @@ static bool ieee80211_config_puncturing(struct ieee80211_link_data *link, u64 *changed) { struct ieee80211_local *local = link->sdata->local; - u16 bitmap = 0, extracted; - - if ((eht_oper->params & IEEE80211_EHT_OPER_INFO_PRESENT) && - (eht_oper->params & - IEEE80211_EHT_OPER_DISABLED_SUBCHANNEL_BITMAP_PRESENT)) { - const struct ieee80211_eht_operation_info *info = - (void *)eht_oper->optional; - const u8 *disable_subchannel_bitmap = info->optional; - - bitmap = get_unaligned_le16(disable_subchannel_bitmap); - } + u16 bitmap, extracted; + bitmap = ieee80211_eht_oper_dis_subchan_bitmap(eht_oper); extracted = ieee80211_extract_dis_subch_bmap(eht_oper, &link->conf->chanreq.oper, bitmap); -- 2.43.0