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 540DAA0555; Thu, 26 May 2022 10:45:54 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id EB0FC40E64; Thu, 26 May 2022 10:45:53 +0200 (CEST) Received: from shelob.oktetlabs.ru (shelob.oktetlabs.ru [91.220.146.113]) by mails.dpdk.org (Postfix) with ESMTP id 3065D40DF7; Thu, 26 May 2022 10:45:53 +0200 (CEST) Received: from bree.oktetlabs.ru (bree.oktetlabs.ru [192.168.34.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by shelob.oktetlabs.ru (Postfix) with ESMTPS id 2D19C90; Thu, 26 May 2022 11:45:52 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 shelob.oktetlabs.ru 2D19C90 Authentication-Results: shelob.oktetlabs.ru/2D19C90; dkim=none; dkim-atps=neutral From: Ivan Malov To: dev@dpdk.org Cc: stable@dpdk.org, Andrew Rybchenko , Andy Moreton , Viacheslav Galaktionov Subject: [PATCH 1/3] common/sfc_efx/base: convert EFX PCIe INTF to MCDI value Date: Thu, 26 May 2022 11:45:48 +0300 Message-Id: <20220526084550.243121-1-ivan.malov@oktetlabs.ru> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 When the driver queries its PCIe interface type via MCDI, the value from the response is translated to an EFX enum. When the driver passes this enum value back to any other MCDI helper, the inverse translation has to be conducted. Fixes: 1bf9ff57ccb3 ("common/sfc_efx/base: allow getting VNIC MCDI client handles") Cc: stable@dpdk.org Signed-off-by: Ivan Malov Reviewed-by: Andrew Rybchenko Reviewed-by: Andy Moreton --- drivers/common/sfc_efx/base/efx_impl.h | 6 ++++ drivers/common/sfc_efx/base/efx_mcdi.c | 44 +++++++++++++++++++++++--- 2 files changed, 46 insertions(+), 4 deletions(-) diff --git a/drivers/common/sfc_efx/base/efx_impl.h b/drivers/common/sfc_efx/base/efx_impl.h index 7dfe30b695..9a5d465fa0 100644 --- a/drivers/common/sfc_efx/base/efx_impl.h +++ b/drivers/common/sfc_efx/base/efx_impl.h @@ -1556,6 +1556,12 @@ efx_mcdi_intf_from_pcie( __in uint32_t pcie_intf, __out efx_pcie_interface_t *efx_intf); +LIBEFX_INTERNAL +extern __checkReturn efx_rc_t +efx_mcdi_intf_to_pcie( + __in efx_pcie_interface_t efx_intf, + __out uint32_t *pcie_intf); + LIBEFX_INTERNAL extern __checkReturn efx_rc_t efx_mcdi_init_evq( diff --git a/drivers/common/sfc_efx/base/efx_mcdi.c b/drivers/common/sfc_efx/base/efx_mcdi.c index 9189a7a8b3..404ca23d58 100644 --- a/drivers/common/sfc_efx/base/efx_mcdi.c +++ b/drivers/common/sfc_efx/base/efx_mcdi.c @@ -659,6 +659,7 @@ efx_mcdi_get_client_handle( EFX_MCDI_DECLARE_BUF(payload, MC_CMD_GET_CLIENT_HANDLE_IN_LEN, MC_CMD_GET_CLIENT_HANDLE_OUT_LEN); + uint32_t pcie_intf; efx_rc_t rc; if (handle == NULL) { @@ -666,6 +667,10 @@ efx_mcdi_get_client_handle( goto fail1; } + rc = efx_mcdi_intf_to_pcie(intf, &pcie_intf); + if (rc != 0) + goto fail2; + req.emr_cmd = MC_CMD_GET_CLIENT_HANDLE; req.emr_in_buf = payload; req.emr_in_length = MC_CMD_GET_CLIENT_HANDLE_IN_LEN; @@ -676,23 +681,25 @@ efx_mcdi_get_client_handle( MC_CMD_GET_CLIENT_HANDLE_IN_TYPE_FUNC); MCDI_IN_SET_WORD(req, GET_CLIENT_HANDLE_IN_FUNC_PF, pf); MCDI_IN_SET_WORD(req, GET_CLIENT_HANDLE_IN_FUNC_VF, vf); - MCDI_IN_SET_DWORD(req, GET_CLIENT_HANDLE_IN_FUNC_INTF, intf); + MCDI_IN_SET_DWORD(req, GET_CLIENT_HANDLE_IN_FUNC_INTF, pcie_intf); efx_mcdi_execute(enp, &req); if (req.emr_rc != 0) { rc = req.emr_rc; - goto fail2; + goto fail3; } if (req.emr_out_length_used < MC_CMD_GET_CLIENT_HANDLE_OUT_LEN) { rc = EMSGSIZE; - goto fail3; + goto fail4; } *handle = MCDI_OUT_DWORD(req, GET_CLIENT_HANDLE_OUT_HANDLE); return 0; +fail4: + EFSYS_PROBE(fail4); fail3: EFSYS_PROBE(fail3); fail2: @@ -709,7 +716,7 @@ efx_mcdi_get_own_client_handle( { efx_rc_t rc; - rc = efx_mcdi_get_client_handle(enp, PCIE_INTERFACE_CALLER, + rc = efx_mcdi_get_client_handle(enp, EFX_PCIE_INTERFACE_CALLER, PCIE_FUNCTION_PF_NULL, PCIE_FUNCTION_VF_NULL, handle); if (rc != 0) goto fail1; @@ -2233,6 +2240,35 @@ efx_mcdi_intf_from_pcie( return (rc); } + __checkReturn efx_rc_t +efx_mcdi_intf_to_pcie( + __in efx_pcie_interface_t efx_intf, + __out uint32_t *pcie_intf) +{ + efx_rc_t rc; + + switch (efx_intf) { + case EFX_PCIE_INTERFACE_CALLER: + *pcie_intf = PCIE_INTERFACE_CALLER; + break; + case EFX_PCIE_INTERFACE_HOST_PRIMARY: + *pcie_intf = PCIE_INTERFACE_HOST_PRIMARY; + break; + case EFX_PCIE_INTERFACE_NIC_EMBEDDED: + *pcie_intf = PCIE_INTERFACE_NIC_EMBEDDED; + break; + default: + rc = EINVAL; + goto fail1; + } + + return (0); + +fail1: + EFSYS_PROBE1(fail1, efx_rc_t, rc); + return (rc); +} + /* * This function returns the pf and vf number of a function. If it is a pf the * vf number is 0xffff. The vf number is the index of the vf on that -- 2.30.2