[v2,3/3] net/mlx5: set VF MAC address from host
Checks
Commit Message
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 <thomas@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(+)
@@ -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)
@@ -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);
@@ -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.
*