Received: by 2002:a05:7412:b130:b0:e2:908c:2ebd with SMTP id az48csp2155813rdb; Mon, 20 Nov 2023 03:49:01 -0800 (PST) X-Google-Smtp-Source: AGHT+IFbk2VDlzaGDN3AO2auDv1a8bfaLtWLdbaq/wquYiOFcAPDazh0bBSkaibtzCuk26dJWuoK X-Received: by 2002:a05:6602:b0e:b0:7a6:889e:c4b7 with SMTP id fl14-20020a0566020b0e00b007a6889ec4b7mr10688274iob.11.1700480941051; Mon, 20 Nov 2023 03:49:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700480941; cv=none; d=google.com; s=arc-20160816; b=zP7ahQhIJVvckuRTXAar0gygrAsUtvEEvgf0PAxh/U6SoYPA92qnKImr4JhILWURVI 24+6bEEuQpE+mBo4c8PUQSZbMP6ASacP8G/eczhaSBzo8gUA7HFGz2Eg28ABO9WjlYqA uwHunhxzfXx/PsGpbQ3+ZU9Njp7XC0Yf/rjHOWxx5ZD/SzXn8a52diXatYSIzKvKN7gA Lu3hT8Z4s9LAbCI98eezUINcAAcysJh6Pmm7mIDpEaah/521ohRna0m/rXHgRT4+rspS 3dbeeyztoAtHAmgBqmzEJTHcEq5+cuJi/FibF1WQdqrkNdGrukYFG7IjlMG3zX3NEtYj b8rw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=bHDLmj7gXLZCrAbn7LPUOz+KROfNZwcy+bAAPLXRLC0=; fh=kbXkj7eW+JJkFh4C0ziRzvXSDgZPrZ5wjaRH6L9CTaU=; b=j2MxW8DQs+q6b/2lno0+2DcDySWj7FzKrky68qsCb0/xIY5EngCzB9qKGL9rCreweh PVLZOFIZaJKA8b/rnwNl1LjWH6h6fccZwEvkRsx8vunacfQa0+U+VhvMc10SvdvNqCrB NpE2kTJP2hEovKvJgv5dtTAP01MHyluHFGlPeGV5cbpBXEJ0bDqDYg6if9NPJBH5Sbam F8iTg6wEvSbnYoQbh9YnV5Tc/eoC53YJgiMAQ0CaRvi94zdnqVTS07CGVwgU6WG5CNXk tPyowVCdqY0wLVfTkb/8XwDa/ijXd9DDDynNBdbqYI2tVZa84ZTXMtMyqn8BYGGD4H9h mYVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=A2Jis3Ql; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id 1-20020a631041000000b005bdd76219edsi7409383pgq.675.2023.11.20.03.48.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Nov 2023 03:49:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=A2Jis3Ql; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id C61BC80A8B72; Mon, 20 Nov 2023 03:42:48 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233288AbjKTLmf (ORCPT + 99 others); Mon, 20 Nov 2023 06:42:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40970 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232566AbjKTLmd (ORCPT ); Mon, 20 Nov 2023 06:42:33 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EEE439C for ; Mon, 20 Nov 2023 03:42:29 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0DC9EC433C7; Mon, 20 Nov 2023 11:42:26 +0000 (UTC) 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== Date: Mon, 20 Nov 2023 11:42:24 +0000 From: Simon Horman To: Ivan Vecera Cc: intel-wired-lan@lists.osuosl.org, Jesse Brandeburg , Tony Nguyen , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , linux-kernel@vger.kernel.org, Jacob Keller , Wojciech Drewek , mschmidt@redhat.com, netdev@vger.kernel.org Subject: Re: [PATCH iwl-next v3 3/5] i40e: Add helpers to find VSI and VEB by SEID and use them Message-ID: <20231120114224.GB223713@kernel.org> References: <20231116152114.88515-1-ivecera@redhat.com> <20231116152114.88515-4-ivecera@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231116152114.88515-4-ivecera@redhat.com> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Mon, 20 Nov 2023 03:42:48 -0800 (PST) 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. ...