patches for DPDK stable branches
 help / color / mirror / Atom feed
* [PATCH 1/3] common/sfc_efx/base: convert EFX PCIe INTF to MCDI value
@ 2022-05-26  8:45 Ivan Malov
  2022-05-31 16:57 ` Andrew Rybchenko
  0 siblings, 1 reply; 2+ messages in thread
From: Ivan Malov @ 2022-05-26  8:45 UTC (permalink / raw)
  To: dev; +Cc: stable, Andrew Rybchenko, Andy Moreton, Viacheslav Galaktionov

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 <ivan.malov@oktetlabs.ru>
Reviewed-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
Reviewed-by: Andy Moreton <amoreton@xilinx.com>
---
 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


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH 1/3] common/sfc_efx/base: convert EFX PCIe INTF to MCDI value
  2022-05-26  8:45 [PATCH 1/3] common/sfc_efx/base: convert EFX PCIe INTF to MCDI value Ivan Malov
@ 2022-05-31 16:57 ` Andrew Rybchenko
  0 siblings, 0 replies; 2+ messages in thread
From: Andrew Rybchenko @ 2022-05-31 16:57 UTC (permalink / raw)
  To: Ivan Malov, dev; +Cc: stable, Andy Moreton, Viacheslav Galaktionov

On 5/26/22 11:45, Ivan Malov wrote:
> 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 <ivan.malov@oktetlabs.ru>
> Reviewed-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
> Reviewed-by: Andy Moreton <amoreton@xilinx.com>

Series applied to dpdk-next-net/main, thanks.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-05-31 16:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-26  8:45 [PATCH 1/3] common/sfc_efx/base: convert EFX PCIe INTF to MCDI value Ivan Malov
2022-05-31 16:57 ` Andrew Rybchenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).