[dpdk-dev] [PATCH 08/35] net/mlx5/windows: support get mac
Tal Shnaiderman
talshn at nvidia.com
Thu Dec 17 18:30:10 CET 2020
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 at nvidia.com>
Acked-by: Matan Azrad <matan at nvidia.com>
---
drivers/net/mlx5/windows/meson.build | 1 +
drivers/net/mlx5/windows/mlx5_ethdev_os.c | 43 +++++++++++++++++++++++++++++++
2 files changed, 44 insertions(+)
create mode 100644 drivers/net/mlx5/windows/mlx5_ethdev_os.c
diff --git a/drivers/net/mlx5/windows/meson.build b/drivers/net/mlx5/windows/meson.build
index f87dcb1b4c..b5d9f0ee04 100644
--- a/drivers/net/mlx5/windows/meson.build
+++ b/drivers/net/mlx5/windows/meson.build
@@ -5,5 +5,6 @@ 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
index 0000000000..0662c095d1
--- /dev/null
+++ b/drivers/net/mlx5/windows/mlx5_ethdev_os.c
@@ -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;
+}
--
2.16.1.windows.4
More information about the dev
mailing list