From nobody Sun Feb 8 14:10:28 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.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 AFFAB2C6B6 for ; Wed, 27 Mar 2024 07:57:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711526277; cv=none; b=bu0opvCbkWJ/ZielsVhZZthz8lugAyunIa+kvLDqDBBfSIyCVaPFQA8BCLcPvu8PnorbYal70M/g6CwjhuZHqc6oMKtF7QjCUC6inPAjSxZJOwYNd5OukCQKmeZh01qZyyvhAd+bb21V4bXnEIF3xTgOVa10nzdrfIjv6a6JmWM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711526277; c=relaxed/simple; bh=jdu3mEkxAJPXd8tZlrYxppddI8oOdg8IgXM8psnS3uE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Jlort38gkC8JIiJlUtqM6nSJN8WrMYh/rwGmatdldCNnE42z55GKu6hqe8xF3a8lzk4j4OtbrSHG5OOS9mxV1ZR2r/D7Wh6B6j52as/OIagz7Mizqr/Q3meb1LEkP/QBq6CcRVwAbKzBx9/yb+dh0GDFT9DBTUI3GQv63WwYp8g= 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=DCSAKhKM; arc=none smtp.client-ip=170.10.129.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="DCSAKhKM" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1711526274; 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=nMSejyBZh+q/Djikou7LY9D5VawfjTNSh4zQaLgPqtU=; b=DCSAKhKMAQY03+qaNXOFzab1h0m7GdBDpZT9s5Hv0KKdypW1naPnQjGHcezRLNELvRYhvv KmtwlDEWnecFLIkkxwX6D2ja/0Y5/DSVmhVAZVo2mF0Stt7ZoFysErO19wMXPr2L6cyv00 g0Mvjt5pTaZ7dabzOXOQf9wdyiQzgLA= 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-661-cy8T5w0dNnOk7rL8fzoSoA-1; Wed, 27 Mar 2024 03:57:51 -0400 X-MC-Unique: cy8T5w0dNnOk7rL8fzoSoA-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 B45DC8007A3; Wed, 27 Mar 2024 07:57:50 +0000 (UTC) Received: from p1.luc.cera.cz (unknown [10.45.224.197]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1B80AC15774; Wed, 27 Mar 2024 07:57:49 +0000 (UTC) From: Ivan Vecera To: intel-wired-lan@lists.osuosl.org Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, mschmidt@redhat.com, aleksandr.loktionov@intel.com, jesse.brandeburg@intel.com, anthony.l.nguyen@intel.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com Subject: [PATCH iwl-next v2 6/7] i40e: Add helper to access main VEB Date: Wed, 27 Mar 2024 08:57:32 +0100 Message-ID: <20240327075733.8967-7-ivecera@redhat.com> In-Reply-To: <20240327075733.8967-1-ivecera@redhat.com> References: <20240327075733.8967-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 Signed-off-by: Ivan Vecera Reviewed-by: Simon Horman Tested-by: Pucha Himasekhar Reddy (A Co= ntingent worker at Intel) --- 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 d6dbd0fd79eb..2e1955064abb 100644 --- a/drivers/net/ethernet/intel/i40e/i40e_main.c +++ b/drivers/net/ethernet/intel/i40e/i40e_main.c @@ -2480,7 +2480,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 @@ -9916,6 +9916,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; @@ -9955,8 +9956,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 @@ -14892,7 +14893,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 */ @@ -14906,12 +14908,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) @@ -15056,13 +15061,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.0