Message ID | 20191030180934.14144-1-i.maximets@ovn.org |
---|---|
State | Superseded |
Headers | show |
Series | [ovs-dev,v2] netdev-dpdk: Add ability to set MAC address. | expand |
On Wed, Oct 30, 2019 at 07:09:34PM +0100, Ilya Maximets wrote: > 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@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. Acked-by: Ben Pfaff <blp@ovn.org>
Hi Ilya, I have taken and tested your code against DPDK 19.11.0 release. I can confirm your code works, but at the moment is not being called. When setting MAC address in OVSDB, there is an interface type check in vswitchd/bridge.c:iface_set_mac() that block calls to any set_etheraddr()s except for internal interfaces. I have submitted a separate patch to allow DPDK interfaces through as well as internal: https://patchwork.ozlabs.org/patch/1215075/ Please, take a look at it and let me if you think it's ok. We have also verified Roni's RFC use-case for cloud controllers ( https://mail.openvswitch.org/pipermail/ovs-dev/2019-October/364063.html ) with DPDK 19.11 - needed changes to propagate representor's MAC to VF are merged. Note: for 19.11 need to prefix struct ether_addr with 'rte_'. Sincerely, Eveline Raine
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
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@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(-)