From: Ivan Malov <ivan.malov@oktetlabs.ru>
To: dev@dpdk.org
Cc: stable@dpdk.org, Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>,
Andy Moreton <amoreton@xilinx.com>,
Viacheslav Galaktionov <viacheslav.galaktionov@oktetlabs.ru>
Subject: [PATCH 1/3] common/sfc_efx/base: convert EFX PCIe INTF to MCDI value
Date: Thu, 26 May 2022 11:45:48 +0300 [thread overview]
Message-ID: <20220526084550.243121-1-ivan.malov@oktetlabs.ru> (raw)
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
next reply other threads:[~2022-05-26 8:45 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-26 8:45 Ivan Malov [this message]
2022-05-26 8:45 ` [PATCH 2/3] common/sfc_efx/base: manage VNIC MAC address by MCDI handle Ivan Malov
2022-05-26 9:54 ` Ray Kinsella
2022-05-26 8:45 ` [PATCH 3/3] net/sfc: allow to control the represented entity MAC address Ivan Malov
2022-05-31 16:57 ` [PATCH 1/3] common/sfc_efx/base: convert EFX PCIe INTF to MCDI value Andrew Rybchenko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220526084550.243121-1-ivan.malov@oktetlabs.ru \
--to=ivan.malov@oktetlabs.ru \
--cc=amoreton@xilinx.com \
--cc=andrew.rybchenko@oktetlabs.ru \
--cc=dev@dpdk.org \
--cc=stable@dpdk.org \
--cc=viacheslav.galaktionov@oktetlabs.ru \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).