[ovs-dev] [PATCH v2] netdev-dpdk: Add ability to set MAC address.
Ilya Maximets
i.maximets at ovn.org
Wed Oct 30 18:09:34 UTC 2019
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>
---
Sending this patch formally in context of discussions for setting VF
MAC addresses.
*Note*: Only compile tested due to lack of HW.
Version 2:
* Removed special treatment of -ENOTSUP.
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 04e1a2d1b..4469860f3 100644
--- a/lib/netdev-dpdk.c
+++ b/lib/netdev-dpdk.c
@@ -2541,15 +2541,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 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
--
2.17.1
More information about the dev
mailing list