common/sfc_efx/base: convert EFX PCIe INTF to MCDI value

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>
This commit is contained in:
Ivan Malov 2022-05-26 11:45:48 +03:00 committed by Andrew Rybchenko
parent 592ab76f9f
commit b85f50487e
2 changed files with 46 additions and 4 deletions

View File

@ -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(

View File

@ -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 @@ fail1:
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