net/mlx5: use port id in PMD log
[dpdk.git] / drivers / net / mlx5 / mlx5_mac.c
index 91c977b..e2f5b5b 100644 (file)
  *   MAC address output buffer.
  *
  * @return
- *   0 on success, -1 on failure and errno is set.
+ *   0 on success, a negative errno value otherwise and rte_errno is set.
  */
 int
 mlx5_get_mac(struct rte_eth_dev *dev, uint8_t (*mac)[ETHER_ADDR_LEN])
 {
        struct ifreq request;
+       int ret;
 
-       if (mlx5_ifreq(dev, SIOCGIFHWADDR, &request))
-               return -1;
+       ret = mlx5_ifreq(dev, SIOCGIFHWADDR, &request);
+       if (ret)
+               return ret;
        memcpy(mac, request.ifr_hwaddr.sa_data, ETHER_ADDR_LEN);
        return 0;
 }
@@ -67,8 +69,13 @@ mlx5_mac_addr_remove(struct rte_eth_dev *dev, uint32_t index)
 {
        assert(index < MLX5_MAX_MAC_ADDRESSES);
        memset(&dev->data->mac_addrs[index], 0, sizeof(struct ether_addr));
-       if (!dev->data->promiscuous)
-               mlx5_traffic_restart(dev);
+       if (!dev->data->promiscuous) {
+               int ret = mlx5_traffic_restart(dev);
+
+               if (ret)
+                       ERROR("port %u cannot remove mac address: %s",
+                             dev->data->port_id, strerror(rte_errno));
+       }
 }
 
 /**
@@ -84,14 +91,13 @@ mlx5_mac_addr_remove(struct rte_eth_dev *dev, uint32_t index)
  *   VMDq pool index to associate address with (ignored).
  *
  * @return
- *   0 on success.
+ *   0 on success, a negative errno value otherwise and rte_errno is set.
  */
 int
 mlx5_mac_addr_add(struct rte_eth_dev *dev, struct ether_addr *mac,
                  uint32_t index, uint32_t vmdq __rte_unused)
 {
        unsigned int i;
-       int ret = 0;
 
        assert(index < MLX5_MAX_MAC_ADDRESSES);
        /* First, make sure this address isn't already configured. */
@@ -102,12 +108,13 @@ mlx5_mac_addr_add(struct rte_eth_dev *dev, struct ether_addr *mac,
                if (memcmp(&dev->data->mac_addrs[i], mac, sizeof(*mac)))
                        continue;
                /* Address already configured elsewhere, return with error. */
-               return EADDRINUSE;
+               rte_errno = EADDRINUSE;
+               return -rte_errno;
        }
        dev->data->mac_addrs[index] = *mac;
        if (!dev->data->promiscuous)
-               mlx5_traffic_restart(dev);
-       return ret;
+               return mlx5_traffic_restart(dev);
+       return 0;
 }
 
 /**
@@ -121,6 +128,11 @@ mlx5_mac_addr_add(struct rte_eth_dev *dev, struct ether_addr *mac,
 void
 mlx5_mac_addr_set(struct rte_eth_dev *dev, struct ether_addr *mac_addr)
 {
-       DEBUG("%p: setting primary MAC address", (void *)dev);
-       mlx5_mac_addr_add(dev, mac_addr, 0, 0);
+       int ret;
+
+       DEBUG("port %u setting primary MAC address", dev->data->port_id);
+       ret = mlx5_mac_addr_add(dev, mac_addr, 0, 0);
+       if (ret)
+               ERROR("port %u cannot set mac address: %s",
+                     dev->data->port_id, strerror(rte_errno));
 }