Received: by 2002:ab2:b82:0:b0:1f3:401:3cfb with SMTP id 2csp465521lqh; Thu, 28 Mar 2024 07:16:39 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUVbOfxlldr8mfKaqIfax0iiAmWyUCdhQBwKP7rV5OUutrmg8pyCqodaBgDFbS2Ip9UlqhTmTuuHcU3SArq8wf22tqsbxuSiIhd1wxnXg== X-Google-Smtp-Source: AGHT+IF2ywnrkFqHx06uRthtCSccckFoo3iGglNZyMLBFBF2yMNN4NQnUFL3H8dHk1IxNDc8gbRD X-Received: by 2002:a05:620a:4724:b0:78b:be87:7cd8 with SMTP id bs36-20020a05620a472400b0078bbe877cd8mr2293727qkb.25.1711635398701; Thu, 28 Mar 2024 07:16:38 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711635398; cv=pass; d=google.com; s=arc-20160816; b=PfL541XhqND1WXu0PM2308Ul1KFChM6ulp3OWusTOhJ32mLqQqBA+joOyD2dyFWC7y ONia+gHgjkVD4/guhvaXFT3z7+jsdnbMm0TMl+vo59O2uQx+A/C/gPa3DmK5NjKtpSTc KKFnN7aA+ncewJmTo86ZrwKsn3oxmyViwgSkl5EiqYhbB9OwCCF7Qb4wP9JB3T6CjsB5 V57M8p0xsVnbgLvq2ZuU28GGm9vaq3KCop+FcbFkNMp5tmR8oNd1O2ebeI/xk99H2qjN rMvJ+a6SwSbHJCjCFMwM/z8d+7wXOVoI+zQi6VykCNIdxeFVtcoXg916hy0XW1Pue2Hq qa9Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :user-agent:content-transfer-encoding:references:in-reply-to:date:cc :to:from:subject:message-id:dkim-signature; bh=qFmBhPh8gg8olzgrUk+NQzaUZcs1g3w7206VS3gQTmM=; fh=AN3TPovGZlXbVOAi9DnJbFLhX12tsufHwxfR0pDbwBE=; b=C+pOS6HNmZg8egIxU0+rHSg9ge5EeuIV1kAsfe6HAVVIJ2jdenrDWAUROsfUUEB44s A1sqwnQTSQ2xmKbVZ4aqp+NohuTZa9t+3K+pEvoBj5Hc1Vx9NLc6KmJIIowR3llzZBph XzO/Wf/wBbiXmd+xD7MpbKZ53Rq0tiK7ye69/LUoaimoX+FYDkisB+19grOpFqfDkGHB kIGzW3A5HSx9teTtNrXdSMwIz0P4TurA8KPlHhJ8aQYHQYxZsebaaNyf14eNDBfXxgkh /+9sc7OTgl6cbrd++b+SqzLGSyqaJsPs8vQ+gco6QsV95aslk5GsoWJ6Gwerfeqt/EXo zSow==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@sipsolutions.net header.s=mail header.b=DoonoYSp; 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-5464-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-wireless+bounces-5464-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 ow27-20020a05620a821b00b0078a00f12cbesi1505676qkn.274.2024.03.28.07.16.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Mar 2024 07:16:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless+bounces-5464-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=DoonoYSp; 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-5464-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-wireless+bounces-5464-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 57D721C2BF1D for ; Thu, 28 Mar 2024 14:16:38 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A6D6811CA9; Thu, 28 Mar 2024 14:16:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sipsolutions.net header.i=@sipsolutions.net header.b="DoonoYSp" 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 945C47D07C for ; Thu, 28 Mar 2024 14:16:30 +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=1711635394; cv=none; b=sZBkiGpbk6yMP4Tre0uyGuYuGnMLKURzmBdPvJNVgksZh0jMyynckMIW37KVQ9Rpfe+ZRFQsXh3PTyc5fw/qG+CfdA+dV/p8X0/WEuR5B0PeLK6aauUXmsDX4aVEKsm4K7MIVg6IGhPMrf+bQRXOSl7Bpfx4Vw2v8/hLhdbnocA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711635394; c=relaxed/simple; bh=LpXl2FH8uvrt+mDGz18YPTIYsQlfLecKrGpVB3IUrDA=; h=Message-ID:Subject:From:To:Cc:Date:In-Reply-To:References: Content-Type:MIME-Version; b=u830nWmEaOVehfxdb3s7QAX0CD41nfza9K2inUnj0heKfdxRgKDZEm84oO+0neg8aeXQR0WzKK7QLNQSKuL9exxCBGLbB7uQk/Vn67Nc+CV+fh0h9hOqlTXC5V/9uOeYWhHsUxjfZoIsCojSIjuRZpNsyE69kc552yy6lL2mdDw= 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=DoonoYSp; 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=MIME-Version:Content-Transfer-Encoding: Content-Type:References:In-Reply-To:Date:Cc:To:From:Subject:Message-ID:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-To: Resent-Cc:Resent-Message-ID; bh=qFmBhPh8gg8olzgrUk+NQzaUZcs1g3w7206VS3gQTmM=; t=1711635391; x=1712844991; b=DoonoYSpY5LjpICkpJ7Cj9DUMXD4Ec9U6+vYOsGbofDmfT6 Z71grhPRPgg+hU0CJ1U6yiFmsPWRmQbWboMZ3NlPuBGRcn6d0M0GowMoEQf09CL8F/m6irRAmf/4x 5eF3KmECv2QxRqSl/g63Z0AnfcK2AvJzQ7b/FU56OApTFGHTwMUPfEzRaBFRQDcn//g59sn1Pl4aX 5kdry0kXxdRwkckUIn9H6zTY5ui0/l13YBoQPfln6fNX8tyWyHlxKFLW0BumeB1/ngyCZ2baIrK/H VXp4RIGFHSSn11GiXMdCef5K2hiFGu6e4jyVVR/2lYNKaKGjDKgss0u47RnZrUuw==; Received: by sipsolutions.net with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.97) (envelope-from ) id 1rpqYN-000000012MS-2C0b; Thu, 28 Mar 2024 15:16:27 +0100 Message-ID: Subject: Re: [PATCH 09/13] wifi: cfg80211: Add multi-hardware iface combination support From: Johannes Berg To: Karthikeyan Periyasamy , ath12k@lists.infradead.org Cc: linux-wireless@vger.kernel.org, Vasanthakumar Thiagarajan Date: Thu, 28 Mar 2024 15:16:26 +0100 In-Reply-To: <20240328072916.1164195-10-quic_periyasa@quicinc.com> References: <20240328072916.1164195-1-quic_periyasa@quicinc.com> <20240328072916.1164195-10-quic_periyasa@quicinc.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.50.4 (3.50.4-1.fc39) Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-malware-bazaar: not-scanned On Thu, 2024-03-28 at 12:59 +0530, Karthikeyan Periyasamy wrote: >=20 > * @new_beacon_int: set this to the beacon interval of a new interface > * that's not operating yet, if such is to be checked as part of > * the verification > + * @chandef: Channel definition for which the interface combination is t= o be > + * checked, when checking during interface preparation on a new channel, > + * for example. This will be used when the driver advertises underlying > + * hw specific interface combination in a multi physical hardware device= . > + * This will be NULL when the interface combination check is not due to > + * channel or the interface combination does not include per-hw > + * advertisement. This is input, so "will be" doesn't make much sense, more like "must be"? But I'm confused as to how that works with num_different_channels being here too? This function was, as far as I can tell, always checking the _full_ state. Now you're changing that, and I'm neither sure why, nor does it seem well documented. > + * @n_per_hw: number of Per-HW interface combinations. > + * @per_hw: @n_per_hw of hw specific interface combinations. Per-hw chan= nel > + * list index as advertised in wiphy @hw_chans is used as index > + * in @per_hw to maintain the interface combination of the corresponding > + * hw. What? If I'm reading that correctly, which is all but guaranteed, doesn't that actually mean you don't need n_per_hw at all, since it necessarily equal to n_hw_chans? > +/** > + * cfg80211_per_hw_iface_comb_advertised - if per-hw iface combination s= upported > + * > + * @wiphy: the wiphy > + * > + * This function is used to check underlying per-hw interface combinatio= n is > + * advertised by the driver. > + */ > +bool cfg80211_per_hw_iface_comb_advertised(struct wiphy *wiphy); Is that even worth an export rather than being inline? Is it even needed outside of cfg80211 itself? Also for cfg80211_get_hw_idx_by_chan(), is it really needed? I'm also wondering if we really should use the "hw_idx" everywhere. Maybe that'd be more useful as a pointer to struct ieee80211_chans_per_hw in most places (other than nl80211, obviously)? The index always feels pretty fragile, a pointer at least gives us type- checking? Even in the interface combination advertising, perhaps, though not sure how that'd work for the drivers. > +static const struct ieee80211_iface_per_hw * > +cfg80211_get_hw_iface_comb_by_idx(struct wiphy *wiphy, > + const struct ieee80211_iface_combination *c, > + int idx) > +{ > + int i; > + > + for (i =3D 0; i < c->n_hw_list; i++) > + if (c->iface_hw_list[i].hw_chans_idx =3D=3D idx) > + break; > + > + if (i =3D=3D c->n_hw_list) > + return NULL; > + > + return &c->iface_hw_list[i]; > +} ??? Hint: it's perfectly legal to return directly from a loop. > +static int > +cfg80211_validate_iface_comb_per_hw_limits(struct wiphy *wiphy, > + struct iface_combination_params *params, > + const struct ieee80211_iface_combination *c, > + u16 *num_ifaces, u32 *all_iftypes) > +{ > + struct ieee80211_iface_limit *limits; > + const struct iface_comb_per_hw_params *per_hw; > + const struct ieee80211_iface_per_hw *per_hw_comb; > + int i, ret =3D 0; The =3D 0 doesn't seem needed. > + ret =3D cfg80211_validate_iface_limits(wiphy, > + per_hw->iftype_num, > + limits, > + per_hw_comb->n_limits, > + all_iftypes); > + > + kfree(limits); > + > + if (ret) > + goto out; > + } > + > +out: > + return ret; That 'out' label is pointless. > +static void cfg80211_put_iface_comb_iftypes(u16 *num_ifaces) > +{ > + kfree(num_ifaces); > +} Not sure I see value in that indirection? > +static u16* missing space > +cfg80211_get_iface_comb_iftypes(struct wiphy *wiphy, > + struct iface_combination_params *params, > + u32 *used_iftypes) > +{ > + const struct iface_comb_per_hw_params *per_hw; > + u16 *num_ifaces; > + int i; > + u8 num_hw; > + > + num_hw =3D params->n_per_hw ? params->n_per_hw : 1; I think we're allowed to use the "?:" shortcut. > + num_ifaces =3D kcalloc(num_hw, sizeof(*num_ifaces), GFP_KERNEL); > + if (!num_ifaces) > + return NULL; But ... maybe we should just cap num_hw to a reasonable limit (4? 5?) and use a static array in the caller instead of allocating here. > + is_per_hw =3D cfg80211_per_hw_iface_comb_advertised(wiphy); Maybe call that "have_per_hw_combinations" or so? Or "check_per_hw" even, "is" seems not clear - "what is?" > + /* check per HW validation */ > + if (params->n_per_hw) { > + if (!is_per_hw) > + return -EINVAL; > + > + if (params->n_per_hw > wiphy->num_hw) > + return -EINVAL; > + } > + > + if (is_per_hw && params->chandef && > + cfg80211_chandef_valid(params->chandef)) > + hw_chan_idx =3D cfg80211_get_hw_idx_by_chan(wiphy, > + params->chandef->chan); > + > + num_ifaces =3D cfg80211_get_iface_comb_iftypes(wiphy, > + params, > + &used_iftypes); > + if (!num_ifaces) > + return -ENOMEM; But still like I said above, all this code seems really odd to me now, it's checking *either* the per-hw and then only for a single HW, *or* the global, but ... seems it should do full checks for both, if needed? johannes