mirror of
https://github.com/openvswitch/ovs
synced 2025-09-02 23:35:27 +00:00
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>
This commit is contained in:
@@ -2910,19 +2910,45 @@ netdev_dpdk_eth_send(struct netdev *netdev, int qid,
|
||||
return 0;
|
||||
}
|
||||
|
||||
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
|
||||
|
Reference in New Issue
Block a user