Re: [ovs-dev] [PATCH] netdev-dpdk: Add ability to set MAC address.

2019-10-30 Thread Ilya Maximets

On 30.10.2019 18:21, Ben Pfaff wrote:

On Wed, Oct 30, 2019 at 04:40:18PM +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  mac="xx:xx:xx:xx:xx:xx"

Signed-off-by: Ilya Maximets 


I'm not sure why this treats -ENOTSUP as success.


You're right. This is a mistake. I had a thought that it'll be
inconvenient to report an error in this case, because some DPDK
virtual devices doesn't implement this functionality, but I
forgot that there will be no attempts to configure MAC if user
didn't set it explicitly.

I'll send v2.

Best regards, Ilya Maximets.
___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


Re: [ovs-dev] [PATCH] netdev-dpdk: Add ability to set MAC address.

2019-10-30 Thread Ben Pfaff
On Wed, Oct 30, 2019 at 04:40:18PM +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  mac="xx:xx:xx:xx:xx:xx"
> 
> Signed-off-by: Ilya Maximets 

I'm not sure why this treats -ENOTSUP as success.
___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] [PATCH] netdev-dpdk: Add ability to set MAC address.

2019-10-30 Thread Ilya Maximets
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  mac="xx:xx:xx:xx:xx:xx"

Signed-off-by: Ilya Maximets 
---

Sending this patch formally in context of discussions for setting VF
MAC addresses.

Only compile tested due to lack of HW.

 lib/netdev-dpdk.c | 20 +---
 1 file changed, 17 insertions(+), 3 deletions(-)

diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
index 04e1a2d1b..b95439fcc 100644
--- a/lib/netdev-dpdk.c
+++ b/lib/netdev-dpdk.c
@@ -2541,15 +2541,29 @@ 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(>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, );
+}
+if (!err || err == -ENOTSUP) {
+err = 0;
+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(>mutex);
 
-return 0;
+return -err;
 }
 
 static int
-- 
2.17.1

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev