Received: by 2002:ab2:6309:0:b0:1fb:d597:ff75 with SMTP id s9csp1147128lqt; Fri, 7 Jun 2024 09:13:34 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXeAIis3+hljEjShCpUD4Xw/j91CmVL2xKBiHNp3Pwnp7F3syZv8eUrWkMgv+5o5TolXFMPdmQSJxcHiNSv+Dacd5R4hjBpqMwMDezw+Q== X-Google-Smtp-Source: AGHT+IGc3SMG6y5gfIQQ6WuIiuFvJTHTAeOeQrwoDLAVxBpinJxzccXSWkrnFfItJzMIwY8QZQ3Y X-Received: by 2002:a2e:a595:0:b0:2ea:df8f:2002 with SMTP id 38308e7fff4ca-2eadf8f229cmr17177491fa.42.1717776814206; Fri, 07 Jun 2024 09:13:34 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717776814; cv=pass; d=google.com; s=arc-20160816; b=ReLFj4OQx7lQZLvGuZEqA1MNs8IXM69W5G8PkfiRueqGzk0ur6d+hKqyAjD9JULPzi KXA7A3802WxzNqA2DbmdXzTrVxxUrhJjzTXPtN9tfid4715OOaIntC/fpNMd561XyrUL kY/dDruHu6zExaF6WaTTKJyQA7D7Lv35654KJOUw03a5K7TDZv3V5QjcnqoiElQ9ILtn ikUeE1ouQxNIZX2o2aNXcILVq/YwrDn5WxyJBSRA5l8+Wnzo8JojG22aJbPvE5fBuStN Gocs8HaTfZFHnrW+Ff91uJJW2YDX0TTgzM1G6wOiEgTFBgLwR55ofpZ7CYMmF6A0srj0 Swfg== 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=mssQG0ePFtkfU1+YGOVKXuRtNO6XYOyVvFzpGYrXr5o=; fh=fUr549cSqKocV7UcRuBHkVs5Q/EFHHdf/SC+m2DGkeo=; b=x+b6pXag/UpxGlVMDQMlVJD0ch/KRDulD9t+eGQ30m9rmSG2CeRSqiIuZqlVrHTyTh O5PmuuprTXUbhomGvTfi15U1kA+6okgtfqtKemBU9Y4DXUAnWjbRpArFjLYAbNKDtWA9 1ClgeLWGSR+X7ZJ+stGBjcBXoHapjyM/m30n3/7GMIGIGFaDd4SqtqhKCANHaj5iuTVY 1ej0idjJSFraRzKI/fbrQ7nM/u9r/EGP0wu/lAZ6B/3/2c6g1dhcq4S/S/ZpSoXvv6FN ixuOaj2OwlDEKALWsOzitz3oC4mgSb/T7LWMulFXkkfusHNT5tPiLcGScyV2hmHZ+9hS z24w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=fail header.i=@nbd.name header.s=20160729 header.b="ryWBETr/"; arc=pass (i=1 dkim=pass dkdomain=nbd.name dmarc=pass fromdomain=nbd.name); spf=pass (google.com: domain of linux-wireless+bounces-8706-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-wireless+bounces-8706-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nbd.name Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-57aae28dfb7si1956070a12.658.2024.06.07.09.13.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jun 2024 09:13:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless+bounces-8706-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=fail header.i=@nbd.name header.s=20160729 header.b="ryWBETr/"; arc=pass (i=1 dkim=pass dkdomain=nbd.name dmarc=pass fromdomain=nbd.name); spf=pass (google.com: domain of linux-wireless+bounces-8706-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-wireless+bounces-8706-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nbd.name 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 400211F2803A for ; Fri, 7 Jun 2024 16:07:44 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 885FD19AA43; Fri, 7 Jun 2024 16:05:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=nbd.name header.i=@nbd.name header.b="ryWBETr/" X-Original-To: linux-wireless@vger.kernel.org Received: from nbd.name (nbd.name [46.4.11.11]) (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 2DC3C19A29A for ; Fri, 7 Jun 2024 16:05:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=46.4.11.11 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717776357; cv=none; b=R5jQGm1G/z8eIw9UIlCuPxNtbVOQdlGbNLssBScIk3fmlsiv6p5+7fpJlnOG4rD8lIevOUE/ioyKLFiA0vmvvElLidFpFZEhdg/9IptX0dT6fDd45rCQhdvNbSvOQA8G8fBh9Vu3r/3dDzEtYPwfow7oQuuRF/rP7idr7oYCkRs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717776357; c=relaxed/simple; bh=khs6sI6vGHhttbCx7S1NAQ3eqV42Luwwh4uqPQwN1IU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BJPFVkIzLblh2GiHlsemv+3AyW9/ajeylXJ0tiXySrpH+ZqTfePvFxZbBcwGD8riD+U/DjJMV90B+NuEwdqmGPqCHVffoIAEc942Fm8P56dhRRcdCzuuiZ3SYqe/l5fDiJaiX6tDzoUq6stTAV+/QVKuFIun7TPtXwZKuPpFPWY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nbd.name; spf=none smtp.mailfrom=nbd.name; dkim=pass (1024-bit key) header.d=nbd.name header.i=@nbd.name header.b=ryWBETr/; arc=none smtp.client-ip=46.4.11.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nbd.name Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=nbd.name DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=nbd.name; s=20160729; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=mssQG0ePFtkfU1+YGOVKXuRtNO6XYOyVvFzpGYrXr5o=; b=ryWBETr/c6sMEhUCAjnJgN7ML9 UGNEWEaTLw2nQfvObCg9HXjkAkCTNoGCvWFc9ZS9iufyaeKDjhh/GSNpQu7XMQ8S2XjxyVgJAeb+9 v665Ds3nFwyVCNeQhar27q7yaRjFhYdyOq7G57FoBFuzUZ6xtvJIsc6zjjz2ETTnjJBU=; Received: from p4ff13226.dip0.t-ipconnect.de ([79.241.50.38] helo=localhost.localdomain) by ds12 with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256 (Exim 4.96) (envelope-from ) id 1sFc6A-008xPc-1t; Fri, 07 Jun 2024 18:05:50 +0200 From: Felix Fietkau To: linux-wireless@vger.kernel.org Cc: johannes@sipsolutions.net, quic_adisi@quicinc.com, quic_periyasa@quicinc.com, ath12k@lists.infradead.org Subject: [RFC v4 3/9] wifi: cfg80211: extend interface combination check for multi-radio Date: Fri, 7 Jun 2024 18:05:42 +0200 Message-ID: <3399aac5c576f1ffcf5375b33e1692cfdad8e097.1717776325.git-series.nbd@nbd.name> X-Mailer: git-send-email 2.44.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Add a field in struct iface_combination_params to check per-radio interface combinations instead of per-wiphy ones. Signed-off-by: Felix Fietkau --- include/net/cfg80211.h | 4 ++++ net/mac80211/util.c | 5 ++++- net/wireless/rdev-ops.h | 17 +++++++++++++++++ net/wireless/trace.h | 5 +++++ net/wireless/util.c | 33 ++++++++++++++++++++++++++------- 5 files changed, 56 insertions(+), 8 deletions(-) diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h index 8a9ef59413d8..307b77e166c1 100644 --- a/include/net/cfg80211.h +++ b/include/net/cfg80211.h @@ -1595,6 +1595,7 @@ struct cfg80211_color_change_settings { * * Used to pass interface combination parameters * + * @radio_idx: wiphy radio index or -1 for global * @num_different_channels: the number of different channels we want * to use for verification * @radar_detect: a bitmap where each bit corresponds to a channel @@ -1608,6 +1609,7 @@ struct cfg80211_color_change_settings { * the verification */ struct iface_combination_params { + int radio_idx; int num_different_channels; u8 radar_detect; int iftype_num[NUM_NL80211_IFTYPES]; @@ -4577,6 +4579,7 @@ struct mgmt_frame_regs { * * @set_hw_timestamp: Enable/disable HW timestamping of TM/FTM frames. * @set_ttlm: set the TID to link mapping. + * @get_radio_mask: get bitmask of radios in use */ struct cfg80211_ops { int (*suspend)(struct wiphy *wiphy, struct cfg80211_wowlan *wow); @@ -4938,6 +4941,7 @@ struct cfg80211_ops { struct cfg80211_set_hw_timestamp *hwts); int (*set_ttlm)(struct wiphy *wiphy, struct net_device *dev, struct cfg80211_ttlm_params *params); + u32 (*get_radio_mask)(struct wiphy *wiphy, struct net_device *dev); }; /* diff --git a/net/mac80211/util.c b/net/mac80211/util.c index 927f752a0209..0d2927e53114 100644 --- a/net/mac80211/util.c +++ b/net/mac80211/util.c @@ -3940,6 +3940,7 @@ int ieee80211_check_combinations(struct ieee80211_sub_if_data *sdata, int total = 1; struct iface_combination_params params = { .radar_detect = radar_detect, + .radio_idx = -1, }; lockdep_assert_wiphy(local->hw.wiphy); @@ -4030,7 +4031,9 @@ int ieee80211_max_num_channels(struct ieee80211_local *local) struct ieee80211_chanctx *ctx; u32 max_num_different_channels = 1; int err; - struct iface_combination_params params = {0}; + struct iface_combination_params params = { + .radio_idx = -1, + }; lockdep_assert_wiphy(local->hw.wiphy); diff --git a/net/wireless/rdev-ops.h b/net/wireless/rdev-ops.h index 43897a5269b6..56ac6410f4b0 100644 --- a/net/wireless/rdev-ops.h +++ b/net/wireless/rdev-ops.h @@ -1542,4 +1542,21 @@ rdev_set_ttlm(struct cfg80211_registered_device *rdev, return ret; } + +static inline u32 +rdev_get_radio_mask(struct cfg80211_registered_device *rdev, + struct net_device *dev) +{ + struct wiphy *wiphy = &rdev->wiphy; + u32 ret; + + if (!rdev->ops->get_radio_mask) + return 0; + + trace_rdev_get_radio_mask(wiphy, dev); + ret = rdev->ops->get_radio_mask(wiphy, dev); + trace_rdev_return_int(wiphy, ret); + + return ret; +} #endif /* __CFG80211_RDEV_OPS */ diff --git a/net/wireless/trace.h b/net/wireless/trace.h index 14cfa0aba93a..12081e81f9c5 100644 --- a/net/wireless/trace.h +++ b/net/wireless/trace.h @@ -4081,6 +4081,11 @@ TRACE_EVENT(cfg80211_links_removed, __entry->link_mask) ); +DEFINE_EVENT(wiphy_netdev_evt, rdev_get_radio_mask, + TP_PROTO(struct wiphy *wiphy, struct net_device *netdev), + TP_ARGS(wiphy, netdev) +); + #endif /* !__RDEV_OPS_TRACE || TRACE_HEADER_MULTI_READ */ #undef TRACE_INCLUDE_PATH diff --git a/net/wireless/util.c b/net/wireless/util.c index 2bde8a354631..3da04ceb6054 100644 --- a/net/wireless/util.c +++ b/net/wireless/util.c @@ -2305,13 +2305,16 @@ static int cfg80211_wdev_bi(struct wireless_dev *wdev) static void cfg80211_calculate_bi_data(struct wiphy *wiphy, u32 new_beacon_int, u32 *beacon_int_gcd, - bool *beacon_int_different) + bool *beacon_int_different, + int radio_idx) { + struct cfg80211_registered_device *rdev; struct wireless_dev *wdev; *beacon_int_gcd = 0; *beacon_int_different = false; + rdev = wiphy_to_rdev(wiphy); list_for_each_entry(wdev, &wiphy->wdev_list, list) { int wdev_bi; @@ -2319,6 +2322,11 @@ static void cfg80211_calculate_bi_data(struct wiphy *wiphy, u32 new_beacon_int, if (wdev->valid_links) continue; + /* skip wdevs not active on the given wiphy radio */ + if (radio_idx >= 0 && + !(rdev_get_radio_mask(rdev, wdev->netdev) & BIT(radio_idx))) + continue; + wdev_bi = cfg80211_wdev_bi(wdev); if (!wdev_bi) @@ -2366,14 +2374,19 @@ int cfg80211_iter_combinations(struct wiphy *wiphy, void *data), void *data) { + const struct wiphy_radio *radio = NULL; + const struct ieee80211_iface_combination *c, *cs; const struct ieee80211_regdomain *regdom; enum nl80211_dfs_regions region = 0; - int i, j, iftype; + int i, j, n, iftype; int num_interfaces = 0; u32 used_iftypes = 0; u32 beacon_int_gcd; bool beacon_int_different; + if (params->radio_idx >= 0) + radio = &wiphy->radio[params->radio_idx]; + /* * This is a bit strange, since the iteration used to rely only on * the data given by the driver, but here it now relies on context, @@ -2385,7 +2398,8 @@ int cfg80211_iter_combinations(struct wiphy *wiphy, * interfaces (while being brought up) and channel/radar data. */ cfg80211_calculate_bi_data(wiphy, params->new_beacon_int, - &beacon_int_gcd, &beacon_int_different); + &beacon_int_gcd, &beacon_int_different, + params->radio_idx); if (params->radar_detect) { rcu_read_lock(); @@ -2402,13 +2416,18 @@ int cfg80211_iter_combinations(struct wiphy *wiphy, used_iftypes |= BIT(iftype); } - for (i = 0; i < wiphy->n_iface_combinations; i++) { - const struct ieee80211_iface_combination *c; + if (radio) { + cs = radio->iface_combinations; + n = radio->n_iface_combinations; + } else { + cs = wiphy->iface_combinations; + n = wiphy->n_iface_combinations; + } + for (i = 0; i < n; i++) { struct ieee80211_iface_limit *limits; u32 all_iftypes = 0; - c = &wiphy->iface_combinations[i]; - + c = &cs[i]; if (num_interfaces > c->max_interfaces) continue; if (params->num_different_channels > c->num_different_channels) -- git-series 0.9.1