[v2,2/3] ethdev: set VF MAC address from host

Message ID 20191029185051.32203-3-thomas@monjalon.net (mailing list archive)
State Changes Requested, archived
Delegated to: Ferruh Yigit
Headers
Series ethdev: configure SR-IOV VF from host |

Checks

Context Check Description
ci/Intel-compilation fail Compilation issues
ci/checkpatch success coding style OK

Commit Message

Thomas Monjalon Oct. 29, 2019, 6:50 p.m. UTC
  The API to set a default MAC address is extended
to support a VF ID as port ID.
In order to be supported by a driver,
the related vf_ops must be implemented.

Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
---
 lib/librte_ethdev/rte_ethdev.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
  

Patch

diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c
index fb3da4dcc3..9cf82ff10b 100644
--- a/lib/librte_ethdev/rte_ethdev.c
+++ b/lib/librte_ethdev/rte_ethdev.c
@@ -3386,20 +3386,23 @@  int
 rte_eth_dev_default_mac_addr_set(uint16_t port_id, struct rte_ether_addr *addr)
 {
 	struct rte_eth_dev *dev;
+	bool vf; /* true if port_id targets a connected VF */
 	int ret;
 
-	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	RTE_ETH_VALID_ID_OR_ERR_RET(port_id, -ENODEV);
 
 	if (!rte_is_valid_assigned_ether_addr(addr))
 		return -EINVAL;
 
+	port_id = port_id_parse(port_id, &vf);
 	dev = &rte_eth_devices[port_id];
-	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->mac_addr_set, -ENOTSUP);
-
-	ret = (*dev->dev_ops->mac_addr_set)(dev, addr);
+	ret = ETH_DEV_OP_CALL(dev, vf, mac_addr_set, addr);
 	if (ret < 0)
 		return ret;
 
+	if (vf)
+		return 0;
+
 	/* Update default address in NIC data structure */
 	rte_ether_addr_copy(addr, &dev->data->mac_addrs[0]);