Received: by 2002:ab2:23c8:0:b0:1f2:fdbc:cb93 with SMTP id a8csp139920lqe; Wed, 27 Mar 2024 00:59:22 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWRA7aX9P31GZ1pOAPdA+Yk0jDsNhuZ9/+KznXw72lJEns+6Lqpy2H4tqRLoL91qEqLC5utBFspkp1ES6ToeF0OM3n5oy4fzjyl+mCc0g== X-Google-Smtp-Source: AGHT+IHMYE7zO3IUyLHQvA/qQ9UbTG9ECf9VduQQ4c1TozOe7HRiw32wcU2CuXw6Pmg72B+CckKc X-Received: by 2002:a05:6a20:244a:b0:1a3:ab01:844a with SMTP id t10-20020a056a20244a00b001a3ab01844amr5899468pzc.11.1711526362620; Wed, 27 Mar 2024 00:59:22 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711526362; cv=pass; d=google.com; s=arc-20160816; b=j/Bn1uEea3RQw2VIhb5IHLcZatxO9y8gWdfa/SeaxW0w/ZCuidCkmswspaZfatDkuH VOy9sZSUpW7h3B0XL/lNI7isrTHTv4f0gtrrpn/W+OW+Ivze/+d3Z9a5W/chOmHAmo8A tlvV79V664NtSvqsK1BJiwNVqKyP+F6e0w0FwsibtBqShrKBSv6SV1w+Dccj445OoT3f 9K89xA+yzHnMcHYxsoKHm/WWJqhECIb6+dLIEeoQtL0GdTdjnyPA3Zc1KDOeoqoX9SHP slStEz4BLP9notFMyNkskW77LALTgr4K8cLWcBHva8XrgnvZPXXsTlO9NiRzmFvK3CQk MgFw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=nMSejyBZh+q/Djikou7LY9D5VawfjTNSh4zQaLgPqtU=; fh=LttDPJ5Ee4PCAxGT1oGINSa8eHk8IA0/KLDF6QTPubo=; b=zSBT2dZ1ejM81LVr5CrkR3+f5wIVPJemwPvLOmL2pDRz5haqUAa1F0bEi1Ig9wqBaB et8D+/CDXcw+KpAP8yGJ4xpuYkOX6EMUsYuW+lHDhKlC4gtXwjD8QEggpU4MkmNCK8YW /fJoV5Jrtp74QrKk3LFrj9l2TJZ8nRiYPSM1BSz1k58EIusNpfS3Mgf3OGYAgUpkY4RG 48Rp+Nr3tBW2qlGplvpA0aH/AQDs/bTynYyrmq+u0sVcshDo+KNBGo8c8X2u0DDD2GB7 UqP3ekV5eD/PWd9E+ZDvP0GWHo4FsBFlQFJ36q5Huap+K7TqizDOeH4GC/gt6ptxXes8 ckBA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=DCSAKhKM; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-120484-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-120484-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id n31-20020a634d5f000000b005d2520bdefbsi11080526pgl.208.2024.03.27.00.59.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Mar 2024 00:59:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-120484-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=DCSAKhKM; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-120484-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-120484-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 435642A346E for ; Wed, 27 Mar 2024 07:59:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4A7633771C; Wed, 27 Mar 2024 07:57:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="DCSAKhKM" 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 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: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.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 --- 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; } +/** + * 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 != 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/ethernet/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_device *netdev, if (vsi->type != I40E_VSI_MAIN || pf->hw.partition_id != 1) goto check_data_pointer; - veb_stats = ((pf->lan_veb != I40E_NO_VEB) && - (pf->lan_veb < I40E_MAX_VEB) && - test_bit(I40E_FLAG_VEB_STATS_ENA, pf->flags)); + veb = i40e_pf_get_main_veb(pf); + veb_stats = veb && test_bit(I40E_FLAG_VEB_STATS_ENA, pf->flags); - if (veb_stats) { - veb = pf->veb[pf->lan_veb]; + if (veb_stats) i40e_update_veb_stats(veb); - } /* 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/ethernet/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, bool promisc) int aq_ret; if (vsi->type == I40E_VSI_MAIN && - pf->lan_veb != 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 = i40e_pf_get_main_vsi(pf); + struct i40e_veb *veb = 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); @@ -14892,7 +14893,8 @@ static void i40e_setup_pf_switch_element(struct i40e_pf *pf, /* Main VEB? */ if (uplink_seid != pf->mac_seid) break; - if (pf->lan_veb >= I40E_MAX_VEB) { + veb = i40e_pf_get_main_veb(pf); + if (!veb) { int v; /* find existing or else empty VEB */ @@ -14906,12 +14908,15 @@ static void i40e_setup_pf_switch_element(struct i40e_pf *pf, pf->lan_veb = v; } } - if (pf->lan_veb >= I40E_MAX_VEB) + + /* Try to get again main VEB as pf->lan_veb may have changed */ + veb = i40e_pf_get_main_veb(pf); + if (!veb) break; - pf->veb[pf->lan_veb]->seid = seid; - pf->veb[pf->lan_veb]->uplink_seid = pf->mac_seid; - pf->veb[pf->lan_veb]->pf = pf; + veb->seid = seid; + veb->uplink_seid = pf->mac_seid; + veb->pf = pf; break; case I40E_SWITCH_ELEMENT_TYPE_VSI: if (num_reported != 1) @@ -15056,13 +15061,15 @@ static int i40e_setup_pf_switch(struct i40e_pf *pf, bool reinit, bool lock_acqui /* first time setup */ main_vsi = i40e_pf_get_main_vsi(pf); if (!main_vsi || reinit) { + struct i40e_veb *veb; u16 uplink_seid; /* 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 = pf->veb[pf->lan_veb]->seid; + veb = i40e_pf_get_main_veb(pf); + if (veb) + uplink_seid = veb->seid; else uplink_seid = pf->mac_seid; if (!main_vsi) -- 2.43.0