Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp2419575rbb; Wed, 28 Feb 2024 00:49:32 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUG1TKQM8CaT8aPkbYeEkkfP23mz/LJFFfnhGuXchIg05STyuQKYTRGbOrnZYuR8q74putWBBjrDJlB8Q7MlnbA9KQVa0DGtbYOvpelYg== X-Google-Smtp-Source: AGHT+IEwMp45KfbLd2S6WIPCCyU9k9OjX9n5Y74Sk+xPuJ2+kdx2Bq16N726wQJh49PMi6dXhhBP X-Received: by 2002:a81:b283:0:b0:608:aee8:32a8 with SMTP id q125-20020a81b283000000b00608aee832a8mr4355419ywh.5.1709110172031; Wed, 28 Feb 2024 00:49:32 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709110172; cv=pass; d=google.com; s=arc-20160816; b=cvf4kveNHpEj0tBc3gab1x/79D06/uMOCv9OI9g7FJcO+2gODriprEWHNDijLjOX+a /JYKs3V9GNlDxtEcZTmbiUivLIJNCAcs6mfEvi1xgBHJNUS8Ma2NKzdgKqnuyKc2ROoZ shB6ODApoSJ5s+tCT6LWMvsXr9YpeZ9atDSSnPz9ihAGDOif0LsYCl/E1j21ubp5YZlW yh6xuTUF8YAjI/zSLSo7UnCc90ts3OTi39AtL2UMyrIPw6CJXCcDPtsmO5kDjcCsD1Hc Dl6d2CGu4TkNvFi2Vd5WMZ3D/RLI5y3hEdZxLnHq5xpaKIRcl0DATO7TRZb6Q/nIbITd Mh8A== 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=nV1zAS4CHCd9wjj2/NVlwm3qWhQlkoLk80Lq09ojcrw=; fh=9lwoBV6O/3blh4nAuY4Mpc5TRPn1Z8qRWDo3jzbi9rU=; b=uXMAKbf4h4DVEf9WYSxkJZrEb7yrphVdB9etZPTbdOAlueAkf1CH4vI32GFJObjCgB VjpJj+migd42JKj0yo5Efg7X1ECunhNLmTcvqx5aSbWu4ogkkOocOg+G8vFXHEQ6FvST QLS9iTWzLzwsRSbSk6BtF+Hgn0oyo669RE/Mz6VY8I4fUk9eHL893xLpVnabeKRx3uqj m8ffTPDfZwBB5sXRNJSCd3wpjcGALTQTJcJNG1Nz1Jd027iLaZxKieWjFIv9H6cqrSgf CLb2XLz/7tDQ0KiXvmST+szh2RuEIT+xiM+rcs/Jgl7Zxn747Je/HkfdyjCxqwyLOsxF Vy2Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@sipsolutions.net header.s=mail header.b=tDIrKspl; 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-4150-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-wireless+bounces-4150-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=REJECT dis=NONE) header.from=sipsolutions.net Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id j23-20020ac86657000000b0042dff81e402si8994046qtp.471.2024.02.28.00.49.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 00:49:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-wireless+bounces-4150-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@sipsolutions.net header.s=mail header.b=tDIrKspl; 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-4150-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-wireless+bounces-4150-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 B7D741C21522 for ; Wed, 28 Feb 2024 08:49:31 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7897F31A82; Wed, 28 Feb 2024 08:49:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sipsolutions.net header.i=@sipsolutions.net header.b="tDIrKspl" 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 EE1C72D60C for ; Wed, 28 Feb 2024 08:49:09 +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=1709110153; cv=none; b=a2Gxxhm0A+IcbKWAEcrh+Wj93bY81V1PDScqLc1vpyuUb/N9kIYbIQUMR8Hoyqr3xQnBFjqlit3Ilhw6BjCiVy3Z24nWC03LFw6+WQW6N/hR1DtJ1wvjGJGdDfEHxxgJ+kCni8cKROUtT9JYQntb66asprhPerDqkFFGxhiv6oI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709110153; c=relaxed/simple; bh=GH234ThYK/CbslSPidh7qj8r735EKZZt1K4fDgj9EC8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=p3otugpKkmGPR+efmPFnWJdaa0GoCDea9RA5awp9hzuHor82VARXauJZKdv3XZdyo8ZFuSgSVlej1GJ1Ff1QNS1SSgkqqX1r+5E0AR17Zm3dvUOsaD6zqVgwD3GyL1BRCsHLgcoHF/IRhgKhXKt9f7zCT2Fbg241tkinVp6Lt24= 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=tDIrKspl; 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=nV1zAS4CHCd9wjj2/NVlwm3qWhQlkoLk80Lq09ojcrw=; t=1709110150; x=1710319750; b=tDIrKsplyfYiRDBI/LYWdG/RsF7TkHCaoXUOw+MEmliNykk /7/kDAYRs578lEMTQAWyF1BN/uwlTnB485UfXBqqfxeXsqMChOfAPKqa/0yTypjbE2ddsl+Dz9Y5w ySY32jumjepZAEvnkudZyC0YQABFn95Xti2gH2auq6gKXcmmxALyI8urkX1AcNgLk59cHPk3yCxjJ h7L0ry0gE0MeuIXbFP0bbhwyhd8/DapAgq+wqroFo9gjHGVmxRa5ooJPAGdhe+jtaKVmpYzYVGRw7 rj3RtCHmq6VegrghPsHWTNGh+FabF5C4mrTWCPGOmjoqFtf4a7x/CNxOIwwHdCPw==; Received: by sipsolutions.net with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.97) (envelope-from ) id 1rfFcg-0000000C0BC-2qTz; Wed, 28 Feb 2024 09:49:06 +0100 From: Johannes Berg To: linux-wireless@vger.kernel.org Cc: Johannes Berg , Ilan Peer , Emmanuel Grumbach , Miriam Rachel Korenblit Subject: [PATCH 3/8] wifi: mac80211: add ieee80211_vif_link_active() helper Date: Wed, 28 Feb 2024 09:48:11 +0100 Message-ID: <20240228094901.688760aff5f7.I06892a503f5ecb9563fbd678d35d08daf7a044b0@changeid> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240228084901.18661-10-johannes@sipsolutions.net> References: <20240228084901.18661-10-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 We sometimes need to check if a link is active, and this is complicated by the fact that active_links has no bits set when the vif isn't (acting as) an MLD. Add a small new helper ieee80211_vif_link_active() to make that a bit easier, and use it in a few places. Reviewed-by: Ilan Peer Reviewed-by: Emmanuel Grumbach Reviewed-by: Miriam Rachel Korenblit Signed-off-by: Johannes Berg --- include/net/mac80211.h | 15 +++++++++++++++ net/mac80211/cfg.c | 3 +-- net/mac80211/chan.c | 3 +-- net/mac80211/driver-ops.c | 14 +++++--------- net/mac80211/util.c | 3 +-- 5 files changed, 23 insertions(+), 15 deletions(-) diff --git a/include/net/mac80211.h b/include/net/mac80211.h index 34d66d0a24b1..6c6d8210d637 100644 --- a/include/net/mac80211.h +++ b/include/net/mac80211.h @@ -2011,6 +2011,21 @@ static inline bool ieee80211_vif_is_mld(const struct ieee80211_vif *vif) return vif->valid_links != 0; } +/** + * ieee80211_vif_link_active - check if a given link is active + * @vif: the vif + * @link_id: the link ID to check + * Return: %true if the vif is an MLD and the link is active, or if + * the vif is not an MLD and the link ID is 0; %false otherwise. + */ +static inline bool ieee80211_vif_link_active(const struct ieee80211_vif *vif, + unsigned int link_id) +{ + if (!ieee80211_vif_is_mld(vif)) + return link_id == 0; + return vif->active_links & BIT(link_id); +} + #define for_each_vif_active_link(vif, link, link_id) \ for (link_id = 0; link_id < ARRAY_SIZE((vif)->link_conf); link_id++) \ if ((!(vif)->active_links || \ diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c index e57ba4f7a589..821a83e487df 100644 --- a/net/mac80211/cfg.c +++ b/net/mac80211/cfg.c @@ -3155,8 +3155,7 @@ int __ieee80211_request_smps_mgd(struct ieee80211_sub_if_data *sdata, if (WARN_ON_ONCE(sdata->vif.type != NL80211_IFTYPE_STATION)) return -EINVAL; - if (ieee80211_vif_is_mld(&sdata->vif) && - !(sdata->vif.active_links & BIT(link->link_id))) + if (!ieee80211_vif_link_active(&sdata->vif, link->link_id)) return 0; old_req = link->u.mgd.req_smps; diff --git a/net/mac80211/chan.c b/net/mac80211/chan.c index 38acdc458c7c..80e4b9784131 100644 --- a/net/mac80211/chan.c +++ b/net/mac80211/chan.c @@ -1701,8 +1701,7 @@ int ieee80211_link_use_channel(struct ieee80211_link_data *link, lockdep_assert_wiphy(local->hw.wiphy); - if (sdata->vif.active_links && - !(sdata->vif.active_links & BIT(link->link_id))) { + if (!ieee80211_vif_link_active(&sdata->vif, link->link_id)) { ieee80211_link_update_chanreq(link, chanreq); return 0; } diff --git a/net/mac80211/driver-ops.c b/net/mac80211/driver-ops.c index 3b7f70073fc3..dce37ba8ebe3 100644 --- a/net/mac80211/driver-ops.c +++ b/net/mac80211/driver-ops.c @@ -1,7 +1,7 @@ // SPDX-License-Identifier: GPL-2.0-only /* * Copyright 2015 Intel Deutschland GmbH - * Copyright (C) 2022-2023 Intel Corporation + * Copyright (C) 2022-2024 Intel Corporation */ #include #include "ieee80211_i.h" @@ -214,8 +214,7 @@ int drv_conf_tx(struct ieee80211_local *local, if (!check_sdata_in_driver(sdata)) return -EIO; - if (sdata->vif.active_links && - !(sdata->vif.active_links & BIT(link->link_id))) + if (!ieee80211_vif_link_active(&sdata->vif, link->link_id)) return 0; if (params->cw_min == 0 || params->cw_min > params->cw_max) { @@ -315,8 +314,7 @@ int drv_assign_vif_chanctx(struct ieee80211_local *local, if (!check_sdata_in_driver(sdata)) return -EIO; - if (sdata->vif.active_links && - !(sdata->vif.active_links & BIT(link_conf->link_id))) + if (!ieee80211_vif_link_active(&sdata->vif, link_conf->link_id)) return 0; trace_drv_assign_vif_chanctx(local, sdata, link_conf, ctx); @@ -343,8 +341,7 @@ void drv_unassign_vif_chanctx(struct ieee80211_local *local, if (!check_sdata_in_driver(sdata)) return; - if (sdata->vif.active_links && - !(sdata->vif.active_links & BIT(link_conf->link_id))) + if (!ieee80211_vif_link_active(&sdata->vif, link_conf->link_id)) return; trace_drv_unassign_vif_chanctx(local, sdata, link_conf, ctx); @@ -461,8 +458,7 @@ void drv_link_info_changed(struct ieee80211_local *local, if (!check_sdata_in_driver(sdata)) return; - if (sdata->vif.active_links && - !(sdata->vif.active_links & BIT(link_id))) + if (!ieee80211_vif_link_active(&sdata->vif, link_id)) return; trace_drv_link_info_changed(local, sdata, info, changed); diff --git a/net/mac80211/util.c b/net/mac80211/util.c index 627bd5a8bda5..d7c4d162321f 100644 --- a/net/mac80211/util.c +++ b/net/mac80211/util.c @@ -1935,8 +1935,7 @@ int ieee80211_reconfig(struct ieee80211_local *local) for (link_id = 0; link_id < ARRAY_SIZE(sdata->vif.link_conf); link_id++) { - if (ieee80211_vif_is_mld(&sdata->vif) && - !(sdata->vif.active_links & BIT(link_id))) + if (!ieee80211_vif_link_active(&sdata->vif, link_id)) continue; link = sdata_dereference(sdata->link[link_id], sdata); -- 2.43.2