[ovs-dev] [PATCH ovs v1 1/2] netdev-dpdk: Add ability to set MAC address.
Noa Ezra
noae at mellanox.com
Thu Mar 5 14:15:05 UTC 2020
From: Ilya Maximets <i.maximets at ovn.org>
It is possible to set MAC address for DPDK ports by calling
rte_eth_dev_default_mac_addr_set(). For some reason OVS didn't
use this functionality avoiding real MAC address configuration.
With this change following command will result in real MAC address
update on HW NIC:
ovs-vsctl set Interface <dpdk interface> mac="xx:xx:xx:xx:xx:xx"
Signed-off-by: Ilya Maximets <i.maximets at ovn.org>
Acked-by: Ben Pfaff <blp at ovn.org>
---
lib/netdev-dpdk.c | 19 ++++++++++++++++---
1 file changed, 16 insertions(+), 3 deletions(-)
diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
index 7ab8186..e375b3d 100644
--- a/lib/netdev-dpdk.c
+++ b/lib/netdev-dpdk.c
@@ -2968,15 +2968,28 @@ static int
netdev_dpdk_set_etheraddr(struct netdev *netdev, const struct eth_addr mac)
{
struct netdev_dpdk *dev = netdev_dpdk_cast(netdev);
+ int err = 0;
ovs_mutex_lock(&dev->mutex);
if (!eth_addr_equals(dev->hwaddr, mac)) {
- dev->hwaddr = mac;
- netdev_change_seq_changed(netdev);
+ if (dev->type == DPDK_DEV_ETH) {
+ struct rte_ether_addr ea;
+
+ memcpy(ea.addr_bytes, mac.ea, ETH_ADDR_LEN);
+ err = rte_eth_dev_default_mac_addr_set(dev->port_id, &ea);
+ }
+ if (!err) {
+ dev->hwaddr = mac;
+ netdev_change_seq_changed(netdev);
+ } else {
+ VLOG_WARN("%s: Failed to set requested mac("ETH_ADDR_FMT"): %s",
+ netdev_get_name(netdev), ETH_ADDR_ARGS(mac),
+ rte_strerror(-err));
+ }
}
ovs_mutex_unlock(&dev->mutex);
- return 0;
+ return -err;
}
static int
--
1.8.3.1
More information about the dev
mailing list