ethdev: return diagnostic when setting MAC address
[dpdk.git] / drivers / net / virtio / virtio_ethdev.c
index da022e9..41042cb 100644 (file)
@@ -67,7 +67,7 @@ static int virtio_mac_addr_add(struct rte_eth_dev *dev,
                                struct ether_addr *mac_addr,
                                uint32_t index, uint32_t vmdq);
 static void virtio_mac_addr_remove(struct rte_eth_dev *dev, uint32_t index);
-static void virtio_mac_addr_set(struct rte_eth_dev *dev,
+static int virtio_mac_addr_set(struct rte_eth_dev *dev,
                                struct ether_addr *mac_addr);
 
 static int virtio_intr_enable(struct rte_eth_dev *dev);
@@ -1056,7 +1056,7 @@ virtio_mac_addr_remove(struct rte_eth_dev *dev, uint32_t index)
        virtio_mac_table_set(hw, uc, mc);
 }
 
-static void
+static int
 virtio_mac_addr_set(struct rte_eth_dev *dev, struct ether_addr *mac_addr)
 {
        struct virtio_hw *hw = dev->data->dev_private;
@@ -1072,9 +1072,14 @@ virtio_mac_addr_set(struct rte_eth_dev *dev, struct ether_addr *mac_addr)
                ctrl.hdr.cmd = VIRTIO_NET_CTRL_MAC_ADDR_SET;
 
                memcpy(ctrl.data, mac_addr, ETHER_ADDR_LEN);
-               virtio_send_command(hw->cvq, &ctrl, &len, 1);
-       } else if (vtpci_with_feature(hw, VIRTIO_NET_F_MAC))
-               virtio_set_hwaddr(hw);
+               return virtio_send_command(hw->cvq, &ctrl, &len, 1);
+       }
+
+       if (!vtpci_with_feature(hw, VIRTIO_NET_F_MAC))
+               return -ENOTSUP;
+
+       virtio_set_hwaddr(hw);
+       return 0;
 }
 
 static int