net/mlx5: support getting interface name on Windows
authorTal Shnaiderman <talshn@nvidia.com>
Mon, 28 Dec 2020 12:32:40 +0000 (14:32 +0200)
committerFerruh Yigit <ferruh.yigit@intel.com>
Fri, 8 Jan 2021 15:03:08 +0000 (16:03 +0100)
This commit copies the interface name as saved in the device context
since its creation.

Signed-off-by: Tal Shnaiderman <talshn@nvidia.com>
Acked-by: Matan Azrad <matan@nvidia.com>
drivers/net/mlx5/windows/mlx5_ethdev_os.c

index 614322b..f0355ac 100644 (file)
@@ -43,6 +43,34 @@ mlx5_get_mac(struct rte_eth_dev *dev, uint8_t (*mac)[RTE_ETHER_ADDR_LEN])
        return 0;
 }
 
+/**
+ * Get interface name from private structure.
+ *
+ *
+ * @param[in] dev
+ *   Pointer to Ethernet device.
+ * @param[out] ifname
+ *   Interface name output buffer.
+ *
+ * @return
+ *   0 on success, a negative errno value otherwise and rte_errno is set.
+ */
+int
+mlx5_get_ifname(const struct rte_eth_dev *dev, char (*ifname)[IF_NAMESIZE])
+{
+       struct mlx5_priv *priv;
+       mlx5_context_st *context_obj;
+
+       if (!dev) {
+               rte_errno = EINVAL;
+               return -rte_errno;
+       }
+       priv = dev->data->dev_private;
+       context_obj = (mlx5_context_st *)priv->sh->ctx;
+       strncpy(*ifname, context_obj->mlx5_dev.name, IF_NAMESIZE);
+       return 0;
+}
+
 /**
  * Get device MTU.
  *