Allow to configure the default MAC address of a VF via its representor port in the host.
This patch is a stub to demonstrate how to implement a VF operation. The real code is not implemented. Signed-off-by: Thomas Monjalon <tho...@monjalon.net> --- drivers/net/mlx5/mlx5.c | 6 ++++++ drivers/net/mlx5/mlx5.h | 1 + drivers/net/mlx5/mlx5_mac.c | 19 +++++++++++++++++++ 3 files changed, 26 insertions(+) diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c index fac510507d..b679b5e299 100644 --- a/drivers/net/mlx5/mlx5.c +++ b/drivers/net/mlx5/mlx5.c @@ -1073,6 +1073,11 @@ const struct eth_dev_ops mlx5_dev_ops_isolate = { .get_module_eeprom = mlx5_get_module_eeprom, }; +/* Available operations for VF connected to a representor. */ +const struct eth_dev_ops mlx5_remote_vf_ops = { + .mac_addr_set = mlx5_vf_mac_addr_set, +}; + /** * Verify and store value for device argument. * @@ -2130,6 +2135,7 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, eth_dev->rx_pkt_burst = removed_rx_burst; eth_dev->tx_pkt_burst = removed_tx_burst; eth_dev->dev_ops = &mlx5_dev_ops; + eth_dev->vf_ops = &mlx5_remote_vf_ops; /* Register MAC address. */ claim_zero(mlx5_mac_addr_add(eth_dev, &mac, 0, 0)); if (config.vf && config.vf_nl_en) diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h index b6a51b2b4d..e34a24ee7c 100644 --- a/drivers/net/mlx5/mlx5.h +++ b/drivers/net/mlx5/mlx5.h @@ -754,6 +754,7 @@ void mlx5_mac_addr_remove(struct rte_eth_dev *dev, uint32_t index); int mlx5_mac_addr_add(struct rte_eth_dev *dev, struct rte_ether_addr *mac, uint32_t index, uint32_t vmdq); int mlx5_mac_addr_set(struct rte_eth_dev *dev, struct rte_ether_addr *mac_addr); +int mlx5_vf_mac_addr_set(struct rte_eth_dev *dev, struct rte_ether_addr *mac); int mlx5_set_mc_addr_list(struct rte_eth_dev *dev, struct rte_ether_addr *mc_addr_set, uint32_t nb_mc_addr); diff --git a/drivers/net/mlx5/mlx5_mac.c b/drivers/net/mlx5/mlx5_mac.c index 0ffef5c5db..4c4dd55b86 100644 --- a/drivers/net/mlx5/mlx5_mac.c +++ b/drivers/net/mlx5/mlx5_mac.c @@ -202,6 +202,25 @@ mlx5_mac_addr_set(struct rte_eth_dev *dev, struct rte_ether_addr *mac_addr) return mlx5_mac_addr_add(dev, mac_addr, 0, 0); } +/** + * DPDK callback to set primary MAC address of the remote VF. + * + * @param dev + * Pointer to Ethernet device structure of a representor. + * @param mac_addr + * MAC address to register in the remote VF. + * + * @return + * 0 on success, a negative errno value otherwise and rte_errno is set. + */ +int mlx5_vf_mac_addr_set(struct rte_eth_dev *dev, struct rte_ether_addr *mac) +{ + DRV_LOG(DEBUG, "VF represented by port %u setting primary MAC address", + dev->data->port_id); + /* TODO: should not be this dev but its VF */ + return mlx5_nl_mac_addr_add(dev, mac, 0); +} + /** * DPDK callback to set multicast addresses list. * -- 2.23.0