Received: by 2002:ab2:7855:0:b0:1f9:5764:f03e with SMTP id m21csp888890lqp; Thu, 23 May 2024 03:10:32 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVa2d1DBpahs1NJia6GKdPJDX/vIIfIcrAj9jPNvgOGZj9mUpIMnx7EapetmECOxas2yjM9ZT7TZlUgyrI3umeKtkl5keXFAYOqifn9Fw== X-Google-Smtp-Source: AGHT+IHoKHTjPV/Bu/3cNqQUnEJaDlCGCa6UQSYQs/cOHew7M7EoDIJGx3qZiHqsLFwo340+/CBv X-Received: by 2002:a17:906:682:b0:a62:2cae:c10 with SMTP id a640c23a62f3a-a622cae0f18mr274571466b.47.1716459032501; Thu, 23 May 2024 03:10:32 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716459032; cv=pass; d=google.com; s=arc-20160816; b=xPKwBMb+dwMSos2ijkqYhhPqHdeZlkSKTmVUa5RSN8c1BNbPVN22i3QId/4yEJmpcG 4JnIvgQzIqQHRbejQX94iLMLEqEmYcHVjeCzsYgA8INC2C2njpkp+cXU2TpdHMaMq/xq UhlydCOWFQ32eJ9XyxOcfBpw51esu7iQgTdyh8/lKMnV/KClFvnV8gbMURMXWSyResjm jsZpCKR56UPGvyA3K6X1L/Yx/zbRqOb/ZXnT5SFQjTVanEeBSOW9HMF+O7/CHQyFqwUB bk+Zw6K/gDlFkbcfC2T3Ase9as/phRm8NQnsfsGN1+HKLGsnw2kGYz20m11Fw0EANIp8 diOw== 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=Bj3oL2LeBKBLofe1PDKTuSeM+LHLUXW8rKvpQlk6hV4=; fh=0ZKV22Mpi0Z+/zRlCC9GRUAKl0wLMxmYgR1nXO1NAEs=; b=DpQvOxTP/o7Ha+Ti04QwDz81wTT/lcH9mbXY8cdX3DCSdzTIwE44P8iDyqoysIrf75 hoBfILqhJTtrjCRUJtfZb1jnVCrjWE8Z6VGZq6n7fPQGL7PXG9sAZjk3Q2lCwksmR4T+ d1vPSGrvxZs++QSg6ibTKjBWsLgZIH5qOURjv7EI4buTTrzazejh8fqqdRLObsz4FVT+ PEW82swSrsucZvTyd9/RJcxr07KXDTe0zLRg1Ji5AxVnbLwy6oaSbsELf8WCY7zWfpqz UngUnDaeX8mb3wvOe1s8fLwEX5dL4gHkN/2a2hH+i4IJ8gr0MTPHraKUEBlaFgeDUhkG 1+rQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@sipsolutions.net header.s=mail header.b=ImvE7JIw; 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-8002-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-wireless+bounces-8002-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=REJECT dis=NONE) header.from=sipsolutions.net Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id a640c23a62f3a-a5a17c2c187si1651022466b.939.2024.05.23.03.10.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 May 2024 03:10:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless+bounces-8002-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=ImvE7JIw; 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-8002-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-wireless+bounces-8002-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 1451E1F23887 for ; Thu, 23 May 2024 10:10:32 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2367F140373; Thu, 23 May 2024 10:09:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sipsolutions.net header.i=@sipsolutions.net header.b="ImvE7JIw" 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 0432E140E37 for ; Thu, 23 May 2024 10:09:55 +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=1716458998; cv=none; b=JktVwuDC+jUR/EzRDGaPq7XyKQqew8Iwyq4Tx3+QrTGhESe7wF+gV5W00L4KiOogwcjpCJ/eRHzV6jDqXaTEITo8xunogLK/JLVsSlDUKa9Pf89jYq1Bn5hS2Ztx2p3cXkgDAEaj2ukhHIjvga4EI1z11sh+NgdX2Bj++VDZ97M= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716458998; c=relaxed/simple; bh=M+eHxTIj/4FrGsitM4DSUIqMDwMySik9W9uQlhFBawU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Jb5IOuTieOagXGdWiPtqCGQ9DzL/I5TA/5WcFncLNHA/n/G4/7hptAQrIP6OTEytCOLImuFq+g4wRS1KmDdeLdjISNERhQqoh/3FZvcDyYDUBLN++KT2t401efXgGEkCMy8TAedrWR1SQOspkhkvUoTk0g/Je4fEvERHNz8OLsM= 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=ImvE7JIw; 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=Bj3oL2LeBKBLofe1PDKTuSeM+LHLUXW8rKvpQlk6hV4=; t=1716458996; x=1717668596; b=ImvE7JIw65nnzHrjTZLFFirIjf5tAPwzjNHwP1pwrLJv99U C9GFx50v6PizXWH7U5Lo6m5UacSFgq48su/Ep0cAHNjcQsMmNrpB8lbldQWg32i67radQe4RNA0YT MgJunYtU3fwJtT+EfOAfcQBEN8/J2pt06tqRB5sIQYKbZ0MA+ox2LwfvEUV7f76G4qWI9WfkJOVlH 22FYiDP/ipS8r/TViuk2AtXrMQFZXQ+jbVYmEDKc4tJV3USroDI23l0TeXtwC+2uZEzPs8MgXQexB vZlrX20rRuwVlPHO3b8VzLeHA0vQdDhLlMZvdgy8g+Tfb67L2BlyOaISjamBiKXQ==; Received: by sipsolutions.net with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.97) (envelope-from ) id 1sA5OT-00000005wvn-2agC; Thu, 23 May 2024 12:09:53 +0200 From: Johannes Berg To: linux-wireless@vger.kernel.org Cc: Johannes Berg , Miriam Rachel Korenblit Subject: [PATCH 7/8] wifi: cfg80211: refactor regulatory beaconing checking Date: Thu, 23 May 2024 12:09:48 +0200 Message-ID: <20240523120945.d44c34dadfc2.I59b4403108e0dbf7fc6ae8f7522e1af520cffb1c@changeid> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240523120945.9a2c19a51e53.I50fa1b1a18b70f63a5095131ac23dc2e71f3d426@changeid> References: <20240523120945.9a2c19a51e53.I50fa1b1a18b70f63a5095131ac23dc2e71f3d426@changeid> 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 There are two functions exported now, with different settings, refactor to just export a single function that take a struct with different settings. This will make it easier to add more parameters. Reviewed-by: Miriam Rachel Korenblit Signed-off-by: Johannes Berg --- include/net/cfg80211.h | 54 +++++++++++++++++++++++++++++++++++++----- net/wireless/chan.c | 30 ++++++++++------------- 2 files changed, 60 insertions(+), 24 deletions(-) diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h index 0e548507fd8d..dcb543344db6 100644 --- a/include/net/cfg80211.h +++ b/include/net/cfg80211.h @@ -8800,6 +8800,31 @@ static inline void cfg80211_report_obss_beacon(struct wiphy *wiphy, sig_dbm); } +/** + * struct cfg80211_beaconing_check_config - beacon check configuration + * @iftype: the interface type to check for + * @relax: allow IR-relaxation conditions to apply (e.g. another + * interface connected already on the same channel) + * NOTE: If this is set, wiphy mutex must be held. + */ +struct cfg80211_beaconing_check_config { + enum nl80211_iftype iftype; + bool relax; +}; + +/** + * cfg80211_reg_check_beaconing - check if beaconing is allowed + * @wiphy: the wiphy + * @chandef: the channel definition + * @cfg: additional parameters for the checking + * + * Return: %true if there is no secondary channel or the secondary channel(s) + * can be used for beaconing (i.e. is not a radar channel etc.) + */ +bool cfg80211_reg_check_beaconing(struct wiphy *wiphy, + struct cfg80211_chan_def *chandef, + struct cfg80211_beaconing_check_config *cfg); + /** * cfg80211_reg_can_beacon - check if beaconing is allowed * @wiphy: the wiphy @@ -8809,9 +8834,17 @@ static inline void cfg80211_report_obss_beacon(struct wiphy *wiphy, * Return: %true if there is no secondary channel or the secondary channel(s) * can be used for beaconing (i.e. is not a radar channel etc.) */ -bool cfg80211_reg_can_beacon(struct wiphy *wiphy, - struct cfg80211_chan_def *chandef, - enum nl80211_iftype iftype); +static inline bool +cfg80211_reg_can_beacon(struct wiphy *wiphy, + struct cfg80211_chan_def *chandef, + enum nl80211_iftype iftype) +{ + struct cfg80211_beaconing_check_config config = { + .iftype = iftype, + }; + + return cfg80211_reg_check_beaconing(wiphy, chandef, &config); +} /** * cfg80211_reg_can_beacon_relax - check if beaconing is allowed with relaxation @@ -8826,9 +8859,18 @@ bool cfg80211_reg_can_beacon(struct wiphy *wiphy, * * Context: Requires the wiphy mutex to be held. */ -bool cfg80211_reg_can_beacon_relax(struct wiphy *wiphy, - struct cfg80211_chan_def *chandef, - enum nl80211_iftype iftype); +static inline bool +cfg80211_reg_can_beacon_relax(struct wiphy *wiphy, + struct cfg80211_chan_def *chandef, + enum nl80211_iftype iftype) +{ + struct cfg80211_beaconing_check_config config = { + .iftype = iftype, + .relax = true, + }; + + return cfg80211_reg_check_beaconing(wiphy, chandef, &config); +} /** * cfg80211_ch_switch_notify - update wdev channel and notify userspace diff --git a/net/wireless/chan.c b/net/wireless/chan.c index 360480604515..8b1796130b28 100644 --- a/net/wireless/chan.c +++ b/net/wireless/chan.c @@ -1550,22 +1550,12 @@ static bool _cfg80211_reg_can_beacon(struct wiphy *wiphy, return res; } -bool cfg80211_reg_can_beacon(struct wiphy *wiphy, - struct cfg80211_chan_def *chandef, - enum nl80211_iftype iftype) -{ - return _cfg80211_reg_can_beacon(wiphy, chandef, iftype, true); -} -EXPORT_SYMBOL(cfg80211_reg_can_beacon); - -bool cfg80211_reg_can_beacon_relax(struct wiphy *wiphy, - struct cfg80211_chan_def *chandef, - enum nl80211_iftype iftype) +bool cfg80211_reg_check_beaconing(struct wiphy *wiphy, + struct cfg80211_chan_def *chandef, + struct cfg80211_beaconing_check_config *cfg) { struct cfg80211_registered_device *rdev = wiphy_to_rdev(wiphy); - bool check_no_ir; - - lockdep_assert_held(&rdev->wiphy.mtx); + bool check_no_ir = true; /* * Under certain conditions suggested by some regulatory bodies a @@ -1573,12 +1563,16 @@ bool cfg80211_reg_can_beacon_relax(struct wiphy *wiphy, * only if such relaxations are not enabled and the conditions are not * met. */ - check_no_ir = !cfg80211_ir_permissive_chan(wiphy, iftype, - chandef->chan); + if (cfg->relax) { + lockdep_assert_held(&rdev->wiphy.mtx); + check_no_ir = !cfg80211_ir_permissive_chan(wiphy, cfg->iftype, + chandef->chan); + } - return _cfg80211_reg_can_beacon(wiphy, chandef, iftype, check_no_ir); + return _cfg80211_reg_can_beacon(wiphy, chandef, cfg->iftype, + check_no_ir); } -EXPORT_SYMBOL(cfg80211_reg_can_beacon_relax); +EXPORT_SYMBOL(cfg80211_reg_check_beaconing); int cfg80211_set_monitor_channel(struct cfg80211_registered_device *rdev, struct cfg80211_chan_def *chandef) -- 2.45.1