diff options
author | Ilya Maximets <i.maximets@ovn.org> | 2020-11-10 12:51:48 +0100 |
---|---|---|
committer | Ilya Maximets <i.maximets@ovn.org> | 2020-11-16 17:47:11 +0100 |
commit | f9b0107dd04a4cb05877d9bb8bd200e0b344fadc (patch) | |
tree | 4cd0a0ea576a5b21a785a670c9b56057637df873 /lib | |
parent | 08ec09725ab1c2fab62da30643db3c41fe85fab3 (diff) | |
download | openvswitch-f9b0107dd04a4cb05877d9bb8bd200e0b344fadc.tar.gz |
netdev-dpdk: Add ability to set MAC address.
It is possible to set the MAC address of DPDK ports by calling
rte_eth_dev_default_mac_addr_set(). OvS does not actually call
this function for non-internal ports, but the implementation is
exposed to be used in a later commit.
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
Signed-off-by: Gaetan Rivet <grive@u256.net>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/netdev-dpdk.c | 32 |
1 files changed, 29 insertions, 3 deletions
diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c index 0b830be78..084f97807 100644 --- a/lib/netdev-dpdk.c +++ b/lib/netdev-dpdk.c @@ -2911,18 +2911,44 @@ netdev_dpdk_eth_send(struct netdev *netdev, int qid, } static int +netdev_dpdk_set_etheraddr__(struct netdev_dpdk *dev, const struct eth_addr mac) + OVS_REQUIRES(dev->mutex) +{ + int err = 0; + + 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; + } else { + VLOG_WARN("%s: Failed to set requested mac("ETH_ADDR_FMT"): %s", + netdev_get_name(&dev->up), ETH_ADDR_ARGS(mac), + rte_strerror(err)); + } + + return err; +} + +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); + err = netdev_dpdk_set_etheraddr__(dev, mac); + if (!err) { + netdev_change_seq_changed(netdev); + } } ovs_mutex_unlock(&dev->mutex); - return 0; + return err; } static int |