From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0E8DFC54FB9 for ; Mon, 20 Nov 2023 11:42:36 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id A149C60681; Mon, 20 Nov 2023 11:42:35 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org A149C60681 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osuosl.org; s=default; t=1700480555; bh=9fzjrdr26hezCxWNUUIuMjfSTQVps9QAiam4rSUA0/Y=; h=Date:From:To:References:In-Reply-To:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Cc:From; b=FwMxjF2tMvK7hYkYuCYZWnMJxJivU0XE+gfXWSDIsr7u4MEjpZmEFu7z4ftpe9bh4 IJmwTSssiBBadWslIiQvrDtz0oKys6Ny40OmBDfm2nVjaAyZskfQxpyuJllJXPG/z8 PoDglV2Ojn9XxFzYBEGEsaL6DAVmcoNgZ32jUFYPbYKtr7/Yq++1vIXXNgB2voGMwv o18N56d1DQAFv428EcFRJ/33HpFK3Q3mdQoQgH84eB3l6mer0nrLouS1bcrX0dr9/r pY1x3LCmc+fFH3vLZyPy2cc8WAA0JtZycnqG5t2g/O+IRp4PDQ3shxTIbhfnCtaDq2 zyKIQ7kNGQeRg== X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ZFB2mD1Q2vrd; Mon, 20 Nov 2023 11:42:34 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by smtp3.osuosl.org (Postfix) with ESMTP id AA16460757; Mon, 20 Nov 2023 11:42:34 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org AA16460757 Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by ash.osuosl.org (Postfix) with ESMTP id 6E5551BF380 for ; Mon, 20 Nov 2023 11:42:33 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 463028148A for ; Mon, 20 Nov 2023 11:42:33 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 463028148A X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id LzO4ZCFjItIZ for ; Mon, 20 Nov 2023 11:42:32 +0000 (UTC) Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by smtp1.osuosl.org (Postfix) with ESMTPS id 4982C8137B for ; Mon, 20 Nov 2023 11:42:32 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 4982C8137B Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by ams.source.kernel.org (Postfix) with ESMTP id 29E59B8166D; Mon, 20 Nov 2023 11:42:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0DC9EC433C7; Mon, 20 Nov 2023 11:42:26 +0000 (UTC) Date: Mon, 20 Nov 2023 11:42:24 +0000 From: Simon Horman To: Ivan Vecera Message-ID: <20231120114224.GB223713@kernel.org> References: <20231116152114.88515-1-ivecera@redhat.com> <20231116152114.88515-4-ivecera@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20231116152114.88515-4-ivecera@redhat.com> X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1700480549; bh=9EOytdIzHSPX1UrWq2Vnd6Lm8YR0exOx45k9xVk7W/M=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=A2Jis3QlXaU0cN9/u0hilLwYwMejoIaYlL1422LpRB1gppQuRCQSadg4tMnMW3mBm EXxUq//f+RhHfJuMXTrwYCuQZzlQtG8pMNeGukYCNc0PbUVqS8BETv4rs/2dAA8c0V ibm1HQ+ghZPnuoyqE8ovTOGASaG4hLvmEYIyj2FlbA5QDubZXNmr+1BK5z4V8C/92C LX7Elxvn5BXeL2mp6fQ83mNgpi3/F3dm9Wt/i08XwkKmIJYx+zOWfWZvICzfr2vB1+ rFMobNVRWxhnoL5sNjEdKzhS87SnW11hrkiYQ9vArvvPuj4S/WLT+HZtnstdXG89Wy MznAYlNk004Pw== X-Mailman-Original-Authentication-Results: smtp1.osuosl.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=A2Jis3Ql Subject: Re: [Intel-wired-lan] [PATCH iwl-next v3 3/5] i40e: Add helpers to find VSI and VEB by SEID and use them X-BeenThere: intel-wired-lan@osuosl.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Wojciech Drewek , netdev@vger.kernel.org, Jesse Brandeburg , linux-kernel@vger.kernel.org, Eric Dumazet , Tony Nguyen , Jakub Kicinski , Jacob Keller , intel-wired-lan@lists.osuosl.org, Paolo Abeni , "David S. Miller" Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: intel-wired-lan-bounces@osuosl.org Sender: "Intel-wired-lan" On Thu, Nov 16, 2023 at 04:21:12PM +0100, Ivan Vecera wrote: > Add two helpers i40e_(veb|vsi)_get_by_seid() to find corresponding > VEB or VSI by their SEID value and use these helpers to replace > existing open-coded loops. > > Reviewed-by: Wojciech Drewek > Signed-off-by: Ivan Vecera Hi Ivan, some minor feedback from my side. ... > diff --git a/drivers/net/ethernet/intel/i40e/i40e.h b/drivers/net/ethernet/intel/i40e/i40e.h > index 1e9266de270b..ca8997d29c02 100644 > --- a/drivers/net/ethernet/intel/i40e/i40e.h > +++ b/drivers/net/ethernet/intel/i40e/i40e.h > @@ -1360,4 +1360,38 @@ static inline struct i40e_pf *i40e_hw_to_pf(struct i40e_hw *hw) > > struct device *i40e_hw_to_dev(struct i40e_hw *hw); > > +/** > + * i40e_pf_get_vsi_by_seid - find VSI by SEID > + * @pf: pointer to a PF nit: @seid is missing here > + **/ > +static inline struct i40e_vsi * > +i40e_pf_get_vsi_by_seid(struct i40e_pf *pf, u16 seid) > +{ > + struct i40e_vsi *vsi; > + int i; > + > + i40e_pf_for_each_vsi(pf, i, vsi) > + if (vsi->seid == seid) > + return vsi; > + > + return NULL; > +} > + > +/** > + * i40e_pf_get_veb_by_seid - find VEB by SEID > + * @pf: pointer to a PF Ditto ... > diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c ... > @@ -14848,23 +14831,16 @@ struct i40e_veb *i40e_veb_setup(struct i40e_pf *pf, u16 flags, > } > > /* make sure there is such a vsi and uplink */ > - i40e_pf_for_each_vsi(pf, vsi_idx, vsi) > - if (vsi->seid == vsi_seid) > - break; > - > - if (vsi_idx == pf->num_alloc_vsi && vsi_seid != 0) { > - dev_info(&pf->pdev->dev, "vsi seid %d not found\n", > - vsi_seid); > - return NULL; > + if (vsi_seid) { > + vsi = i40e_pf_get_vsi_by_seid(pf, vsi_seid); > + if (!vsi) { > + dev_err(&pf->pdev->dev, "vsi seid %d not found\n", > + vsi_seid); > + return NULL; > + } > } > - > if (uplink_seid && uplink_seid != pf->mac_seid) { > - i40e_pf_for_each_veb(pf, veb_idx, veb) { > - if (veb->seid == uplink_seid) { > - uplink_veb = veb; > - break; > - } > - } > + uplink_veb = i40e_pf_get_veb_by_seid(pf, uplink_seid); > if (!uplink_veb) { > dev_info(&pf->pdev->dev, > "uplink seid %d not found\n", uplink_seid); The next part of this function looks like this: if (!uplink_veb) { dev_info(&pf->pdev->dev, "uplink seid %d not found\n", uplink_seid); return NULL; } } /* get veb sw struct */ veb_idx = i40e_veb_mem_alloc(pf); if (veb_idx < 0) goto err_alloc; veb = pf->veb[veb_idx]; veb->flags = flags; veb->uplink_seid = uplink_seid; veb->veb_idx = (uplink_veb ? uplink_veb->idx : I40E_NO_VEB); veb->enabled_tc = (enabled_tc ? enabled_tc : 0x1); /* create the VEB in the switch */ ret = i40e_add_veb(veb, vsi); Smatch complains that vsi may be used uninitialised here. Which does seem possible to me if vsi_seid is 0. ... _______________________________________________ Intel-wired-lan mailing list Intel-wired-lan@osuosl.org https://lists.osuosl.org/mailman/listinfo/intel-wired-lan