From nobody Sat Feb 7 11:39:06 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (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 6DF90171E71 for ; Fri, 26 Apr 2024 17:50:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714153821; cv=none; b=fQn8Lpng9GyetUBhJS8R/rQyQwi9nAY2bWHgXVvdtyKjnf9X4XPdTvJBS4vhVD8HFAjXRQgHmW6jtbqeqqPGSz1GWamozXSM6uBXjdCRFOiVwjP+yC3quSAnw59lWd+nOGFkKqOKp1F4SFEs/QSTLz6CngPcvfampyu6uBfK7ww= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714153821; c=relaxed/simple; bh=IrOyuos8J+8LPmr7JCCUNriN5z7rzTrPhAAICgTnZ8Q=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JZR4ztpmAOqmL3dzXp57uywR5iEeIl2+84JieZbFuYmJsP/E7JfsmOT5r/8uSaz1PrYiSVHf7c0w0dXqulERS6sbhSEAO31DBaMfN9BC9L9GQTOgqcLzyJkODLUTDLYSqogNouXL5AbJduJMC1guLkkIU4sGink8r9Iw4XSENHU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=fik83fAe; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="fik83fAe" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1714153818; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=9tFVCkuBtcueGN0p1piynNZfeLjIXAW4XnpIAwyZRkU=; b=fik83fAeVJ/yA/Kjj+9uilUVfL2qbx68FJfzGBNy/++GZMNvFVVLou/gjkRL4P2L6sXUde Hgb4K9v558WwO95JsAL9FkP84tBYu0K83eeoU9lRXxaC6fIKvWPswq7W9fzlxgmdsz7AeS fgeqLqJqm33vvDJD+laKcKUdOcP2OGw= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-594-CrzqDw66NOCW_3eXG-w3NA-1; Fri, 26 Apr 2024 13:50:12 -0400 X-MC-Unique: CrzqDw66NOCW_3eXG-w3NA-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 96C12800935; Fri, 26 Apr 2024 17:50:11 +0000 (UTC) Received: from p1.luc.cera.cz (unknown [10.45.225.10]) by smtp.corp.redhat.com (Postfix) with ESMTP id B4B43C13FA3; Fri, 26 Apr 2024 17:50:09 +0000 (UTC) From: Ivan Vecera To: netdev@vger.kernel.org Cc: Michal Schmidt , Aleksandr Loktionov , Tony Nguyen , Pucha Himasekhar Reddy , Jesse Brandeburg , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , intel-wired-lan@lists.osuosl.org (moderated list:INTEL ETHERNET DRIVERS), linux-kernel@vger.kernel.org (open list) Subject: [PATCH net-next v3 6/7] i40e: Add helper to access main VEB Date: Fri, 26 Apr 2024 19:49:45 +0200 Message-ID: <20240426174953.208591-7-ivecera@redhat.com> In-Reply-To: <20240426174953.208591-1-ivecera@redhat.com> References: <20240426174953.208591-1-ivecera@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.8 Content-Type: text/plain; charset="utf-8" Add a helper to access main VEB: i40e_pf_get_main_veb(pf) replaces 'pf->veb[pf->lan_veb]' Reviewed-by: Michal Schmidt Reviewed-by: Aleksandr Loktionov Reviewed-by: Tony Nguyen Tested-by: Pucha Himasekhar Reddy Signed-off-by: Ivan Vecera --- drivers/net/ethernet/intel/i40e/i40e.h | 11 ++++++++ .../net/ethernet/intel/i40e/i40e_ethtool.c | 9 +++---- drivers/net/ethernet/intel/i40e/i40e_main.c | 27 ++++++++++++------- 3 files changed, 31 insertions(+), 16 deletions(-) diff --git a/drivers/net/ethernet/intel/i40e/i40e.h b/drivers/net/ethernet/= intel/i40e/i40e.h index fb0b913692e1..2f135db416cf 100644 --- a/drivers/net/ethernet/intel/i40e/i40e.h +++ b/drivers/net/ethernet/intel/i40e/i40e.h @@ -1401,4 +1401,15 @@ i40e_pf_get_veb_by_seid(struct i40e_pf *pf, u16 seid) return NULL; } =20 +/** + * i40e_pf_get_main_veb - get pointer to main VEB + * @pf: pointer to a PF + * + * Return pointer to main VEB or NULL if it does not exist + **/ +static inline struct i40e_veb *i40e_pf_get_main_veb(struct i40e_pf *pf) +{ + return (pf->lan_veb !=3D I40E_NO_VEB) ? pf->veb[pf->lan_veb] : NULL; +} + #endif /* _I40E_H_ */ diff --git a/drivers/net/ethernet/intel/i40e/i40e_ethtool.c b/drivers/net/e= thernet/intel/i40e/i40e_ethtool.c index 5cd0d1b45f01..4e28785c9fb2 100644 --- a/drivers/net/ethernet/intel/i40e/i40e_ethtool.c +++ b/drivers/net/ethernet/intel/i40e/i40e_ethtool.c @@ -2425,14 +2425,11 @@ static void i40e_get_ethtool_stats(struct net_devic= e *netdev, if (vsi->type !=3D I40E_VSI_MAIN || pf->hw.partition_id !=3D 1) goto check_data_pointer; =20 - veb_stats =3D ((pf->lan_veb !=3D I40E_NO_VEB) && - (pf->lan_veb < I40E_MAX_VEB) && - test_bit(I40E_FLAG_VEB_STATS_ENA, pf->flags)); + veb =3D i40e_pf_get_main_veb(pf); + veb_stats =3D veb && test_bit(I40E_FLAG_VEB_STATS_ENA, pf->flags); =20 - if (veb_stats) { - veb =3D pf->veb[pf->lan_veb]; + if (veb_stats) i40e_update_veb_stats(veb); - } =20 /* If veb stats aren't enabled, pass NULL instead of the veb so that * we initialize stats to zero and update the data pointer diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethe= rnet/intel/i40e/i40e_main.c index 85d609ad81dc..26e5c21df19d 100644 --- a/drivers/net/ethernet/intel/i40e/i40e_main.c +++ b/drivers/net/ethernet/intel/i40e/i40e_main.c @@ -2481,7 +2481,7 @@ static int i40e_set_promiscuous(struct i40e_pf *pf, b= ool promisc) int aq_ret; =20 if (vsi->type =3D=3D I40E_VSI_MAIN && - pf->lan_veb !=3D I40E_NO_VEB && + i40e_pf_get_main_veb(pf) && !test_bit(I40E_FLAG_MFP_ENA, pf->flags)) { /* set defport ON for Main VSI instead of true promisc * this way we will get all unicast/multicast and VLAN @@ -9909,6 +9909,7 @@ static void i40e_veb_link_event(struct i40e_veb *veb,= bool link_up) static void i40e_link_event(struct i40e_pf *pf) { struct i40e_vsi *vsi =3D i40e_pf_get_main_vsi(pf); + struct i40e_veb *veb =3D i40e_pf_get_main_veb(pf); u8 new_link_speed, old_link_speed; bool new_link, old_link; int status; @@ -9948,8 +9949,8 @@ static void i40e_link_event(struct i40e_pf *pf) /* Notify the base of the switch tree connected to * the link. Floating VEBs are not notified. */ - if (pf->lan_veb < I40E_MAX_VEB && pf->veb[pf->lan_veb]) - i40e_veb_link_event(pf->veb[pf->lan_veb], new_link); + if (veb) + i40e_veb_link_event(veb, new_link); else i40e_vsi_link_event(vsi, new_link); =20 @@ -14881,7 +14882,8 @@ static void i40e_setup_pf_switch_element(struct i40= e_pf *pf, /* Main VEB? */ if (uplink_seid !=3D pf->mac_seid) break; - if (pf->lan_veb >=3D I40E_MAX_VEB) { + veb =3D i40e_pf_get_main_veb(pf); + if (!veb) { int v; =20 /* find existing or else empty VEB */ @@ -14895,12 +14897,15 @@ static void i40e_setup_pf_switch_element(struct i= 40e_pf *pf, pf->lan_veb =3D v; } } - if (pf->lan_veb >=3D I40E_MAX_VEB) + + /* Try to get again main VEB as pf->lan_veb may have changed */ + veb =3D i40e_pf_get_main_veb(pf); + if (!veb) break; =20 - pf->veb[pf->lan_veb]->seid =3D seid; - pf->veb[pf->lan_veb]->uplink_seid =3D pf->mac_seid; - pf->veb[pf->lan_veb]->pf =3D pf; + veb->seid =3D seid; + veb->uplink_seid =3D pf->mac_seid; + veb->pf =3D pf; break; case I40E_SWITCH_ELEMENT_TYPE_VSI: if (num_reported !=3D 1) @@ -15045,13 +15050,15 @@ static int i40e_setup_pf_switch(struct i40e_pf *p= f, bool reinit, bool lock_acqui /* first time setup */ main_vsi =3D i40e_pf_get_main_vsi(pf); if (!main_vsi || reinit) { + struct i40e_veb *veb; u16 uplink_seid; =20 /* Set up the PF VSI associated with the PF's main VSI * that is already in the HW switch */ - if (pf->lan_veb < I40E_MAX_VEB && pf->veb[pf->lan_veb]) - uplink_seid =3D pf->veb[pf->lan_veb]->seid; + veb =3D i40e_pf_get_main_veb(pf); + if (veb) + uplink_seid =3D veb->seid; else uplink_seid =3D pf->mac_seid; if (!main_vsi) --=20 2.43.2