ipc: stop async IPC loop on callback request
[dpdk.git] / drivers / net / mlx5 / mlx5_mac.c
index 526e843..edc7a32 100644 (file)
@@ -67,13 +67,19 @@ mlx5_get_mac(struct rte_eth_dev *dev, uint8_t (*mac)[ETHER_ADDR_LEN])
 void
 mlx5_mac_addr_remove(struct rte_eth_dev *dev, uint32_t index)
 {
+       struct priv *priv = dev->data->dev_private;
+       const int vf = priv->config.vf;
+       int ret;
+
        assert(index < MLX5_MAX_MAC_ADDRESSES);
+       if (vf)
+               mlx5_nl_mac_addr_remove(dev, &dev->data->mac_addrs[index],
+                                       index);
        memset(&dev->data->mac_addrs[index], 0, sizeof(struct ether_addr));
        if (!dev->data->promiscuous) {
-               int ret = mlx5_traffic_restart(dev);
-
+               ret = mlx5_traffic_restart(dev);
                if (ret)
-                       DRV_LOG(ERR, "port %u cannot remove mac address: %s",
+                       DRV_LOG(ERR, "port %u cannot restart traffic: %s",
                                dev->data->port_id, strerror(rte_errno));
        }
 }
@@ -97,6 +103,8 @@ int
 mlx5_mac_addr_add(struct rte_eth_dev *dev, struct ether_addr *mac,
                  uint32_t index, uint32_t vmdq __rte_unused)
 {
+       struct priv *priv = dev->data->dev_private;
+       const int vf = priv->config.vf;
        unsigned int i;
 
        assert(index < MLX5_MAX_MAC_ADDRESSES);
@@ -111,6 +119,12 @@ mlx5_mac_addr_add(struct rte_eth_dev *dev, struct ether_addr *mac,
                rte_errno = EADDRINUSE;
                return -rte_errno;
        }
+       if (vf) {
+               int ret = mlx5_nl_mac_addr_add(dev, mac, index);
+
+               if (ret)
+                       return ret;
+       }
        dev->data->mac_addrs[index] = *mac;
        if (!dev->data->promiscuous)
                return mlx5_traffic_restart(dev);
@@ -124,17 +138,14 @@ mlx5_mac_addr_add(struct rte_eth_dev *dev, struct ether_addr *mac,
  *   Pointer to Ethernet device structure.
  * @param mac_addr
  *   MAC address to register.
+ *
+ * @return
+ *   0 on success, a negative errno value otherwise and rte_errno is set.
  */
-void
+int
 mlx5_mac_addr_set(struct rte_eth_dev *dev, struct ether_addr *mac_addr)
 {
-       int ret;
-
        DRV_LOG(DEBUG, "port %u setting primary MAC address",
                dev->data->port_id);
-
-       ret = mlx5_mac_addr_add(dev, mac_addr, 0, 0);
-       if (ret)
-               DRV_LOG(ERR, "port %u cannot set mac address: %s",
-                       dev->data->port_id, strerror(rte_errno));
+       return mlx5_mac_addr_add(dev, mac_addr, 0, 0);
 }