DPDK patches and discussions
 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-26  8:45 ` [PATCH 2/3] common/sfc_efx/base: manage VNIC MAC address by MCDI handle Ivan Malov
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ 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] 5+ messages in thread

* [PATCH 2/3] common/sfc_efx/base: manage VNIC MAC address by MCDI handle
  2022-05-26  8:45 [PATCH 1/3] common/sfc_efx/base: convert EFX PCIe INTF to MCDI value Ivan Malov
@ 2022-05-26  8:45 ` 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
  2 siblings, 1 reply; 5+ messages in thread
From: Ivan Malov @ 2022-05-26  8:45 UTC (permalink / raw)
  To: dev; +Cc: Andrew Rybchenko, Andy Moreton, Ray Kinsella

The board admin may need to assign a MAC address to a guest
VNIC identified by its MCDI handle. Provide an API for that.

In the case when a libefx-based driver is used at the guest,
it will need to check its MAC address using the symmetrical
API if the admin has tweaked it by means of its representor.

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/ef10_nic.c |   9 ++-
 drivers/common/sfc_efx/base/efx.h      |  21 ++++-
 drivers/common/sfc_efx/base/efx_mcdi.c | 101 +++++++++++++++++++++++++
 drivers/common/sfc_efx/version.map     |   2 +
 4 files changed, 127 insertions(+), 6 deletions(-)

