From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 4A276A0C43; Fri, 27 Aug 2021 09:00:33 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 20134412CC; Fri, 27 Aug 2021 08:58:56 +0200 (CEST) Received: from shelob.oktetlabs.ru (shelob.oktetlabs.ru [91.220.146.113]) by mails.dpdk.org (Postfix) with ESMTP id D4C71412A6 for ; Fri, 27 Aug 2021 08:58:53 +0200 (CEST) Received: by shelob.oktetlabs.ru (Postfix, from userid 122) id AA2B37F6E3; Fri, 27 Aug 2021 09:58:53 +0300 (MSK) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on shelob.oktetlabs.ru X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=ALL_TRUSTED, DKIM_ADSP_DISCARD, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.2 Received: from aros.oktetlabs.ru (aros.oktetlabs.ru [192.168.38.17]) by shelob.oktetlabs.ru (Postfix) with ESMTP id DF4DC7F6EF; Fri, 27 Aug 2021 09:57:35 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 shelob.oktetlabs.ru DF4DC7F6EF Authentication-Results: shelob.oktetlabs.ru/DF4DC7F6EF; dkim=none; dkim-atps=neutral From: Andrew Rybchenko To: dev@dpdk.org Cc: Viacheslav Galaktionov , Andy Moreton Date: Fri, 27 Aug 2021 09:57:07 +0300 Message-Id: <20210827065717.1838258-29-andrew.rybchenko@oktetlabs.ru> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210827065717.1838258-1-andrew.rybchenko@oktetlabs.ru> References: <20210827065717.1838258-1-andrew.rybchenko@oktetlabs.ru> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH 28/38] common/sfc_efx/base: add multi-host function M-port selector X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Viacheslav Galaktionov Provide helper function to compose multi-host aware PCIe function M-port selector. The firmware expects mport selectors to use different sets of values to represent a PCIe interface in mport selectors and elsewhere. In order to avoid having the user perform the conversion themselves, it is now done automatically when a selector is constructed. In addition, a type has been added to libefx for possible PCIe interfaces. This is done to abstract different representations away from the users. Allow to support matching traffic coming from an arbitrary PCIe end-point of the NIC and redirect traffic to it. Signed-off-by: Viacheslav Galaktionov Signed-off-by: Andrew Rybchenko Reviewed-by: Andy Moreton --- drivers/common/sfc_efx/base/efx.h | 22 +++++++ drivers/common/sfc_efx/base/efx_mae.c | 86 +++++++++++++++++++++++---- drivers/common/sfc_efx/version.map | 1 + 3 files changed, 96 insertions(+), 13 deletions(-) diff --git a/drivers/common/sfc_efx/base/efx.h b/drivers/common/sfc_efx/base/efx.h index 0a178128ba..159e7957a3 100644 --- a/drivers/common/sfc_efx/base/efx.h +++ b/drivers/common/sfc_efx/base/efx.h @@ -82,6 +82,13 @@ efx_family( #if EFSYS_OPT_PCI +/* PCIe interface numbers for multi-host configurations. */ +typedef enum efx_pcie_interface_e { + EFX_PCIE_INTERFACE_CALLER = 1000, + EFX_PCIE_INTERFACE_HOST_PRIMARY, + EFX_PCIE_INTERFACE_NIC_EMBEDDED, +} efx_pcie_interface_t; + typedef struct efx_pci_ops_s { /* * Function for reading PCIe configuration space. @@ -4237,6 +4244,21 @@ efx_mae_mport_by_pcie_function( __in uint32_t vf, __out efx_mport_sel_t *mportp); +/* + * Get MPORT selector of a multi-host PCIe function. + * + * The resulting MPORT selector is opaque to the caller and can be + * passed as an argument to efx_mae_match_spec_mport_set() + * and efx_mae_action_set_populate_deliver(). + */ +LIBEFX_API +extern __checkReturn efx_rc_t +efx_mae_mport_by_pcie_mh_function( + __in efx_pcie_interface_t intf, + __in uint32_t pf, + __in uint32_t vf, + __out efx_mport_sel_t *mportp); + /* * Get MPORT selector by an MPORT ID * diff --git a/drivers/common/sfc_efx/base/efx_mae.c b/drivers/common/sfc_efx/base/efx_mae.c index 3f498fe189..37cc48eafc 100644 --- a/drivers/common/sfc_efx/base/efx_mae.c +++ b/drivers/common/sfc_efx/base/efx_mae.c @@ -727,35 +727,95 @@ efx_mae_mport_by_pcie_function( efx_dword_t dword; efx_rc_t rc; + rc = efx_mae_mport_by_pcie_mh_function(EFX_PCIE_INTERFACE_CALLER, + pf, vf, mportp); + if (rc != 0) + goto fail1; + + return (0); + +fail1: + EFSYS_PROBE1(fail1, efx_rc_t, rc); + return (rc); +} + +static __checkReturn efx_rc_t +efx_mae_intf_to_selector( + __in efx_pcie_interface_t intf, + __out uint32_t *selector_intfp) +{ + efx_rc_t rc; + + switch (intf) { + case EFX_PCIE_INTERFACE_HOST_PRIMARY: + EFX_STATIC_ASSERT(MAE_MPORT_SELECTOR_HOST_PRIMARY <= + EFX_MASK32(MAE_MPORT_SELECTOR_FUNC_INTF_ID)); + *selector_intfp = MAE_MPORT_SELECTOR_HOST_PRIMARY; + break; + case EFX_PCIE_INTERFACE_NIC_EMBEDDED: + EFX_STATIC_ASSERT(MAE_MPORT_SELECTOR_NIC_EMBEDDED <= + EFX_MASK32(MAE_MPORT_SELECTOR_FUNC_INTF_ID)); + *selector_intfp = MAE_MPORT_SELECTOR_NIC_EMBEDDED; + break; + case EFX_PCIE_INTERFACE_CALLER: + EFX_STATIC_ASSERT(MAE_MPORT_SELECTOR_CALLER_INTF <= + EFX_MASK32(MAE_MPORT_SELECTOR_FUNC_INTF_ID)); + *selector_intfp = MAE_MPORT_SELECTOR_CALLER_INTF; + break; + default: + rc = EINVAL; + goto fail1; + } + + return (0); + +fail1: + EFSYS_PROBE1(fail1, efx_rc_t, rc); + return (rc); +} + + __checkReturn efx_rc_t +efx_mae_mport_by_pcie_mh_function( + __in efx_pcie_interface_t intf, + __in uint32_t pf, + __in uint32_t vf, + __out efx_mport_sel_t *mportp) +{ + uint32_t selector_intf; + efx_dword_t dword; + efx_rc_t rc; + EFX_STATIC_ASSERT(EFX_PCI_VF_INVALID == MAE_MPORT_SELECTOR_FUNC_VF_ID_NULL); - if (pf > EFX_MASK32(MAE_MPORT_SELECTOR_FUNC_PF_ID)) { - rc = EINVAL; + rc = efx_mae_intf_to_selector(intf, &selector_intf); + if (rc != 0) goto fail1; + + if (pf > EFX_MASK32(MAE_MPORT_SELECTOR_FUNC_MH_PF_ID)) { + rc = EINVAL; + goto fail2; } if (vf > EFX_MASK32(MAE_MPORT_SELECTOR_FUNC_VF_ID)) { rc = EINVAL; - goto fail2; + goto fail3; } - EFX_POPULATE_DWORD_3(dword, - MAE_MPORT_SELECTOR_TYPE, MAE_MPORT_SELECTOR_TYPE_FUNC, - MAE_MPORT_SELECTOR_FUNC_PF_ID, pf, + + EFX_POPULATE_DWORD_4(dword, + MAE_MPORT_SELECTOR_TYPE, MAE_MPORT_SELECTOR_TYPE_MH_FUNC, + MAE_MPORT_SELECTOR_FUNC_INTF_ID, selector_intf, + MAE_MPORT_SELECTOR_FUNC_MH_PF_ID, pf, MAE_MPORT_SELECTOR_FUNC_VF_ID, vf); memset(mportp, 0, sizeof (*mportp)); - /* - * The constructed DWORD is little-endian, - * but the resulting value is meant to be - * passed to MCDIs, where it will undergo - * host-order to little endian conversion. - */ - mportp->sel = EFX_DWORD_FIELD(dword, EFX_DWORD_0); + mportp->sel = dword.ed_u32[0]; return (0); +fail3: + EFSYS_PROBE(fail3); fail2: EFSYS_PROBE(fail2); fail1: diff --git a/drivers/common/sfc_efx/version.map b/drivers/common/sfc_efx/version.map index 3488367f68..225909892b 100644 --- a/drivers/common/sfc_efx/version.map +++ b/drivers/common/sfc_efx/version.map @@ -125,6 +125,7 @@ INTERNAL { efx_mae_match_specs_class_cmp; efx_mae_match_specs_equal; efx_mae_mport_by_pcie_function; + efx_mae_mport_by_pcie_mh_function; efx_mae_mport_by_phy_port; efx_mae_mport_by_id; efx_mae_mport_free; -- 2.30.2