net/mlx5: support getting MAC on Windows
authorTal Shnaiderman <talshn@nvidia.com>
Mon, 28 Dec 2020 12:32:35 +0000 (14:32 +0200)
committerFerruh Yigit <ferruh.yigit@intel.com>
Fri, 8 Jan 2021 15:03:07 +0000 (16:03 +0100)
This commits implements API mlx5_get_mac().  It returns the MAC address
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/meson.build
drivers/net/mlx5/windows/mlx5_ethdev_os.c [new file with mode: 0644]

index e1fb56b..d7d501c 100644 (file)
@@ -5,4 +5,5 @@ includes += include_directories('.')
 sources += files(
        'mlx5_os.c',
        'mlx5_mp_os.c',
+       'mlx5_ethdev_os.c',
 )
diff --git a/drivers/net/mlx5/windows/mlx5_ethdev_os.c b/drivers/net/mlx5/windows/mlx5_ethdev_os.c
new file mode 100644 (file)
index 0000000..0662c09
--- /dev/null
@@ -0,0 +1,43 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright 2020 Mellanox Technologies, Ltd
+ */
+#include <stdio.h>
+
+#include <rte_errno.h>
+#include <rte_ether.h>
+#include <rte_ethdev_driver.h>
+#include <rte_interrupts.h>
+
+#include <mlx5_glue.h>
+#include <mlx5_devx_cmds.h>
+#include <mlx5_common.h>
+#include <mlx5_win_ext.h>
+#include <mlx5_malloc.h>
+#include <mlx5.h>
+
+/**
+ * Get MAC address by querying netdevice.
+ *
+ * @param[in] dev
+ *   Pointer to Ethernet device.
+ * @param[out] mac
+ *   MAC address output buffer.
+ *
+ * @return
+ *   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)[RTE_ETHER_ADDR_LEN])
+{
+       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;
+       memcpy(mac, context_obj->mlx5_dev.eth_mac, RTE_ETHER_ADDR_LEN);
+       return 0;
+}