diff --git a/drivers/common/sfc_efx/base/ef10_nic.c b/drivers/common/sfc_efx/base/ef10_nic.c
index aa667309ab..b27fc64210 100644
--- a/drivers/common/sfc_efx/base/ef10_nic.c
+++ b/drivers/common/sfc_efx/base/ef10_nic.c
@@ -1991,8 +1991,9 @@ efx_mcdi_nic_board_cfg(
 	if ((rc = ef10_mcdi_get_pf_count(enp, &encp->enc_hw_pf_count)) != 0)
 		goto fail4;
 
-	/* MAC address for this function */
-	if (EFX_PCI_FUNCTION_IS_PF(encp)) {
+	rc = efx_mcdi_client_mac_addr_get(enp, CLIENT_HANDLE_SELF, mac_addr);
+	if ((rc != 0) && EFX_PCI_FUNCTION_IS_PF(encp)) {
+		/* Fallback for legacy MAC address get approach (PF) */
 		rc = efx_mcdi_get_mac_address_pf(enp, mac_addr);
 #if EFSYS_OPT_ALLOW_UNCONFIGURED_NIC
 		/*
@@ -2011,9 +2012,11 @@ efx_mcdi_nic_board_cfg(
 			rc = EINVAL;
 		}
 #endif /* EFSYS_OPT_ALLOW_UNCONFIGURED_NIC */
-	} else {
+	} else if (rc != 0) {
+		/* Fallback for legacy MAC address get approach (VF) */
 		rc = efx_mcdi_get_mac_address_vf(enp, mac_addr);
 	}
+
 	if (rc != 0)
 		goto fail5;
 
diff --git a/drivers/common/sfc_efx/base/efx.h b/drivers/common/sfc_efx/base/efx.h
index 854527e0fd..95f5fb6bc0 100644
--- a/drivers/common/sfc_efx/base/efx.h
+++ b/drivers/common/sfc_efx/base/efx.h
@@ -311,6 +311,8 @@ efx_nic_check_pcie_link_speed(
 	__in		uint32_t pcie_link_gen,
 	__out		efx_pcie_link_performance_t *resultp);
 
+#define	EFX_MAC_ADDR_LEN 6
+
 #if EFSYS_OPT_MCDI
 
 #if EFSYS_OPT_RIVERHEAD || EFX_OPTS_EF10()
@@ -406,6 +408,20 @@ efx_mcdi_get_own_client_handle(
 	__in		efx_nic_t *enp,
 	__out		uint32_t *handle);
 
+LIBEFX_API
+extern	__checkReturn	efx_rc_t
+efx_mcdi_client_mac_addr_get(
+	__in		efx_nic_t *enp,
+	__in		uint32_t client_handle,
+	__out		uint8_t addr_bytes[EFX_MAC_ADDR_LEN]);
+
+LIBEFX_API
+extern	__checkReturn	efx_rc_t
+efx_mcdi_client_mac_addr_set(
+	__in		efx_nic_t *enp,
+	__in		uint32_t client_handle,
+	__in		const uint8_t addr_bytes[EFX_MAC_ADDR_LEN]);
+
 LIBEFX_API
 extern			void
 efx_mcdi_fini(
@@ -616,11 +632,10 @@ typedef enum efx_link_mode_e {
 	EFX_LINK_NMODES
 } efx_link_mode_t;
 
-#define	EFX_MAC_ADDR_LEN 6
-
 #define	EFX_VNI_OR_VSID_LEN 3
 
-#define	EFX_MAC_ADDR_IS_MULTICAST(_address) (((uint8_t *)_address)[0] & 0x01)
+#define	EFX_MAC_ADDR_IS_MULTICAST(_address)	\
+	(((const uint8_t *)_address)[0] & 0x01)
 
 #define	EFX_MAC_MULTICAST_LIST_MAX	256
 
diff --git a/drivers/common/sfc_efx/base/efx_mcdi.c b/drivers/common/sfc_efx/base/efx_mcdi.c
index 404ca23d58..6274cf6bac 100644
--- a/drivers/common/sfc_efx/base/efx_mcdi.c
+++ b/drivers/common/sfc_efx/base/efx_mcdi.c
@@ -727,6 +727,107 @@ efx_mcdi_get_own_client_handle(
 	return (rc);
 }
 
+	__checkReturn	efx_rc_t
+efx_mcdi_client_mac_addr_get(
+	__in		efx_nic_t *enp,
+	__in		uint32_t client_handle,
+	__out		uint8_t addr_bytes[EFX_MAC_ADDR_LEN])
+{
+	efx_mcdi_req_t req;
+	EFX_MCDI_DECLARE_BUF(payload,
+	    MC_CMD_GET_CLIENT_MAC_ADDRESSES_IN_LEN,
+	    MC_CMD_GET_CLIENT_MAC_ADDRESSES_OUT_LEN(1));
+	efx_rc_t rc;
+
+	req.emr_cmd = MC_CMD_GET_CLIENT_MAC_ADDRESSES;
+	req.emr_in_buf = payload;
+	req.emr_in_length = MC_CMD_GET_CLIENT_MAC_ADDRESSES_IN_LEN;
+	req.emr_out_buf = payload;
+	req.emr_out_length = MC_CMD_GET_CLIENT_MAC_ADDRESSES_OUT_LEN(1);
+
+	MCDI_IN_SET_DWORD(req, GET_CLIENT_MAC_ADDRESSES_IN_CLIENT_HANDLE,
+	    client_handle);
+
+	efx_mcdi_execute(enp, &req);
+
+	if (req.emr_rc != 0) {
+		rc = req.emr_rc;
+		goto fail1;
+	}
+
+	if (req.emr_out_length_used <
+	    MC_CMD_GET_CLIENT_MAC_ADDRESSES_OUT_LEN(1)) {
+		rc = EMSGSIZE;
+		goto fail2;
+	}
+
+	memcpy(addr_bytes,
+	    MCDI_OUT2(req, uint8_t, GET_CLIENT_MAC_ADDRESSES_OUT_MAC_ADDRS),
+	    EFX_MAC_ADDR_LEN);
+
+	return (0);
+
+fail2:
+	EFSYS_PROBE(fail2);
+fail1:
+	EFSYS_PROBE1(fail1, efx_rc_t, rc);
+	return (rc);
+}
+
+	__checkReturn	efx_rc_t
+efx_mcdi_client_mac_addr_set(
+	__in		efx_nic_t *enp,
+	__in		uint32_t client_handle,
+	__in		const uint8_t addr_bytes[EFX_MAC_ADDR_LEN])
+{
+	efx_mcdi_req_t req;
+	EFX_MCDI_DECLARE_BUF(payload,
+	    MC_CMD_SET_CLIENT_MAC_ADDRESSES_IN_LEN(1),
+	    MC_CMD_SET_CLIENT_MAC_ADDRESSES_OUT_LEN);
+	uint32_t oui;
+	efx_rc_t rc;
+
+	if (EFX_MAC_ADDR_IS_MULTICAST(addr_bytes)) {
+		rc = EINVAL;
+		goto fail1;
+	}
+
+	oui = addr_bytes[0] << 16 | addr_bytes[1] << 8 | addr_bytes[2];
+	if (oui == 0x000000) {
+		rc = EINVAL;
+		goto fail2;
+	}
+
+	req.emr_cmd = MC_CMD_SET_CLIENT_MAC_ADDRESSES;
+	req.emr_in_buf = payload;
+	req.emr_in_length = MC_CMD_SET_CLIENT_MAC_ADDRESSES_IN_LEN(1);
+	req.emr_out_buf = payload;
+	req.emr_out_length = MC_CMD_SET_CLIENT_MAC_ADDRESSES_OUT_LEN;
+
+	MCDI_IN_SET_DWORD(req, SET_CLIENT_MAC_ADDRESSES_IN_CLIENT_HANDLE,
+	    client_handle);
+
+	memcpy(MCDI_IN2(req, uint8_t, SET_CLIENT_MAC_ADDRESSES_IN_MAC_ADDRS),
+	    addr_bytes, EFX_MAC_ADDR_LEN);
+
+	efx_mcdi_execute(enp, &req);
+
+	if (req.emr_rc != 0) {
+		rc = req.emr_rc;
+		goto fail3;
+	}
+
+	return (0);
+
+fail3:
+	EFSYS_PROBE(fail3);
+fail2:
+	EFSYS_PROBE(fail2);
+fail1:
+	EFSYS_PROBE1(fail1, efx_rc_t, rc);
+	return (rc);
+}
+
 			void
 efx_mcdi_get_timeout(
 	__in		efx_nic_t *enp,
diff --git a/drivers/common/sfc_efx/version.map b/drivers/common/sfc_efx/version.map
index 9510897b83..a54aab0a08 100644
--- a/drivers/common/sfc_efx/version.map
+++ b/drivers/common/sfc_efx/version.map
@@ -144,6 +144,8 @@ INTERNAL {
 	efx_mae_outer_rule_remove;
 	efx_mae_read_mport_journal;
 
+	efx_mcdi_client_mac_addr_get;
+	efx_mcdi_client_mac_addr_set;
 	efx_mcdi_fini;
 	efx_mcdi_get_client_handle;
 	efx_mcdi_get_own_client_handle;
-- 
2.30.2


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

* [PATCH 3/3] net/sfc: allow to control the represented entity MAC address
  2022-05-26  8:45 [PATCH 1/3] common/sfc_efx/base: convert EFX PCIe INTF to MCDI value Ivan Malov
  2022-05-26  8:45 ` [PATCH 2/3] common/sfc_efx/base: manage VNIC MAC address by MCDI handle Ivan Malov
@ 2022-05-26  8:45 ` Ivan Malov
  2022-05-31 16:57 ` [PATCH 1/3] common/sfc_efx/base: convert EFX PCIe INTF to MCDI value Andrew Rybchenko
  2 siblings, 0 replies; 5+ messages in thread
From: Ivan Malov @ 2022-05-26  8:45 UTC (permalink / raw)
  To: dev; +Cc: Andrew Rybchenko, Andy Moreton

The MAC address is accessed via the representor ethdev's one.

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/net/sfc/sfc_port.c           |  1 +
 drivers/net/sfc/sfc_repr.c           | 29 ++++++++++++++++--
 drivers/net/sfc/sfc_repr_proxy.c     | 45 +++++++++++++++++++++++++++-
 drivers/net/sfc/sfc_repr_proxy.h     |  1 +
 drivers/net/sfc/sfc_repr_proxy_api.h |  7 ++++-
 5 files changed, 78 insertions(+), 5 deletions(-)

diff --git a/drivers/net/sfc/sfc_port.c b/drivers/net/sfc/sfc_port.c
index 91139375ea..5f312ab1ba 100644
--- a/drivers/net/sfc/sfc_port.c
+++ b/drivers/net/sfc/sfc_port.c
@@ -8,6 +8,7 @@
  */
 
 #include <rte_bitmap.h>
+#include <rte_ether.h>
 
 #include "efx.h"
 
diff --git a/drivers/net/sfc/sfc_repr.c b/drivers/net/sfc/sfc_repr.c
index 9d88d554c1..d0e5385889 100644
--- a/drivers/net/sfc/sfc_repr.c
+++ b/drivers/net/sfc/sfc_repr.c
@@ -853,6 +853,17 @@ sfc_repr_dev_close(struct rte_eth_dev *dev)
 	return 0;
 }
 
+static int
+sfc_repr_mac_addr_set(struct rte_eth_dev *dev, struct rte_ether_addr *mac_addr)
+{
+	struct sfc_repr_shared *srs = sfc_repr_shared_by_eth_dev(dev);
+	int ret;
+
+	ret = sfc_repr_proxy_repr_entity_mac_addr_set(srs->pf_port_id,
+						      srs->repr_id, mac_addr);
+	return -ret;
+}
+
 static int
 sfc_repr_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
 {
@@ -889,6 +900,7 @@ static const struct eth_dev_ops sfc_repr_dev_ops = {
 	.dev_close			= sfc_repr_dev_close,
 	.dev_infos_get			= sfc_repr_dev_infos_get,
 	.link_update			= sfc_repr_dev_link_update,
+	.mac_addr_set			= sfc_repr_mac_addr_set,
 	.stats_get			= sfc_repr_stats_get,
 	.rx_queue_setup			= sfc_repr_rx_queue_setup,
 	.rx_queue_release		= sfc_repr_rx_queue_release,
@@ -956,9 +968,9 @@ sfc_repr_eth_dev_init(struct rte_eth_dev *dev, void *init_params)
 	}
 
 	ret = sfc_repr_proxy_add_port(repr_data->pf_port_id,
-				      srs->switch_port_id,
-				      dev->data->port_id,
-				      &repr_data->mport_sel);
+				      srs->switch_port_id, dev->data->port_id,
+				      &repr_data->mport_sel, repr_data->intf,
+				      repr_data->pf, repr_data->vf);
 	if (ret != 0) {
 		SFC_GENERIC_LOG(ERR, "%s() failed to add repr proxy port",
 				__func__);
@@ -996,6 +1008,16 @@ sfc_repr_eth_dev_init(struct rte_eth_dev *dev, void *init_params)
 		goto fail_mac_addrs;
 	}
 
+	rte_eth_random_addr(dev->data->mac_addrs[0].addr_bytes);
+
+	ret = sfc_repr_proxy_repr_entity_mac_addr_set(repr_data->pf_port_id,
+						      srs->repr_id,
+						      &dev->data->mac_addrs[0]);
+	if (ret != 0) {
+		ret = -ret;
+		goto fail_mac_addr_set;
+	}
+
 	dev->rx_pkt_burst = sfc_repr_rx_burst;
 	dev->tx_pkt_burst = sfc_repr_tx_burst;
 	dev->dev_ops = &sfc_repr_dev_ops;
@@ -1005,6 +1027,7 @@ sfc_repr_eth_dev_init(struct rte_eth_dev *dev, void *init_params)
 
 	return 0;
 
+fail_mac_addr_set:
 fail_mac_addrs:
 	sfc_repr_unlock(sr);
 	free(sr);
diff --git a/drivers/net/sfc/sfc_repr_proxy.c b/drivers/net/sfc/sfc_repr_proxy.c
index 8660d419a3..4b958ced61 100644
--- a/drivers/net/sfc/sfc_repr_proxy.c
+++ b/drivers/net/sfc/sfc_repr_proxy.c
@@ -1280,7 +1280,8 @@ sfc_repr_proxy_stop(struct sfc_adapter *sa)
 
 int
 sfc_repr_proxy_add_port(uint16_t pf_port_id, uint16_t repr_id,
-			uint16_t rte_port_id, const efx_mport_sel_t *mport_sel)
+			uint16_t rte_port_id, const efx_mport_sel_t *mport_sel,
+			efx_pcie_interface_t intf, uint16_t pf, uint16_t vf)
 {
 	struct sfc_repr_proxy_port *port;
 	struct sfc_repr_proxy *rp;
@@ -1319,6 +1320,14 @@ sfc_repr_proxy_add_port(uint16_t pf_port_id, uint16_t repr_id,
 	port->rte_port_id = rte_port_id;
 	port->repr_id = repr_id;
 
+	rc = efx_mcdi_get_client_handle(sa->nic, intf, pf, vf,
+					&port->remote_vnic_mcdi_client_handle);
+	if (rc != 0) {
+		sfc_err(sa, "failed to get the represented VNIC's MCDI handle (repr_id=%u): %s",
+			repr_id, rte_strerror(rc));
+		goto fail_client_handle;
+	}
+
 	if (rp->started) {
 		rc = sfc_repr_proxy_mbox_send(&rp->mbox, port,
 					      SFC_REPR_PROXY_MBOX_ADD_PORT);
@@ -1337,6 +1346,7 @@ sfc_repr_proxy_add_port(uint16_t pf_port_id, uint16_t repr_id,
 	return 0;
 
 fail_port_add:
+fail_client_handle:
 fail_mport_id:
 	rte_free(port);
 fail_alloc_port:
@@ -1664,3 +1674,36 @@ sfc_repr_proxy_stop_repr(uint16_t pf_port_id, uint16_t repr_id)
 
 	return 0;
 }
+
+int
+sfc_repr_proxy_repr_entity_mac_addr_set(uint16_t pf_port_id, uint16_t repr_id,
+					const struct rte_ether_addr *mac_addr)
+{
+	struct sfc_repr_proxy_port *port;
+	struct sfc_repr_proxy *rp;
+	struct sfc_adapter *sa;
+	int rc;
+
+	sa = sfc_get_adapter_by_pf_port_id(pf_port_id);
+	rp = sfc_repr_proxy_by_adapter(sa);
+
+	port = sfc_repr_proxy_find_port(rp, repr_id);
+	if (port == NULL) {
+		sfc_err(sa, "%s() failed: no such port (repr_id=%u)",
+			__func__, repr_id);
+		sfc_put_adapter(sa);
+		return ENOENT;
+	}
+
+	rc = efx_mcdi_client_mac_addr_set(sa->nic,
+					  port->remote_vnic_mcdi_client_handle,
+					  mac_addr->addr_bytes);
+	if (rc != 0) {
+		sfc_err(sa, "%s() failed: cannot set MAC address (repr_id=%u): %s",
+			__func__, repr_id, rte_strerror(rc));
+	}
+
+	sfc_put_adapter(sa);
+
+	return rc;
+}
diff --git a/drivers/net/sfc/sfc_repr_proxy.h b/drivers/net/sfc/sfc_repr_proxy.h
index b49b1a2a96..260e2cab30 100644
--- a/drivers/net/sfc/sfc_repr_proxy.h
+++ b/drivers/net/sfc/sfc_repr_proxy.h
@@ -64,6 +64,7 @@ struct sfc_repr_proxy_port {
 	uint16_t				repr_id;
 	uint16_t				rte_port_id;
 	efx_mport_id_t				egress_mport;
+	uint32_t				remote_vnic_mcdi_client_handle;
 	struct sfc_repr_proxy_rxq		rxq[SFC_REPR_RXQ_MAX];
 	struct sfc_repr_proxy_txq		txq[SFC_REPR_TXQ_MAX];
 	struct sfc_mae_rule			*mae_rule;
diff --git a/drivers/net/sfc/sfc_repr_proxy_api.h b/drivers/net/sfc/sfc_repr_proxy_api.h
index 95b065801d..1d38ab2451 100644
--- a/drivers/net/sfc/sfc_repr_proxy_api.h
+++ b/drivers/net/sfc/sfc_repr_proxy_api.h
@@ -23,7 +23,9 @@ extern "C" {
 
 int sfc_repr_proxy_add_port(uint16_t pf_port_id, uint16_t repr_id,
 			    uint16_t rte_port_id,
-			    const efx_mport_sel_t *mport_set);
+			    const efx_mport_sel_t *mport_sel,
+			    efx_pcie_interface_t intf, uint16_t pf,
+			    uint16_t vf);
 int sfc_repr_proxy_del_port(uint16_t pf_port_id, uint16_t repr_id);
 
 int sfc_repr_proxy_add_rxq(uint16_t pf_port_id, uint16_t repr_id,
@@ -41,6 +43,9 @@ void sfc_repr_proxy_del_txq(uint16_t pf_port_id, uint16_t repr_id,
 int sfc_repr_proxy_start_repr(uint16_t pf_port_id, uint16_t repr_id);
 int sfc_repr_proxy_stop_repr(uint16_t pf_port_id, uint16_t repr_id);
 
+int sfc_repr_proxy_repr_entity_mac_addr_set(uint16_t pf_port_id,
+		uint16_t repr_id, const struct rte_ether_addr *mac_addr);
+
 #ifdef __cplusplus
 }
 #endif
-- 
2.30.2


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

* Re: [PATCH 2/3] common/sfc_efx/base: manage VNIC MAC address by MCDI handle
  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
  0 siblings, 0 replies; 5+ messages in thread
From: Ray Kinsella @ 2022-05-26  9:54 UTC (permalink / raw)
  To: Ivan Malov; +Cc: dev, Andrew Rybchenko, Andy Moreton


Ivan Malov <ivan.malov@oktetlabs.ru> writes:

> The board admin may need to assign a MAC address to a guest
> VNIC identified by its MCDI handle. Provide an API for that.
>
> In the case when a libefx-based driver is used at the guest,
> it will need to check its MAC address using the symmetrical
> API if the admin has tweaked it by means of its representor.
>
> 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/ef10_nic.c |   9 ++-
>  drivers/common/sfc_efx/base/efx.h      |  21 ++++-
>  drivers/common/sfc_efx/base/efx_mcdi.c | 101 +++++++++++++++++++++++++
>  drivers/common/sfc_efx/version.map     |   2 +
>  4 files changed, 127 insertions(+), 6 deletions(-)
>

Acked-by: Ray Kinsella <mdr@ashoe.eu>

^ permalink raw reply	[flat|nested] 5+ 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-26  8:45 ` [PATCH 2/3] common/sfc_efx/base: manage VNIC MAC address by MCDI handle Ivan Malov
  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 ` Andrew Rybchenko
  2 siblings, 0 replies; 5+ 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] 5+ messages in thread

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

Thread overview: 5+ 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-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

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).