DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH v1 0/8] mlx5 PMD multi OS support - part #3
@ 2020-07-14 14:20 Ophir Munk
  2020-07-14 14:20 ` [dpdk-dev] [PATCH v1 1/8] net/mlx5: move flow prio discovery and adjust under verbs Ophir Munk
                   ` (7 more replies)
  0 siblings, 8 replies; 28+ messages in thread
From: Ophir Munk @ 2020-07-14 14:20 UTC (permalink / raw)
  To: dev; +Cc: Raslan Darawsheh, Ophir Munk, Matan Azrad

This patch series is part of preparing mlx5 PMD to compile
and run under multiple OSs. Part #3

v1: Initial version

Ophir Munk (8):
  net/mlx5: move flow prio discovery and adjust under verbs
  net/mlx5: replace Linux specific calls with rte API
  net/mlx5: refactor Linux MAC operations
  linux/mlx5: add setters for promiscuous and all-multi
  net/mlx5: eliminate dependency on Linux in shared header
  net/mlx5: header file cleanup
  net/mlx5: refactor multi process communication
  mlx5: remove inclusion of verbs header files

 drivers/common/mlx5/linux/mlx5_common_os.h    |   7 +-
 drivers/common/mlx5/linux/mlx5_common_verbs.c |  15 -
 drivers/common/mlx5/mlx5_common_mp.h          |  11 +-
 drivers/common/mlx5/mlx5_common_mr.h          |  11 +-
 drivers/common/mlx5/mlx5_devx_cmds.c          |   8 +-
 drivers/common/mlx5/mlx5_prm.h                |  13 +-
 drivers/net/mlx5/Makefile                     |   2 +-
 drivers/net/mlx5/linux/meson.build            |   1 +
 drivers/net/mlx5/linux/mlx5_ethdev_os.c       | 416 +++++++++++++++++++---
 drivers/net/mlx5/linux/mlx5_mp_os.c           | 211 +++++++++++
 drivers/net/mlx5/linux/mlx5_os.c              | 490 +++++++++++---------------
 drivers/net/mlx5/linux/mlx5_verbs.c           |  15 -
 drivers/net/mlx5/meson.build                  |   1 -
 drivers/net/mlx5/mlx5.c                       | 124 +------
 drivers/net/mlx5/mlx5.h                       |  67 ++--
 drivers/net/mlx5/mlx5_flow.c                  | 121 -------
 drivers/net/mlx5/mlx5_flow.h                  |  12 +-
 drivers/net/mlx5/mlx5_flow_dv.c               |  20 +-
 drivers/net/mlx5/mlx5_flow_verbs.c            | 122 ++++++-
 drivers/net/mlx5/mlx5_mac.c                   |  59 +---
 drivers/net/mlx5/mlx5_mp.c                    | 211 -----------
 drivers/net/mlx5/mlx5_mr.c                    |   9 -
 drivers/net/mlx5/mlx5_mr.h                    |  11 -
 drivers/net/mlx5/mlx5_rss.c                   |  10 -
 drivers/net/mlx5/mlx5_rxmode.c                |  23 +-
 drivers/net/mlx5/mlx5_rxq.c                   |  20 +-
 drivers/net/mlx5/mlx5_rxtx.c                  |  12 +-
 drivers/net/mlx5/mlx5_rxtx.h                  |  11 -
 drivers/net/mlx5/mlx5_rxtx_vec.c              |  12 +-
 drivers/net/mlx5/mlx5_trigger.c               |   4 +-
 drivers/net/mlx5/mlx5_txq.c                   |  40 ++-
 drivers/net/mlx5/mlx5_vlan.c                  |  17 -
 32 files changed, 1000 insertions(+), 1106 deletions(-)
 create mode 100644 drivers/net/mlx5/linux/mlx5_mp_os.c
 delete mode 100644 drivers/net/mlx5/mlx5_mp.c

-- 
2.8.4


^ permalink raw reply	[flat|nested] 28+ messages in thread

* [dpdk-dev] [PATCH v1 1/8] net/mlx5: move flow prio discovery and adjust under verbs
  2020-07-14 14:20 [dpdk-dev] [PATCH v1 0/8] mlx5 PMD multi OS support - part #3 Ophir Munk
@ 2020-07-14 14:20 ` Ophir Munk
  2020-07-14 14:20 ` [dpdk-dev] [PATCH v1 2/8] net/mlx5: replace Linux specific calls with rte API Ophir Munk
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 28+ messages in thread
From: Ophir Munk @ 2020-07-14 14:20 UTC (permalink / raw)
  To: dev; +Cc: Raslan Darawsheh, Ophir Munk, Matan Azrad

Function calls mlx5_flow_adjust_priority() and
mlx5_flow_discover_priorities() are verbs based. Move them from file
mlx5_flow.c to file mlx5_flow_verbs.c

Signed-off-by: Ophir Munk <ophirmu@mellanox.com>
Acked-by: Matan Azrad <matan@mellanox.com>
---
 drivers/net/mlx5/mlx5.h            |   1 -
 drivers/net/mlx5/mlx5_flow.c       | 112 -------------------------------------
 drivers/net/mlx5/mlx5_flow.h       |   1 +
 drivers/net/mlx5/mlx5_flow_verbs.c | 112 +++++++++++++++++++++++++++++++++++++
 4 files changed, 113 insertions(+), 113 deletions(-)

diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h
index 46e66eb..4323e67 100644
--- a/drivers/net/mlx5/mlx5.h
+++ b/drivers/net/mlx5/mlx5.h
@@ -841,7 +841,6 @@ int mlx5_traffic_restart(struct rte_eth_dev *dev);
 
 int mlx5_flow_discover_mreg_c(struct rte_eth_dev *eth_dev);
 bool mlx5_flow_ext_mreg_supported(struct rte_eth_dev *dev);
-int mlx5_flow_discover_priorities(struct rte_eth_dev *dev);
 void mlx5_flow_print(struct rte_flow *flow);
 int mlx5_flow_validate(struct rte_eth_dev *dev,
 		       const struct rte_flow_attr *attr,
diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c
index ae5ccc2..5fdf6df 100644
--- a/drivers/net/mlx5/mlx5_flow.c
+++ b/drivers/net/mlx5/mlx5_flow.c
@@ -29,7 +29,6 @@
 #include <rte_malloc.h>
 #include <rte_ip.h>
 
-#include <mlx5_glue.h>
 #include <mlx5_devx_cmds.h>
 #include <mlx5_prm.h>
 
@@ -266,17 +265,6 @@ struct mlx5_fdir {
 	struct rte_flow_action_queue queue;
 };
 
-/* Map of Verbs to Flow priority with 8 Verbs priorities. */
-static const uint32_t priority_map_3[][MLX5_PRIORITY_MAP_MAX] = {
-	{ 0, 1, 2 }, { 2, 3, 4 }, { 5, 6, 7 },
-};
-
-/* Map of Verbs to Flow priority with 16 Verbs priorities. */
-static const uint32_t priority_map_5[][MLX5_PRIORITY_MAP_MAX] = {
-	{ 0, 1, 2 }, { 3, 4, 5 }, { 6, 7, 8 },
-	{ 9, 10, 11 }, { 12, 13, 14 },
-};
-
 /* Tunnel information. */
 struct mlx5_flow_tunnel_info {
 	uint64_t tunnel; /**< Tunnel bit (see MLX5_FLOW_*). */
@@ -483,106 +471,6 @@ mlx5_flow_ext_mreg_supported(struct rte_eth_dev *dev)
 }
 
 /**
- * Discover the maximum number of priority available.
- *
- * @param[in] dev
- *   Pointer to the Ethernet device structure.
- *
- * @return
- *   number of supported flow priority on success, a negative errno
- *   value otherwise and rte_errno is set.
- */
-int
-mlx5_flow_discover_priorities(struct rte_eth_dev *dev)
-{
-	struct mlx5_priv *priv = dev->data->dev_private;
-	struct {
-		struct ibv_flow_attr attr;
-		struct ibv_flow_spec_eth eth;
-		struct ibv_flow_spec_action_drop drop;
-	} flow_attr = {
-		.attr = {
-			.num_of_specs = 2,
-			.port = (uint8_t)priv->dev_port,
-		},
-		.eth = {
-			.type = IBV_FLOW_SPEC_ETH,
-			.size = sizeof(struct ibv_flow_spec_eth),
-		},
-		.drop = {
-			.size = sizeof(struct ibv_flow_spec_action_drop),
-			.type = IBV_FLOW_SPEC_ACTION_DROP,
-		},
-	};
-	struct ibv_flow *flow;
-	struct mlx5_hrxq *drop = mlx5_hrxq_drop_new(dev);
-	uint16_t vprio[] = { 8, 16 };
-	int i;
-	int priority = 0;
-
-	if (!drop) {
-		rte_errno = ENOTSUP;
-		return -rte_errno;
-	}
-	for (i = 0; i != RTE_DIM(vprio); i++) {
-		flow_attr.attr.priority = vprio[i] - 1;
-		flow = mlx5_glue->create_flow(drop->qp, &flow_attr.attr);
-		if (!flow)
-			break;
-		claim_zero(mlx5_glue->destroy_flow(flow));
-		priority = vprio[i];
-	}
-	mlx5_hrxq_drop_release(dev);
-	switch (priority) {
-	case 8:
-		priority = RTE_DIM(priority_map_3);
-		break;
-	case 16:
-		priority = RTE_DIM(priority_map_5);
-		break;
-	default:
-		rte_errno = ENOTSUP;
-		DRV_LOG(ERR,
-			"port %u verbs maximum priority: %d expected 8/16",
-			dev->data->port_id, priority);
-		return -rte_errno;
-	}
-	DRV_LOG(INFO, "port %u flow maximum priority: %d",
-		dev->data->port_id, priority);
-	return priority;
-}
-
-/**
- * Adjust flow priority based on the highest layer and the request priority.
- *
- * @param[in] dev
- *   Pointer to the Ethernet device structure.
- * @param[in] priority
- *   The rule base priority.
- * @param[in] subpriority
- *   The priority based on the items.
- *
- * @return
- *   The new priority.
- */
-uint32_t mlx5_flow_adjust_priority(struct rte_eth_dev *dev, int32_t priority,
-				   uint32_t subpriority)
-{
-	uint32_t res = 0;
-	struct mlx5_priv *priv = dev->data->dev_private;
-
-	switch (priv->config.flow_prio) {
-	case RTE_DIM(priority_map_3):
-		res = priority_map_3[priority][subpriority];
-		break;
-	case RTE_DIM(priority_map_5):
-		res = priority_map_5[priority][subpriority];
-		break;
-	}
-	return  res;
-}
-
-/**
  * Verify the @p item specifications (spec, last, mask) are compatible with the
  * NIC capabilities.
  *
diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h
index 43cbda8..616c14a 100644
--- a/drivers/net/mlx5/mlx5_flow.h
+++ b/drivers/net/mlx5/mlx5_flow.h
@@ -919,6 +919,7 @@ int mlx5_flow_group_to_table(const struct rte_flow_attr *attributes,
 uint64_t mlx5_flow_hashfields_adjust(struct mlx5_flow_rss_desc *rss_desc,
 				     int tunnel, uint64_t layer_types,
 				     uint64_t hash_fields);
+int mlx5_flow_discover_priorities(struct rte_eth_dev *dev);
 uint32_t mlx5_flow_adjust_priority(struct rte_eth_dev *dev, int32_t priority,
 				   uint32_t subpriority);
 int mlx5_flow_get_reg_id(struct rte_eth_dev *dev,
diff --git a/drivers/net/mlx5/mlx5_flow_verbs.c b/drivers/net/mlx5/mlx5_flow_verbs.c
index 781c97f..9b8ae5b 100644
--- a/drivers/net/mlx5/mlx5_flow_verbs.c
+++ b/drivers/net/mlx5/mlx5_flow_verbs.c
@@ -37,6 +37,118 @@
 #define VERBS_SPEC_INNER(item_flags) \
 	(!!((item_flags) & MLX5_FLOW_LAYER_TUNNEL) ? IBV_FLOW_SPEC_INNER : 0)
 
+/* Map of Verbs to Flow priority with 8 Verbs priorities. */
+static const uint32_t priority_map_3[][MLX5_PRIORITY_MAP_MAX] = {
+	{ 0, 1, 2 }, { 2, 3, 4 }, { 5, 6, 7 },
+};
+
+/* Map of Verbs to Flow priority with 16 Verbs priorities. */
+static const uint32_t priority_map_5[][MLX5_PRIORITY_MAP_MAX] = {
+	{ 0, 1, 2 }, { 3, 4, 5 }, { 6, 7, 8 },
+	{ 9, 10, 11 }, { 12, 13, 14 },
+};
+
+/**
+ * Discover the maximum number of priority available.
+ *
+ * @param[in] dev
+ *   Pointer to the Ethernet device structure.
+ *
+ * @return
+ *   number of supported flow priority on success, a negative errno
+ *   value otherwise and rte_errno is set.
+ */
+int
+mlx5_flow_discover_priorities(struct rte_eth_dev *dev)
+{
+	struct mlx5_priv *priv = dev->data->dev_private;
+	struct {
+		struct ibv_flow_attr attr;
+		struct ibv_flow_spec_eth eth;
+		struct ibv_flow_spec_action_drop drop;
+	} flow_attr = {
+		.attr = {
+			.num_of_specs = 2,
+			.port = (uint8_t)priv->dev_port,
+		},
+		.eth = {
+			.type = IBV_FLOW_SPEC_ETH,
+			.size = sizeof(struct ibv_flow_spec_eth),
+		},
+		.drop = {
+			.size = sizeof(struct ibv_flow_spec_action_drop),
+			.type = IBV_FLOW_SPEC_ACTION_DROP,
+		},
+	};
+	struct ibv_flow *flow;
+	struct mlx5_hrxq *drop = mlx5_hrxq_drop_new(dev);
+	uint16_t vprio[] = { 8, 16 };
+	int i;
+	int priority = 0;
+
+	if (!drop) {
+		rte_errno = ENOTSUP;
+		return -rte_errno;
+	}
+	for (i = 0; i != RTE_DIM(vprio); i++) {
+		flow_attr.attr.priority = vprio[i] - 1;
+		flow = mlx5_glue->create_flow(drop->qp, &flow_attr.attr);
+		if (!flow)
+			break;
+		claim_zero(mlx5_glue->destroy_flow(flow));
+		priority = vprio[i];
+	}
+	mlx5_hrxq_drop_release(dev);
+	switch (priority) {
+	case 8:
+		priority = RTE_DIM(priority_map_3);
+		break;
+	case 16:
+		priority = RTE_DIM(priority_map_5);
+		break;
+	default:
+		rte_errno = ENOTSUP;
+		DRV_LOG(ERR,
+			"port %u verbs maximum priority: %d expected 8/16",
+			dev->data->port_id, priority);
+		return -rte_errno;
+	}
+	DRV_LOG(INFO, "port %u flow maximum priority: %d",
+		dev->data->port_id, priority);
+	return priority;
+}
+
+/**
+ * Adjust flow priority based on the highest layer and the request priority.
+ *
+ * @param[in] dev
+ *   Pointer to the Ethernet device structure.
+ * @param[in] priority
+ *   The rule base priority.
+ * @param[in] subpriority
+ *   The priority based on the items.
+ *
+ * @return
+ *   The new priority.
+ */
+uint32_t
+mlx5_flow_adjust_priority(struct rte_eth_dev *dev, int32_t priority,
+				   uint32_t subpriority)
+{
+	uint32_t res = 0;
+	struct mlx5_priv *priv = dev->data->dev_private;
+
+	switch (priv->config.flow_prio) {
+	case RTE_DIM(priority_map_3):
+		res = priority_map_3[priority][subpriority];
+		break;
+	case RTE_DIM(priority_map_5):
+		res = priority_map_5[priority][subpriority];
+		break;
+	}
+	return  res;
+}
+
 /**
  * Get Verbs flow counter by index.
  *
-- 
2.8.4


^ permalink raw reply	[flat|nested] 28+ messages in thread

* [dpdk-dev] [PATCH v1 2/8] net/mlx5: replace Linux specific calls with rte API
  2020-07-14 14:20 [dpdk-dev] [PATCH v1 0/8] mlx5 PMD multi OS support - part #3 Ophir Munk
  2020-07-14 14:20 ` [dpdk-dev] [PATCH v1 1/8] net/mlx5: move flow prio discovery and adjust under verbs Ophir Munk
@ 2020-07-14 14:20 ` Ophir Munk
  2020-07-14 14:20 ` [dpdk-dev] [PATCH v1 3/8] net/mlx5: refactor Linux MAC operations Ophir Munk
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 28+ messages in thread
From: Ophir Munk @ 2020-07-14 14:20 UTC (permalink / raw)
  To: dev; +Cc: Raslan Darawsheh, Ophir Munk, Matan Azrad

The following Linux calls are replaced by their matching rte APIs.

mmap ==> rte_mem_map()
munmap == >rte_mem_unmap()
sysconf(_SC_PAGESIZE) ==> rte_mem_page_size()

Signed-off-by: Ophir Munk <ophirmu@mellanox.com>
Acked-by: Matan Azrad <matan@mellanox.com>
---
 drivers/common/mlx5/mlx5_devx_cmds.c |  8 +++++++-
 drivers/common/mlx5/mlx5_prm.h       |  2 +-
 drivers/net/mlx5/linux/mlx5_os.c     | 11 ++++++++---
 drivers/net/mlx5/linux/mlx5_verbs.c  |  1 -
 drivers/net/mlx5/mlx5_flow_dv.c      |  9 ++++++++-
 drivers/net/mlx5/mlx5_rxq.c          |  9 ++++++++-
 drivers/net/mlx5/mlx5_txq.c          | 29 +++++++++++++++++++++--------
 7 files changed, 53 insertions(+), 16 deletions(-)

diff --git a/drivers/common/mlx5/mlx5_devx_cmds.c b/drivers/common/mlx5/mlx5_devx_cmds.c
index 2179a83..795e85f 100644
--- a/drivers/common/mlx5/mlx5_devx_cmds.c
+++ b/drivers/common/mlx5/mlx5_devx_cmds.c
@@ -5,6 +5,7 @@
 
 #include <rte_errno.h>
 #include <rte_malloc.h>
+#include <rte_eal_paging.h>
 
 #include "mlx5_prm.h"
 #include "mlx5_devx_cmds.h"
@@ -158,7 +159,12 @@ mlx5_devx_cmd_mkey_create(void *ctx,
 		return NULL;
 	}
 	memset(in, 0, in_size_dw * 4);
-	pgsize = sysconf(_SC_PAGESIZE);
+	pgsize = rte_mem_page_size();
+	if (pgsize == (size_t)-1) {
+		DRV_LOG(ERR, "Failed to get page size");
+		rte_errno = ENOMEM;
+		return NULL;
+	}
 	MLX5_SET(create_mkey_in, in, opcode, MLX5_CMD_OP_CREATE_MKEY);
 	mkc = MLX5_ADDR_OF(create_mkey_in, in, memory_key_mkey_entry);
 	if (klm_num > 0) {
diff --git a/drivers/common/mlx5/mlx5_prm.h b/drivers/common/mlx5/mlx5_prm.h
index c63795f..1b7b4c7 100644
--- a/drivers/common/mlx5/mlx5_prm.h
+++ b/drivers/common/mlx5/mlx5_prm.h
@@ -253,7 +253,7 @@
 #define MLX5_MAX_LOG_RQ_SEGS 5u
 
 /* The alignment needed for WQ buffer. */
-#define MLX5_WQE_BUF_ALIGNMENT sysconf(_SC_PAGESIZE)
+#define MLX5_WQE_BUF_ALIGNMENT rte_mem_page_size()
 
 /* Completion mode. */
 enum mlx5_completion_mode {
diff --git a/drivers/net/mlx5/linux/mlx5_os.c b/drivers/net/mlx5/linux/mlx5_os.c
index 2dc57b2..e5f024a 100644
--- a/drivers/net/mlx5/linux/mlx5_os.c
+++ b/drivers/net/mlx5/linux/mlx5_os.c
@@ -10,7 +10,6 @@
 #include <stdlib.h>
 #include <errno.h>
 #include <net/if.h>
-#include <sys/mman.h>
 #include <linux/rtnetlink.h>
 #include <linux/sockios.h>
 #include <linux/ethtool.h>
@@ -37,6 +36,7 @@
 #include <rte_spinlock.h>
 #include <rte_string_fns.h>
 #include <rte_alarm.h>
+#include <rte_eal_paging.h>
 
 #include <mlx5_glue.h>
 #include <mlx5_devx_cmds.h>
@@ -133,7 +133,7 @@ mlx5_os_get_dev_attr(void *ctx, struct mlx5_dev_attr *device_attr)
  * Verbs callback to allocate a memory. This function should allocate the space
  * according to the size provided residing inside a huge page.
  * Please note that all allocation must respect the alignment from libmlx5
- * (i.e. currently sysconf(_SC_PAGESIZE)).
+ * (i.e. currently rte_mem_page_size()).
  *
  * @param[in] size
  *   The size in bytes of the memory to allocate.
@@ -148,8 +148,13 @@ mlx5_alloc_verbs_buf(size_t size, void *data)
 {
 	struct mlx5_priv *priv = data;
 	void *ret;
-	size_t alignment = sysconf(_SC_PAGESIZE);
 	unsigned int socket = SOCKET_ID_ANY;
+	size_t alignment = rte_mem_page_size();
+	if (alignment == (size_t)-1) {
+		DRV_LOG(ERR, "Failed to get mem page size");
+		rte_errno = ENOMEM;
+		return NULL;
+	}
 
 	if (priv->verbs_alloc_ctx.type == MLX5_VERBS_ALLOC_TYPE_TX_QUEUE) {
 		const struct mlx5_txq_ctrl *ctrl = priv->verbs_alloc_ctx.obj;
diff --git a/drivers/net/mlx5/linux/mlx5_verbs.c b/drivers/net/mlx5/linux/mlx5_verbs.c
index 6b59fa1..5ac6982 100644
--- a/drivers/net/mlx5/linux/mlx5_verbs.c
+++ b/drivers/net/mlx5/linux/mlx5_verbs.c
@@ -7,7 +7,6 @@
 #include <string.h>
 #include <stdint.h>
 #include <unistd.h>
-#include <sys/mman.h>
 #include <inttypes.h>
 
 /* Verbs header. */
diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c
index 8b5b683..7ce30e0 100644
--- a/drivers/net/mlx5/mlx5_flow_dv.c
+++ b/drivers/net/mlx5/mlx5_flow_dv.c
@@ -29,6 +29,7 @@
 #include <rte_gre.h>
 #include <rte_vxlan.h>
 #include <rte_gtp.h>
+#include <rte_eal_paging.h>
 
 #include <mlx5_devx_cmds.h>
 #include <mlx5_prm.h>
@@ -4175,7 +4176,13 @@ flow_dv_create_counter_stat_mem_mng(struct rte_eth_dev *dev, int raws_n)
 			MLX5_COUNTERS_PER_POOL +
 			sizeof(struct mlx5_counter_stats_raw)) * raws_n +
 			sizeof(struct mlx5_counter_stats_mem_mng);
-	uint8_t *mem = rte_calloc(__func__, 1, size, sysconf(_SC_PAGESIZE));
+	size_t pgsize = rte_mem_page_size();
+	if (pgsize == (size_t)-1) {
+		DRV_LOG(ERR, "Failed to get mem page size");
+		rte_errno = ENOMEM;
+		return NULL;
+	}
+	uint8_t *mem = rte_calloc(__func__, 1, size, pgsize);
 	int i;
 
 	if (!mem) {
diff --git a/drivers/net/mlx5/mlx5_rxq.c b/drivers/net/mlx5/mlx5_rxq.c
index b436f06..637b131 100644
--- a/drivers/net/mlx5/mlx5_rxq.c
+++ b/drivers/net/mlx5/mlx5_rxq.c
@@ -28,6 +28,7 @@
 #include <rte_interrupts.h>
 #include <rte_debug.h>
 #include <rte_io.h>
+#include <rte_eal_paging.h>
 
 #include <mlx5_glue.h>
 #include <mlx5_devx_cmds.h>
@@ -1230,7 +1231,13 @@ mlx5_devx_rq_new(struct rte_eth_dev *dev, uint16_t idx, uint32_t cqn)
 	/* Calculate and allocate WQ memory space. */
 	wqe_size = 1 << log_wqe_size; /* round up power of two.*/
 	wq_size = wqe_n * wqe_size;
-	buf = rte_calloc_socket(__func__, 1, wq_size, MLX5_WQE_BUF_ALIGNMENT,
+	size_t alignment = MLX5_WQE_BUF_ALIGNMENT;
+	if (alignment == (size_t)-1) {
+		DRV_LOG(ERR, "Failed to get mem page size");
+		rte_errno = ENOMEM;
+		return NULL;
+	}
+	buf = rte_calloc_socket(__func__, 1, wq_size, alignment,
 				rxq_ctrl->socket);
 	if (!buf)
 		return NULL;
diff --git a/drivers/net/mlx5/mlx5_txq.c b/drivers/net/mlx5/mlx5_txq.c
index 35b3ade..a9bf42d 100644
--- a/drivers/net/mlx5/mlx5_txq.c
+++ b/drivers/net/mlx5/mlx5_txq.c
@@ -8,7 +8,6 @@
 #include <string.h>
 #include <stdint.h>
 #include <unistd.h>
-#include <sys/mman.h>
 #include <inttypes.h>
 
 /* Verbs header. */
@@ -26,6 +25,7 @@
 #include <rte_malloc.h>
 #include <rte_ethdev_driver.h>
 #include <rte_common.h>
+#include <rte_eal_paging.h>
 
 #include <mlx5_glue.h>
 #include <mlx5_devx_cmds.h>
@@ -340,10 +340,14 @@ txq_uar_init(struct mlx5_txq_ctrl *txq_ctrl)
 {
 	struct mlx5_priv *priv = txq_ctrl->priv;
 	struct mlx5_proc_priv *ppriv = MLX5_PROC_PRIV(PORT_ID(priv));
-	const size_t page_size = sysconf(_SC_PAGESIZE);
 #ifndef RTE_ARCH_64
 	unsigned int lock_idx;
 #endif
+	const size_t page_size = rte_mem_page_size();
+	if (page_size == (size_t)-1) {
+		DRV_LOG(ERR, "Failed to get mem page size");
+		rte_errno = ENOMEM;
+	}
 
 	if (txq_ctrl->type != MLX5_TXQ_TYPE_STANDARD)
 		return;
@@ -382,7 +386,12 @@ txq_uar_init_secondary(struct mlx5_txq_ctrl *txq_ctrl, int fd)
 	void *addr;
 	uintptr_t uar_va;
 	uintptr_t offset;
-	const size_t page_size = sysconf(_SC_PAGESIZE);
+	const size_t page_size = rte_mem_page_size();
+	if (page_size == (size_t)-1) {
+		DRV_LOG(ERR, "Failed to get mem page size");
+		rte_errno = ENOMEM;
+		return -rte_errno;
+	}
 
 	if (txq_ctrl->type != MLX5_TXQ_TYPE_STANDARD)
 		return 0;
@@ -393,9 +402,9 @@ txq_uar_init_secondary(struct mlx5_txq_ctrl *txq_ctrl, int fd)
 	 */
 	uar_va = (uintptr_t)txq_ctrl->bf_reg;
 	offset = uar_va & (page_size - 1); /* Offset in page. */
-	addr = mmap(NULL, page_size, PROT_WRITE, MAP_SHARED, fd,
-			txq_ctrl->uar_mmap_offset);
-	if (addr == MAP_FAILED) {
+	addr = rte_mem_map(NULL, page_size, RTE_PROT_WRITE, RTE_MAP_SHARED,
+			    fd, txq_ctrl->uar_mmap_offset);
+	if (!addr) {
 		DRV_LOG(ERR,
 			"port %u mmap failed for BF reg of txq %u",
 			txq->port_id, txq->idx);
@@ -418,13 +427,17 @@ static void
 txq_uar_uninit_secondary(struct mlx5_txq_ctrl *txq_ctrl)
 {
 	struct mlx5_proc_priv *ppriv = MLX5_PROC_PRIV(PORT_ID(txq_ctrl->priv));
-	const size_t page_size = sysconf(_SC_PAGESIZE);
 	void *addr;
+	const size_t page_size = rte_mem_page_size();
+	if (page_size == (size_t)-1) {
+		DRV_LOG(ERR, "Failed to get mem page size");
+		rte_errno = ENOMEM;
+	}
 
 	if (txq_ctrl->type != MLX5_TXQ_TYPE_STANDARD)
 		return;
 	addr = ppriv->uar_table[txq_ctrl->txq.idx];
-	munmap(RTE_PTR_ALIGN_FLOOR(addr, page_size), page_size);
+	rte_mem_unmap(RTE_PTR_ALIGN_FLOOR(addr, page_size), page_size);
 }
 
 /**
-- 
2.8.4


^ permalink raw reply	[flat|nested] 28+ messages in thread

* [dpdk-dev] [PATCH v1 3/8] net/mlx5: refactor Linux MAC operations
  2020-07-14 14:20 [dpdk-dev] [PATCH v1 0/8] mlx5 PMD multi OS support - part #3 Ophir Munk
  2020-07-14 14:20 ` [dpdk-dev] [PATCH v1 1/8] net/mlx5: move flow prio discovery and adjust under verbs Ophir Munk
  2020-07-14 14:20 ` [dpdk-dev] [PATCH v1 2/8] net/mlx5: replace Linux specific calls with rte API Ophir Munk
@ 2020-07-14 14:20 ` Ophir Munk
  2020-07-14 14:20 ` [dpdk-dev] [PATCH v1 4/8] linux/mlx5: add setters for promiscuous and all-multi Ophir Munk
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 28+ messages in thread
From: Ophir Munk @ 2020-07-14 14:20 UTC (permalink / raw)
  To: dev; +Cc: Raslan Darawsheh, Ophir Munk, Matan Azrad

Move OS specific MAC operations add, remove, modify VF into file
linux/mlx5_os.c.
Remove unused function mlx5_get_mac().

Signed-off-by: Ophir Munk <ophirmu@mellanox.com>
Acked-by: Matan Azrad <matan@mellanox.com>
---
 drivers/net/mlx5/linux/mlx5_os.c | 97 ++++++++++++++++++++++++++++++++++++++++
 drivers/net/mlx5/mlx5.h          |  7 ++-
 drivers/net/mlx5/mlx5_mac.c      | 49 +++-----------------
 3 files changed, 110 insertions(+), 43 deletions(-)

diff --git a/drivers/net/mlx5/linux/mlx5_os.c b/drivers/net/mlx5/linux/mlx5_os.c
index e5f024a..b5993a7 100644
--- a/drivers/net/mlx5/linux/mlx5_os.c
+++ b/drivers/net/mlx5/linux/mlx5_os.c
@@ -67,6 +67,30 @@
 #endif
 
 /**
+ * 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.
+ */
+static int
+mlx5_get_mac(struct rte_eth_dev *dev, uint8_t (*mac)[RTE_ETHER_ADDR_LEN])
+{
+	struct ifreq request;
+	int ret;
+
+	ret = mlx5_ifreq(dev, SIOCGIFHWADDR, &request);
+	if (ret)
+		return ret;
+	memcpy(mac, request.ifr_hwaddr.sa_data, RTE_ETHER_ADDR_LEN);
+	return 0;
+}
+
+/**
  * Get mlx5 device attributes. The glue function query_device_ex() is called
  * with out parameter of type 'struct ibv_device_attr_ex *'. Then fill in mlx5
  * device attributes from the glue out parameter.
@@ -2274,6 +2298,79 @@ mlx5_os_set_reg_mr_cb(mlx5_reg_mr_t *reg_mr_cb,
 	*dereg_mr_cb = mlx5_verbs_ops.dereg_mr;
 }
 
+/**
+ * Remove a MAC address from device
+ *
+ * @param dev
+ *   Pointer to Ethernet device structure.
+ * @param index
+ *   MAC address index.
+ */
+void
+mlx5_os_mac_addr_remove(struct rte_eth_dev *dev, uint32_t index)
+{
+	struct mlx5_priv *priv = dev->data->dev_private;
+	const int vf = priv->config.vf;
+
+	if (vf)
+		mlx5_nl_mac_addr_remove(priv->nl_socket_route,
+					mlx5_ifindex(dev), priv->mac_own,
+					&dev->data->mac_addrs[index], index);
+}
+
+/**
+ * Adds a MAC address to the device
+ *
+ * @param dev
+ *   Pointer to Ethernet device structure.
+ * @param mac_addr
+ *   MAC address to register.
+ * @param index
+ *   MAC address index.
+ *
+ * @return
+ *   0 on success, a negative errno value otherwise
+ */
+int
+mlx5_os_mac_addr_add(struct rte_eth_dev *dev, struct rte_ether_addr *mac,
+		     uint32_t index)
+{
+	struct mlx5_priv *priv = dev->data->dev_private;
+	const int vf = priv->config.vf;
+	int ret = 0;
+
+	if (vf)
+		ret = mlx5_nl_mac_addr_add(priv->nl_socket_route,
+					   mlx5_ifindex(dev), priv->mac_own,
+					   mac, index);
+	return ret;
+}
+
+/**
+ * Modfiy a VF MAC address
+ *
+ * @param priv
+ *   Pointer to device private data.
+ * @param mac_addr
+ *   MAC address to modify into.
+ * @param iface_idx
+ *   Net device interface index
+ * @param vf_index
+ *   VF index
+ *
+ * @return
+ *   0 on success, a negative errno value otherwise
+ */
+int
+mlx5_os_vf_mac_addr_modify(struct mlx5_priv *priv,
+			   unsigned int iface_idx,
+			   struct rte_ether_addr *mac_addr,
+			   int vf_index)
+{
+	return mlx5_nl_vf_mac_addr_modify
+		(priv->nl_socket_route, iface_idx, mac_addr, vf_index);
+}
+
 const struct eth_dev_ops mlx5_os_dev_ops = {
 	.dev_configure = mlx5_dev_configure,
 	.dev_start = mlx5_dev_start,
diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h
index 4323e67..bf1d97a 100644
--- a/drivers/net/mlx5/mlx5.h
+++ b/drivers/net/mlx5/mlx5.h
@@ -775,7 +775,6 @@ int mlx5_dev_configure_rss_reta(struct rte_eth_dev *dev);
 
 /* mlx5_mac.c */
 
-int mlx5_get_mac(struct rte_eth_dev *dev, uint8_t (*mac)[RTE_ETHER_ADDR_LEN]);
 void mlx5_mac_addr_remove(struct rte_eth_dev *dev, uint32_t index);
 int mlx5_mac_addr_add(struct rte_eth_dev *dev, struct rte_ether_addr *mac,
 		      uint32_t index, uint32_t vmdq);
@@ -940,4 +939,10 @@ int mlx5_os_get_stats_n(struct rte_eth_dev *dev);
 void mlx5_os_stats_init(struct rte_eth_dev *dev);
 void mlx5_os_set_reg_mr_cb(mlx5_reg_mr_t *reg_mr_cb,
 			   mlx5_dereg_mr_t *dereg_mr_cb);
+void mlx5_os_mac_addr_remove(struct rte_eth_dev *dev, uint32_t index);
+int mlx5_os_mac_addr_add(struct rte_eth_dev *dev, struct rte_ether_addr *mac,
+			 uint32_t index);
+int mlx5_os_vf_mac_addr_modify(struct mlx5_priv *priv, unsigned int iface_idx,
+			       struct rte_ether_addr *mac_addr,
+			       int vf_index);
 #endif /* RTE_PMD_MLX5_H_ */
diff --git a/drivers/net/mlx5/mlx5_mac.c b/drivers/net/mlx5/mlx5_mac.c
index 291f772..2a88086 100644
--- a/drivers/net/mlx5/mlx5_mac.c
+++ b/drivers/net/mlx5/mlx5_mac.c
@@ -32,30 +32,6 @@
 #include "mlx5_rxtx.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 ifreq request;
-	int ret;
-
-	ret = mlx5_ifreq(dev, SIOCGIFHWADDR, &request);
-	if (ret)
-		return ret;
-	memcpy(mac, request.ifr_hwaddr.sa_data, RTE_ETHER_ADDR_LEN);
-	return 0;
-}
-
-/**
  * Remove a MAC address from the internal array.
  *
  * @param dev
@@ -66,16 +42,10 @@ mlx5_get_mac(struct rte_eth_dev *dev, uint8_t (*mac)[RTE_ETHER_ADDR_LEN])
 static void
 mlx5_internal_mac_addr_remove(struct rte_eth_dev *dev, uint32_t index)
 {
-	struct mlx5_priv *priv = dev->data->dev_private;
-	const int vf = priv->config.vf;
-
 	MLX5_ASSERT(index < MLX5_MAX_MAC_ADDRESSES);
 	if (rte_is_zero_ether_addr(&dev->data->mac_addrs[index]))
 		return;
-	if (vf)
-		mlx5_nl_mac_addr_remove(priv->nl_socket_route,
-					mlx5_ifindex(dev), priv->mac_own,
-					&dev->data->mac_addrs[index], index);
+	mlx5_os_mac_addr_remove(dev, index);
 	memset(&dev->data->mac_addrs[index], 0, sizeof(struct rte_ether_addr));
 }
 
@@ -96,9 +66,8 @@ static int
 mlx5_internal_mac_addr_add(struct rte_eth_dev *dev, struct rte_ether_addr *mac,
 			   uint32_t index)
 {
-	struct mlx5_priv *priv = dev->data->dev_private;
-	const int vf = priv->config.vf;
 	unsigned int i;
+	int ret;
 
 	MLX5_ASSERT(index < MLX5_MAX_MAC_ADDRESSES);
 	if (rte_is_zero_ether_addr(mac)) {
@@ -116,14 +85,10 @@ mlx5_internal_mac_addr_add(struct rte_eth_dev *dev, struct rte_ether_addr *mac,
 		rte_errno = EADDRINUSE;
 		return -rte_errno;
 	}
-	if (vf) {
-		int ret = mlx5_nl_mac_addr_add(priv->nl_socket_route,
-					       mlx5_ifindex(dev), priv->mac_own,
-					       mac, index);
+	ret = mlx5_os_mac_addr_add(dev, mac, index);
+	if (ret)
+		return ret;
 
-		if (ret)
-			return ret;
-	}
 	dev->data->mac_addrs[index] = *mac;
 	return 0;
 }
@@ -210,8 +175,8 @@ mlx5_mac_addr_set(struct rte_eth_dev *dev, struct rte_ether_addr *mac_addr)
 			priv = rte_eth_devices[port_id].data->dev_private;
 			if (priv->master == 1) {
 				priv = dev->data->dev_private;
-				return mlx5_nl_vf_mac_addr_modify
-				       (priv->nl_socket_route,
+				return mlx5_os_vf_mac_addr_modify
+				       (priv,
 					mlx5_ifindex(&rte_eth_devices[port_id]),
 					mac_addr, priv->representor_id);
 			}
-- 
2.8.4


^ permalink raw reply	[flat|nested] 28+ messages in thread

* [dpdk-dev] [PATCH v1 4/8] linux/mlx5: add setters for promiscuous and all-multi
  2020-07-14 14:20 [dpdk-dev] [PATCH v1 0/8] mlx5 PMD multi OS support - part #3 Ophir Munk
                   ` (2 preceding siblings ...)
  2020-07-14 14:20 ` [dpdk-dev] [PATCH v1 3/8] net/mlx5: refactor Linux MAC operations Ophir Munk
@ 2020-07-14 14:20 ` Ophir Munk
  2020-07-14 14:20 ` [dpdk-dev] [PATCH v1 5/8] net/mlx5: eliminate dependency on Linux in shared header Ophir Munk
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 28+ messages in thread
From: Ophir Munk @ 2020-07-14 14:20 UTC (permalink / raw)
  To: dev; +Cc: Raslan Darawsheh, Ophir Munk, Matan Azrad

This commit adds Linux implementation of routines mlx5_os_set_promisc()
and mlx5_os_set_promisc(). The routines call netlink APIs.

Signed-off-by: Ophir Munk <ophirmu@mellanox.com>
Acked-by: Matan Azrad <matan@mellanox.com>
---
 drivers/net/mlx5/linux/mlx5_os.c | 40 ++++++++++++++++++++++++++++++++++++++++
 drivers/net/mlx5/mlx5.h          |  2 ++
 drivers/net/mlx5/mlx5_rxmode.c   | 12 ++++--------
 3 files changed, 46 insertions(+), 8 deletions(-)

diff --git a/drivers/net/mlx5/linux/mlx5_os.c b/drivers/net/mlx5/linux/mlx5_os.c
index b5993a7..7de57a4 100644
--- a/drivers/net/mlx5/linux/mlx5_os.c
+++ b/drivers/net/mlx5/linux/mlx5_os.c
@@ -2371,6 +2371,46 @@ mlx5_os_vf_mac_addr_modify(struct mlx5_priv *priv,
 		(priv->nl_socket_route, iface_idx, mac_addr, vf_index);
 }
 
+/**
+ * Set device promiscuous mode
+ *
+ * @param dev
+ *   Pointer to Ethernet device structure.
+ * @param enable
+ *   0 - promiscuous is disabled, otherwise - enabled
+ *
+ * @return
+ *   0 on success, a negative error value otherwise
+ */
+int
+mlx5_os_set_promisc(struct rte_eth_dev *dev, int enable)
+{
+	struct mlx5_priv *priv = dev->data->dev_private;
+
+	return mlx5_nl_promisc(priv->nl_socket_route,
+			       mlx5_ifindex(dev), !!enable);
+}
+
+/**
+ * Set device promiscuous mode
+ *
+ * @param dev
+ *   Pointer to Ethernet device structure.
+ * @param enable
+ *   0 - all multicase is disabled, otherwise - enabled
+ *
+ * @return
+ *   0 on success, a negative error value otherwise
+ */
+int
+mlx5_os_set_allmulti(struct rte_eth_dev *dev, int enable)
+{
+	struct mlx5_priv *priv = dev->data->dev_private;
+
+	return mlx5_nl_allmulti(priv->nl_socket_route,
+				mlx5_ifindex(dev), !!enable);
+}
+
 const struct eth_dev_ops mlx5_os_dev_ops = {
 	.dev_configure = mlx5_dev_configure,
 	.dev_start = mlx5_dev_start,
diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h
index bf1d97a..f719cfc 100644
--- a/drivers/net/mlx5/mlx5.h
+++ b/drivers/net/mlx5/mlx5.h
@@ -945,4 +945,6 @@ int mlx5_os_mac_addr_add(struct rte_eth_dev *dev, struct rte_ether_addr *mac,
 int mlx5_os_vf_mac_addr_modify(struct mlx5_priv *priv, unsigned int iface_idx,
 			       struct rte_ether_addr *mac_addr,
 			       int vf_index);
+int mlx5_os_set_promisc(struct rte_eth_dev *dev, int enable);
+int mlx5_os_set_allmulti(struct rte_eth_dev *dev, int enable);
 #endif /* RTE_PMD_MLX5_H_ */
diff --git a/drivers/net/mlx5/mlx5_rxmode.c b/drivers/net/mlx5/mlx5_rxmode.c
index 84c8b05..80b1256 100644
--- a/drivers/net/mlx5/mlx5_rxmode.c
+++ b/drivers/net/mlx5/mlx5_rxmode.c
@@ -47,8 +47,7 @@ mlx5_promiscuous_enable(struct rte_eth_dev *dev)
 		return 0;
 	}
 	if (priv->config.vf) {
-		ret = mlx5_nl_promisc(priv->nl_socket_route, mlx5_ifindex(dev),
-				      1);
+		ret = mlx5_os_set_promisc(dev, 1);
 		if (ret)
 			return ret;
 	}
@@ -81,8 +80,7 @@ mlx5_promiscuous_disable(struct rte_eth_dev *dev)
 
 	dev->data->promiscuous = 0;
 	if (priv->config.vf) {
-		ret = mlx5_nl_promisc(priv->nl_socket_route, mlx5_ifindex(dev),
-				      0);
+		ret = mlx5_os_set_promisc(dev, 0);
 		if (ret)
 			return ret;
 	}
@@ -122,8 +120,7 @@ mlx5_allmulticast_enable(struct rte_eth_dev *dev)
 		return 0;
 	}
 	if (priv->config.vf) {
-		ret = mlx5_nl_allmulti(priv->nl_socket_route, mlx5_ifindex(dev),
-				       1);
+		ret = mlx5_os_set_allmulti(dev, 1);
 		if (ret)
 			goto error;
 	}
@@ -156,8 +153,7 @@ mlx5_allmulticast_disable(struct rte_eth_dev *dev)
 
 	dev->data->all_multicast = 0;
 	if (priv->config.vf) {
-		ret = mlx5_nl_allmulti(priv->nl_socket_route, mlx5_ifindex(dev),
-				       0);
+		ret = mlx5_os_set_allmulti(dev, 0);
 		if (ret)
 			goto error;
 	}
-- 
2.8.4


^ permalink raw reply	[flat|nested] 28+ messages in thread

* [dpdk-dev] [PATCH v1 5/8] net/mlx5: eliminate dependency on Linux in shared header
  2020-07-14 14:20 [dpdk-dev] [PATCH v1 0/8] mlx5 PMD multi OS support - part #3 Ophir Munk
                   ` (3 preceding siblings ...)
  2020-07-14 14:20 ` [dpdk-dev] [PATCH v1 4/8] linux/mlx5: add setters for promiscuous and all-multi Ophir Munk
@ 2020-07-14 14:20 ` Ophir Munk
  2020-07-14 14:21 ` [dpdk-dev] [PATCH v1 6/8] net/mlx5: header file cleanup Ophir Munk
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 28+ messages in thread
From: Ophir Munk @ 2020-07-14 14:20 UTC (permalink / raw)
  To: dev; +Cc: Raslan Darawsheh, Ophir Munk, Matan Azrad

This commit eliminates Linux dependencies in shared file mlx5.h.

1. All functions using 'struct ifreq' are moved to file
linux/mlx5_ethdev_os.c such that this struct can be removed from mlx5.h.
2. Function mlx5_set_flags() that uses Linux flags (e.g. IFF_UP) is
changed to static and its prototype is removed from mlx5.h.
3. Remove redundant member verbs_action from 'struct mlx5_priv'.

Signed-off-by: Ophir Munk <ophirmu@mellanox.com>
Acked-by: Matan Azrad <matan@mellanox.com>
---
 drivers/net/mlx5/linux/mlx5_ethdev_os.c | 314 +++++++++++++++++++++++++++++++-
 drivers/net/mlx5/linux/mlx5_os.c        | 309 -------------------------------
 drivers/net/mlx5/mlx5.h                 |  15 +-
 3 files changed, 318 insertions(+), 320 deletions(-)

diff --git a/drivers/net/mlx5/linux/mlx5_ethdev_os.c b/drivers/net/mlx5/linux/mlx5_ethdev_os.c
index 701614a..765a521 100644
--- a/drivers/net/mlx5/linux/mlx5_ethdev_os.c
+++ b/drivers/net/mlx5/linux/mlx5_ethdev_os.c
@@ -177,7 +177,7 @@ mlx5_get_ifname(const struct rte_eth_dev *dev, char (*ifname)[IF_NAMESIZE])
  * @return
  *   0 on success, a negative errno value otherwise and rte_errno is set.
  */
-int
+static int
 mlx5_ifreq(const struct rte_eth_dev *dev, int req, struct ifreq *ifr)
 {
 	int sock = socket(PF_INET, SOCK_DGRAM, IPPROTO_IP);
@@ -257,7 +257,7 @@ mlx5_set_mtu(struct rte_eth_dev *dev, uint16_t mtu)
  * @return
  *   0 on success, a negative errno value otherwise and rte_errno is set.
  */
-int
+static int
 mlx5_set_flags(struct rte_eth_dev *dev, unsigned int keep, unsigned int flags)
 {
 	struct ifreq request;
@@ -1185,3 +1185,313 @@ int mlx5_get_module_eeprom(struct rte_eth_dev *dev,
 	rte_free(eeprom);
 	return ret;
 }
+
+/**
+ * Read device counters table.
+ *
+ * @param dev
+ *   Pointer to Ethernet device.
+ * @param[out] stats
+ *   Counters table output buffer.
+ *
+ * @return
+ *   0 on success and stats is filled, negative errno value otherwise and
+ *   rte_errno is set.
+ */
+int
+mlx5_os_read_dev_counters(struct rte_eth_dev *dev, uint64_t *stats)
+{
+	struct mlx5_priv *priv = dev->data->dev_private;
+	struct mlx5_xstats_ctrl *xstats_ctrl = &priv->xstats_ctrl;
+	unsigned int i;
+	struct ifreq ifr;
+	unsigned int stats_sz = xstats_ctrl->stats_n * sizeof(uint64_t);
+	unsigned char et_stat_buf[sizeof(struct ethtool_stats) + stats_sz];
+	struct ethtool_stats *et_stats = (struct ethtool_stats *)et_stat_buf;
+	int ret;
+
+	et_stats->cmd = ETHTOOL_GSTATS;
+	et_stats->n_stats = xstats_ctrl->stats_n;
+	ifr.ifr_data = (caddr_t)et_stats;
+	ret = mlx5_ifreq(dev, SIOCETHTOOL, &ifr);
+	if (ret) {
+		DRV_LOG(WARNING,
+			"port %u unable to read statistic values from device",
+			dev->data->port_id);
+		return ret;
+	}
+	for (i = 0; i != xstats_ctrl->mlx5_stats_n; ++i) {
+		if (xstats_ctrl->info[i].dev) {
+			ret = mlx5_os_read_dev_stat(priv,
+					    xstats_ctrl->info[i].ctr_name,
+					    &stats[i]);
+			/* return last xstats counter if fail to read. */
+			if (ret == 0)
+				xstats_ctrl->xstats[i] = stats[i];
+			else
+				stats[i] = xstats_ctrl->xstats[i];
+		} else {
+			stats[i] = (uint64_t)
+				et_stats->data[xstats_ctrl->dev_table_idx[i]];
+		}
+	}
+	return 0;
+}
+
+/**
+ * Query the number of statistics provided by ETHTOOL.
+ *
+ * @param dev
+ *   Pointer to Ethernet device.
+ *
+ * @return
+ *   Number of statistics on success, negative errno value otherwise and
+ *   rte_errno is set.
+ */
+int
+mlx5_os_get_stats_n(struct rte_eth_dev *dev)
+{
+	struct ethtool_drvinfo drvinfo;
+	struct ifreq ifr;
+	int ret;
+
+	drvinfo.cmd = ETHTOOL_GDRVINFO;
+	ifr.ifr_data = (caddr_t)&drvinfo;
+	ret = mlx5_ifreq(dev, SIOCETHTOOL, &ifr);
+	if (ret) {
+		DRV_LOG(WARNING, "port %u unable to query number of statistics",
+			dev->data->port_id);
+		return ret;
+	}
+	return drvinfo.n_stats;
+}
+
+static const struct mlx5_counter_ctrl mlx5_counters_init[] = {
+	{
+		.dpdk_name = "rx_port_unicast_bytes",
+		.ctr_name = "rx_vport_unicast_bytes",
+	},
+	{
+		.dpdk_name = "rx_port_multicast_bytes",
+		.ctr_name = "rx_vport_multicast_bytes",
+	},
+	{
+		.dpdk_name = "rx_port_broadcast_bytes",
+		.ctr_name = "rx_vport_broadcast_bytes",
+	},
+	{
+		.dpdk_name = "rx_port_unicast_packets",
+		.ctr_name = "rx_vport_unicast_packets",
+	},
+	{
+		.dpdk_name = "rx_port_multicast_packets",
+		.ctr_name = "rx_vport_multicast_packets",
+	},
+	{
+		.dpdk_name = "rx_port_broadcast_packets",
+		.ctr_name = "rx_vport_broadcast_packets",
+	},
+	{
+		.dpdk_name = "tx_port_unicast_bytes",
+		.ctr_name = "tx_vport_unicast_bytes",
+	},
+	{
+		.dpdk_name = "tx_port_multicast_bytes",
+		.ctr_name = "tx_vport_multicast_bytes",
+	},
+	{
+		.dpdk_name = "tx_port_broadcast_bytes",
+		.ctr_name = "tx_vport_broadcast_bytes",
+	},
+	{
+		.dpdk_name = "tx_port_unicast_packets",
+		.ctr_name = "tx_vport_unicast_packets",
+	},
+	{
+		.dpdk_name = "tx_port_multicast_packets",
+		.ctr_name = "tx_vport_multicast_packets",
+	},
+	{
+		.dpdk_name = "tx_port_broadcast_packets",
+		.ctr_name = "tx_vport_broadcast_packets",
+	},
+	{
+		.dpdk_name = "rx_wqe_err",
+		.ctr_name = "rx_wqe_err",
+	},
+	{
+		.dpdk_name = "rx_crc_errors_phy",
+		.ctr_name = "rx_crc_errors_phy",
+	},
+	{
+		.dpdk_name = "rx_in_range_len_errors_phy",
+		.ctr_name = "rx_in_range_len_errors_phy",
+	},
+	{
+		.dpdk_name = "rx_symbol_err_phy",
+		.ctr_name = "rx_symbol_err_phy",
+	},
+	{
+		.dpdk_name = "tx_errors_phy",
+		.ctr_name = "tx_errors_phy",
+	},
+	{
+		.dpdk_name = "rx_out_of_buffer",
+		.ctr_name = "out_of_buffer",
+		.dev = 1,
+	},
+	{
+		.dpdk_name = "tx_packets_phy",
+		.ctr_name = "tx_packets_phy",
+	},
+	{
+		.dpdk_name = "rx_packets_phy",
+		.ctr_name = "rx_packets_phy",
+	},
+	{
+		.dpdk_name = "tx_discards_phy",
+		.ctr_name = "tx_discards_phy",
+	},
+	{
+		.dpdk_name = "rx_discards_phy",
+		.ctr_name = "rx_discards_phy",
+	},
+	{
+		.dpdk_name = "tx_bytes_phy",
+		.ctr_name = "tx_bytes_phy",
+	},
+	{
+		.dpdk_name = "rx_bytes_phy",
+		.ctr_name = "rx_bytes_phy",
+	},
+	/* Representor only */
+	{
+		.dpdk_name = "rx_packets",
+		.ctr_name = "vport_rx_packets",
+	},
+	{
+		.dpdk_name = "rx_bytes",
+		.ctr_name = "vport_rx_bytes",
+	},
+	{
+		.dpdk_name = "tx_packets",
+		.ctr_name = "vport_tx_packets",
+	},
+	{
+		.dpdk_name = "tx_bytes",
+		.ctr_name = "vport_tx_bytes",
+	},
+};
+
+static const unsigned int xstats_n = RTE_DIM(mlx5_counters_init);
+
+/**
+ * Init the structures to read device counters.
+ *
+ * @param dev
+ *   Pointer to Ethernet device.
+ */
+void
+mlx5_os_stats_init(struct rte_eth_dev *dev)
+{
+	struct mlx5_priv *priv = dev->data->dev_private;
+	struct mlx5_xstats_ctrl *xstats_ctrl = &priv->xstats_ctrl;
+	struct mlx5_stats_ctrl *stats_ctrl = &priv->stats_ctrl;
+	unsigned int i;
+	unsigned int j;
+	struct ifreq ifr;
+	struct ethtool_gstrings *strings = NULL;
+	unsigned int dev_stats_n;
+	unsigned int str_sz;
+	int ret;
+
+	/* So that it won't aggregate for each init. */
+	xstats_ctrl->mlx5_stats_n = 0;
+	ret = mlx5_os_get_stats_n(dev);
+	if (ret < 0) {
+		DRV_LOG(WARNING, "port %u no extended statistics available",
+			dev->data->port_id);
+		return;
+	}
+	dev_stats_n = ret;
+	/* Allocate memory to grab stat names and values. */
+	str_sz = dev_stats_n * ETH_GSTRING_LEN;
+	strings = (struct ethtool_gstrings *)
+		  rte_malloc("xstats_strings",
+			     str_sz + sizeof(struct ethtool_gstrings), 0);
+	if (!strings) {
+		DRV_LOG(WARNING, "port %u unable to allocate memory for xstats",
+		     dev->data->port_id);
+		return;
+	}
+	strings->cmd = ETHTOOL_GSTRINGS;
+	strings->string_set = ETH_SS_STATS;
+	strings->len = dev_stats_n;
+	ifr.ifr_data = (caddr_t)strings;
+	ret = mlx5_ifreq(dev, SIOCETHTOOL, &ifr);
+	if (ret) {
+		DRV_LOG(WARNING, "port %u unable to get statistic names",
+			dev->data->port_id);
+		goto free;
+	}
+	for (i = 0; i != dev_stats_n; ++i) {
+		const char *curr_string = (const char *)
+			&strings->data[i * ETH_GSTRING_LEN];
+
+		for (j = 0; j != xstats_n; ++j) {
+			if (!strcmp(mlx5_counters_init[j].ctr_name,
+				    curr_string)) {
+				unsigned int idx = xstats_ctrl->mlx5_stats_n++;
+
+				xstats_ctrl->dev_table_idx[idx] = i;
+				xstats_ctrl->info[idx] = mlx5_counters_init[j];
+				break;
+			}
+		}
+	}
+	/* Add dev counters. */
+	for (i = 0; i != xstats_n; ++i) {
+		if (mlx5_counters_init[i].dev) {
+			unsigned int idx = xstats_ctrl->mlx5_stats_n++;
+
+			xstats_ctrl->info[idx] = mlx5_counters_init[i];
+			xstats_ctrl->hw_stats[idx] = 0;
+		}
+	}
+	MLX5_ASSERT(xstats_ctrl->mlx5_stats_n <= MLX5_MAX_XSTATS);
+	xstats_ctrl->stats_n = dev_stats_n;
+	/* Copy to base at first time. */
+	ret = mlx5_os_read_dev_counters(dev, xstats_ctrl->base);
+	if (ret)
+		DRV_LOG(ERR, "port %u cannot read device counters: %s",
+			dev->data->port_id, strerror(rte_errno));
+	mlx5_os_read_dev_stat(priv, "out_of_buffer", &stats_ctrl->imissed_base);
+	stats_ctrl->imissed = 0;
+free:
+	rte_free(strings);
+}
+
+/**
+ * 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 ifreq request;
+	int ret;
+
+	ret = mlx5_ifreq(dev, SIOCGIFHWADDR, &request);
+	if (ret)
+		return ret;
+	memcpy(mac, request.ifr_hwaddr.sa_data, RTE_ETHER_ADDR_LEN);
+	return 0;
+}
+
diff --git a/drivers/net/mlx5/linux/mlx5_os.c b/drivers/net/mlx5/linux/mlx5_os.c
index 7de57a4..a853219 100644
--- a/drivers/net/mlx5/linux/mlx5_os.c
+++ b/drivers/net/mlx5/linux/mlx5_os.c
@@ -67,30 +67,6 @@
 #endif
 
 /**
- * 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.
- */
-static int
-mlx5_get_mac(struct rte_eth_dev *dev, uint8_t (*mac)[RTE_ETHER_ADDR_LEN])
-{
-	struct ifreq request;
-	int ret;
-
-	ret = mlx5_ifreq(dev, SIOCGIFHWADDR, &request);
-	if (ret)
-		return ret;
-	memcpy(mac, request.ifr_hwaddr.sa_data, RTE_ETHER_ADDR_LEN);
-	return 0;
-}
-
-/**
  * Get mlx5 device attributes. The glue function query_device_ex() is called
  * with out parameter of type 'struct ibv_device_attr_ex *'. Then fill in mlx5
  * device attributes from the glue out parameter.
@@ -1997,291 +1973,6 @@ mlx5_os_read_dev_stat(struct mlx5_priv *priv, const char *ctr_name,
 }
 
 /**
- * Read device counters table.
- *
- * @param dev
- *   Pointer to Ethernet device.
- * @param[out] stats
- *   Counters table output buffer.
- *
- * @return
- *   0 on success and stats is filled, negative errno value otherwise and
- *   rte_errno is set.
- */
-int
-mlx5_os_read_dev_counters(struct rte_eth_dev *dev, uint64_t *stats)
-{
-	struct mlx5_priv *priv = dev->data->dev_private;
-	struct mlx5_xstats_ctrl *xstats_ctrl = &priv->xstats_ctrl;
-	unsigned int i;
-	struct ifreq ifr;
-	unsigned int stats_sz = xstats_ctrl->stats_n * sizeof(uint64_t);
-	unsigned char et_stat_buf[sizeof(struct ethtool_stats) + stats_sz];
-	struct ethtool_stats *et_stats = (struct ethtool_stats *)et_stat_buf;
-	int ret;
-
-	et_stats->cmd = ETHTOOL_GSTATS;
-	et_stats->n_stats = xstats_ctrl->stats_n;
-	ifr.ifr_data = (caddr_t)et_stats;
-	ret = mlx5_ifreq(dev, SIOCETHTOOL, &ifr);
-	if (ret) {
-		DRV_LOG(WARNING,
-			"port %u unable to read statistic values from device",
-			dev->data->port_id);
-		return ret;
-	}
-	for (i = 0; i != xstats_ctrl->mlx5_stats_n; ++i) {
-		if (xstats_ctrl->info[i].dev) {
-			ret = mlx5_os_read_dev_stat(priv,
-					    xstats_ctrl->info[i].ctr_name,
-					    &stats[i]);
-			/* return last xstats counter if fail to read. */
-			if (ret == 0)
-				xstats_ctrl->xstats[i] = stats[i];
-			else
-				stats[i] = xstats_ctrl->xstats[i];
-		} else {
-			stats[i] = (uint64_t)
-				et_stats->data[xstats_ctrl->dev_table_idx[i]];
-		}
-	}
-	return 0;
-}
-
-/**
- * Query the number of statistics provided by ETHTOOL.
- *
- * @param dev
- *   Pointer to Ethernet device.
- *
- * @return
- *   Number of statistics on success, negative errno value otherwise and
- *   rte_errno is set.
- */
-int
-mlx5_os_get_stats_n(struct rte_eth_dev *dev)
-{
-	struct ethtool_drvinfo drvinfo;
-	struct ifreq ifr;
-	int ret;
-
-	drvinfo.cmd = ETHTOOL_GDRVINFO;
-	ifr.ifr_data = (caddr_t)&drvinfo;
-	ret = mlx5_ifreq(dev, SIOCETHTOOL, &ifr);
-	if (ret) {
-		DRV_LOG(WARNING, "port %u unable to query number of statistics",
-			dev->data->port_id);
-		return ret;
-	}
-	return drvinfo.n_stats;
-}
-
-static const struct mlx5_counter_ctrl mlx5_counters_init[] = {
-	{
-		.dpdk_name = "rx_port_unicast_bytes",
-		.ctr_name = "rx_vport_unicast_bytes",
-	},
-	{
-		.dpdk_name = "rx_port_multicast_bytes",
-		.ctr_name = "rx_vport_multicast_bytes",
-	},
-	{
-		.dpdk_name = "rx_port_broadcast_bytes",
-		.ctr_name = "rx_vport_broadcast_bytes",
-	},
-	{
-		.dpdk_name = "rx_port_unicast_packets",
-		.ctr_name = "rx_vport_unicast_packets",
-	},
-	{
-		.dpdk_name = "rx_port_multicast_packets",
-		.ctr_name = "rx_vport_multicast_packets",
-	},
-	{
-		.dpdk_name = "rx_port_broadcast_packets",
-		.ctr_name = "rx_vport_broadcast_packets",
-	},
-	{
-		.dpdk_name = "tx_port_unicast_bytes",
-		.ctr_name = "tx_vport_unicast_bytes",
-	},
-	{
-		.dpdk_name = "tx_port_multicast_bytes",
-		.ctr_name = "tx_vport_multicast_bytes",
-	},
-	{
-		.dpdk_name = "tx_port_broadcast_bytes",
-		.ctr_name = "tx_vport_broadcast_bytes",
-	},
-	{
-		.dpdk_name = "tx_port_unicast_packets",
-		.ctr_name = "tx_vport_unicast_packets",
-	},
-	{
-		.dpdk_name = "tx_port_multicast_packets",
-		.ctr_name = "tx_vport_multicast_packets",
-	},
-	{
-		.dpdk_name = "tx_port_broadcast_packets",
-		.ctr_name = "tx_vport_broadcast_packets",
-	},
-	{
-		.dpdk_name = "rx_wqe_err",
-		.ctr_name = "rx_wqe_err",
-	},
-	{
-		.dpdk_name = "rx_crc_errors_phy",
-		.ctr_name = "rx_crc_errors_phy",
-	},
-	{
-		.dpdk_name = "rx_in_range_len_errors_phy",
-		.ctr_name = "rx_in_range_len_errors_phy",
-	},
-	{
-		.dpdk_name = "rx_symbol_err_phy",
-		.ctr_name = "rx_symbol_err_phy",
-	},
-	{
-		.dpdk_name = "tx_errors_phy",
-		.ctr_name = "tx_errors_phy",
-	},
-	{
-		.dpdk_name = "rx_out_of_buffer",
-		.ctr_name = "out_of_buffer",
-		.dev = 1,
-	},
-	{
-		.dpdk_name = "tx_packets_phy",
-		.ctr_name = "tx_packets_phy",
-	},
-	{
-		.dpdk_name = "rx_packets_phy",
-		.ctr_name = "rx_packets_phy",
-	},
-	{
-		.dpdk_name = "tx_discards_phy",
-		.ctr_name = "tx_discards_phy",
-	},
-	{
-		.dpdk_name = "rx_discards_phy",
-		.ctr_name = "rx_discards_phy",
-	},
-	{
-		.dpdk_name = "tx_bytes_phy",
-		.ctr_name = "tx_bytes_phy",
-	},
-	{
-		.dpdk_name = "rx_bytes_phy",
-		.ctr_name = "rx_bytes_phy",
-	},
-	/* Representor only */
-	{
-		.dpdk_name = "rx_packets",
-		.ctr_name = "vport_rx_packets",
-	},
-	{
-		.dpdk_name = "rx_bytes",
-		.ctr_name = "vport_rx_bytes",
-	},
-	{
-		.dpdk_name = "tx_packets",
-		.ctr_name = "vport_tx_packets",
-	},
-	{
-		.dpdk_name = "tx_bytes",
-		.ctr_name = "vport_tx_bytes",
-	},
-};
-
-static const unsigned int xstats_n = RTE_DIM(mlx5_counters_init);
-
-/**
- * Init the structures to read device counters.
- *
- * @param dev
- *   Pointer to Ethernet device.
- */
-void
-mlx5_os_stats_init(struct rte_eth_dev *dev)
-{
-	struct mlx5_priv *priv = dev->data->dev_private;
-	struct mlx5_xstats_ctrl *xstats_ctrl = &priv->xstats_ctrl;
-	struct mlx5_stats_ctrl *stats_ctrl = &priv->stats_ctrl;
-	unsigned int i;
-	unsigned int j;
-	struct ifreq ifr;
-	struct ethtool_gstrings *strings = NULL;
-	unsigned int dev_stats_n;
-	unsigned int str_sz;
-	int ret;
-
-	/* So that it won't aggregate for each init. */
-	xstats_ctrl->mlx5_stats_n = 0;
-	ret = mlx5_os_get_stats_n(dev);
-	if (ret < 0) {
-		DRV_LOG(WARNING, "port %u no extended statistics available",
-			dev->data->port_id);
-		return;
-	}
-	dev_stats_n = ret;
-	/* Allocate memory to grab stat names and values. */
-	str_sz = dev_stats_n * ETH_GSTRING_LEN;
-	strings = (struct ethtool_gstrings *)
-		  rte_malloc("xstats_strings",
-			     str_sz + sizeof(struct ethtool_gstrings), 0);
-	if (!strings) {
-		DRV_LOG(WARNING, "port %u unable to allocate memory for xstats",
-		     dev->data->port_id);
-		return;
-	}
-	strings->cmd = ETHTOOL_GSTRINGS;
-	strings->string_set = ETH_SS_STATS;
-	strings->len = dev_stats_n;
-	ifr.ifr_data = (caddr_t)strings;
-	ret = mlx5_ifreq(dev, SIOCETHTOOL, &ifr);
-	if (ret) {
-		DRV_LOG(WARNING, "port %u unable to get statistic names",
-			dev->data->port_id);
-		goto free;
-	}
-	for (i = 0; i != dev_stats_n; ++i) {
-		const char *curr_string = (const char *)
-			&strings->data[i * ETH_GSTRING_LEN];
-
-		for (j = 0; j != xstats_n; ++j) {
-			if (!strcmp(mlx5_counters_init[j].ctr_name,
-				    curr_string)) {
-				unsigned int idx = xstats_ctrl->mlx5_stats_n++;
-
-				xstats_ctrl->dev_table_idx[idx] = i;
-				xstats_ctrl->info[idx] = mlx5_counters_init[j];
-				break;
-			}
-		}
-	}
-	/* Add dev counters. */
-	for (i = 0; i != xstats_n; ++i) {
-		if (mlx5_counters_init[i].dev) {
-			unsigned int idx = xstats_ctrl->mlx5_stats_n++;
-
-			xstats_ctrl->info[idx] = mlx5_counters_init[i];
-			xstats_ctrl->hw_stats[idx] = 0;
-		}
-	}
-	MLX5_ASSERT(xstats_ctrl->mlx5_stats_n <= MLX5_MAX_XSTATS);
-	xstats_ctrl->stats_n = dev_stats_n;
-	/* Copy to base at first time. */
-	ret = mlx5_os_read_dev_counters(dev, xstats_ctrl->base);
-	if (ret)
-		DRV_LOG(ERR, "port %u cannot read device counters: %s",
-			dev->data->port_id, strerror(rte_errno));
-	mlx5_os_read_dev_stat(priv, "out_of_buffer", &stats_ctrl->imissed_base);
-	stats_ctrl->imissed = 0;
-free:
-	rte_free(strings);
-}
-
-/**
  * Set the reg_mr and dereg_mr call backs
  *
  * @param reg_mr_cb[out]
diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h
index f719cfc..a1d4734 100644
--- a/drivers/net/mlx5/mlx5.h
+++ b/drivers/net/mlx5/mlx5.h
@@ -649,7 +649,6 @@ struct mlx5_priv {
 	LIST_HEAD(ind_tables, mlx5_ind_table_obj) ind_tbls;
 	/* Pointer to next element. */
 	rte_atomic32_t refcnt; /**< Reference counter. */
-	struct ibv_flow_action *verbs_action;
 	/**< Verbs modify header action object. */
 	uint8_t ft_type; /**< Flow table type, Rx or Tx. */
 	uint8_t max_lro_msg_size;
@@ -735,10 +734,8 @@ int mlx5_hairpin_cap_get(struct rte_eth_dev *dev,
 
 int mlx5_get_ifname(const struct rte_eth_dev *dev, char (*ifname)[IF_NAMESIZE]);
 unsigned int mlx5_ifindex(const struct rte_eth_dev *dev);
-int mlx5_ifreq(const struct rte_eth_dev *dev, int req, struct ifreq *ifr);
+int mlx5_get_mac(struct rte_eth_dev *dev, uint8_t (*mac)[RTE_ETHER_ADDR_LEN]);
 int mlx5_get_mtu(struct rte_eth_dev *dev, uint16_t *mtu);
-int mlx5_set_flags(struct rte_eth_dev *dev, unsigned int keep,
-		   unsigned int flags);
 int mlx5_set_mtu(struct rte_eth_dev *dev, uint16_t mtu);
 int mlx5_read_clock(struct rte_eth_dev *dev, uint64_t *clock);
 int mlx5_link_update(struct rte_eth_dev *dev, int wait_to_complete);
@@ -772,6 +769,11 @@ int mlx5_get_module_info(struct rte_eth_dev *dev,
 int mlx5_get_module_eeprom(struct rte_eth_dev *dev,
 			   struct rte_dev_eeprom_info *info);
 int mlx5_dev_configure_rss_reta(struct rte_eth_dev *dev);
+int mlx5_os_read_dev_stat(struct mlx5_priv *priv,
+			  const char *ctr_name, uint64_t *stat);
+int mlx5_os_read_dev_counters(struct rte_eth_dev *dev, uint64_t *stats);
+int mlx5_os_get_stats_n(struct rte_eth_dev *dev);
+void mlx5_os_stats_init(struct rte_eth_dev *dev);
 
 /* mlx5_mac.c */
 
@@ -932,11 +934,6 @@ int mlx5_os_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
 		       struct rte_pci_device *pci_dev);
 void mlx5_os_dev_shared_handler_install(struct mlx5_dev_ctx_shared *sh);
 void mlx5_os_dev_shared_handler_uninstall(struct mlx5_dev_ctx_shared *sh);
-int mlx5_os_read_dev_stat(struct mlx5_priv *priv,
-			  const char *ctr_name, uint64_t *stat);
-int mlx5_os_read_dev_counters(struct rte_eth_dev *dev, uint64_t *stats);
-int mlx5_os_get_stats_n(struct rte_eth_dev *dev);
-void mlx5_os_stats_init(struct rte_eth_dev *dev);
 void mlx5_os_set_reg_mr_cb(mlx5_reg_mr_t *reg_mr_cb,
 			   mlx5_dereg_mr_t *dereg_mr_cb);
 void mlx5_os_mac_addr_remove(struct rte_eth_dev *dev, uint32_t index);
-- 
2.8.4


^ permalink raw reply	[flat|nested] 28+ messages in thread

* [dpdk-dev] [PATCH v1 6/8] net/mlx5: header file cleanup
  2020-07-14 14:20 [dpdk-dev] [PATCH v1 0/8] mlx5 PMD multi OS support - part #3 Ophir Munk
                   ` (4 preceding siblings ...)
  2020-07-14 14:20 ` [dpdk-dev] [PATCH v1 5/8] net/mlx5: eliminate dependency on Linux in shared header Ophir Munk
@ 2020-07-14 14:21 ` Ophir Munk
  2020-07-14 14:21 ` [dpdk-dev] [PATCH v1 7/8] net/mlx5: refactor multi process communication Ophir Munk
  2020-07-14 14:21 ` [dpdk-dev] [PATCH v1 8/8] mlx5: remove inclusion of verbs header files Ophir Munk
  7 siblings, 0 replies; 28+ messages in thread
From: Ophir Munk @ 2020-07-14 14:21 UTC (permalink / raw)
  To: dev; +Cc: Raslan Darawsheh, Ophir Munk, Matan Azrad

The cleanup refers to header file mlx5.h.
1. Remove unused prototypes.
2. Move prototypes under their correct title.
3. Change functions to static and remove their prototye from the header
file.

Signed-off-by: Ophir Munk <ophirmu@mellanox.com>
Acked-by: Matan Azrad <matan@mellanox.com>
---
 drivers/net/mlx5/linux/mlx5_ethdev_os.c | 102 ++++++++++++++++----------------
 drivers/net/mlx5/mlx5.h                 |  19 +++---
 2 files changed, 59 insertions(+), 62 deletions(-)

diff --git a/drivers/net/mlx5/linux/mlx5_ethdev_os.c b/drivers/net/mlx5/linux/mlx5_ethdev_os.c
index 765a521..95f33bb 100644
--- a/drivers/net/mlx5/linux/mlx5_ethdev_os.c
+++ b/drivers/net/mlx5/linux/mlx5_ethdev_os.c
@@ -972,6 +972,57 @@ mlx5_is_removed(struct rte_eth_dev *dev)
 }
 
 /**
+ * Analyze gathered port parameters via sysfs to recognize master
+ * and representor devices for E-Switch configuration.
+ *
+ * @param[in] device_dir
+ *   flag of presence of "device" directory under port device key.
+ * @param[inout] switch_info
+ *   Port information, including port name as a number and port name
+ *   type if recognized
+ *
+ * @return
+ *   master and representor flags are set in switch_info according to
+ *   recognized parameters (if any).
+ */
+static void
+mlx5_sysfs_check_switch_info(bool device_dir,
+			     struct mlx5_switch_info *switch_info)
+{
+	switch (switch_info->name_type) {
+	case MLX5_PHYS_PORT_NAME_TYPE_UNKNOWN:
+		/*
+		 * Name is not recognized, assume the master,
+		 * check the device directory presence.
+		 */
+		switch_info->master = device_dir;
+		break;
+	case MLX5_PHYS_PORT_NAME_TYPE_NOTSET:
+		/*
+		 * Name is not set, this assumes the legacy naming
+		 * schema for master, just check if there is
+		 * a device directory.
+		 */
+		switch_info->master = device_dir;
+		break;
+	case MLX5_PHYS_PORT_NAME_TYPE_UPLINK:
+		/* New uplink naming schema recognized. */
+		switch_info->master = 1;
+		break;
+	case MLX5_PHYS_PORT_NAME_TYPE_LEGACY:
+		/* Legacy representors naming schema. */
+		switch_info->representor = !device_dir;
+		break;
+	case MLX5_PHYS_PORT_NAME_TYPE_PFHPF:
+		/* Fallthrough */
+	case MLX5_PHYS_PORT_NAME_TYPE_PFVF:
+		/* New representors naming schema. */
+		switch_info->representor = 1;
+		break;
+	}
+}
+
+/**
  * Get switch information associated with network interface.
  *
  * @param ifindex
@@ -1050,57 +1101,6 @@ mlx5_sysfs_switch_info(unsigned int ifindex, struct mlx5_switch_info *info)
 }
 
 /**
- * Analyze gathered port parameters via sysfs to recognize master
- * and representor devices for E-Switch configuration.
- *
- * @param[in] device_dir
- *   flag of presence of "device" directory under port device key.
- * @param[inout] switch_info
- *   Port information, including port name as a number and port name
- *   type if recognized
- *
- * @return
- *   master and representor flags are set in switch_info according to
- *   recognized parameters (if any).
- */
-void
-mlx5_sysfs_check_switch_info(bool device_dir,
-			     struct mlx5_switch_info *switch_info)
-{
-	switch (switch_info->name_type) {
-	case MLX5_PHYS_PORT_NAME_TYPE_UNKNOWN:
-		/*
-		 * Name is not recognized, assume the master,
-		 * check the device directory presence.
-		 */
-		switch_info->master = device_dir;
-		break;
-	case MLX5_PHYS_PORT_NAME_TYPE_NOTSET:
-		/*
-		 * Name is not set, this assumes the legacy naming
-		 * schema for master, just check if there is
-		 * a device directory.
-		 */
-		switch_info->master = device_dir;
-		break;
-	case MLX5_PHYS_PORT_NAME_TYPE_UPLINK:
-		/* New uplink naming schema recognized. */
-		switch_info->master = 1;
-		break;
-	case MLX5_PHYS_PORT_NAME_TYPE_LEGACY:
-		/* Legacy representors naming schema. */
-		switch_info->representor = !device_dir;
-		break;
-	case MLX5_PHYS_PORT_NAME_TYPE_PFHPF:
-		/* Fallthrough */
-	case MLX5_PHYS_PORT_NAME_TYPE_PFVF:
-		/* New representors naming schema. */
-		switch_info->representor = 1;
-		break;
-	}
-}
-
-/**
  * DPDK callback to retrieve plug-in module EEPROM information (type and size).
  *
  * @param dev
diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h
index a1d4734..87cfbfe 100644
--- a/drivers/net/mlx5/mlx5.h
+++ b/drivers/net/mlx5/mlx5.h
@@ -729,6 +729,10 @@ const uint32_t *mlx5_dev_supported_ptypes_get(struct rte_eth_dev *dev);
 int mlx5_dev_set_mtu(struct rte_eth_dev *dev, uint16_t mtu);
 int mlx5_hairpin_cap_get(struct rte_eth_dev *dev,
 			 struct rte_eth_hairpin_cap *cap);
+eth_rx_burst_t mlx5_select_rx_function(struct rte_eth_dev *dev);
+struct mlx5_priv *mlx5_port_to_eswitch_info(uint16_t port, bool valid);
+struct mlx5_priv *mlx5_dev_to_eswitch_info(struct rte_eth_dev *dev);
+int mlx5_dev_configure_rss_reta(struct rte_eth_dev *dev);
 
 /* mlx5_ethdev_os.c */
 
@@ -739,27 +743,17 @@ int mlx5_get_mtu(struct rte_eth_dev *dev, uint16_t *mtu);
 int mlx5_set_mtu(struct rte_eth_dev *dev, uint16_t mtu);
 int mlx5_read_clock(struct rte_eth_dev *dev, uint64_t *clock);
 int mlx5_link_update(struct rte_eth_dev *dev, int wait_to_complete);
-int mlx5_force_link_status_change(struct rte_eth_dev *dev, int status);
 int mlx5_dev_get_flow_ctrl(struct rte_eth_dev *dev,
 			   struct rte_eth_fc_conf *fc_conf);
 int mlx5_dev_set_flow_ctrl(struct rte_eth_dev *dev,
 			   struct rte_eth_fc_conf *fc_conf);
-void mlx5_dev_link_status_handler(void *arg);
 void mlx5_dev_interrupt_handler(void *arg);
 void mlx5_dev_interrupt_handler_devx(void *arg);
-void mlx5_dev_interrupt_handler_uninstall(struct rte_eth_dev *dev);
-void mlx5_dev_interrupt_handler_install(struct rte_eth_dev *dev);
 int mlx5_set_link_down(struct rte_eth_dev *dev);
 int mlx5_set_link_up(struct rte_eth_dev *dev);
 int mlx5_is_removed(struct rte_eth_dev *dev);
-eth_tx_burst_t mlx5_select_tx_function(struct rte_eth_dev *dev);
-eth_rx_burst_t mlx5_select_rx_function(struct rte_eth_dev *dev);
-struct mlx5_priv *mlx5_port_to_eswitch_info(uint16_t port, bool valid);
-struct mlx5_priv *mlx5_dev_to_eswitch_info(struct rte_eth_dev *dev);
 int mlx5_sysfs_switch_info(unsigned int ifindex,
 			   struct mlx5_switch_info *info);
-void mlx5_sysfs_check_switch_info(bool device_dir,
-				  struct mlx5_switch_info *switch_info);
 void mlx5_translate_port_name(const char *port_name_in,
 			      struct mlx5_switch_info *port_info_out);
 void mlx5_intr_callback_unregister(const struct rte_intr_handle *handle,
@@ -768,7 +762,6 @@ int mlx5_get_module_info(struct rte_eth_dev *dev,
 			 struct rte_eth_dev_module_info *modinfo);
 int mlx5_get_module_eeprom(struct rte_eth_dev *dev,
 			   struct rte_dev_eeprom_info *info);
-int mlx5_dev_configure_rss_reta(struct rte_eth_dev *dev);
 int mlx5_os_read_dev_stat(struct mlx5_priv *priv,
 			  const char *ctr_name, uint64_t *stat);
 int mlx5_os_read_dev_counters(struct rte_eth_dev *dev, uint64_t *stats);
@@ -944,4 +937,8 @@ int mlx5_os_vf_mac_addr_modify(struct mlx5_priv *priv, unsigned int iface_idx,
 			       int vf_index);
 int mlx5_os_set_promisc(struct rte_eth_dev *dev, int enable);
 int mlx5_os_set_allmulti(struct rte_eth_dev *dev, int enable);
+
+/* mlx5_rxtx.c */
+
+eth_tx_burst_t mlx5_select_tx_function(struct rte_eth_dev *dev);
 #endif /* RTE_PMD_MLX5_H_ */
-- 
2.8.4


^ permalink raw reply	[flat|nested] 28+ messages in thread

* [dpdk-dev] [PATCH v1 7/8] net/mlx5: refactor multi process communication
  2020-07-14 14:20 [dpdk-dev] [PATCH v1 0/8] mlx5 PMD multi OS support - part #3 Ophir Munk
                   ` (5 preceding siblings ...)
  2020-07-14 14:21 ` [dpdk-dev] [PATCH v1 6/8] net/mlx5: header file cleanup Ophir Munk
@ 2020-07-14 14:21 ` Ophir Munk
  2020-07-14 14:21 ` [dpdk-dev] [PATCH v1 8/8] mlx5: remove inclusion of verbs header files Ophir Munk
  7 siblings, 0 replies; 28+ messages in thread
From: Ophir Munk @ 2020-07-14 14:21 UTC (permalink / raw)
  To: dev; +Cc: Raslan Darawsheh, Ophir Munk, Matan Azrad

1. The shared data communication between the primary and the secondary
processes is implemented using Linux API. Move the Linux API code under
linux directory (file linux/mlx5_os.c).

2. File net/mlx5/mlx5_mp.c handles requests to the primary and secondary
processes (e.g. start_rxtx, stop_rxtx). It is Linux based so it is moved
under linux (new file linux/mlx5_mp_os.c).

Signed-off-by: Ophir Munk <ophirmu@mellanox.com>
Acked-by: Matan Azrad <matan@mellanox.com>
---
 drivers/net/mlx5/Makefile           |   2 +-
 drivers/net/mlx5/linux/meson.build  |   1 +
 drivers/net/mlx5/linux/mlx5_mp_os.c | 211 ++++++++++++++++++++++++++++++++++++
 drivers/net/mlx5/linux/mlx5_os.c    | 111 +++++++++++++++++++
 drivers/net/mlx5/meson.build        |   1 -
 drivers/net/mlx5/mlx5.c             | 114 +------------------
 drivers/net/mlx5/mlx5.h             |  13 ++-
 drivers/net/mlx5/mlx5_mp.c          | 211 ------------------------------------
 drivers/net/mlx5/mlx5_trigger.c     |   4 +-
 9 files changed, 336 insertions(+), 332 deletions(-)
 create mode 100644 drivers/net/mlx5/linux/mlx5_mp_os.c
 delete mode 100644 drivers/net/mlx5/mlx5_mp.c

diff --git a/drivers/net/mlx5/Makefile b/drivers/net/mlx5/Makefile
index a458402..bb45294 100644
--- a/drivers/net/mlx5/Makefile
+++ b/drivers/net/mlx5/Makefile
@@ -29,12 +29,12 @@ SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5_flow.c
 SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5_flow_meter.c
 SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5_flow_dv.c
 SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5_flow_verbs.c
-SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5_mp.c
 SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5_utils.c
 SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += linux/mlx5_socket.c
 SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += linux/mlx5_os.c
 SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += linux/mlx5_ethdev_os.c
 SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += linux/mlx5_verbs.c
+SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += linux/mlx5_mp_os.c
 
 # Basic CFLAGS.
 CFLAGS += -O3
diff --git a/drivers/net/mlx5/linux/meson.build b/drivers/net/mlx5/linux/meson.build
index 14eed03..2def8e3 100644
--- a/drivers/net/mlx5/linux/meson.build
+++ b/drivers/net/mlx5/linux/meson.build
@@ -7,5 +7,6 @@ sources += files(
 	'mlx5_os.c',
 	'mlx5_ethdev_os.c',
 	'mlx5_verbs.c',
+	'mlx5_mp_os.c',
 )
 
diff --git a/drivers/net/mlx5/linux/mlx5_mp_os.c b/drivers/net/mlx5/linux/mlx5_mp_os.c
new file mode 100644
index 0000000..65b0025
--- /dev/null
+++ b/drivers/net/mlx5/linux/mlx5_mp_os.c
@@ -0,0 +1,211 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright 2019 6WIND S.A.
+ * Copyright 2019 Mellanox Technologies, Ltd
+ */
+
+#include <stdio.h>
+#include <time.h>
+
+#include <rte_eal.h>
+#include <rte_ethdev_driver.h>
+#include <rte_string_fns.h>
+
+#include <mlx5_common_mp.h>
+#include <mlx5_common_mr.h>
+
+#include "mlx5.h"
+#include "mlx5_rxtx.h"
+#include "mlx5_utils.h"
+
+int
+mlx5_mp_os_primary_handle(const struct rte_mp_msg *mp_msg, const void *peer)
+{
+	struct rte_mp_msg mp_res;
+	struct mlx5_mp_param *res = (struct mlx5_mp_param *)mp_res.param;
+	const struct mlx5_mp_param *param =
+		(const struct mlx5_mp_param *)mp_msg->param;
+	struct rte_eth_dev *dev;
+	struct mlx5_priv *priv;
+	struct mr_cache_entry entry;
+	uint32_t lkey;
+	int ret;
+
+	MLX5_ASSERT(rte_eal_process_type() == RTE_PROC_PRIMARY);
+	if (!rte_eth_dev_is_valid_port(param->port_id)) {
+		rte_errno = ENODEV;
+		DRV_LOG(ERR, "port %u invalid port ID", param->port_id);
+		return -rte_errno;
+	}
+	dev = &rte_eth_devices[param->port_id];
+	priv = dev->data->dev_private;
+	switch (param->type) {
+	case MLX5_MP_REQ_CREATE_MR:
+		mp_init_msg(&priv->mp_id, &mp_res, param->type);
+		lkey = mlx5_mr_create_primary(priv->sh->pd,
+					      &priv->sh->share_cache,
+					      &entry, param->args.addr,
+					      priv->config.mr_ext_memseg_en);
+		if (lkey == UINT32_MAX)
+			res->result = -rte_errno;
+		ret = rte_mp_reply(&mp_res, peer);
+		break;
+	case MLX5_MP_REQ_VERBS_CMD_FD:
+		mp_init_msg(&priv->mp_id, &mp_res, param->type);
+		mp_res.num_fds = 1;
+		mp_res.fds[0] = ((struct ibv_context *)priv->sh->ctx)->cmd_fd;
+		res->result = 0;
+		ret = rte_mp_reply(&mp_res, peer);
+		break;
+	case MLX5_MP_REQ_QUEUE_STATE_MODIFY:
+		mp_init_msg(&priv->mp_id, &mp_res, param->type);
+		res->result = mlx5_queue_state_modify_primary
+					(dev, &param->args.state_modify);
+		ret = rte_mp_reply(&mp_res, peer);
+		break;
+	default:
+		rte_errno = EINVAL;
+		DRV_LOG(ERR, "port %u invalid mp request type",
+			dev->data->port_id);
+		return -rte_errno;
+	}
+	return ret;
+}
+
+/**
+ * IPC message handler of a secondary process.
+ *
+ * @param[in] dev
+ *   Pointer to Ethernet structure.
+ * @param[in] peer
+ *   Pointer to the peer socket path.
+ *
+ * @return
+ *   0 on success, a negative errno value otherwise and rte_errno is set.
+ */
+int
+mlx5_mp_os_secondary_handle(const struct rte_mp_msg *mp_msg, const void *peer)
+{
+	struct rte_mp_msg mp_res;
+	struct mlx5_mp_param *res = (struct mlx5_mp_param *)mp_res.param;
+	const struct mlx5_mp_param *param =
+		(const struct mlx5_mp_param *)mp_msg->param;
+	struct rte_eth_dev *dev;
+	struct mlx5_priv *priv;
+	int ret;
+
+	MLX5_ASSERT(rte_eal_process_type() == RTE_PROC_SECONDARY);
+	if (!rte_eth_dev_is_valid_port(param->port_id)) {
+		rte_errno = ENODEV;
+		DRV_LOG(ERR, "port %u invalid port ID", param->port_id);
+		return -rte_errno;
+	}
+	dev = &rte_eth_devices[param->port_id];
+	priv = dev->data->dev_private;
+	switch (param->type) {
+	case MLX5_MP_REQ_START_RXTX:
+		DRV_LOG(INFO, "port %u starting datapath", dev->data->port_id);
+		rte_mb();
+		dev->rx_pkt_burst = mlx5_select_rx_function(dev);
+		dev->tx_pkt_burst = mlx5_select_tx_function(dev);
+		mp_init_msg(&priv->mp_id, &mp_res, param->type);
+		res->result = 0;
+		ret = rte_mp_reply(&mp_res, peer);
+		break;
+	case MLX5_MP_REQ_STOP_RXTX:
+		DRV_LOG(INFO, "port %u stopping datapath", dev->data->port_id);
+		dev->rx_pkt_burst = removed_rx_burst;
+		dev->tx_pkt_burst = removed_tx_burst;
+		rte_mb();
+		mp_init_msg(&priv->mp_id, &mp_res, param->type);
+		res->result = 0;
+		ret = rte_mp_reply(&mp_res, peer);
+		break;
+	default:
+		rte_errno = EINVAL;
+		DRV_LOG(ERR, "port %u invalid mp request type",
+			dev->data->port_id);
+		return -rte_errno;
+	}
+	return ret;
+}
+
+/**
+ * Broadcast request of stopping/starting data-path to secondary processes.
+ *
+ * @param[in] dev
+ *   Pointer to Ethernet structure.
+ * @param[in] type
+ *   Request type.
+ */
+static void
+mp_req_on_rxtx(struct rte_eth_dev *dev, enum mlx5_mp_req_type type)
+{
+	struct rte_mp_msg mp_req;
+	struct rte_mp_msg *mp_res;
+	struct rte_mp_reply mp_rep;
+	struct mlx5_mp_param *res;
+	struct timespec ts = {.tv_sec = MLX5_MP_REQ_TIMEOUT_SEC, .tv_nsec = 0};
+	struct mlx5_priv *priv = dev->data->dev_private;
+	int ret;
+	int i;
+
+	MLX5_ASSERT(rte_eal_process_type() == RTE_PROC_PRIMARY);
+	if (!mlx5_shared_data->secondary_cnt)
+		return;
+	if (type != MLX5_MP_REQ_START_RXTX && type != MLX5_MP_REQ_STOP_RXTX) {
+		DRV_LOG(ERR, "port %u unknown request (req_type %d)",
+			dev->data->port_id, type);
+		return;
+	}
+	mp_init_msg(&priv->mp_id, &mp_req, type);
+	ret = rte_mp_request_sync(&mp_req, &mp_rep, &ts);
+	if (ret) {
+		if (rte_errno != ENOTSUP)
+			DRV_LOG(ERR, "port %u failed to request stop/start Rx/Tx (%d)",
+				dev->data->port_id, type);
+		goto exit;
+	}
+	if (mp_rep.nb_sent != mp_rep.nb_received) {
+		DRV_LOG(ERR,
+			"port %u not all secondaries responded (req_type %d)",
+			dev->data->port_id, type);
+		goto exit;
+	}
+	for (i = 0; i < mp_rep.nb_received; i++) {
+		mp_res = &mp_rep.msgs[i];
+		res = (struct mlx5_mp_param *)mp_res->param;
+		if (res->result) {
+			DRV_LOG(ERR, "port %u request failed on secondary #%d",
+				dev->data->port_id, i);
+			goto exit;
+		}
+	}
+exit:
+	free(mp_rep.msgs);
+}
+
+/**
+ * Broadcast request of starting data-path to secondary processes. The request
+ * is synchronous.
+ *
+ * @param[in] dev
+ *   Pointer to Ethernet structure.
+ */
+void
+mlx5_mp_os_req_start_rxtx(struct rte_eth_dev *dev)
+{
+	mp_req_on_rxtx(dev, MLX5_MP_REQ_START_RXTX);
+}
+
+/**
+ * Broadcast request of stopping data-path to secondary processes. The request
+ * is synchronous.
+ *
+ * @param[in] dev
+ *   Pointer to Ethernet structure.
+ */
+void
+mlx5_mp_os_req_stop_rxtx(struct rte_eth_dev *dev)
+{
+	mp_req_on_rxtx(dev, MLX5_MP_REQ_STOP_RXTX);
+}
diff --git a/drivers/net/mlx5/linux/mlx5_os.c b/drivers/net/mlx5/linux/mlx5_os.c
index a853219..2385d69 100644
--- a/drivers/net/mlx5/linux/mlx5_os.c
+++ b/drivers/net/mlx5/linux/mlx5_os.c
@@ -66,6 +66,14 @@
 #define MLX5DV_CONTEXT_FLAGS_CQE_128B_COMP (1 << 4)
 #endif
 
+static const char *MZ_MLX5_PMD_SHARED_DATA = "mlx5_pmd_shared_data";
+
+/* Spinlock for mlx5_shared_data allocation. */
+static rte_spinlock_t mlx5_shared_data_lock = RTE_SPINLOCK_INITIALIZER;
+
+/* Process local data for secondary processes. */
+static struct mlx5_local_data mlx5_local_data;
+
 /**
  * Get mlx5 device attributes. The glue function query_device_ex() is called
  * with out parameter of type 'struct ibv_device_attr_ex *'. Then fill in mlx5
@@ -356,6 +364,109 @@ mlx5_os_free_shared_dr(struct mlx5_priv *priv)
 }
 
 /**
+ * Initialize shared data between primary and secondary process.
+ *
+ * A memzone is reserved by primary process and secondary processes attach to
+ * the memzone.
+ *
+ * @return
+ *   0 on success, a negative errno value otherwise and rte_errno is set.
+ */
+static int
+mlx5_init_shared_data(void)
+{
+	const struct rte_memzone *mz;
+	int ret = 0;
+
+	rte_spinlock_lock(&mlx5_shared_data_lock);
+	if (mlx5_shared_data == NULL) {
+		if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
+			/* Allocate shared memory. */
+			mz = rte_memzone_reserve(MZ_MLX5_PMD_SHARED_DATA,
+						 sizeof(*mlx5_shared_data),
+						 SOCKET_ID_ANY, 0);
+			if (mz == NULL) {
+				DRV_LOG(ERR,
+					"Cannot allocate mlx5 shared data");
+				ret = -rte_errno;
+				goto error;
+			}
+			mlx5_shared_data = mz->addr;
+			memset(mlx5_shared_data, 0, sizeof(*mlx5_shared_data));
+			rte_spinlock_init(&mlx5_shared_data->lock);
+		} else {
+			/* Lookup allocated shared memory. */
+			mz = rte_memzone_lookup(MZ_MLX5_PMD_SHARED_DATA);
+			if (mz == NULL) {
+				DRV_LOG(ERR,
+					"Cannot attach mlx5 shared data");
+				ret = -rte_errno;
+				goto error;
+			}
+			mlx5_shared_data = mz->addr;
+			memset(&mlx5_local_data, 0, sizeof(mlx5_local_data));
+		}
+	}
+error:
+	rte_spinlock_unlock(&mlx5_shared_data_lock);
+	return ret;
+}
+
+/**
+ * PMD global initialization.
+ *
+ * Independent from individual device, this function initializes global
+ * per-PMD data structures distinguishing primary and secondary processes.
+ * Hence, each initialization is called once per a process.
+ *
+ * @return
+ *   0 on success, a negative errno value otherwise and rte_errno is set.
+ */
+static int
+mlx5_init_once(void)
+{
+	struct mlx5_shared_data *sd;
+	struct mlx5_local_data *ld = &mlx5_local_data;
+	int ret = 0;
+
+	if (mlx5_init_shared_data())
+		return -rte_errno;
+	sd = mlx5_shared_data;
+	MLX5_ASSERT(sd);
+	rte_spinlock_lock(&sd->lock);
+	switch (rte_eal_process_type()) {
+	case RTE_PROC_PRIMARY:
+		if (sd->init_done)
+			break;
+		LIST_INIT(&sd->mem_event_cb_list);
+		rte_rwlock_init(&sd->mem_event_rwlock);
+		rte_mem_event_callback_register("MLX5_MEM_EVENT_CB",
+						mlx5_mr_mem_event_cb, NULL);
+		ret = mlx5_mp_init_primary(MLX5_MP_NAME,
+					   mlx5_mp_os_primary_handle);
+		if (ret)
+			goto out;
+		sd->init_done = true;
+		break;
+	case RTE_PROC_SECONDARY:
+		if (ld->init_done)
+			break;
+		ret = mlx5_mp_init_secondary(MLX5_MP_NAME,
+					     mlx5_mp_os_secondary_handle);
+		if (ret)
+			goto out;
+		++sd->secondary_cnt;
+		ld->init_done = true;
+		break;
+	default:
+		break;
+	}
+out:
+	rte_spinlock_unlock(&sd->lock);
+	return ret;
+}
+
+/**
  * Spawn an Ethernet device from Verbs information.
  *
  * @param dpdk_dev
diff --git a/drivers/net/mlx5/meson.build b/drivers/net/mlx5/meson.build
index e95ce02..c8dcb76 100644
--- a/drivers/net/mlx5/meson.build
+++ b/drivers/net/mlx5/meson.build
@@ -22,7 +22,6 @@ sources = files(
 	'mlx5_rxmode.c',
 	'mlx5_rxq.c',
 	'mlx5_rxtx.c',
-	'mlx5_mp.c',
 	'mlx5_stats.c',
 	'mlx5_trigger.c',
 	'mlx5_txq.c',
diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c
index 0c654ed..10a0306 100644
--- a/drivers/net/mlx5/mlx5.c
+++ b/drivers/net/mlx5/mlx5.c
@@ -167,16 +167,11 @@
 /* Flow memory reclaim mode. */
 #define MLX5_RECLAIM_MEM "reclaim_mem_mode"
 
-static const char *MZ_MLX5_PMD_SHARED_DATA = "mlx5_pmd_shared_data";
-
 /* Shared memory between primary and secondary processes. */
 struct mlx5_shared_data *mlx5_shared_data;
 
-/* Spinlock for mlx5_shared_data allocation. */
-static rte_spinlock_t mlx5_shared_data_lock = RTE_SPINLOCK_INITIALIZER;
-
-/* Process local data for secondary processes. */
-static struct mlx5_local_data mlx5_local_data;
+/** Driver-specific log messages type. */
+int mlx5_logtype;
 
 static LIST_HEAD(, mlx5_dev_ctx_shared) mlx5_dev_ctx_list =
 						LIST_HEAD_INITIALIZER();
@@ -966,55 +961,6 @@ mlx5_alloc_table_hash_list(struct mlx5_priv *priv)
 }
 
 /**
- * Initialize shared data between primary and secondary process.
- *
- * A memzone is reserved by primary process and secondary processes attach to
- * the memzone.
- *
- * @return
- *   0 on success, a negative errno value otherwise and rte_errno is set.
- */
-static int
-mlx5_init_shared_data(void)
-{
-	const struct rte_memzone *mz;
-	int ret = 0;
-
-	rte_spinlock_lock(&mlx5_shared_data_lock);
-	if (mlx5_shared_data == NULL) {
-		if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
-			/* Allocate shared memory. */
-			mz = rte_memzone_reserve(MZ_MLX5_PMD_SHARED_DATA,
-						 sizeof(*mlx5_shared_data),
-						 SOCKET_ID_ANY, 0);
-			if (mz == NULL) {
-				DRV_LOG(ERR,
-					"Cannot allocate mlx5 shared data");
-				ret = -rte_errno;
-				goto error;
-			}
-			mlx5_shared_data = mz->addr;
-			memset(mlx5_shared_data, 0, sizeof(*mlx5_shared_data));
-			rte_spinlock_init(&mlx5_shared_data->lock);
-		} else {
-			/* Lookup allocated shared memory. */
-			mz = rte_memzone_lookup(MZ_MLX5_PMD_SHARED_DATA);
-			if (mz == NULL) {
-				DRV_LOG(ERR,
-					"Cannot attach mlx5 shared data");
-				ret = -rte_errno;
-				goto error;
-			}
-			mlx5_shared_data = mz->addr;
-			memset(&mlx5_local_data, 0, sizeof(mlx5_local_data));
-		}
-	}
-error:
-	rte_spinlock_unlock(&mlx5_shared_data_lock);
-	return ret;
-}
-
-/**
  * Retrieve integer value from environment variable.
  *
  * @param[in] name
@@ -1155,7 +1101,7 @@ mlx5_dev_close(struct rte_eth_dev *dev)
 	dev->tx_pkt_burst = removed_tx_burst;
 	rte_wmb();
 	/* Disable datapath on secondary process. */
-	mlx5_mp_req_stop_rxtx(dev);
+	mlx5_mp_os_req_stop_rxtx(dev);
 	if (priv->rxqs != NULL) {
 		/* XXX race condition if mlx5_rx_burst() is still running. */
 		usleep(1000);
@@ -1461,60 +1407,6 @@ mlx5_args(struct mlx5_dev_config *config, struct rte_devargs *devargs)
 }
 
 /**
- * PMD global initialization.
- *
- * Independent from individual device, this function initializes global
- * per-PMD data structures distinguishing primary and secondary processes.
- * Hence, each initialization is called once per a process.
- *
- * @return
- *   0 on success, a negative errno value otherwise and rte_errno is set.
- */
-int
-mlx5_init_once(void)
-{
-	struct mlx5_shared_data *sd;
-	struct mlx5_local_data *ld = &mlx5_local_data;
-	int ret = 0;
-
-	if (mlx5_init_shared_data())
-		return -rte_errno;
-	sd = mlx5_shared_data;
-	MLX5_ASSERT(sd);
-	rte_spinlock_lock(&sd->lock);
-	switch (rte_eal_process_type()) {
-	case RTE_PROC_PRIMARY:
-		if (sd->init_done)
-			break;
-		LIST_INIT(&sd->mem_event_cb_list);
-		rte_rwlock_init(&sd->mem_event_rwlock);
-		rte_mem_event_callback_register("MLX5_MEM_EVENT_CB",
-						mlx5_mr_mem_event_cb, NULL);
-		ret = mlx5_mp_init_primary(MLX5_MP_NAME,
-					   mlx5_mp_primary_handle);
-		if (ret)
-			goto out;
-		sd->init_done = true;
-		break;
-	case RTE_PROC_SECONDARY:
-		if (ld->init_done)
-			break;
-		ret = mlx5_mp_init_secondary(MLX5_MP_NAME,
-					     mlx5_mp_secondary_handle);
-		if (ret)
-			goto out;
-		++sd->secondary_cnt;
-		ld->init_done = true;
-		break;
-	default:
-		break;
-	}
-out:
-	rte_spinlock_unlock(&sd->lock);
-	return ret;
-}
-
-/**
  * Configures the minimal amount of data to inline into WQE
  * while sending packets.
  *
diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h
index 87cfbfe..fa223a1 100644
--- a/drivers/net/mlx5/mlx5.h
+++ b/drivers/net/mlx5/mlx5.h
@@ -710,7 +710,6 @@ void mlx5_set_min_inline(struct mlx5_dev_spawn_data *spawn,
 void mlx5_set_metadata_mask(struct rte_eth_dev *dev);
 int mlx5_dev_check_sibling_config(struct mlx5_priv *priv,
 				  struct mlx5_dev_config *config);
-int mlx5_init_once(void);
 int mlx5_dev_configure(struct rte_eth_dev *dev);
 int mlx5_dev_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *info);
 int mlx5_fw_version_get(struct rte_eth_dev *dev, char *fw_ver, size_t fw_size);
@@ -893,11 +892,13 @@ void mlx5_flow_rxq_dynf_metadata_set(struct rte_eth_dev *dev);
 int mlx5_flow_get_aged_flows(struct rte_eth_dev *dev, void **contexts,
 			uint32_t nb_contexts, struct rte_flow_error *error);
 
-/* mlx5_mp.c */
-int mlx5_mp_primary_handle(const struct rte_mp_msg *mp_msg, const void *peer);
-int mlx5_mp_secondary_handle(const struct rte_mp_msg *mp_msg, const void *peer);
-void mlx5_mp_req_start_rxtx(struct rte_eth_dev *dev);
-void mlx5_mp_req_stop_rxtx(struct rte_eth_dev *dev);
+/* mlx5_mp_os.c */
+int mlx5_mp_os_primary_handle(const struct rte_mp_msg *mp_msg,
+			      const void *peer);
+int mlx5_mp_os_secondary_handle(const struct rte_mp_msg *mp_msg,
+				const void *peer);
+void mlx5_mp_os_req_start_rxtx(struct rte_eth_dev *dev);
+void mlx5_mp_os_req_stop_rxtx(struct rte_eth_dev *dev);
 
 /* mlx5_socket.c */
 
diff --git a/drivers/net/mlx5/mlx5_mp.c b/drivers/net/mlx5/mlx5_mp.c
deleted file mode 100644
index a2b5c40..0000000
--- a/drivers/net/mlx5/mlx5_mp.c
+++ /dev/null
@@ -1,211 +0,0 @@
-/* SPDX-License-Identifier: BSD-3-Clause
- * Copyright 2019 6WIND S.A.
- * Copyright 2019 Mellanox Technologies, Ltd
- */
-
-#include <stdio.h>
-#include <time.h>
-
-#include <rte_eal.h>
-#include <rte_ethdev_driver.h>
-#include <rte_string_fns.h>
-
-#include <mlx5_common_mp.h>
-#include <mlx5_common_mr.h>
-
-#include "mlx5.h"
-#include "mlx5_rxtx.h"
-#include "mlx5_utils.h"
-
-int
-mlx5_mp_primary_handle(const struct rte_mp_msg *mp_msg, const void *peer)
-{
-	struct rte_mp_msg mp_res;
-	struct mlx5_mp_param *res = (struct mlx5_mp_param *)mp_res.param;
-	const struct mlx5_mp_param *param =
-		(const struct mlx5_mp_param *)mp_msg->param;
-	struct rte_eth_dev *dev;
-	struct mlx5_priv *priv;
-	struct mr_cache_entry entry;
-	uint32_t lkey;
-	int ret;
-
-	MLX5_ASSERT(rte_eal_process_type() == RTE_PROC_PRIMARY);
-	if (!rte_eth_dev_is_valid_port(param->port_id)) {
-		rte_errno = ENODEV;
-		DRV_LOG(ERR, "port %u invalid port ID", param->port_id);
-		return -rte_errno;
-	}
-	dev = &rte_eth_devices[param->port_id];
-	priv = dev->data->dev_private;
-	switch (param->type) {
-	case MLX5_MP_REQ_CREATE_MR:
-		mp_init_msg(&priv->mp_id, &mp_res, param->type);
-		lkey = mlx5_mr_create_primary(priv->sh->pd,
-					      &priv->sh->share_cache,
-					      &entry, param->args.addr,
-					      priv->config.mr_ext_memseg_en);
-		if (lkey == UINT32_MAX)
-			res->result = -rte_errno;
-		ret = rte_mp_reply(&mp_res, peer);
-		break;
-	case MLX5_MP_REQ_VERBS_CMD_FD:
-		mp_init_msg(&priv->mp_id, &mp_res, param->type);
-		mp_res.num_fds = 1;
-		mp_res.fds[0] = ((struct ibv_context *)priv->sh->ctx)->cmd_fd;
-		res->result = 0;
-		ret = rte_mp_reply(&mp_res, peer);
-		break;
-	case MLX5_MP_REQ_QUEUE_STATE_MODIFY:
-		mp_init_msg(&priv->mp_id, &mp_res, param->type);
-		res->result = mlx5_queue_state_modify_primary
-					(dev, &param->args.state_modify);
-		ret = rte_mp_reply(&mp_res, peer);
-		break;
-	default:
-		rte_errno = EINVAL;
-		DRV_LOG(ERR, "port %u invalid mp request type",
-			dev->data->port_id);
-		return -rte_errno;
-	}
-	return ret;
-}
-
-/**
- * IPC message handler of a secondary process.
- *
- * @param[in] dev
- *   Pointer to Ethernet structure.
- * @param[in] peer
- *   Pointer to the peer socket path.
- *
- * @return
- *   0 on success, a negative errno value otherwise and rte_errno is set.
- */
-int
-mlx5_mp_secondary_handle(const struct rte_mp_msg *mp_msg, const void *peer)
-{
-	struct rte_mp_msg mp_res;
-	struct mlx5_mp_param *res = (struct mlx5_mp_param *)mp_res.param;
-	const struct mlx5_mp_param *param =
-		(const struct mlx5_mp_param *)mp_msg->param;
-	struct rte_eth_dev *dev;
-	struct mlx5_priv *priv;
-	int ret;
-
-	MLX5_ASSERT(rte_eal_process_type() == RTE_PROC_SECONDARY);
-	if (!rte_eth_dev_is_valid_port(param->port_id)) {
-		rte_errno = ENODEV;
-		DRV_LOG(ERR, "port %u invalid port ID", param->port_id);
-		return -rte_errno;
-	}
-	dev = &rte_eth_devices[param->port_id];
-	priv = dev->data->dev_private;
-	switch (param->type) {
-	case MLX5_MP_REQ_START_RXTX:
-		DRV_LOG(INFO, "port %u starting datapath", dev->data->port_id);
-		rte_mb();
-		dev->rx_pkt_burst = mlx5_select_rx_function(dev);
-		dev->tx_pkt_burst = mlx5_select_tx_function(dev);
-		mp_init_msg(&priv->mp_id, &mp_res, param->type);
-		res->result = 0;
-		ret = rte_mp_reply(&mp_res, peer);
-		break;
-	case MLX5_MP_REQ_STOP_RXTX:
-		DRV_LOG(INFO, "port %u stopping datapath", dev->data->port_id);
-		dev->rx_pkt_burst = removed_rx_burst;
-		dev->tx_pkt_burst = removed_tx_burst;
-		rte_mb();
-		mp_init_msg(&priv->mp_id, &mp_res, param->type);
-		res->result = 0;
-		ret = rte_mp_reply(&mp_res, peer);
-		break;
-	default:
-		rte_errno = EINVAL;
-		DRV_LOG(ERR, "port %u invalid mp request type",
-			dev->data->port_id);
-		return -rte_errno;
-	}
-	return ret;
-}
-
-/**
- * Broadcast request of stopping/starting data-path to secondary processes.
- *
- * @param[in] dev
- *   Pointer to Ethernet structure.
- * @param[in] type
- *   Request type.
- */
-static void
-mp_req_on_rxtx(struct rte_eth_dev *dev, enum mlx5_mp_req_type type)
-{
-	struct rte_mp_msg mp_req;
-	struct rte_mp_msg *mp_res;
-	struct rte_mp_reply mp_rep;
-	struct mlx5_mp_param *res;
-	struct timespec ts = {.tv_sec = MLX5_MP_REQ_TIMEOUT_SEC, .tv_nsec = 0};
-	struct mlx5_priv *priv = dev->data->dev_private;
-	int ret;
-	int i;
-
-	MLX5_ASSERT(rte_eal_process_type() == RTE_PROC_PRIMARY);
-	if (!mlx5_shared_data->secondary_cnt)
-		return;
-	if (type != MLX5_MP_REQ_START_RXTX && type != MLX5_MP_REQ_STOP_RXTX) {
-		DRV_LOG(ERR, "port %u unknown request (req_type %d)",
-			dev->data->port_id, type);
-		return;
-	}
-	mp_init_msg(&priv->mp_id, &mp_req, type);
-	ret = rte_mp_request_sync(&mp_req, &mp_rep, &ts);
-	if (ret) {
-		if (rte_errno != ENOTSUP)
-			DRV_LOG(ERR, "port %u failed to request stop/start Rx/Tx (%d)",
-				dev->data->port_id, type);
-		goto exit;
-	}
-	if (mp_rep.nb_sent != mp_rep.nb_received) {
-		DRV_LOG(ERR,
-			"port %u not all secondaries responded (req_type %d)",
-			dev->data->port_id, type);
-		goto exit;
-	}
-	for (i = 0; i < mp_rep.nb_received; i++) {
-		mp_res = &mp_rep.msgs[i];
-		res = (struct mlx5_mp_param *)mp_res->param;
-		if (res->result) {
-			DRV_LOG(ERR, "port %u request failed on secondary #%d",
-				dev->data->port_id, i);
-			goto exit;
-		}
-	}
-exit:
-	free(mp_rep.msgs);
-}
-
-/**
- * Broadcast request of starting data-path to secondary processes. The request
- * is synchronous.
- *
- * @param[in] dev
- *   Pointer to Ethernet structure.
- */
-void
-mlx5_mp_req_start_rxtx(struct rte_eth_dev *dev)
-{
-	mp_req_on_rxtx(dev, MLX5_MP_REQ_START_RXTX);
-}
-
-/**
- * Broadcast request of stopping data-path to secondary processes. The request
- * is synchronous.
- *
- * @param[in] dev
- *   Pointer to Ethernet structure.
- */
-void
-mlx5_mp_req_stop_rxtx(struct rte_eth_dev *dev)
-{
-	mp_req_on_rxtx(dev, MLX5_MP_REQ_STOP_RXTX);
-}
diff --git a/drivers/net/mlx5/mlx5_trigger.c b/drivers/net/mlx5/mlx5_trigger.c
index ef74609..360fd6f 100644
--- a/drivers/net/mlx5/mlx5_trigger.c
+++ b/drivers/net/mlx5/mlx5_trigger.c
@@ -340,7 +340,7 @@ mlx5_dev_start(struct rte_eth_dev *dev)
 	dev->tx_pkt_burst = mlx5_select_tx_function(dev);
 	dev->rx_pkt_burst = mlx5_select_rx_function(dev);
 	/* Enable datapath on secondary process. */
-	mlx5_mp_req_start_rxtx(dev);
+	mlx5_mp_os_req_start_rxtx(dev);
 	if (priv->sh->intr_handle.fd >= 0) {
 		priv->sh->port[priv->dev_port - 1].ih_port_id =
 					(uint32_t)dev->data->port_id;
@@ -385,7 +385,7 @@ mlx5_dev_stop(struct rte_eth_dev *dev)
 	dev->tx_pkt_burst = removed_tx_burst;
 	rte_wmb();
 	/* Disable datapath on secondary process. */
-	mlx5_mp_req_stop_rxtx(dev);
+	mlx5_mp_os_req_stop_rxtx(dev);
 	usleep(1000 * priv->rxqs_n);
 	DRV_LOG(DEBUG, "port %u stopping device", dev->data->port_id);
 	mlx5_flow_stop_default(dev);
-- 
2.8.4


^ permalink raw reply	[flat|nested] 28+ messages in thread

* [dpdk-dev] [PATCH v1 8/8] mlx5: remove inclusion of verbs header files
  2020-07-14 14:20 [dpdk-dev] [PATCH v1 0/8] mlx5 PMD multi OS support - part #3 Ophir Munk
                   ` (6 preceding siblings ...)
  2020-07-14 14:21 ` [dpdk-dev] [PATCH v1 7/8] net/mlx5: refactor multi process communication Ophir Munk
@ 2020-07-14 14:21 ` Ophir Munk
  2020-07-19  7:11   ` [dpdk-dev] [PATCH v2 0/8] mlx5 PMD multi OS support - part #3 Ophir Munk
  7 siblings, 1 reply; 28+ messages in thread
From: Ophir Munk @ 2020-07-14 14:21 UTC (permalink / raw)
  To: dev; +Cc: Raslan Darawsheh, Ophir Munk, Matan Azrad

Several source files include verbs header files as in (1). These source
files will not compile under non-Linux operating systems. This commit
removes this inclusion in two cases:

Case 1: There is no usage of ibv_* or mlx5dv_* symbols in the source
file so the inclusion in (1) can be safely removed.

Case 2: verbs symbols are used. Please note the inclusion in (1) already
appears in file linux/mlx5_glue.h (which represents the interface
to the rdma-core library). Therefore, replace (1) in the source file
with (2).  Under non-Linux operating systems - file mlx5_glue.h will not
include (1).

(1)
 #include <infiniband/verbs.h>
 #include <infiniband/mlx5dv.h>

(2)
 #include <mlx5_glue.h>

Signed-off-by: Ophir Munk <ophirmu@mellanox.com>
Acked-by: Matan Azrad <matan@mellanox.com>
---
 drivers/common/mlx5/linux/mlx5_common_os.h    |  7 +------
 drivers/common/mlx5/linux/mlx5_common_verbs.c | 15 ---------------
 drivers/common/mlx5/mlx5_common_mp.h          | 11 +----------
 drivers/common/mlx5/mlx5_common_mr.h          | 11 +----------
 drivers/common/mlx5/mlx5_prm.h                | 11 +----------
 drivers/net/mlx5/linux/mlx5_os.c              | 10 ----------
 drivers/net/mlx5/linux/mlx5_verbs.c           | 14 --------------
 drivers/net/mlx5/mlx5.c                       | 10 ----------
 drivers/net/mlx5/mlx5.h                       | 10 ----------
 drivers/net/mlx5/mlx5_flow.c                  | 11 +----------
 drivers/net/mlx5/mlx5_flow.h                  | 11 +----------
 drivers/net/mlx5/mlx5_flow_dv.c               | 11 +----------
 drivers/net/mlx5/mlx5_flow_verbs.c            | 10 ----------
 drivers/net/mlx5/mlx5_mac.c                   | 10 ----------
 drivers/net/mlx5/mlx5_mr.c                    |  9 ---------
 drivers/net/mlx5/mlx5_mr.h                    | 11 -----------
 drivers/net/mlx5/mlx5_rss.c                   | 10 ----------
 drivers/net/mlx5/mlx5_rxmode.c                | 11 +----------
 drivers/net/mlx5/mlx5_rxq.c                   | 11 -----------
 drivers/net/mlx5/mlx5_rxtx.c                  | 12 +-----------
 drivers/net/mlx5/mlx5_rxtx.h                  | 11 -----------
 drivers/net/mlx5/mlx5_rxtx_vec.c              | 12 +-----------
 drivers/net/mlx5/mlx5_txq.c                   | 11 -----------
 drivers/net/mlx5/mlx5_vlan.c                  | 17 -----------------
 24 files changed, 10 insertions(+), 257 deletions(-)

diff --git a/drivers/common/mlx5/linux/mlx5_common_os.h b/drivers/common/mlx5/linux/mlx5_common_os.h
index 9a6872c..55c0902 100644
--- a/drivers/common/mlx5/linux/mlx5_common_os.h
+++ b/drivers/common/mlx5/linux/mlx5_common_os.h
@@ -15,12 +15,7 @@
 #include <rte_devargs.h>
 
 #include "mlx5_autoconf.h"
-#ifdef HAVE_INFINIBAND_VERBS_H
-#include <infiniband/verbs.h>
-#endif
-#ifdef HAVE_INFINIBAND_MLX5DV_H
-#include <infiniband/mlx5dv.h>
-#endif
+#include "mlx5_glue.h"
 
 /**
  * Get device name. Given an ibv_device pointer - return a
diff --git a/drivers/common/mlx5/linux/mlx5_common_verbs.c b/drivers/common/mlx5/linux/mlx5_common_verbs.c
index a2fc7a3..339535d 100644
--- a/drivers/common/mlx5/linux/mlx5_common_verbs.c
+++ b/drivers/common/mlx5/linux/mlx5_common_verbs.c
@@ -10,22 +10,7 @@
 #include <sys/mman.h>
 #include <inttypes.h>
 
-/* Verbs header. */
-/* ISO C doesn't support unnamed structs/unions, disabling -pedantic. */
 #include "mlx5_autoconf.h"
-#ifdef PEDANTIC
-#pragma GCC diagnostic ignored "-Wpedantic"
-#endif
-#ifdef HAVE_INFINIBAND_VERBS_H
-#include <infiniband/verbs.h>
-#endif
-#ifdef HAVE_INFINIBAND_MLX5DV_H
-#include <infiniband/mlx5dv.h>
-#endif
-#ifdef PEDANTIC
-#pragma GCC diagnostic error "-Wpedantic"
-#endif
-
 #include <mlx5_glue.h>
 #include <mlx5_common.h>
 #include <mlx5_common_mr.h>
diff --git a/drivers/common/mlx5/mlx5_common_mp.h b/drivers/common/mlx5/mlx5_common_mp.h
index 05466fd..64260c0 100644
--- a/drivers/common/mlx5/mlx5_common_mp.h
+++ b/drivers/common/mlx5/mlx5_common_mp.h
@@ -6,16 +6,7 @@
 #ifndef RTE_PMD_MLX5_COMMON_MP_H_
 #define RTE_PMD_MLX5_COMMON_MP_H_
 
-/* Verbs header. */
-/* ISO C doesn't support unnamed structs/unions, disabling -pedantic. */
-#ifdef PEDANTIC
-#pragma GCC diagnostic ignored "-Wpedantic"
-#endif
-#include <infiniband/verbs.h>
-#ifdef PEDANTIC
-#pragma GCC diagnostic error "-Wpedantic"
-#endif
-
+#include <mlx5_glue.h>
 #include <rte_eal.h>
 #include <rte_string_fns.h>
 
diff --git a/drivers/common/mlx5/mlx5_common_mr.h b/drivers/common/mlx5/mlx5_common_mr.h
index b23ee66..a2c426d 100644
--- a/drivers/common/mlx5/mlx5_common_mr.h
+++ b/drivers/common/mlx5/mlx5_common_mr.h
@@ -10,21 +10,12 @@
 #include <stdint.h>
 #include <sys/queue.h>
 
-/* Verbs header. */
-/* ISO C doesn't support unnamed structs/unions, disabling -pedantic. */
-#ifdef PEDANTIC
-#pragma GCC diagnostic ignored "-Wpedantic"
-#endif
-#include <infiniband/verbs.h>
-#include <infiniband/mlx5dv.h>
-#ifdef PEDANTIC
-#pragma GCC diagnostic error "-Wpedantic"
-#endif
 
 #include <rte_rwlock.h>
 #include <rte_bitmap.h>
 #include <rte_memory.h>
 
+#include "mlx5_glue.h"
 #include "mlx5_common_mp.h"
 
 /* Size of per-queue MR cache array for linear search. */
diff --git a/drivers/common/mlx5/mlx5_prm.h b/drivers/common/mlx5/mlx5_prm.h
index 1b7b4c7..9ae2386 100644
--- a/drivers/common/mlx5/mlx5_prm.h
+++ b/drivers/common/mlx5/mlx5_prm.h
@@ -6,21 +6,12 @@
 #ifndef RTE_PMD_MLX5_PRM_H_
 #define RTE_PMD_MLX5_PRM_H_
 
-/* Verbs header. */
-/* ISO C doesn't support unnamed structs/unions, disabling -pedantic. */
-#ifdef PEDANTIC
-#pragma GCC diagnostic ignored "-Wpedantic"
-#endif
-#include <infiniband/mlx5dv.h>
-#ifdef PEDANTIC
-#pragma GCC diagnostic error "-Wpedantic"
-#endif
-
 #include <unistd.h>
 
 #include <rte_vect.h>
 #include <rte_byteorder.h>
 
+#include <mlx5_glue.h>
 #include "mlx5_autoconf.h"
 
 /* RSS hash key size. */
diff --git a/drivers/net/mlx5/linux/mlx5_os.c b/drivers/net/mlx5/linux/mlx5_os.c
index 2385d69..37903ed 100644
--- a/drivers/net/mlx5/linux/mlx5_os.c
+++ b/drivers/net/mlx5/linux/mlx5_os.c
@@ -15,16 +15,6 @@
 #include <linux/ethtool.h>
 #include <fcntl.h>
 
-/* Verbs header. */
-/* ISO C doesn't support unnamed structs/unions, disabling -pedantic. */
-#ifdef PEDANTIC
-#pragma GCC diagnostic ignored "-Wpedantic"
-#endif
-#include <infiniband/verbs.h>
-#ifdef PEDANTIC
-#pragma GCC diagnostic error "-Wpedantic"
-#endif
-
 #include <rte_malloc.h>
 #include <rte_ethdev_driver.h>
 #include <rte_ethdev_pci.h>
diff --git a/drivers/net/mlx5/linux/mlx5_verbs.c b/drivers/net/mlx5/linux/mlx5_verbs.c
index 5ac6982..d41b0fe 100644
--- a/drivers/net/mlx5/linux/mlx5_verbs.c
+++ b/drivers/net/mlx5/linux/mlx5_verbs.c
@@ -9,21 +9,7 @@
 #include <unistd.h>
 #include <inttypes.h>
 
-/* Verbs header. */
-/* ISO C doesn't support unnamed structs/unions, disabling -pedantic. */
 #include "mlx5_autoconf.h"
-#ifdef PEDANTIC
-#pragma GCC diagnostic ignored "-Wpedantic"
-#endif
-#ifdef HAVE_INFINIBAND_VERBS_H
-#include <infiniband/verbs.h>
-#endif
-#ifdef HAVE_INFINIBAND_MLX5DV_H
-#include <infiniband/mlx5dv.h>
-#endif
-#ifdef PEDANTIC
-#pragma GCC diagnostic error "-Wpedantic"
-#endif
 
 #include <rte_mbuf.h>
 #include <rte_malloc.h>
diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c
index 10a0306..5dff36a 100644
--- a/drivers/net/mlx5/mlx5.c
+++ b/drivers/net/mlx5/mlx5.c
@@ -13,16 +13,6 @@
 #include <sys/mman.h>
 #include <linux/rtnetlink.h>
 
-/* Verbs header. */
-/* ISO C doesn't support unnamed structs/unions, disabling -pedantic. */
-#ifdef PEDANTIC
-#pragma GCC diagnostic ignored "-Wpedantic"
-#endif
-#include <infiniband/verbs.h>
-#ifdef PEDANTIC
-#pragma GCC diagnostic error "-Wpedantic"
-#endif
-
 #include <rte_malloc.h>
 #include <rte_ethdev_driver.h>
 #include <rte_ethdev_pci.h>
diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h
index fa223a1..d6372eb 100644
--- a/drivers/net/mlx5/mlx5.h
+++ b/drivers/net/mlx5/mlx5.h
@@ -14,16 +14,6 @@
 #include <netinet/in.h>
 #include <sys/queue.h>
 
-/* Verbs header. */
-/* ISO C doesn't support unnamed structs/unions, disabling -pedantic. */
-#ifdef PEDANTIC
-#pragma GCC diagnostic ignored "-Wpedantic"
-#endif
-#include <infiniband/verbs.h>
-#ifdef PEDANTIC
-#pragma GCC diagnostic error "-Wpedantic"
-#endif
-
 #include <rte_pci.h>
 #include <rte_ether.h>
 #include <rte_ethdev_driver.h>
diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c
index 5fdf6df..4b90269 100644
--- a/drivers/net/mlx5/mlx5_flow.c
+++ b/drivers/net/mlx5/mlx5_flow.c
@@ -10,16 +10,6 @@
 #include <string.h>
 #include <stdbool.h>
 
-/* Verbs header. */
-/* ISO C doesn't support unnamed structs/unions, disabling -pedantic. */
-#ifdef PEDANTIC
-#pragma GCC diagnostic ignored "-Wpedantic"
-#endif
-#include <infiniband/verbs.h>
-#ifdef PEDANTIC
-#pragma GCC diagnostic error "-Wpedantic"
-#endif
-
 #include <rte_common.h>
 #include <rte_ether.h>
 #include <rte_ethdev_driver.h>
@@ -29,6 +19,7 @@
 #include <rte_malloc.h>
 #include <rte_ip.h>
 
+#include <mlx5_glue.h>
 #include <mlx5_devx_cmds.h>
 #include <mlx5_prm.h>
 
diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h
index 616c14a..bc0066a 100644
--- a/drivers/net/mlx5/mlx5_flow.h
+++ b/drivers/net/mlx5/mlx5_flow.h
@@ -11,20 +11,11 @@
 #include <stdint.h>
 #include <string.h>
 
-/* Verbs header. */
-/* ISO C doesn't support unnamed structs/unions, disabling -pedantic. */
-#ifdef PEDANTIC
-#pragma GCC diagnostic ignored "-Wpedantic"
-#endif
-#include <infiniband/verbs.h>
-#ifdef PEDANTIC
-#pragma GCC diagnostic error "-Wpedantic"
-#endif
-
 #include <rte_atomic.h>
 #include <rte_alarm.h>
 #include <rte_mtr.h>
 
+#include <mlx5_glue.h>
 #include <mlx5_prm.h>
 
 #include "mlx5.h"
diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c
index 7ce30e0..8ec8755 100644
--- a/drivers/net/mlx5/mlx5_flow_dv.c
+++ b/drivers/net/mlx5/mlx5_flow_dv.c
@@ -8,16 +8,6 @@
 #include <string.h>
 #include <unistd.h>
 
-/* Verbs header. */
-/* ISO C doesn't support unnamed structs/unions, disabling -pedantic. */
-#ifdef PEDANTIC
-#pragma GCC diagnostic ignored "-Wpedantic"
-#endif
-#include <infiniband/verbs.h>
-#ifdef PEDANTIC
-#pragma GCC diagnostic error "-Wpedantic"
-#endif
-
 #include <rte_common.h>
 #include <rte_ether.h>
 #include <rte_ethdev_driver.h>
@@ -31,6 +21,7 @@
 #include <rte_gtp.h>
 #include <rte_eal_paging.h>
 
+#include <mlx5_glue.h>
 #include <mlx5_devx_cmds.h>
 #include <mlx5_prm.h>
 
diff --git a/drivers/net/mlx5/mlx5_flow_verbs.c b/drivers/net/mlx5/mlx5_flow_verbs.c
index 9b8ae5b..544b26d 100644
--- a/drivers/net/mlx5/mlx5_flow_verbs.c
+++ b/drivers/net/mlx5/mlx5_flow_verbs.c
@@ -8,16 +8,6 @@
 #include <stdint.h>
 #include <string.h>
 
-/* Verbs header. */
-/* ISO C doesn't support unnamed structs/unions, disabling -pedantic. */
-#ifdef PEDANTIC
-#pragma GCC diagnostic ignored "-Wpedantic"
-#endif
-#include <infiniband/verbs.h>
-#ifdef PEDANTIC
-#pragma GCC diagnostic error "-Wpedantic"
-#endif
-
 #include <rte_common.h>
 #include <rte_ether.h>
 #include <rte_ethdev_driver.h>
diff --git a/drivers/net/mlx5/mlx5_mac.c b/drivers/net/mlx5/mlx5_mac.c
index 2a88086..2d808d6 100644
--- a/drivers/net/mlx5/mlx5_mac.c
+++ b/drivers/net/mlx5/mlx5_mac.c
@@ -12,16 +12,6 @@
 #include <sys/ioctl.h>
 #include <arpa/inet.h>
 
-/* Verbs header. */
-/* ISO C doesn't support unnamed structs/unions, disabling -pedantic. */
-#ifdef PEDANTIC
-#pragma GCC diagnostic ignored "-Wpedantic"
-#endif
-#include <infiniband/verbs.h>
-#ifdef PEDANTIC
-#pragma GCC diagnostic error "-Wpedantic"
-#endif
-
 #include <rte_ether.h>
 #include <rte_ethdev_driver.h>
 #include <rte_common.h>
diff --git a/drivers/net/mlx5/mlx5_mr.c b/drivers/net/mlx5/mlx5_mr.c
index 3b781b6..dbcf0aa 100644
--- a/drivers/net/mlx5/mlx5_mr.c
+++ b/drivers/net/mlx5/mlx5_mr.c
@@ -3,21 +3,12 @@
  * Copyright 2016 Mellanox Technologies, Ltd
  */
 
-#ifdef PEDANTIC
-#pragma GCC diagnostic ignored "-Wpedantic"
-#endif
-#include <infiniband/verbs.h>
-#ifdef PEDANTIC
-#pragma GCC diagnostic error "-Wpedantic"
-#endif
-
 #include <rte_eal_memconfig.h>
 #include <rte_mempool.h>
 #include <rte_malloc.h>
 #include <rte_rwlock.h>
 #include <rte_bus_pci.h>
 
-#include <mlx5_glue.h>
 #include <mlx5_common_mp.h>
 #include <mlx5_common_mr.h>
 
diff --git a/drivers/net/mlx5/mlx5_mr.h b/drivers/net/mlx5/mlx5_mr.h
index 0c5877b..4a7fab6 100644
--- a/drivers/net/mlx5/mlx5_mr.h
+++ b/drivers/net/mlx5/mlx5_mr.h
@@ -10,17 +10,6 @@
 #include <stdint.h>
 #include <sys/queue.h>
 
-/* Verbs header. */
-/* ISO C doesn't support unnamed structs/unions, disabling -pedantic. */
-#ifdef PEDANTIC
-#pragma GCC diagnostic ignored "-Wpedantic"
-#endif
-#include <infiniband/verbs.h>
-#include <infiniband/mlx5dv.h>
-#ifdef PEDANTIC
-#pragma GCC diagnostic error "-Wpedantic"
-#endif
-
 #include <rte_ethdev.h>
 #include <rte_rwlock.h>
 #include <rte_bitmap.h>
diff --git a/drivers/net/mlx5/mlx5_rss.c b/drivers/net/mlx5/mlx5_rss.c
index 653b069..f11851f 100644
--- a/drivers/net/mlx5/mlx5_rss.c
+++ b/drivers/net/mlx5/mlx5_rss.c
@@ -8,16 +8,6 @@
 #include <errno.h>
 #include <string.h>
 
-/* Verbs header. */
-/* ISO C doesn't support unnamed structs/unions, disabling -pedantic. */
-#ifdef PEDANTIC
-#pragma GCC diagnostic ignored "-Wpedantic"
-#endif
-#include <infiniband/verbs.h>
-#ifdef PEDANTIC
-#pragma GCC diagnostic error "-Wpedantic"
-#endif
-
 #include <rte_malloc.h>
 #include <rte_ethdev_driver.h>
 
diff --git a/drivers/net/mlx5/mlx5_rxmode.c b/drivers/net/mlx5/mlx5_rxmode.c
index 80b1256..7613ff7 100644
--- a/drivers/net/mlx5/mlx5_rxmode.c
+++ b/drivers/net/mlx5/mlx5_rxmode.c
@@ -7,18 +7,9 @@
 #include <errno.h>
 #include <string.h>
 
-/* Verbs header. */
-/* ISO C doesn't support unnamed structs/unions, disabling -pedantic. */
-#ifdef PEDANTIC
-#pragma GCC diagnostic ignored "-Wpedantic"
-#endif
-#include <infiniband/verbs.h>
-#ifdef PEDANTIC
-#pragma GCC diagnostic error "-Wpedantic"
-#endif
-
 #include <rte_ethdev_driver.h>
 
+#include <mlx5_glue.h>
 #include "mlx5.h"
 #include "mlx5_rxtx.h"
 #include "mlx5_utils.h"
diff --git a/drivers/net/mlx5/mlx5_rxq.c b/drivers/net/mlx5/mlx5_rxq.c
index 637b131..2308ae8 100644
--- a/drivers/net/mlx5/mlx5_rxq.c
+++ b/drivers/net/mlx5/mlx5_rxq.c
@@ -10,17 +10,6 @@
 #include <fcntl.h>
 #include <sys/queue.h>
 
-/* Verbs header. */
-/* ISO C doesn't support unnamed structs/unions, disabling -pedantic. */
-#ifdef PEDANTIC
-#pragma GCC diagnostic ignored "-Wpedantic"
-#endif
-#include <infiniband/verbs.h>
-#include <infiniband/mlx5dv.h>
-#ifdef PEDANTIC
-#pragma GCC diagnostic error "-Wpedantic"
-#endif
-
 #include <rte_mbuf.h>
 #include <rte_malloc.h>
 #include <rte_ethdev_driver.h>
diff --git a/drivers/net/mlx5/mlx5_rxtx.c b/drivers/net/mlx5/mlx5_rxtx.c
index 894f441..86b0e8b 100644
--- a/drivers/net/mlx5/mlx5_rxtx.c
+++ b/drivers/net/mlx5/mlx5_rxtx.c
@@ -7,17 +7,6 @@
 #include <string.h>
 #include <stdlib.h>
 
-/* Verbs header. */
-/* ISO C doesn't support unnamed structs/unions, disabling -pedantic. */
-#ifdef PEDANTIC
-#pragma GCC diagnostic ignored "-Wpedantic"
-#endif
-#include <infiniband/verbs.h>
-#include <infiniband/mlx5dv.h>
-#ifdef PEDANTIC
-#pragma GCC diagnostic error "-Wpedantic"
-#endif
-
 #include <rte_mbuf.h>
 #include <rte_mempool.h>
 #include <rte_prefetch.h>
@@ -27,6 +16,7 @@
 #include <rte_cycles.h>
 #include <rte_flow.h>
 
+#include <mlx5_glue.h>
 #include <mlx5_devx_cmds.h>
 #include <mlx5_prm.h>
 #include <mlx5_common.h>
diff --git a/drivers/net/mlx5/mlx5_rxtx.h b/drivers/net/mlx5/mlx5_rxtx.h
index 26621ff..43a4406 100644
--- a/drivers/net/mlx5/mlx5_rxtx.h
+++ b/drivers/net/mlx5/mlx5_rxtx.h
@@ -10,17 +10,6 @@
 #include <stdint.h>
 #include <sys/queue.h>
 
-/* Verbs header. */
-/* ISO C doesn't support unnamed structs/unions, disabling -pedantic. */
-#ifdef PEDANTIC
-#pragma GCC diagnostic ignored "-Wpedantic"
-#endif
-#include <infiniband/verbs.h>
-#include <infiniband/mlx5dv.h>
-#ifdef PEDANTIC
-#pragma GCC diagnostic error "-Wpedantic"
-#endif
-
 #include <rte_mbuf.h>
 #include <rte_mempool.h>
 #include <rte_common.h>
diff --git a/drivers/net/mlx5/mlx5_rxtx_vec.c b/drivers/net/mlx5/mlx5_rxtx_vec.c
index 7fae201..711dcd3 100644
--- a/drivers/net/mlx5/mlx5_rxtx_vec.c
+++ b/drivers/net/mlx5/mlx5_rxtx_vec.c
@@ -7,21 +7,11 @@
 #include <string.h>
 #include <stdlib.h>
 
-/* Verbs header. */
-/* ISO C doesn't support unnamed structs/unions, disabling -pedantic. */
-#ifdef PEDANTIC
-#pragma GCC diagnostic ignored "-Wpedantic"
-#endif
-#include <infiniband/verbs.h>
-#include <infiniband/mlx5dv.h>
-#ifdef PEDANTIC
-#pragma GCC diagnostic error "-Wpedantic"
-#endif
-
 #include <rte_mbuf.h>
 #include <rte_mempool.h>
 #include <rte_prefetch.h>
 
+#include <mlx5_glue.h>
 #include <mlx5_prm.h>
 
 #include "mlx5_defs.h"
diff --git a/drivers/net/mlx5/mlx5_txq.c b/drivers/net/mlx5/mlx5_txq.c
index a9bf42d..e9f5a8c 100644
--- a/drivers/net/mlx5/mlx5_txq.c
+++ b/drivers/net/mlx5/mlx5_txq.c
@@ -10,17 +10,6 @@
 #include <unistd.h>
 #include <inttypes.h>
 
-/* Verbs header. */
-/* ISO C doesn't support unnamed structs/unions, disabling -pedantic. */
-#ifdef PEDANTIC
-#pragma GCC diagnostic ignored "-Wpedantic"
-#endif
-#include <infiniband/verbs.h>
-#include <infiniband/mlx5dv.h>
-#ifdef PEDANTIC
-#pragma GCC diagnostic error "-Wpedantic"
-#endif
-
 #include <rte_mbuf.h>
 #include <rte_malloc.h>
 #include <rte_ethdev_driver.h>
diff --git a/drivers/net/mlx5/mlx5_vlan.c b/drivers/net/mlx5/mlx5_vlan.c
index f65e416..6e1d71f 100644
--- a/drivers/net/mlx5/mlx5_vlan.c
+++ b/drivers/net/mlx5/mlx5_vlan.c
@@ -8,23 +8,6 @@
 #include <stdint.h>
 #include <unistd.h>
 
-
-/*
- * Not needed by this file; included to work around the lack of off_t
- * definition for mlx5dv.h with unpatched rdma-core versions.
- */
-#include <sys/types.h>
-
-/* Verbs headers do not support -pedantic. */
-#ifdef PEDANTIC
-#pragma GCC diagnostic ignored "-Wpedantic"
-#endif
-#include <infiniband/mlx5dv.h>
-#include <infiniband/verbs.h>
-#ifdef PEDANTIC
-#pragma GCC diagnostic error "-Wpedantic"
-#endif
-
 #include <rte_ethdev_driver.h>
 #include <rte_common.h>
 #include <rte_malloc.h>
-- 
2.8.4


^ permalink raw reply	[flat|nested] 28+ messages in thread

* [dpdk-dev] [PATCH v2 0/8] mlx5 PMD multi OS support - part #3
  2020-07-14 14:21 ` [dpdk-dev] [PATCH v1 8/8] mlx5: remove inclusion of verbs header files Ophir Munk
@ 2020-07-19  7:11   ` Ophir Munk
  2020-07-19  7:11     ` [dpdk-dev] [PATCH v2 1/8] net/mlx5: move flow prio discovery and adjust under Verbs Ophir Munk
                       ` (7 more replies)
  0 siblings, 8 replies; 28+ messages in thread
From: Ophir Munk @ 2020-07-19  7:11 UTC (permalink / raw)
  To: dev; +Cc: Raslan Darawsheh, Ophir Munk, Matan Azrad


This patch series is part of preparing mlx5 PMD to compile
and run under multiple OSs. Part #3

v1: Initial version
v2: Version rebased

Ophir Munk (8):
  net/mlx5: move flow prio discovery and adjust under Verbs
  net/mlx5: replace Linux specific calls with rte API
  net/mlx5: refactor Linux MAC operations
  linux/mlx5: add setters for promiscuous and all-multi
  net/mlx5: eliminate dependency on Linux in shared header
  net/mlx5: header file cleanup
  net/mlx5: refactor multi process communication
  mlx5: remove inclusion of Verbs header files

 drivers/common/mlx5/linux/mlx5_common_os.h    |   7 +-
 drivers/common/mlx5/linux/mlx5_common_verbs.c |  15 -
 drivers/common/mlx5/mlx5_common_mp.h          |  11 +-
 drivers/common/mlx5/mlx5_common_mr.h          |  11 +-
 drivers/common/mlx5/mlx5_devx_cmds.c          |   9 +-
 drivers/common/mlx5/mlx5_prm.h                |  15 +-
 drivers/net/mlx5/Makefile                     |   2 +-
 drivers/net/mlx5/linux/meson.build            |   1 +
 drivers/net/mlx5/linux/mlx5_ethdev_os.c       | 416 +++++++++++++++++++---
 drivers/net/mlx5/linux/mlx5_mp_os.c           | 212 +++++++++++
 drivers/net/mlx5/linux/mlx5_os.c              | 490 +++++++++++---------------
 drivers/net/mlx5/linux/mlx5_verbs.c           |  15 -
 drivers/net/mlx5/meson.build                  |   1 -
 drivers/net/mlx5/mlx5.c                       | 124 +------
 drivers/net/mlx5/mlx5.h                       |  66 ++--
 drivers/net/mlx5/mlx5_flow.c                  | 121 -------
 drivers/net/mlx5/mlx5_flow.h                  |  12 +-
 drivers/net/mlx5/mlx5_flow_dv.c               |  20 +-
 drivers/net/mlx5/mlx5_flow_verbs.c            | 122 ++++++-
 drivers/net/mlx5/mlx5_mac.c                   |  59 +---
 drivers/net/mlx5/mlx5_mp.c                    | 212 -----------
 drivers/net/mlx5/mlx5_mr.c                    |   9 -
 drivers/net/mlx5/mlx5_mr.h                    |  11 -
 drivers/net/mlx5/mlx5_rss.c                   |  10 -
 drivers/net/mlx5/mlx5_rxmode.c                |  23 +-
 drivers/net/mlx5/mlx5_rxq.c                   |  20 +-
 drivers/net/mlx5/mlx5_rxtx.c                  |  12 +-
 drivers/net/mlx5/mlx5_rxtx.h                  |  11 -
 drivers/net/mlx5/mlx5_rxtx_vec.c              |  12 +-
 drivers/net/mlx5/mlx5_trigger.c               |   4 +-
 drivers/net/mlx5/mlx5_txpp.c                  |  15 +-
 drivers/net/mlx5/mlx5_txq.c                   |  56 +--
 drivers/net/mlx5/mlx5_vlan.c                  |  17 -
 33 files changed, 1029 insertions(+), 1112 deletions(-)
 create mode 100644 drivers/net/mlx5/linux/mlx5_mp_os.c
 delete mode 100644 drivers/net/mlx5/mlx5_mp.c

-- 
2.8.4


^ permalink raw reply	[flat|nested] 28+ messages in thread

* [dpdk-dev] [PATCH v2 1/8] net/mlx5: move flow prio discovery and adjust under Verbs
  2020-07-19  7:11   ` [dpdk-dev] [PATCH v2 0/8] mlx5 PMD multi OS support - part #3 Ophir Munk
@ 2020-07-19  7:11     ` Ophir Munk
  2020-07-19  7:11     ` [dpdk-dev] [PATCH v2 2/8] net/mlx5: replace Linux specific calls with rte API Ophir Munk
                       ` (6 subsequent siblings)
  7 siblings, 0 replies; 28+ messages in thread
From: Ophir Munk @ 2020-07-19  7:11 UTC (permalink / raw)
  To: dev; +Cc: Raslan Darawsheh, Ophir Munk, Matan Azrad

Function calls mlx5_flow_adjust_priority() and
mlx5_flow_discover_priorities() are Verbs based. Move them from file
mlx5_flow.c to file mlx5_flow_verbs.c

Signed-off-by: Ophir Munk <ophirmu@mellanox.com>
Acked-by: Matan Azrad <matan@mellanox.com>
---
 drivers/net/mlx5/mlx5.h            |   1 -
 drivers/net/mlx5/mlx5_flow.c       | 112 -------------------------------------
 drivers/net/mlx5/mlx5_flow.h       |   1 +
 drivers/net/mlx5/mlx5_flow_verbs.c | 112 +++++++++++++++++++++++++++++++++++++
 4 files changed, 113 insertions(+), 113 deletions(-)

diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h
index 78ebd19..9179ad3 100644
--- a/drivers/net/mlx5/mlx5.h
+++ b/drivers/net/mlx5/mlx5.h
@@ -925,7 +925,6 @@ int mlx5_traffic_restart(struct rte_eth_dev *dev);
 
 int mlx5_flow_discover_mreg_c(struct rte_eth_dev *eth_dev);
 bool mlx5_flow_ext_mreg_supported(struct rte_eth_dev *dev);
-int mlx5_flow_discover_priorities(struct rte_eth_dev *dev);
 void mlx5_flow_print(struct rte_flow *flow);
 int mlx5_flow_validate(struct rte_eth_dev *dev,
 		       const struct rte_flow_attr *attr,
diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c
index d171ab0..52047db 100644
--- a/drivers/net/mlx5/mlx5_flow.c
+++ b/drivers/net/mlx5/mlx5_flow.c
@@ -29,7 +29,6 @@
 #include <rte_malloc.h>
 #include <rte_ip.h>
 
-#include <mlx5_glue.h>
 #include <mlx5_devx_cmds.h>
 #include <mlx5_prm.h>
 #include <mlx5_malloc.h>
@@ -267,17 +266,6 @@ struct mlx5_fdir {
 	struct rte_flow_action_queue queue;
 };
 
-/* Map of Verbs to Flow priority with 8 Verbs priorities. */
-static const uint32_t priority_map_3[][MLX5_PRIORITY_MAP_MAX] = {
-	{ 0, 1, 2 }, { 2, 3, 4 }, { 5, 6, 7 },
-};
-
-/* Map of Verbs to Flow priority with 16 Verbs priorities. */
-static const uint32_t priority_map_5[][MLX5_PRIORITY_MAP_MAX] = {
-	{ 0, 1, 2 }, { 3, 4, 5 }, { 6, 7, 8 },
-	{ 9, 10, 11 }, { 12, 13, 14 },
-};
-
 /* Tunnel information. */
 struct mlx5_flow_tunnel_info {
 	uint64_t tunnel; /**< Tunnel bit (see MLX5_FLOW_*). */
@@ -484,106 +472,6 @@ mlx5_flow_ext_mreg_supported(struct rte_eth_dev *dev)
 }
 
 /**
- * Discover the maximum number of priority available.
- *
- * @param[in] dev
- *   Pointer to the Ethernet device structure.
- *
- * @return
- *   number of supported flow priority on success, a negative errno
- *   value otherwise and rte_errno is set.
- */
-int
-mlx5_flow_discover_priorities(struct rte_eth_dev *dev)
-{
-	struct mlx5_priv *priv = dev->data->dev_private;
-	struct {
-		struct ibv_flow_attr attr;
-		struct ibv_flow_spec_eth eth;
-		struct ibv_flow_spec_action_drop drop;
-	} flow_attr = {
-		.attr = {
-			.num_of_specs = 2,
-			.port = (uint8_t)priv->dev_port,
-		},
-		.eth = {
-			.type = IBV_FLOW_SPEC_ETH,
-			.size = sizeof(struct ibv_flow_spec_eth),
-		},
-		.drop = {
-			.size = sizeof(struct ibv_flow_spec_action_drop),
-			.type = IBV_FLOW_SPEC_ACTION_DROP,
-		},
-	};
-	struct ibv_flow *flow;
-	struct mlx5_hrxq *drop = mlx5_hrxq_drop_new(dev);
-	uint16_t vprio[] = { 8, 16 };
-	int i;
-	int priority = 0;
-
-	if (!drop) {
-		rte_errno = ENOTSUP;
-		return -rte_errno;
-	}
-	for (i = 0; i != RTE_DIM(vprio); i++) {
-		flow_attr.attr.priority = vprio[i] - 1;
-		flow = mlx5_glue->create_flow(drop->qp, &flow_attr.attr);
-		if (!flow)
-			break;
-		claim_zero(mlx5_glue->destroy_flow(flow));
-		priority = vprio[i];
-	}
-	mlx5_hrxq_drop_release(dev);
-	switch (priority) {
-	case 8:
-		priority = RTE_DIM(priority_map_3);
-		break;
-	case 16:
-		priority = RTE_DIM(priority_map_5);
-		break;
-	default:
-		rte_errno = ENOTSUP;
-		DRV_LOG(ERR,
-			"port %u verbs maximum priority: %d expected 8/16",
-			dev->data->port_id, priority);
-		return -rte_errno;
-	}
-	DRV_LOG(INFO, "port %u flow maximum priority: %d",
-		dev->data->port_id, priority);
-	return priority;
-}
-
-/**
- * Adjust flow priority based on the highest layer and the request priority.
- *
- * @param[in] dev
- *   Pointer to the Ethernet device structure.
- * @param[in] priority
- *   The rule base priority.
- * @param[in] subpriority
- *   The priority based on the items.
- *
- * @return
- *   The new priority.
- */
-uint32_t mlx5_flow_adjust_priority(struct rte_eth_dev *dev, int32_t priority,
-				   uint32_t subpriority)
-{
-	uint32_t res = 0;
-	struct mlx5_priv *priv = dev->data->dev_private;
-
-	switch (priv->config.flow_prio) {
-	case RTE_DIM(priority_map_3):
-		res = priority_map_3[priority][subpriority];
-		break;
-	case RTE_DIM(priority_map_5):
-		res = priority_map_5[priority][subpriority];
-		break;
-	}
-	return  res;
-}
-
-/**
  * Verify the @p item specifications (spec, last, mask) are compatible with the
  * NIC capabilities.
  *
diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h
index 6dfeef3..314b5e3 100644
--- a/drivers/net/mlx5/mlx5_flow.h
+++ b/drivers/net/mlx5/mlx5_flow.h
@@ -922,6 +922,7 @@ int mlx5_flow_group_to_table(const struct rte_flow_attr *attributes,
 uint64_t mlx5_flow_hashfields_adjust(struct mlx5_flow_rss_desc *rss_desc,
 				     int tunnel, uint64_t layer_types,
 				     uint64_t hash_fields);
+int mlx5_flow_discover_priorities(struct rte_eth_dev *dev);
 uint32_t mlx5_flow_adjust_priority(struct rte_eth_dev *dev, int32_t priority,
 				   uint32_t subpriority);
 int mlx5_flow_get_reg_id(struct rte_eth_dev *dev,
diff --git a/drivers/net/mlx5/mlx5_flow_verbs.c b/drivers/net/mlx5/mlx5_flow_verbs.c
index 72106b4..5d11ba7 100644
--- a/drivers/net/mlx5/mlx5_flow_verbs.c
+++ b/drivers/net/mlx5/mlx5_flow_verbs.c
@@ -38,6 +38,118 @@
 #define VERBS_SPEC_INNER(item_flags) \
 	(!!((item_flags) & MLX5_FLOW_LAYER_TUNNEL) ? IBV_FLOW_SPEC_INNER : 0)
 
+/* Map of Verbs to Flow priority with 8 Verbs priorities. */
+static const uint32_t priority_map_3[][MLX5_PRIORITY_MAP_MAX] = {
+	{ 0, 1, 2 }, { 2, 3, 4 }, { 5, 6, 7 },
+};
+
+/* Map of Verbs to Flow priority with 16 Verbs priorities. */
+static const uint32_t priority_map_5[][MLX5_PRIORITY_MAP_MAX] = {
+	{ 0, 1, 2 }, { 3, 4, 5 }, { 6, 7, 8 },
+	{ 9, 10, 11 }, { 12, 13, 14 },
+};
+
+/**
+ * Discover the maximum number of priority available.
+ *
+ * @param[in] dev
+ *   Pointer to the Ethernet device structure.
+ *
+ * @return
+ *   number of supported flow priority on success, a negative errno
+ *   value otherwise and rte_errno is set.
+ */
+int
+mlx5_flow_discover_priorities(struct rte_eth_dev *dev)
+{
+	struct mlx5_priv *priv = dev->data->dev_private;
+	struct {
+		struct ibv_flow_attr attr;
+		struct ibv_flow_spec_eth eth;
+		struct ibv_flow_spec_action_drop drop;
+	} flow_attr = {
+		.attr = {
+			.num_of_specs = 2,
+			.port = (uint8_t)priv->dev_port,
+		},
+		.eth = {
+			.type = IBV_FLOW_SPEC_ETH,
+			.size = sizeof(struct ibv_flow_spec_eth),
+		},
+		.drop = {
+			.size = sizeof(struct ibv_flow_spec_action_drop),
+			.type = IBV_FLOW_SPEC_ACTION_DROP,
+		},
+	};
+	struct ibv_flow *flow;
+	struct mlx5_hrxq *drop = mlx5_hrxq_drop_new(dev);
+	uint16_t vprio[] = { 8, 16 };
+	int i;
+	int priority = 0;
+
+	if (!drop) {
+		rte_errno = ENOTSUP;
+		return -rte_errno;
+	}
+	for (i = 0; i != RTE_DIM(vprio); i++) {
+		flow_attr.attr.priority = vprio[i] - 1;
+		flow = mlx5_glue->create_flow(drop->qp, &flow_attr.attr);
+		if (!flow)
+			break;
+		claim_zero(mlx5_glue->destroy_flow(flow));
+		priority = vprio[i];
+	}
+	mlx5_hrxq_drop_release(dev);
+	switch (priority) {
+	case 8:
+		priority = RTE_DIM(priority_map_3);
+		break;
+	case 16:
+		priority = RTE_DIM(priority_map_5);
+		break;
+	default:
+		rte_errno = ENOTSUP;
+		DRV_LOG(ERR,
+			"port %u verbs maximum priority: %d expected 8/16",
+			dev->data->port_id, priority);
+		return -rte_errno;
+	}
+	DRV_LOG(INFO, "port %u flow maximum priority: %d",
+		dev->data->port_id, priority);
+	return priority;
+}
+
+/**
+ * Adjust flow priority based on the highest layer and the request priority.
+ *
+ * @param[in] dev
+ *   Pointer to the Ethernet device structure.
+ * @param[in] priority
+ *   The rule base priority.
+ * @param[in] subpriority
+ *   The priority based on the items.
+ *
+ * @return
+ *   The new priority.
+ */
+uint32_t
+mlx5_flow_adjust_priority(struct rte_eth_dev *dev, int32_t priority,
+				   uint32_t subpriority)
+{
+	uint32_t res = 0;
+	struct mlx5_priv *priv = dev->data->dev_private;
+
+	switch (priv->config.flow_prio) {
+	case RTE_DIM(priority_map_3):
+		res = priority_map_3[priority][subpriority];
+		break;
+	case RTE_DIM(priority_map_5):
+		res = priority_map_5[priority][subpriority];
+		break;
+	}
+	return  res;
+}
+
 /**
  * Get Verbs flow counter by index.
  *
-- 
2.8.4


^ permalink raw reply	[flat|nested] 28+ messages in thread

* [dpdk-dev] [PATCH v2 2/8] net/mlx5: replace Linux specific calls with rte API
  2020-07-19  7:11   ` [dpdk-dev] [PATCH v2 0/8] mlx5 PMD multi OS support - part #3 Ophir Munk
  2020-07-19  7:11     ` [dpdk-dev] [PATCH v2 1/8] net/mlx5: move flow prio discovery and adjust under Verbs Ophir Munk
@ 2020-07-19  7:11     ` Ophir Munk
  2020-07-19  7:11     ` [dpdk-dev] [PATCH v2 3/8] net/mlx5: refactor Linux MAC operations Ophir Munk
                       ` (5 subsequent siblings)
  7 siblings, 0 replies; 28+ messages in thread
From: Ophir Munk @ 2020-07-19  7:11 UTC (permalink / raw)
  To: dev; +Cc: Raslan Darawsheh, Ophir Munk, Matan Azrad

The following Linux calls are replaced by their matching rte APIs.

mmap ==> rte_mem_map()
munmap == >rte_mem_unmap()
sysconf(_SC_PAGESIZE) ==> rte_mem_page_size()

Signed-off-by: Ophir Munk <ophirmu@mellanox.com>
Acked-by: Matan Azrad <matan@mellanox.com>
---
 drivers/common/mlx5/mlx5_devx_cmds.c |  9 +++++++-
 drivers/common/mlx5/mlx5_prm.h       |  4 ++--
 drivers/net/mlx5/linux/mlx5_os.c     | 11 ++++++---
 drivers/net/mlx5/linux/mlx5_verbs.c  |  1 -
 drivers/net/mlx5/mlx5_flow_dv.c      |  9 +++++++-
 drivers/net/mlx5/mlx5_rxq.c          |  9 +++++++-
 drivers/net/mlx5/mlx5_txpp.c         | 15 ++++++++++--
 drivers/net/mlx5/mlx5_txq.c          | 45 ++++++++++++++++++++++++++++--------
 8 files changed, 82 insertions(+), 21 deletions(-)

diff --git a/drivers/common/mlx5/mlx5_devx_cmds.c b/drivers/common/mlx5/mlx5_devx_cmds.c
index e5acfa3..d97e700 100644
--- a/drivers/common/mlx5/mlx5_devx_cmds.c
+++ b/drivers/common/mlx5/mlx5_devx_cmds.c
@@ -5,6 +5,7 @@
 
 #include <rte_errno.h>
 #include <rte_malloc.h>
+#include <rte_eal_paging.h>
 
 #include "mlx5_prm.h"
 #include "mlx5_devx_cmds.h"
@@ -222,7 +223,13 @@ mlx5_devx_cmd_mkey_create(void *ctx,
 		return NULL;
 	}
 	memset(in, 0, in_size_dw * 4);
-	pgsize = sysconf(_SC_PAGESIZE);
+	pgsize = rte_mem_page_size();
+	if (pgsize == (size_t)-1) {
+		mlx5_free(mkey);
+		DRV_LOG(ERR, "Failed to get page size");
+		rte_errno = ENOMEM;
+		return NULL;
+	}
 	MLX5_SET(create_mkey_in, in, opcode, MLX5_CMD_OP_CREATE_MKEY);
 	mkc = MLX5_ADDR_OF(create_mkey_in, in, memory_key_mkey_entry);
 	if (klm_num > 0) {
diff --git a/drivers/common/mlx5/mlx5_prm.h b/drivers/common/mlx5/mlx5_prm.h
index aba0368..83fe3af 100644
--- a/drivers/common/mlx5/mlx5_prm.h
+++ b/drivers/common/mlx5/mlx5_prm.h
@@ -267,10 +267,10 @@
 #define MLX5_MAX_LOG_RQ_SEGS 5u
 
 /* The alignment needed for WQ buffer. */
-#define MLX5_WQE_BUF_ALIGNMENT sysconf(_SC_PAGESIZE)
+#define MLX5_WQE_BUF_ALIGNMENT rte_mem_page_size()
 
 /* The alignment needed for CQ buffer. */
-#define MLX5_CQE_BUF_ALIGNMENT sysconf(_SC_PAGESIZE)
+#define MLX5_CQE_BUF_ALIGNMENT rte_mem_page_size()
 
 /* Completion mode. */
 enum mlx5_completion_mode {
diff --git a/drivers/net/mlx5/linux/mlx5_os.c b/drivers/net/mlx5/linux/mlx5_os.c
index bf1c750..292062e 100644
--- a/drivers/net/mlx5/linux/mlx5_os.c
+++ b/drivers/net/mlx5/linux/mlx5_os.c
@@ -10,7 +10,6 @@
 #include <stdlib.h>
 #include <errno.h>
 #include <net/if.h>
-#include <sys/mman.h>
 #include <linux/rtnetlink.h>
 #include <linux/sockios.h>
 #include <linux/ethtool.h>
@@ -37,6 +36,7 @@
 #include <rte_spinlock.h>
 #include <rte_string_fns.h>
 #include <rte_alarm.h>
+#include <rte_eal_paging.h>
 
 #include <mlx5_glue.h>
 #include <mlx5_devx_cmds.h>
@@ -134,7 +134,7 @@ mlx5_os_get_dev_attr(void *ctx, struct mlx5_dev_attr *device_attr)
  * Verbs callback to allocate a memory. This function should allocate the space
  * according to the size provided residing inside a huge page.
  * Please note that all allocation must respect the alignment from libmlx5
- * (i.e. currently sysconf(_SC_PAGESIZE)).
+ * (i.e. currently rte_mem_page_size()).
  *
  * @param[in] size
  *   The size in bytes of the memory to allocate.
@@ -149,8 +149,13 @@ mlx5_alloc_verbs_buf(size_t size, void *data)
 {
 	struct mlx5_priv *priv = data;
 	void *ret;
-	size_t alignment = sysconf(_SC_PAGESIZE);
 	unsigned int socket = SOCKET_ID_ANY;
+	size_t alignment = rte_mem_page_size();
+	if (alignment == (size_t)-1) {
+		DRV_LOG(ERR, "Failed to get mem page size");
+		rte_errno = ENOMEM;
+		return NULL;
+	}
 
 	if (priv->verbs_alloc_ctx.type == MLX5_VERBS_ALLOC_TYPE_TX_QUEUE) {
 		const struct mlx5_txq_ctrl *ctrl = priv->verbs_alloc_ctx.obj;
diff --git a/drivers/net/mlx5/linux/mlx5_verbs.c b/drivers/net/mlx5/linux/mlx5_verbs.c
index 6b59fa1..5ac6982 100644
--- a/drivers/net/mlx5/linux/mlx5_verbs.c
+++ b/drivers/net/mlx5/linux/mlx5_verbs.c
@@ -7,7 +7,6 @@
 #include <string.h>
 #include <stdint.h>
 #include <unistd.h>
-#include <sys/mman.h>
 #include <inttypes.h>
 
 /* Verbs header. */
diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c
index 0b36ec3..4121f9d 100644
--- a/drivers/net/mlx5/mlx5_flow_dv.c
+++ b/drivers/net/mlx5/mlx5_flow_dv.c
@@ -29,6 +29,7 @@
 #include <rte_gre.h>
 #include <rte_vxlan.h>
 #include <rte_gtp.h>
+#include <rte_eal_paging.h>
 
 #include <mlx5_devx_cmds.h>
 #include <mlx5_prm.h>
@@ -4177,7 +4178,13 @@ flow_dv_create_counter_stat_mem_mng(struct rte_eth_dev *dev, int raws_n)
 			MLX5_COUNTERS_PER_POOL +
 			sizeof(struct mlx5_counter_stats_raw)) * raws_n +
 			sizeof(struct mlx5_counter_stats_mem_mng);
-	uint8_t *mem = mlx5_malloc(MLX5_MEM_ZERO, size, sysconf(_SC_PAGESIZE),
+	size_t pgsize = rte_mem_page_size();
+	if (pgsize == (size_t)-1) {
+		DRV_LOG(ERR, "Failed to get mem page size");
+		rte_errno = ENOMEM;
+		return NULL;
+	}
+	uint8_t *mem = mlx5_malloc(MLX5_MEM_ZERO, size, pgsize,
 				  SOCKET_ID_ANY);
 	int i;
 
diff --git a/drivers/net/mlx5/mlx5_rxq.c b/drivers/net/mlx5/mlx5_rxq.c
index 67d996c..9e7df8e 100644
--- a/drivers/net/mlx5/mlx5_rxq.c
+++ b/drivers/net/mlx5/mlx5_rxq.c
@@ -28,6 +28,7 @@
 #include <rte_interrupts.h>
 #include <rte_debug.h>
 #include <rte_io.h>
+#include <rte_eal_paging.h>
 
 #include <mlx5_glue.h>
 #include <mlx5_devx_cmds.h>
@@ -1233,8 +1234,14 @@ mlx5_devx_rq_new(struct rte_eth_dev *dev, uint16_t idx, uint32_t cqn)
 	/* Calculate and allocate WQ memory space. */
 	wqe_size = 1 << log_wqe_size; /* round up power of two.*/
 	wq_size = wqe_n * wqe_size;
+	size_t alignment = MLX5_WQE_BUF_ALIGNMENT;
+	if (alignment == (size_t)-1) {
+		DRV_LOG(ERR, "Failed to get mem page size");
+		rte_errno = ENOMEM;
+		return NULL;
+	}
 	buf = mlx5_malloc(MLX5_MEM_RTE | MLX5_MEM_ZERO, wq_size,
-			  MLX5_WQE_BUF_ALIGNMENT, rxq_ctrl->socket);
+			  alignment, rxq_ctrl->socket);
 	if (!buf)
 		return NULL;
 	rxq_data->wqes = buf;
diff --git a/drivers/net/mlx5/mlx5_txpp.c b/drivers/net/mlx5/mlx5_txpp.c
index f840551..14d4a66 100644
--- a/drivers/net/mlx5/mlx5_txpp.c
+++ b/drivers/net/mlx5/mlx5_txpp.c
@@ -10,6 +10,7 @@
 #include <rte_alarm.h>
 #include <rte_malloc.h>
 #include <rte_cycles.h>
+#include <rte_eal_paging.h>
 
 #include <mlx5_malloc.h>
 
@@ -249,10 +250,15 @@ mlx5_txpp_create_rearm_queue(struct mlx5_dev_ctx_shared *sh)
 	struct mlx5_devx_modify_sq_attr msq_attr = { 0 };
 	struct mlx5_devx_cq_attr cq_attr = { 0 };
 	struct mlx5_txpp_wq *wq = &sh->txpp.rearm_queue;
-	size_t page_size = sysconf(_SC_PAGESIZE);
+	size_t page_size;
 	uint32_t umem_size, umem_dbrec;
 	int ret;
 
+	page_size = rte_mem_page_size();
+	if (page_size == (size_t)-1) {
+		DRV_LOG(ERR, "Failed to get mem page size");
+		return -ENOMEM;
+	}
 	/* Allocate memory buffer for CQEs and doorbell record. */
 	umem_size = sizeof(struct mlx5_cqe) * MLX5_TXPP_REARM_CQ_SIZE;
 	umem_dbrec = RTE_ALIGN(umem_size, MLX5_DBR_SIZE);
@@ -472,10 +478,15 @@ mlx5_txpp_create_clock_queue(struct mlx5_dev_ctx_shared *sh)
 	struct mlx5_devx_modify_sq_attr msq_attr = { 0 };
 	struct mlx5_devx_cq_attr cq_attr = { 0 };
 	struct mlx5_txpp_wq *wq = &sh->txpp.clock_queue;
-	size_t page_size = sysconf(_SC_PAGESIZE);
+	size_t page_size;
 	uint32_t umem_size, umem_dbrec;
 	int ret;
 
+	page_size = rte_mem_page_size();
+	if (page_size == (size_t)-1) {
+		DRV_LOG(ERR, "Failed to get mem page size");
+		return -ENOMEM;
+	}
 	sh->txpp.tsa = mlx5_malloc(MLX5_MEM_RTE | MLX5_MEM_ZERO,
 				   MLX5_TXPP_REARM_SQ_SIZE *
 				   sizeof(struct mlx5_txpp_ts),
diff --git a/drivers/net/mlx5/mlx5_txq.c b/drivers/net/mlx5/mlx5_txq.c
index 4a73299..46034b5 100644
--- a/drivers/net/mlx5/mlx5_txq.c
+++ b/drivers/net/mlx5/mlx5_txq.c
@@ -8,7 +8,6 @@
 #include <string.h>
 #include <stdint.h>
 #include <unistd.h>
-#include <sys/mman.h>
 #include <inttypes.h>
 
 /* Verbs header. */
@@ -26,6 +25,7 @@
 #include <rte_malloc.h>
 #include <rte_ethdev_driver.h>
 #include <rte_common.h>
+#include <rte_eal_paging.h>
 
 #include <mlx5_glue.h>
 #include <mlx5_devx_cmds.h>
@@ -344,10 +344,14 @@ txq_uar_init(struct mlx5_txq_ctrl *txq_ctrl)
 {
 	struct mlx5_priv *priv = txq_ctrl->priv;
 	struct mlx5_proc_priv *ppriv = MLX5_PROC_PRIV(PORT_ID(priv));
-	const size_t page_size = sysconf(_SC_PAGESIZE);
 #ifndef RTE_ARCH_64
 	unsigned int lock_idx;
 #endif
+	const size_t page_size = rte_mem_page_size();
+	if (page_size == (size_t)-1) {
+		DRV_LOG(ERR, "Failed to get mem page size");
+		rte_errno = ENOMEM;
+	}
 
 	if (txq_ctrl->type != MLX5_TXQ_TYPE_STANDARD)
 		return;
@@ -386,7 +390,12 @@ txq_uar_init_secondary(struct mlx5_txq_ctrl *txq_ctrl, int fd)
 	void *addr;
 	uintptr_t uar_va;
 	uintptr_t offset;
-	const size_t page_size = sysconf(_SC_PAGESIZE);
+	const size_t page_size = rte_mem_page_size();
+	if (page_size == (size_t)-1) {
+		DRV_LOG(ERR, "Failed to get mem page size");
+		rte_errno = ENOMEM;
+		return -rte_errno;
+	}
 
 	if (txq_ctrl->type != MLX5_TXQ_TYPE_STANDARD)
 		return 0;
@@ -397,9 +406,9 @@ txq_uar_init_secondary(struct mlx5_txq_ctrl *txq_ctrl, int fd)
 	 */
 	uar_va = (uintptr_t)txq_ctrl->bf_reg;
 	offset = uar_va & (page_size - 1); /* Offset in page. */
-	addr = mmap(NULL, page_size, PROT_WRITE, MAP_SHARED, fd,
-			txq_ctrl->uar_mmap_offset);
-	if (addr == MAP_FAILED) {
+	addr = rte_mem_map(NULL, page_size, RTE_PROT_WRITE, RTE_MAP_SHARED,
+			    fd, txq_ctrl->uar_mmap_offset);
+	if (!addr) {
 		DRV_LOG(ERR,
 			"port %u mmap failed for BF reg of txq %u",
 			txq->port_id, txq->idx);
@@ -422,13 +431,17 @@ static void
 txq_uar_uninit_secondary(struct mlx5_txq_ctrl *txq_ctrl)
 {
 	struct mlx5_proc_priv *ppriv = MLX5_PROC_PRIV(PORT_ID(txq_ctrl->priv));
-	const size_t page_size = sysconf(_SC_PAGESIZE);
 	void *addr;
+	const size_t page_size = rte_mem_page_size();
+	if (page_size == (size_t)-1) {
+		DRV_LOG(ERR, "Failed to get mem page size");
+		rte_errno = ENOMEM;
+	}
 
 	if (txq_ctrl->type != MLX5_TXQ_TYPE_STANDARD)
 		return;
 	addr = ppriv->uar_table[txq_ctrl->txq.idx];
-	munmap(RTE_PTR_ALIGN_FLOOR(addr, page_size), page_size);
+	rte_mem_unmap(RTE_PTR_ALIGN_FLOOR(addr, page_size), page_size);
 }
 
 /**
@@ -642,13 +655,19 @@ mlx5_txq_obj_devx_new(struct rte_eth_dev *dev, uint16_t idx)
 	struct mlx5_devx_modify_sq_attr msq_attr = { 0 };
 	struct mlx5_devx_cq_attr cq_attr = { 0 };
 	struct mlx5_txq_obj *txq_obj = NULL;
-	size_t page_size = sysconf(_SC_PAGESIZE);
+	size_t page_size;
 	struct mlx5_cqe *cqe;
 	uint32_t i, nqe;
 	int ret = 0;
 
 	MLX5_ASSERT(txq_data);
 	MLX5_ASSERT(!txq_ctrl->obj);
+	page_size = rte_mem_page_size();
+	if (page_size == (size_t)-1) {
+		DRV_LOG(ERR, "Failed to get mem page size");
+		rte_errno = ENOMEM;
+		return NULL;
+	}
 	txq_obj = mlx5_malloc(MLX5_MEM_RTE | MLX5_MEM_ZERO,
 			      sizeof(struct mlx5_txq_obj), 0,
 			      txq_ctrl->socket);
@@ -674,9 +693,15 @@ mlx5_txq_obj_devx_new(struct rte_eth_dev *dev, uint16_t idx)
 		goto error;
 	}
 	/* Allocate memory buffer for CQEs. */
+	size_t alignment = MLX5_CQE_BUF_ALIGNMENT;
+	if (alignment == (size_t)-1) {
+		DRV_LOG(ERR, "Failed to get mem page size");
+		rte_errno = ENOMEM;
+		goto error;
+	}
 	txq_obj->cq_buf = mlx5_malloc(MLX5_MEM_RTE | MLX5_MEM_ZERO,
 				      nqe * sizeof(struct mlx5_cqe),
-				      MLX5_CQE_BUF_ALIGNMENT,
+				      alignment,
 				      sh->numa_node);
 	if (!txq_obj->cq_buf) {
 		DRV_LOG(ERR,
-- 
2.8.4


^ permalink raw reply	[flat|nested] 28+ messages in thread

* [dpdk-dev] [PATCH v2 3/8] net/mlx5: refactor Linux MAC operations
  2020-07-19  7:11   ` [dpdk-dev] [PATCH v2 0/8] mlx5 PMD multi OS support - part #3 Ophir Munk
  2020-07-19  7:11     ` [dpdk-dev] [PATCH v2 1/8] net/mlx5: move flow prio discovery and adjust under Verbs Ophir Munk
  2020-07-19  7:11     ` [dpdk-dev] [PATCH v2 2/8] net/mlx5: replace Linux specific calls with rte API Ophir Munk
@ 2020-07-19  7:11     ` Ophir Munk
  2020-07-19  7:11     ` [dpdk-dev] [PATCH v2 4/8] linux/mlx5: add setters for promiscuous and all-multi Ophir Munk
                       ` (4 subsequent siblings)
  7 siblings, 0 replies; 28+ messages in thread
From: Ophir Munk @ 2020-07-19  7:11 UTC (permalink / raw)
  To: dev; +Cc: Raslan Darawsheh, Ophir Munk, Matan Azrad

Move OS specific MAC operations add, remove, modify VF into file
linux/mlx5_os.c.
Remove unused function mlx5_get_mac().

Signed-off-by: Ophir Munk <ophirmu@mellanox.com>
Acked-by: Matan Azrad <matan@mellanox.com>
---
 drivers/net/mlx5/linux/mlx5_os.c | 97 ++++++++++++++++++++++++++++++++++++++++
 drivers/net/mlx5/mlx5.h          |  7 ++-
 drivers/net/mlx5/mlx5_mac.c      | 49 +++-----------------
 3 files changed, 110 insertions(+), 43 deletions(-)

diff --git a/drivers/net/mlx5/linux/mlx5_os.c b/drivers/net/mlx5/linux/mlx5_os.c
index 292062e..fda2233 100644
--- a/drivers/net/mlx5/linux/mlx5_os.c
+++ b/drivers/net/mlx5/linux/mlx5_os.c
@@ -68,6 +68,30 @@
 #endif
 
 /**
+ * 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.
+ */
+static int
+mlx5_get_mac(struct rte_eth_dev *dev, uint8_t (*mac)[RTE_ETHER_ADDR_LEN])
+{
+	struct ifreq request;
+	int ret;
+
+	ret = mlx5_ifreq(dev, SIOCGIFHWADDR, &request);
+	if (ret)
+		return ret;
+	memcpy(mac, request.ifr_hwaddr.sa_data, RTE_ETHER_ADDR_LEN);
+	return 0;
+}
+
+/**
  * Get mlx5 device attributes. The glue function query_device_ex() is called
  * with out parameter of type 'struct ibv_device_attr_ex *'. Then fill in mlx5
  * device attributes from the glue out parameter.
@@ -2351,6 +2375,79 @@ mlx5_os_set_reg_mr_cb(mlx5_reg_mr_t *reg_mr_cb,
 	*dereg_mr_cb = mlx5_verbs_ops.dereg_mr;
 }
 
+/**
+ * Remove a MAC address from device
+ *
+ * @param dev
+ *   Pointer to Ethernet device structure.
+ * @param index
+ *   MAC address index.
+ */
+void
+mlx5_os_mac_addr_remove(struct rte_eth_dev *dev, uint32_t index)
+{
+	struct mlx5_priv *priv = dev->data->dev_private;
+	const int vf = priv->config.vf;
+
+	if (vf)
+		mlx5_nl_mac_addr_remove(priv->nl_socket_route,
+					mlx5_ifindex(dev), priv->mac_own,
+					&dev->data->mac_addrs[index], index);
+}
+
+/**
+ * Adds a MAC address to the device
+ *
+ * @param dev
+ *   Pointer to Ethernet device structure.
+ * @param mac_addr
+ *   MAC address to register.
+ * @param index
+ *   MAC address index.
+ *
+ * @return
+ *   0 on success, a negative errno value otherwise
+ */
+int
+mlx5_os_mac_addr_add(struct rte_eth_dev *dev, struct rte_ether_addr *mac,
+		     uint32_t index)
+{
+	struct mlx5_priv *priv = dev->data->dev_private;
+	const int vf = priv->config.vf;
+	int ret = 0;
+
+	if (vf)
+		ret = mlx5_nl_mac_addr_add(priv->nl_socket_route,
+					   mlx5_ifindex(dev), priv->mac_own,
+					   mac, index);
+	return ret;
+}
+
+/**
+ * Modify a VF MAC address
+ *
+ * @param priv
+ *   Pointer to device private data.
+ * @param mac_addr
+ *   MAC address to modify into.
+ * @param iface_idx
+ *   Net device interface index
+ * @param vf_index
+ *   VF index
+ *
+ * @return
+ *   0 on success, a negative errno value otherwise
+ */
+int
+mlx5_os_vf_mac_addr_modify(struct mlx5_priv *priv,
+			   unsigned int iface_idx,
+			   struct rte_ether_addr *mac_addr,
+			   int vf_index)
+{
+	return mlx5_nl_vf_mac_addr_modify
+		(priv->nl_socket_route, iface_idx, mac_addr, vf_index);
+}
+
 const struct eth_dev_ops mlx5_os_dev_ops = {
 	.dev_configure = mlx5_dev_configure,
 	.dev_start = mlx5_dev_start,
diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h
index 9179ad3..ac72e9c 100644
--- a/drivers/net/mlx5/mlx5.h
+++ b/drivers/net/mlx5/mlx5.h
@@ -859,7 +859,6 @@ int mlx5_dev_configure_rss_reta(struct rte_eth_dev *dev);
 
 /* mlx5_mac.c */
 
-int mlx5_get_mac(struct rte_eth_dev *dev, uint8_t (*mac)[RTE_ETHER_ADDR_LEN]);
 void mlx5_mac_addr_remove(struct rte_eth_dev *dev, uint32_t index);
 int mlx5_mac_addr_add(struct rte_eth_dev *dev, struct rte_ether_addr *mac,
 		      uint32_t index, uint32_t vmdq);
@@ -1024,6 +1023,12 @@ int mlx5_os_get_stats_n(struct rte_eth_dev *dev);
 void mlx5_os_stats_init(struct rte_eth_dev *dev);
 void mlx5_os_set_reg_mr_cb(mlx5_reg_mr_t *reg_mr_cb,
 			   mlx5_dereg_mr_t *dereg_mr_cb);
+void mlx5_os_mac_addr_remove(struct rte_eth_dev *dev, uint32_t index);
+int mlx5_os_mac_addr_add(struct rte_eth_dev *dev, struct rte_ether_addr *mac,
+			 uint32_t index);
+int mlx5_os_vf_mac_addr_modify(struct mlx5_priv *priv, unsigned int iface_idx,
+			       struct rte_ether_addr *mac_addr,
+			       int vf_index);
 
 /* mlx5_txpp.c */
 
diff --git a/drivers/net/mlx5/mlx5_mac.c b/drivers/net/mlx5/mlx5_mac.c
index 291f772..2a88086 100644
--- a/drivers/net/mlx5/mlx5_mac.c
+++ b/drivers/net/mlx5/mlx5_mac.c
@@ -32,30 +32,6 @@
 #include "mlx5_rxtx.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 ifreq request;
-	int ret;
-
-	ret = mlx5_ifreq(dev, SIOCGIFHWADDR, &request);
-	if (ret)
-		return ret;
-	memcpy(mac, request.ifr_hwaddr.sa_data, RTE_ETHER_ADDR_LEN);
-	return 0;
-}
-
-/**
  * Remove a MAC address from the internal array.
  *
  * @param dev
@@ -66,16 +42,10 @@ mlx5_get_mac(struct rte_eth_dev *dev, uint8_t (*mac)[RTE_ETHER_ADDR_LEN])
 static void
 mlx5_internal_mac_addr_remove(struct rte_eth_dev *dev, uint32_t index)
 {
-	struct mlx5_priv *priv = dev->data->dev_private;
-	const int vf = priv->config.vf;
-
 	MLX5_ASSERT(index < MLX5_MAX_MAC_ADDRESSES);
 	if (rte_is_zero_ether_addr(&dev->data->mac_addrs[index]))
 		return;
-	if (vf)
-		mlx5_nl_mac_addr_remove(priv->nl_socket_route,
-					mlx5_ifindex(dev), priv->mac_own,
-					&dev->data->mac_addrs[index], index);
+	mlx5_os_mac_addr_remove(dev, index);
 	memset(&dev->data->mac_addrs[index], 0, sizeof(struct rte_ether_addr));
 }
 
@@ -96,9 +66,8 @@ static int
 mlx5_internal_mac_addr_add(struct rte_eth_dev *dev, struct rte_ether_addr *mac,
 			   uint32_t index)
 {
-	struct mlx5_priv *priv = dev->data->dev_private;
-	const int vf = priv->config.vf;
 	unsigned int i;
+	int ret;
 
 	MLX5_ASSERT(index < MLX5_MAX_MAC_ADDRESSES);
 	if (rte_is_zero_ether_addr(mac)) {
@@ -116,14 +85,10 @@ mlx5_internal_mac_addr_add(struct rte_eth_dev *dev, struct rte_ether_addr *mac,
 		rte_errno = EADDRINUSE;
 		return -rte_errno;
 	}
-	if (vf) {
-		int ret = mlx5_nl_mac_addr_add(priv->nl_socket_route,
-					       mlx5_ifindex(dev), priv->mac_own,
-					       mac, index);
+	ret = mlx5_os_mac_addr_add(dev, mac, index);
+	if (ret)
+		return ret;
 
-		if (ret)
-			return ret;
-	}
 	dev->data->mac_addrs[index] = *mac;
 	return 0;
 }
@@ -210,8 +175,8 @@ mlx5_mac_addr_set(struct rte_eth_dev *dev, struct rte_ether_addr *mac_addr)
 			priv = rte_eth_devices[port_id].data->dev_private;
 			if (priv->master == 1) {
 				priv = dev->data->dev_private;
-				return mlx5_nl_vf_mac_addr_modify
-				       (priv->nl_socket_route,
+				return mlx5_os_vf_mac_addr_modify
+				       (priv,
 					mlx5_ifindex(&rte_eth_devices[port_id]),
 					mac_addr, priv->representor_id);
 			}
-- 
2.8.4


^ permalink raw reply	[flat|nested] 28+ messages in thread

* [dpdk-dev] [PATCH v2 4/8] linux/mlx5: add setters for promiscuous and all-multi
  2020-07-19  7:11   ` [dpdk-dev] [PATCH v2 0/8] mlx5 PMD multi OS support - part #3 Ophir Munk
                       ` (2 preceding siblings ...)
  2020-07-19  7:11     ` [dpdk-dev] [PATCH v2 3/8] net/mlx5: refactor Linux MAC operations Ophir Munk
@ 2020-07-19  7:11     ` Ophir Munk
  2020-07-19  7:11     ` [dpdk-dev] [PATCH v2 5/8] net/mlx5: eliminate dependency on Linux in shared header Ophir Munk
                       ` (3 subsequent siblings)
  7 siblings, 0 replies; 28+ messages in thread
From: Ophir Munk @ 2020-07-19  7:11 UTC (permalink / raw)
  To: dev; +Cc: Raslan Darawsheh, Ophir Munk, Matan Azrad

This commit adds Linux implementation of routines mlx5_os_set_promisc()
and mlx5_os_set_promisc(). The routines call netlink APIs.

Signed-off-by: Ophir Munk <ophirmu@mellanox.com>
Acked-by: Matan Azrad <matan@mellanox.com>
---
 drivers/net/mlx5/linux/mlx5_os.c | 40 ++++++++++++++++++++++++++++++++++++++++
 drivers/net/mlx5/mlx5.h          |  2 ++
 drivers/net/mlx5/mlx5_rxmode.c   | 12 ++++--------
 3 files changed, 46 insertions(+), 8 deletions(-)

diff --git a/drivers/net/mlx5/linux/mlx5_os.c b/drivers/net/mlx5/linux/mlx5_os.c
index fda2233..14fffe3 100644
--- a/drivers/net/mlx5/linux/mlx5_os.c
+++ b/drivers/net/mlx5/linux/mlx5_os.c
@@ -2448,6 +2448,46 @@ mlx5_os_vf_mac_addr_modify(struct mlx5_priv *priv,
 		(priv->nl_socket_route, iface_idx, mac_addr, vf_index);
 }
 
+/**
+ * Set device promiscuous mode
+ *
+ * @param dev
+ *   Pointer to Ethernet device structure.
+ * @param enable
+ *   0 - promiscuous is disabled, otherwise - enabled
+ *
+ * @return
+ *   0 on success, a negative error value otherwise
+ */
+int
+mlx5_os_set_promisc(struct rte_eth_dev *dev, int enable)
+{
+	struct mlx5_priv *priv = dev->data->dev_private;
+
+	return mlx5_nl_promisc(priv->nl_socket_route,
+			       mlx5_ifindex(dev), !!enable);
+}
+
+/**
+ * Set device promiscuous mode
+ *
+ * @param dev
+ *   Pointer to Ethernet device structure.
+ * @param enable
+ *   0 - all multicase is disabled, otherwise - enabled
+ *
+ * @return
+ *   0 on success, a negative error value otherwise
+ */
+int
+mlx5_os_set_allmulti(struct rte_eth_dev *dev, int enable)
+{
+	struct mlx5_priv *priv = dev->data->dev_private;
+
+	return mlx5_nl_allmulti(priv->nl_socket_route,
+				mlx5_ifindex(dev), !!enable);
+}
+
 const struct eth_dev_ops mlx5_os_dev_ops = {
 	.dev_configure = mlx5_dev_configure,
 	.dev_start = mlx5_dev_start,
diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h
index ac72e9c..afc0e83 100644
--- a/drivers/net/mlx5/mlx5.h
+++ b/drivers/net/mlx5/mlx5.h
@@ -1029,6 +1029,8 @@ int mlx5_os_mac_addr_add(struct rte_eth_dev *dev, struct rte_ether_addr *mac,
 int mlx5_os_vf_mac_addr_modify(struct mlx5_priv *priv, unsigned int iface_idx,
 			       struct rte_ether_addr *mac_addr,
 			       int vf_index);
+int mlx5_os_set_promisc(struct rte_eth_dev *dev, int enable);
+int mlx5_os_set_allmulti(struct rte_eth_dev *dev, int enable);
 
 /* mlx5_txpp.c */
 
diff --git a/drivers/net/mlx5/mlx5_rxmode.c b/drivers/net/mlx5/mlx5_rxmode.c
index 84c8b05..80b1256 100644
--- a/drivers/net/mlx5/mlx5_rxmode.c
+++ b/drivers/net/mlx5/mlx5_rxmode.c
@@ -47,8 +47,7 @@ mlx5_promiscuous_enable(struct rte_eth_dev *dev)
 		return 0;
 	}
 	if (priv->config.vf) {
-		ret = mlx5_nl_promisc(priv->nl_socket_route, mlx5_ifindex(dev),
-				      1);
+		ret = mlx5_os_set_promisc(dev, 1);
 		if (ret)
 			return ret;
 	}
@@ -81,8 +80,7 @@ mlx5_promiscuous_disable(struct rte_eth_dev *dev)
 
 	dev->data->promiscuous = 0;
 	if (priv->config.vf) {
-		ret = mlx5_nl_promisc(priv->nl_socket_route, mlx5_ifindex(dev),
-				      0);
+		ret = mlx5_os_set_promisc(dev, 0);
 		if (ret)
 			return ret;
 	}
@@ -122,8 +120,7 @@ mlx5_allmulticast_enable(struct rte_eth_dev *dev)
 		return 0;
 	}
 	if (priv->config.vf) {
-		ret = mlx5_nl_allmulti(priv->nl_socket_route, mlx5_ifindex(dev),
-				       1);
+		ret = mlx5_os_set_allmulti(dev, 1);
 		if (ret)
 			goto error;
 	}
@@ -156,8 +153,7 @@ mlx5_allmulticast_disable(struct rte_eth_dev *dev)
 
 	dev->data->all_multicast = 0;
 	if (priv->config.vf) {
-		ret = mlx5_nl_allmulti(priv->nl_socket_route, mlx5_ifindex(dev),
-				       0);
+		ret = mlx5_os_set_allmulti(dev, 0);
 		if (ret)
 			goto error;
 	}
-- 
2.8.4


^ permalink raw reply	[flat|nested] 28+ messages in thread

* [dpdk-dev] [PATCH v2 5/8] net/mlx5: eliminate dependency on Linux in shared header
  2020-07-19  7:11   ` [dpdk-dev] [PATCH v2 0/8] mlx5 PMD multi OS support - part #3 Ophir Munk
                       ` (3 preceding siblings ...)
  2020-07-19  7:11     ` [dpdk-dev] [PATCH v2 4/8] linux/mlx5: add setters for promiscuous and all-multi Ophir Munk
@ 2020-07-19  7:11     ` Ophir Munk
  2020-07-19  7:11     ` [dpdk-dev] [PATCH v2 6/8] net/mlx5: header file cleanup Ophir Munk
                       ` (2 subsequent siblings)
  7 siblings, 0 replies; 28+ messages in thread
From: Ophir Munk @ 2020-07-19  7:11 UTC (permalink / raw)
  To: dev; +Cc: Raslan Darawsheh, Ophir Munk, Matan Azrad

This commit eliminates Linux dependencies in shared file mlx5.h.

1. All functions using 'struct ifreq' are moved to file
linux/mlx5_ethdev_os.c such that this struct can be removed from mlx5.h.
2. Function mlx5_set_flags() that uses Linux flags (e.g. IFF_UP) is
changed to static and its prototype is removed from mlx5.h.
3. Remove redundant member verbs_action from 'struct mlx5_priv'.

Signed-off-by: Ophir Munk <ophirmu@mellanox.com>
Acked-by: Matan Azrad <matan@mellanox.com>
---
 drivers/net/mlx5/linux/mlx5_ethdev_os.c | 314 +++++++++++++++++++++++++++++++-
 drivers/net/mlx5/linux/mlx5_os.c        | 309 -------------------------------
 drivers/net/mlx5/mlx5.h                 |  15 +-
 3 files changed, 318 insertions(+), 320 deletions(-)

diff --git a/drivers/net/mlx5/linux/mlx5_ethdev_os.c b/drivers/net/mlx5/linux/mlx5_ethdev_os.c
index 6b8a151..e79d576 100644
--- a/drivers/net/mlx5/linux/mlx5_ethdev_os.c
+++ b/drivers/net/mlx5/linux/mlx5_ethdev_os.c
@@ -178,7 +178,7 @@ mlx5_get_ifname(const struct rte_eth_dev *dev, char (*ifname)[IF_NAMESIZE])
  * @return
  *   0 on success, a negative errno value otherwise and rte_errno is set.
  */
-int
+static int
 mlx5_ifreq(const struct rte_eth_dev *dev, int req, struct ifreq *ifr)
 {
 	int sock = socket(PF_INET, SOCK_DGRAM, IPPROTO_IP);
@@ -258,7 +258,7 @@ mlx5_set_mtu(struct rte_eth_dev *dev, uint16_t mtu)
  * @return
  *   0 on success, a negative errno value otherwise and rte_errno is set.
  */
-int
+static int
 mlx5_set_flags(struct rte_eth_dev *dev, unsigned int keep, unsigned int flags)
 {
 	struct ifreq request;
@@ -1187,3 +1187,313 @@ int mlx5_get_module_eeprom(struct rte_eth_dev *dev,
 	mlx5_free(eeprom);
 	return ret;
 }
+
+/**
+ * Read device counters table.
+ *
+ * @param dev
+ *   Pointer to Ethernet device.
+ * @param[out] stats
+ *   Counters table output buffer.
+ *
+ * @return
+ *   0 on success and stats is filled, negative errno value otherwise and
+ *   rte_errno is set.
+ */
+int
+mlx5_os_read_dev_counters(struct rte_eth_dev *dev, uint64_t *stats)
+{
+	struct mlx5_priv *priv = dev->data->dev_private;
+	struct mlx5_xstats_ctrl *xstats_ctrl = &priv->xstats_ctrl;
+	unsigned int i;
+	struct ifreq ifr;
+	unsigned int stats_sz = xstats_ctrl->stats_n * sizeof(uint64_t);
+	unsigned char et_stat_buf[sizeof(struct ethtool_stats) + stats_sz];
+	struct ethtool_stats *et_stats = (struct ethtool_stats *)et_stat_buf;
+	int ret;
+
+	et_stats->cmd = ETHTOOL_GSTATS;
+	et_stats->n_stats = xstats_ctrl->stats_n;
+	ifr.ifr_data = (caddr_t)et_stats;
+	ret = mlx5_ifreq(dev, SIOCETHTOOL, &ifr);
+	if (ret) {
+		DRV_LOG(WARNING,
+			"port %u unable to read statistic values from device",
+			dev->data->port_id);
+		return ret;
+	}
+	for (i = 0; i != xstats_ctrl->mlx5_stats_n; ++i) {
+		if (xstats_ctrl->info[i].dev) {
+			ret = mlx5_os_read_dev_stat(priv,
+					    xstats_ctrl->info[i].ctr_name,
+					    &stats[i]);
+			/* return last xstats counter if fail to read. */
+			if (ret == 0)
+				xstats_ctrl->xstats[i] = stats[i];
+			else
+				stats[i] = xstats_ctrl->xstats[i];
+		} else {
+			stats[i] = (uint64_t)
+				et_stats->data[xstats_ctrl->dev_table_idx[i]];
+		}
+	}
+	return 0;
+}
+
+/**
+ * Query the number of statistics provided by ETHTOOL.
+ *
+ * @param dev
+ *   Pointer to Ethernet device.
+ *
+ * @return
+ *   Number of statistics on success, negative errno value otherwise and
+ *   rte_errno is set.
+ */
+int
+mlx5_os_get_stats_n(struct rte_eth_dev *dev)
+{
+	struct ethtool_drvinfo drvinfo;
+	struct ifreq ifr;
+	int ret;
+
+	drvinfo.cmd = ETHTOOL_GDRVINFO;
+	ifr.ifr_data = (caddr_t)&drvinfo;
+	ret = mlx5_ifreq(dev, SIOCETHTOOL, &ifr);
+	if (ret) {
+		DRV_LOG(WARNING, "port %u unable to query number of statistics",
+			dev->data->port_id);
+		return ret;
+	}
+	return drvinfo.n_stats;
+}
+
+static const struct mlx5_counter_ctrl mlx5_counters_init[] = {
+	{
+		.dpdk_name = "rx_port_unicast_bytes",
+		.ctr_name = "rx_vport_unicast_bytes",
+	},
+	{
+		.dpdk_name = "rx_port_multicast_bytes",
+		.ctr_name = "rx_vport_multicast_bytes",
+	},
+	{
+		.dpdk_name = "rx_port_broadcast_bytes",
+		.ctr_name = "rx_vport_broadcast_bytes",
+	},
+	{
+		.dpdk_name = "rx_port_unicast_packets",
+		.ctr_name = "rx_vport_unicast_packets",
+	},
+	{
+		.dpdk_name = "rx_port_multicast_packets",
+		.ctr_name = "rx_vport_multicast_packets",
+	},
+	{
+		.dpdk_name = "rx_port_broadcast_packets",
+		.ctr_name = "rx_vport_broadcast_packets",
+	},
+	{
+		.dpdk_name = "tx_port_unicast_bytes",
+		.ctr_name = "tx_vport_unicast_bytes",
+	},
+	{
+		.dpdk_name = "tx_port_multicast_bytes",
+		.ctr_name = "tx_vport_multicast_bytes",
+	},
+	{
+		.dpdk_name = "tx_port_broadcast_bytes",
+		.ctr_name = "tx_vport_broadcast_bytes",
+	},
+	{
+		.dpdk_name = "tx_port_unicast_packets",
+		.ctr_name = "tx_vport_unicast_packets",
+	},
+	{
+		.dpdk_name = "tx_port_multicast_packets",
+		.ctr_name = "tx_vport_multicast_packets",
+	},
+	{
+		.dpdk_name = "tx_port_broadcast_packets",
+		.ctr_name = "tx_vport_broadcast_packets",
+	},
+	{
+		.dpdk_name = "rx_wqe_err",
+		.ctr_name = "rx_wqe_err",
+	},
+	{
+		.dpdk_name = "rx_crc_errors_phy",
+		.ctr_name = "rx_crc_errors_phy",
+	},
+	{
+		.dpdk_name = "rx_in_range_len_errors_phy",
+		.ctr_name = "rx_in_range_len_errors_phy",
+	},
+	{
+		.dpdk_name = "rx_symbol_err_phy",
+		.ctr_name = "rx_symbol_err_phy",
+	},
+	{
+		.dpdk_name = "tx_errors_phy",
+		.ctr_name = "tx_errors_phy",
+	},
+	{
+		.dpdk_name = "rx_out_of_buffer",
+		.ctr_name = "out_of_buffer",
+		.dev = 1,
+	},
+	{
+		.dpdk_name = "tx_packets_phy",
+		.ctr_name = "tx_packets_phy",
+	},
+	{
+		.dpdk_name = "rx_packets_phy",
+		.ctr_name = "rx_packets_phy",
+	},
+	{
+		.dpdk_name = "tx_discards_phy",
+		.ctr_name = "tx_discards_phy",
+	},
+	{
+		.dpdk_name = "rx_discards_phy",
+		.ctr_name = "rx_discards_phy",
+	},
+	{
+		.dpdk_name = "tx_bytes_phy",
+		.ctr_name = "tx_bytes_phy",
+	},
+	{
+		.dpdk_name = "rx_bytes_phy",
+		.ctr_name = "rx_bytes_phy",
+	},
+	/* Representor only */
+	{
+		.dpdk_name = "rx_packets",
+		.ctr_name = "vport_rx_packets",
+	},
+	{
+		.dpdk_name = "rx_bytes",
+		.ctr_name = "vport_rx_bytes",
+	},
+	{
+		.dpdk_name = "tx_packets",
+		.ctr_name = "vport_tx_packets",
+	},
+	{
+		.dpdk_name = "tx_bytes",
+		.ctr_name = "vport_tx_bytes",
+	},
+};
+
+static const unsigned int xstats_n = RTE_DIM(mlx5_counters_init);
+
+/**
+ * Init the structures to read device counters.
+ *
+ * @param dev
+ *   Pointer to Ethernet device.
+ */
+void
+mlx5_os_stats_init(struct rte_eth_dev *dev)
+{
+	struct mlx5_priv *priv = dev->data->dev_private;
+	struct mlx5_xstats_ctrl *xstats_ctrl = &priv->xstats_ctrl;
+	struct mlx5_stats_ctrl *stats_ctrl = &priv->stats_ctrl;
+	unsigned int i;
+	unsigned int j;
+	struct ifreq ifr;
+	struct ethtool_gstrings *strings = NULL;
+	unsigned int dev_stats_n;
+	unsigned int str_sz;
+	int ret;
+
+	/* So that it won't aggregate for each init. */
+	xstats_ctrl->mlx5_stats_n = 0;
+	ret = mlx5_os_get_stats_n(dev);
+	if (ret < 0) {
+		DRV_LOG(WARNING, "port %u no extended statistics available",
+			dev->data->port_id);
+		return;
+	}
+	dev_stats_n = ret;
+	/* Allocate memory to grab stat names and values. */
+	str_sz = dev_stats_n * ETH_GSTRING_LEN;
+	strings = (struct ethtool_gstrings *)
+		  mlx5_malloc(0, str_sz + sizeof(struct ethtool_gstrings), 0,
+			      SOCKET_ID_ANY);
+	if (!strings) {
+		DRV_LOG(WARNING, "port %u unable to allocate memory for xstats",
+		     dev->data->port_id);
+		return;
+	}
+	strings->cmd = ETHTOOL_GSTRINGS;
+	strings->string_set = ETH_SS_STATS;
+	strings->len = dev_stats_n;
+	ifr.ifr_data = (caddr_t)strings;
+	ret = mlx5_ifreq(dev, SIOCETHTOOL, &ifr);
+	if (ret) {
+		DRV_LOG(WARNING, "port %u unable to get statistic names",
+			dev->data->port_id);
+		goto free;
+	}
+	for (i = 0; i != dev_stats_n; ++i) {
+		const char *curr_string = (const char *)
+			&strings->data[i * ETH_GSTRING_LEN];
+
+		for (j = 0; j != xstats_n; ++j) {
+			if (!strcmp(mlx5_counters_init[j].ctr_name,
+				    curr_string)) {
+				unsigned int idx = xstats_ctrl->mlx5_stats_n++;
+
+				xstats_ctrl->dev_table_idx[idx] = i;
+				xstats_ctrl->info[idx] = mlx5_counters_init[j];
+				break;
+			}
+		}
+	}
+	/* Add dev counters. */
+	for (i = 0; i != xstats_n; ++i) {
+		if (mlx5_counters_init[i].dev) {
+			unsigned int idx = xstats_ctrl->mlx5_stats_n++;
+
+			xstats_ctrl->info[idx] = mlx5_counters_init[i];
+			xstats_ctrl->hw_stats[idx] = 0;
+		}
+	}
+	MLX5_ASSERT(xstats_ctrl->mlx5_stats_n <= MLX5_MAX_XSTATS);
+	xstats_ctrl->stats_n = dev_stats_n;
+	/* Copy to base at first time. */
+	ret = mlx5_os_read_dev_counters(dev, xstats_ctrl->base);
+	if (ret)
+		DRV_LOG(ERR, "port %u cannot read device counters: %s",
+			dev->data->port_id, strerror(rte_errno));
+	mlx5_os_read_dev_stat(priv, "out_of_buffer", &stats_ctrl->imissed_base);
+	stats_ctrl->imissed = 0;
+free:
+	mlx5_free(strings);
+}
+
+/**
+ * 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 ifreq request;
+	int ret;
+
+	ret = mlx5_ifreq(dev, SIOCGIFHWADDR, &request);
+	if (ret)
+		return ret;
+	memcpy(mac, request.ifr_hwaddr.sa_data, RTE_ETHER_ADDR_LEN);
+	return 0;
+}
+
diff --git a/drivers/net/mlx5/linux/mlx5_os.c b/drivers/net/mlx5/linux/mlx5_os.c
index 14fffe3..4e21018 100644
--- a/drivers/net/mlx5/linux/mlx5_os.c
+++ b/drivers/net/mlx5/linux/mlx5_os.c
@@ -68,30 +68,6 @@
 #endif
 
 /**
- * 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.
- */
-static int
-mlx5_get_mac(struct rte_eth_dev *dev, uint8_t (*mac)[RTE_ETHER_ADDR_LEN])
-{
-	struct ifreq request;
-	int ret;
-
-	ret = mlx5_ifreq(dev, SIOCGIFHWADDR, &request);
-	if (ret)
-		return ret;
-	memcpy(mac, request.ifr_hwaddr.sa_data, RTE_ETHER_ADDR_LEN);
-	return 0;
-}
-
-/**
  * Get mlx5 device attributes. The glue function query_device_ex() is called
  * with out parameter of type 'struct ibv_device_attr_ex *'. Then fill in mlx5
  * device attributes from the glue out parameter.
@@ -2074,291 +2050,6 @@ mlx5_os_read_dev_stat(struct mlx5_priv *priv, const char *ctr_name,
 }
 
 /**
- * Read device counters table.
- *
- * @param dev
- *   Pointer to Ethernet device.
- * @param[out] stats
- *   Counters table output buffer.
- *
- * @return
- *   0 on success and stats is filled, negative errno value otherwise and
- *   rte_errno is set.
- */
-int
-mlx5_os_read_dev_counters(struct rte_eth_dev *dev, uint64_t *stats)
-{
-	struct mlx5_priv *priv = dev->data->dev_private;
-	struct mlx5_xstats_ctrl *xstats_ctrl = &priv->xstats_ctrl;
-	unsigned int i;
-	struct ifreq ifr;
-	unsigned int stats_sz = xstats_ctrl->stats_n * sizeof(uint64_t);
-	unsigned char et_stat_buf[sizeof(struct ethtool_stats) + stats_sz];
-	struct ethtool_stats *et_stats = (struct ethtool_stats *)et_stat_buf;
-	int ret;
-
-	et_stats->cmd = ETHTOOL_GSTATS;
-	et_stats->n_stats = xstats_ctrl->stats_n;
-	ifr.ifr_data = (caddr_t)et_stats;
-	ret = mlx5_ifreq(dev, SIOCETHTOOL, &ifr);
-	if (ret) {
-		DRV_LOG(WARNING,
-			"port %u unable to read statistic values from device",
-			dev->data->port_id);
-		return ret;
-	}
-	for (i = 0; i != xstats_ctrl->mlx5_stats_n; ++i) {
-		if (xstats_ctrl->info[i].dev) {
-			ret = mlx5_os_read_dev_stat(priv,
-					    xstats_ctrl->info[i].ctr_name,
-					    &stats[i]);
-			/* return last xstats counter if fail to read. */
-			if (ret == 0)
-				xstats_ctrl->xstats[i] = stats[i];
-			else
-				stats[i] = xstats_ctrl->xstats[i];
-		} else {
-			stats[i] = (uint64_t)
-				et_stats->data[xstats_ctrl->dev_table_idx[i]];
-		}
-	}
-	return 0;
-}
-
-/**
- * Query the number of statistics provided by ETHTOOL.
- *
- * @param dev
- *   Pointer to Ethernet device.
- *
- * @return
- *   Number of statistics on success, negative errno value otherwise and
- *   rte_errno is set.
- */
-int
-mlx5_os_get_stats_n(struct rte_eth_dev *dev)
-{
-	struct ethtool_drvinfo drvinfo;
-	struct ifreq ifr;
-	int ret;
-
-	drvinfo.cmd = ETHTOOL_GDRVINFO;
-	ifr.ifr_data = (caddr_t)&drvinfo;
-	ret = mlx5_ifreq(dev, SIOCETHTOOL, &ifr);
-	if (ret) {
-		DRV_LOG(WARNING, "port %u unable to query number of statistics",
-			dev->data->port_id);
-		return ret;
-	}
-	return drvinfo.n_stats;
-}
-
-static const struct mlx5_counter_ctrl mlx5_counters_init[] = {
-	{
-		.dpdk_name = "rx_port_unicast_bytes",
-		.ctr_name = "rx_vport_unicast_bytes",
-	},
-	{
-		.dpdk_name = "rx_port_multicast_bytes",
-		.ctr_name = "rx_vport_multicast_bytes",
-	},
-	{
-		.dpdk_name = "rx_port_broadcast_bytes",
-		.ctr_name = "rx_vport_broadcast_bytes",
-	},
-	{
-		.dpdk_name = "rx_port_unicast_packets",
-		.ctr_name = "rx_vport_unicast_packets",
-	},
-	{
-		.dpdk_name = "rx_port_multicast_packets",
-		.ctr_name = "rx_vport_multicast_packets",
-	},
-	{
-		.dpdk_name = "rx_port_broadcast_packets",
-		.ctr_name = "rx_vport_broadcast_packets",
-	},
-	{
-		.dpdk_name = "tx_port_unicast_bytes",
-		.ctr_name = "tx_vport_unicast_bytes",
-	},
-	{
-		.dpdk_name = "tx_port_multicast_bytes",
-		.ctr_name = "tx_vport_multicast_bytes",
-	},
-	{
-		.dpdk_name = "tx_port_broadcast_bytes",
-		.ctr_name = "tx_vport_broadcast_bytes",
-	},
-	{
-		.dpdk_name = "tx_port_unicast_packets",
-		.ctr_name = "tx_vport_unicast_packets",
-	},
-	{
-		.dpdk_name = "tx_port_multicast_packets",
-		.ctr_name = "tx_vport_multicast_packets",
-	},
-	{
-		.dpdk_name = "tx_port_broadcast_packets",
-		.ctr_name = "tx_vport_broadcast_packets",
-	},
-	{
-		.dpdk_name = "rx_wqe_err",
-		.ctr_name = "rx_wqe_err",
-	},
-	{
-		.dpdk_name = "rx_crc_errors_phy",
-		.ctr_name = "rx_crc_errors_phy",
-	},
-	{
-		.dpdk_name = "rx_in_range_len_errors_phy",
-		.ctr_name = "rx_in_range_len_errors_phy",
-	},
-	{
-		.dpdk_name = "rx_symbol_err_phy",
-		.ctr_name = "rx_symbol_err_phy",
-	},
-	{
-		.dpdk_name = "tx_errors_phy",
-		.ctr_name = "tx_errors_phy",
-	},
-	{
-		.dpdk_name = "rx_out_of_buffer",
-		.ctr_name = "out_of_buffer",
-		.dev = 1,
-	},
-	{
-		.dpdk_name = "tx_packets_phy",
-		.ctr_name = "tx_packets_phy",
-	},
-	{
-		.dpdk_name = "rx_packets_phy",
-		.ctr_name = "rx_packets_phy",
-	},
-	{
-		.dpdk_name = "tx_discards_phy",
-		.ctr_name = "tx_discards_phy",
-	},
-	{
-		.dpdk_name = "rx_discards_phy",
-		.ctr_name = "rx_discards_phy",
-	},
-	{
-		.dpdk_name = "tx_bytes_phy",
-		.ctr_name = "tx_bytes_phy",
-	},
-	{
-		.dpdk_name = "rx_bytes_phy",
-		.ctr_name = "rx_bytes_phy",
-	},
-	/* Representor only */
-	{
-		.dpdk_name = "rx_packets",
-		.ctr_name = "vport_rx_packets",
-	},
-	{
-		.dpdk_name = "rx_bytes",
-		.ctr_name = "vport_rx_bytes",
-	},
-	{
-		.dpdk_name = "tx_packets",
-		.ctr_name = "vport_tx_packets",
-	},
-	{
-		.dpdk_name = "tx_bytes",
-		.ctr_name = "vport_tx_bytes",
-	},
-};
-
-static const unsigned int xstats_n = RTE_DIM(mlx5_counters_init);
-
-/**
- * Init the structures to read device counters.
- *
- * @param dev
- *   Pointer to Ethernet device.
- */
-void
-mlx5_os_stats_init(struct rte_eth_dev *dev)
-{
-	struct mlx5_priv *priv = dev->data->dev_private;
-	struct mlx5_xstats_ctrl *xstats_ctrl = &priv->xstats_ctrl;
-	struct mlx5_stats_ctrl *stats_ctrl = &priv->stats_ctrl;
-	unsigned int i;
-	unsigned int j;
-	struct ifreq ifr;
-	struct ethtool_gstrings *strings = NULL;
-	unsigned int dev_stats_n;
-	unsigned int str_sz;
-	int ret;
-
-	/* So that it won't aggregate for each init. */
-	xstats_ctrl->mlx5_stats_n = 0;
-	ret = mlx5_os_get_stats_n(dev);
-	if (ret < 0) {
-		DRV_LOG(WARNING, "port %u no extended statistics available",
-			dev->data->port_id);
-		return;
-	}
-	dev_stats_n = ret;
-	/* Allocate memory to grab stat names and values. */
-	str_sz = dev_stats_n * ETH_GSTRING_LEN;
-	strings = (struct ethtool_gstrings *)
-		  mlx5_malloc(0, str_sz + sizeof(struct ethtool_gstrings), 0,
-			      SOCKET_ID_ANY);
-	if (!strings) {
-		DRV_LOG(WARNING, "port %u unable to allocate memory for xstats",
-		     dev->data->port_id);
-		return;
-	}
-	strings->cmd = ETHTOOL_GSTRINGS;
-	strings->string_set = ETH_SS_STATS;
-	strings->len = dev_stats_n;
-	ifr.ifr_data = (caddr_t)strings;
-	ret = mlx5_ifreq(dev, SIOCETHTOOL, &ifr);
-	if (ret) {
-		DRV_LOG(WARNING, "port %u unable to get statistic names",
-			dev->data->port_id);
-		goto free;
-	}
-	for (i = 0; i != dev_stats_n; ++i) {
-		const char *curr_string = (const char *)
-			&strings->data[i * ETH_GSTRING_LEN];
-
-		for (j = 0; j != xstats_n; ++j) {
-			if (!strcmp(mlx5_counters_init[j].ctr_name,
-				    curr_string)) {
-				unsigned int idx = xstats_ctrl->mlx5_stats_n++;
-
-				xstats_ctrl->dev_table_idx[idx] = i;
-				xstats_ctrl->info[idx] = mlx5_counters_init[j];
-				break;
-			}
-		}
-	}
-	/* Add dev counters. */
-	for (i = 0; i != xstats_n; ++i) {
-		if (mlx5_counters_init[i].dev) {
-			unsigned int idx = xstats_ctrl->mlx5_stats_n++;
-
-			xstats_ctrl->info[idx] = mlx5_counters_init[i];
-			xstats_ctrl->hw_stats[idx] = 0;
-		}
-	}
-	MLX5_ASSERT(xstats_ctrl->mlx5_stats_n <= MLX5_MAX_XSTATS);
-	xstats_ctrl->stats_n = dev_stats_n;
-	/* Copy to base at first time. */
-	ret = mlx5_os_read_dev_counters(dev, xstats_ctrl->base);
-	if (ret)
-		DRV_LOG(ERR, "port %u cannot read device counters: %s",
-			dev->data->port_id, strerror(rte_errno));
-	mlx5_os_read_dev_stat(priv, "out_of_buffer", &stats_ctrl->imissed_base);
-	stats_ctrl->imissed = 0;
-free:
-	mlx5_free(strings);
-}
-
-/**
  * Set the reg_mr and dereg_mr call backs
  *
  * @param reg_mr_cb[out]
diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h
index afc0e83..00ee2e3 100644
--- a/drivers/net/mlx5/mlx5.h
+++ b/drivers/net/mlx5/mlx5.h
@@ -736,7 +736,6 @@ struct mlx5_priv {
 	LIST_HEAD(ind_tables, mlx5_ind_table_obj) ind_tbls;
 	/* Pointer to next element. */
 	rte_atomic32_t refcnt; /**< Reference counter. */
-	struct ibv_flow_action *verbs_action;
 	/**< Verbs modify header action object. */
 	uint8_t ft_type; /**< Flow table type, Rx or Tx. */
 	uint8_t max_lro_msg_size;
@@ -819,10 +818,8 @@ int mlx5_hairpin_cap_get(struct rte_eth_dev *dev,
 
 int mlx5_get_ifname(const struct rte_eth_dev *dev, char (*ifname)[IF_NAMESIZE]);
 unsigned int mlx5_ifindex(const struct rte_eth_dev *dev);
-int mlx5_ifreq(const struct rte_eth_dev *dev, int req, struct ifreq *ifr);
+int mlx5_get_mac(struct rte_eth_dev *dev, uint8_t (*mac)[RTE_ETHER_ADDR_LEN]);
 int mlx5_get_mtu(struct rte_eth_dev *dev, uint16_t *mtu);
-int mlx5_set_flags(struct rte_eth_dev *dev, unsigned int keep,
-		   unsigned int flags);
 int mlx5_set_mtu(struct rte_eth_dev *dev, uint16_t mtu);
 int mlx5_read_clock(struct rte_eth_dev *dev, uint64_t *clock);
 int mlx5_link_update(struct rte_eth_dev *dev, int wait_to_complete);
@@ -856,6 +853,11 @@ int mlx5_get_module_info(struct rte_eth_dev *dev,
 int mlx5_get_module_eeprom(struct rte_eth_dev *dev,
 			   struct rte_dev_eeprom_info *info);
 int mlx5_dev_configure_rss_reta(struct rte_eth_dev *dev);
+int mlx5_os_read_dev_stat(struct mlx5_priv *priv,
+			  const char *ctr_name, uint64_t *stat);
+int mlx5_os_read_dev_counters(struct rte_eth_dev *dev, uint64_t *stats);
+int mlx5_os_get_stats_n(struct rte_eth_dev *dev);
+void mlx5_os_stats_init(struct rte_eth_dev *dev);
 
 /* mlx5_mac.c */
 
@@ -1016,11 +1018,6 @@ int mlx5_os_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
 		       struct rte_pci_device *pci_dev);
 void mlx5_os_dev_shared_handler_install(struct mlx5_dev_ctx_shared *sh);
 void mlx5_os_dev_shared_handler_uninstall(struct mlx5_dev_ctx_shared *sh);
-int mlx5_os_read_dev_stat(struct mlx5_priv *priv,
-			  const char *ctr_name, uint64_t *stat);
-int mlx5_os_read_dev_counters(struct rte_eth_dev *dev, uint64_t *stats);
-int mlx5_os_get_stats_n(struct rte_eth_dev *dev);
-void mlx5_os_stats_init(struct rte_eth_dev *dev);
 void mlx5_os_set_reg_mr_cb(mlx5_reg_mr_t *reg_mr_cb,
 			   mlx5_dereg_mr_t *dereg_mr_cb);
 void mlx5_os_mac_addr_remove(struct rte_eth_dev *dev, uint32_t index);
-- 
2.8.4


^ permalink raw reply	[flat|nested] 28+ messages in thread

* [dpdk-dev] [PATCH v2 6/8] net/mlx5: header file cleanup
  2020-07-19  7:11   ` [dpdk-dev] [PATCH v2 0/8] mlx5 PMD multi OS support - part #3 Ophir Munk
                       ` (4 preceding siblings ...)
  2020-07-19  7:11     ` [dpdk-dev] [PATCH v2 5/8] net/mlx5: eliminate dependency on Linux in shared header Ophir Munk
@ 2020-07-19  7:11     ` Ophir Munk
  2020-07-19  7:11     ` [dpdk-dev] [PATCH v2 7/8] net/mlx5: refactor multi process communication Ophir Munk
  2020-07-19  7:11     ` [dpdk-dev] [PATCH v2 8/8] mlx5: remove inclusion of Verbs header files Ophir Munk
  7 siblings, 0 replies; 28+ messages in thread
From: Ophir Munk @ 2020-07-19  7:11 UTC (permalink / raw)
  To: dev; +Cc: Raslan Darawsheh, Ophir Munk, Matan Azrad

The cleanup refers to header file mlx5.h.
1. Remove unused prototypes.
2. Move prototypes under their correct title.
3. Change functions to static and remove their prototye from the header
file.

Signed-off-by: Ophir Munk <ophirmu@mellanox.com>
Acked-by: Matan Azrad <matan@mellanox.com>
---
 drivers/net/mlx5/linux/mlx5_ethdev_os.c | 102 ++++++++++++++++----------------
 drivers/net/mlx5/mlx5.h                 |  18 +++---
 2 files changed, 58 insertions(+), 62 deletions(-)

diff --git a/drivers/net/mlx5/linux/mlx5_ethdev_os.c b/drivers/net/mlx5/linux/mlx5_ethdev_os.c
index e79d576..1735157 100644
--- a/drivers/net/mlx5/linux/mlx5_ethdev_os.c
+++ b/drivers/net/mlx5/linux/mlx5_ethdev_os.c
@@ -973,6 +973,57 @@ mlx5_is_removed(struct rte_eth_dev *dev)
 }
 
 /**
+ * Analyze gathered port parameters via sysfs to recognize master
+ * and representor devices for E-Switch configuration.
+ *
+ * @param[in] device_dir
+ *   flag of presence of "device" directory under port device key.
+ * @param[inout] switch_info
+ *   Port information, including port name as a number and port name
+ *   type if recognized
+ *
+ * @return
+ *   master and representor flags are set in switch_info according to
+ *   recognized parameters (if any).
+ */
+static void
+mlx5_sysfs_check_switch_info(bool device_dir,
+			     struct mlx5_switch_info *switch_info)
+{
+	switch (switch_info->name_type) {
+	case MLX5_PHYS_PORT_NAME_TYPE_UNKNOWN:
+		/*
+		 * Name is not recognized, assume the master,
+		 * check the device directory presence.
+		 */
+		switch_info->master = device_dir;
+		break;
+	case MLX5_PHYS_PORT_NAME_TYPE_NOTSET:
+		/*
+		 * Name is not set, this assumes the legacy naming
+		 * schema for master, just check if there is
+		 * a device directory.
+		 */
+		switch_info->master = device_dir;
+		break;
+	case MLX5_PHYS_PORT_NAME_TYPE_UPLINK:
+		/* New uplink naming schema recognized. */
+		switch_info->master = 1;
+		break;
+	case MLX5_PHYS_PORT_NAME_TYPE_LEGACY:
+		/* Legacy representors naming schema. */
+		switch_info->representor = !device_dir;
+		break;
+	case MLX5_PHYS_PORT_NAME_TYPE_PFHPF:
+		/* Fallthrough */
+	case MLX5_PHYS_PORT_NAME_TYPE_PFVF:
+		/* New representors naming schema. */
+		switch_info->representor = 1;
+		break;
+	}
+}
+
+/**
  * Get switch information associated with network interface.
  *
  * @param ifindex
@@ -1051,57 +1102,6 @@ mlx5_sysfs_switch_info(unsigned int ifindex, struct mlx5_switch_info *info)
 }
 
 /**
- * Analyze gathered port parameters via sysfs to recognize master
- * and representor devices for E-Switch configuration.
- *
- * @param[in] device_dir
- *   flag of presence of "device" directory under port device key.
- * @param[inout] switch_info
- *   Port information, including port name as a number and port name
- *   type if recognized
- *
- * @return
- *   master and representor flags are set in switch_info according to
- *   recognized parameters (if any).
- */
-void
-mlx5_sysfs_check_switch_info(bool device_dir,
-			     struct mlx5_switch_info *switch_info)
-{
-	switch (switch_info->name_type) {
-	case MLX5_PHYS_PORT_NAME_TYPE_UNKNOWN:
-		/*
-		 * Name is not recognized, assume the master,
-		 * check the device directory presence.
-		 */
-		switch_info->master = device_dir;
-		break;
-	case MLX5_PHYS_PORT_NAME_TYPE_NOTSET:
-		/*
-		 * Name is not set, this assumes the legacy naming
-		 * schema for master, just check if there is
-		 * a device directory.
-		 */
-		switch_info->master = device_dir;
-		break;
-	case MLX5_PHYS_PORT_NAME_TYPE_UPLINK:
-		/* New uplink naming schema recognized. */
-		switch_info->master = 1;
-		break;
-	case MLX5_PHYS_PORT_NAME_TYPE_LEGACY:
-		/* Legacy representors naming schema. */
-		switch_info->representor = !device_dir;
-		break;
-	case MLX5_PHYS_PORT_NAME_TYPE_PFHPF:
-		/* Fallthrough */
-	case MLX5_PHYS_PORT_NAME_TYPE_PFVF:
-		/* New representors naming schema. */
-		switch_info->representor = 1;
-		break;
-	}
-}
-
-/**
  * DPDK callback to retrieve plug-in module EEPROM information (type and size).
  *
  * @param dev
diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h
index 00ee2e3..147ff62 100644
--- a/drivers/net/mlx5/mlx5.h
+++ b/drivers/net/mlx5/mlx5.h
@@ -813,6 +813,10 @@ const uint32_t *mlx5_dev_supported_ptypes_get(struct rte_eth_dev *dev);
 int mlx5_dev_set_mtu(struct rte_eth_dev *dev, uint16_t mtu);
 int mlx5_hairpin_cap_get(struct rte_eth_dev *dev,
 			 struct rte_eth_hairpin_cap *cap);
+eth_rx_burst_t mlx5_select_rx_function(struct rte_eth_dev *dev);
+struct mlx5_priv *mlx5_port_to_eswitch_info(uint16_t port, bool valid);
+struct mlx5_priv *mlx5_dev_to_eswitch_info(struct rte_eth_dev *dev);
+int mlx5_dev_configure_rss_reta(struct rte_eth_dev *dev);
 
 /* mlx5_ethdev_os.c */
 
@@ -823,27 +827,17 @@ int mlx5_get_mtu(struct rte_eth_dev *dev, uint16_t *mtu);
 int mlx5_set_mtu(struct rte_eth_dev *dev, uint16_t mtu);
 int mlx5_read_clock(struct rte_eth_dev *dev, uint64_t *clock);
 int mlx5_link_update(struct rte_eth_dev *dev, int wait_to_complete);
-int mlx5_force_link_status_change(struct rte_eth_dev *dev, int status);
 int mlx5_dev_get_flow_ctrl(struct rte_eth_dev *dev,
 			   struct rte_eth_fc_conf *fc_conf);
 int mlx5_dev_set_flow_ctrl(struct rte_eth_dev *dev,
 			   struct rte_eth_fc_conf *fc_conf);
-void mlx5_dev_link_status_handler(void *arg);
 void mlx5_dev_interrupt_handler(void *arg);
 void mlx5_dev_interrupt_handler_devx(void *arg);
-void mlx5_dev_interrupt_handler_uninstall(struct rte_eth_dev *dev);
-void mlx5_dev_interrupt_handler_install(struct rte_eth_dev *dev);
 int mlx5_set_link_down(struct rte_eth_dev *dev);
 int mlx5_set_link_up(struct rte_eth_dev *dev);
 int mlx5_is_removed(struct rte_eth_dev *dev);
-eth_tx_burst_t mlx5_select_tx_function(struct rte_eth_dev *dev);
-eth_rx_burst_t mlx5_select_rx_function(struct rte_eth_dev *dev);
-struct mlx5_priv *mlx5_port_to_eswitch_info(uint16_t port, bool valid);
-struct mlx5_priv *mlx5_dev_to_eswitch_info(struct rte_eth_dev *dev);
 int mlx5_sysfs_switch_info(unsigned int ifindex,
 			   struct mlx5_switch_info *info);
-void mlx5_sysfs_check_switch_info(bool device_dir,
-				  struct mlx5_switch_info *switch_info);
 void mlx5_translate_port_name(const char *port_name_in,
 			      struct mlx5_switch_info *port_info_out);
 void mlx5_intr_callback_unregister(const struct rte_intr_handle *handle,
@@ -852,7 +846,6 @@ int mlx5_get_module_info(struct rte_eth_dev *dev,
 			 struct rte_eth_dev_module_info *modinfo);
 int mlx5_get_module_eeprom(struct rte_eth_dev *dev,
 			   struct rte_dev_eeprom_info *info);
-int mlx5_dev_configure_rss_reta(struct rte_eth_dev *dev);
 int mlx5_os_read_dev_stat(struct mlx5_priv *priv,
 			  const char *ctr_name, uint64_t *stat);
 int mlx5_os_read_dev_counters(struct rte_eth_dev *dev, uint64_t *stats);
@@ -1043,4 +1036,7 @@ int mlx5_txpp_xstats_get_names(struct rte_eth_dev *dev,
 			       unsigned int n, unsigned int n_used);
 void mlx5_txpp_interrupt_handler(void *cb_arg);
 
+/* mlx5_rxtx.c */
+
+eth_tx_burst_t mlx5_select_tx_function(struct rte_eth_dev *dev);
 #endif /* RTE_PMD_MLX5_H_ */
-- 
2.8.4


^ permalink raw reply	[flat|nested] 28+ messages in thread

* [dpdk-dev] [PATCH v2 7/8] net/mlx5: refactor multi process communication
  2020-07-19  7:11   ` [dpdk-dev] [PATCH v2 0/8] mlx5 PMD multi OS support - part #3 Ophir Munk
                       ` (5 preceding siblings ...)
  2020-07-19  7:11     ` [dpdk-dev] [PATCH v2 6/8] net/mlx5: header file cleanup Ophir Munk
@ 2020-07-19  7:11     ` Ophir Munk
  2020-07-19  7:11     ` [dpdk-dev] [PATCH v2 8/8] mlx5: remove inclusion of Verbs header files Ophir Munk
  7 siblings, 0 replies; 28+ messages in thread
From: Ophir Munk @ 2020-07-19  7:11 UTC (permalink / raw)
  To: dev; +Cc: Raslan Darawsheh, Ophir Munk, Matan Azrad

1. The shared data communication between the primary and the secondary
processes is implemented using Linux API. Move the Linux API code under
linux directory (file linux/mlx5_os.c).

2. File net/mlx5/mlx5_mp.c handles requests to the primary and secondary
processes (e.g. start_rxtx, stop_rxtx). It is Linux based so it is moved
under linux (new file linux/mlx5_mp_os.c).

Signed-off-by: Ophir Munk <ophirmu@mellanox.com>
Acked-by: Matan Azrad <matan@mellanox.com>
---
 drivers/net/mlx5/Makefile           |   2 +-
 drivers/net/mlx5/linux/meson.build  |   1 +
 drivers/net/mlx5/linux/mlx5_mp_os.c | 212 ++++++++++++++++++++++++++++++++++++
 drivers/net/mlx5/linux/mlx5_os.c    | 111 +++++++++++++++++++
 drivers/net/mlx5/meson.build        |   1 -
 drivers/net/mlx5/mlx5.c             | 114 +------------------
 drivers/net/mlx5/mlx5.h             |  13 ++-
 drivers/net/mlx5/mlx5_mp.c          | 212 ------------------------------------
 drivers/net/mlx5/mlx5_trigger.c     |   4 +-
 9 files changed, 337 insertions(+), 333 deletions(-)
 create mode 100644 drivers/net/mlx5/linux/mlx5_mp_os.c
 delete mode 100644 drivers/net/mlx5/mlx5_mp.c

diff --git a/drivers/net/mlx5/Makefile b/drivers/net/mlx5/Makefile
index 3c5f486..cca7c9e 100644
--- a/drivers/net/mlx5/Makefile
+++ b/drivers/net/mlx5/Makefile
@@ -30,12 +30,12 @@ SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5_flow.c
 SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5_flow_meter.c
 SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5_flow_dv.c
 SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5_flow_verbs.c
-SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5_mp.c
 SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5_utils.c
 SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += linux/mlx5_socket.c
 SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += linux/mlx5_os.c
 SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += linux/mlx5_ethdev_os.c
 SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += linux/mlx5_verbs.c
+SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += linux/mlx5_mp_os.c
 
 # Basic CFLAGS.
 CFLAGS += -O3
diff --git a/drivers/net/mlx5/linux/meson.build b/drivers/net/mlx5/linux/meson.build
index 14eed03..2def8e3 100644
--- a/drivers/net/mlx5/linux/meson.build
+++ b/drivers/net/mlx5/linux/meson.build
@@ -7,5 +7,6 @@ sources += files(
 	'mlx5_os.c',
 	'mlx5_ethdev_os.c',
 	'mlx5_verbs.c',
+	'mlx5_mp_os.c',
 )
 
diff --git a/drivers/net/mlx5/linux/mlx5_mp_os.c b/drivers/net/mlx5/linux/mlx5_mp_os.c
new file mode 100644
index 0000000..dd9a2c2
--- /dev/null
+++ b/drivers/net/mlx5/linux/mlx5_mp_os.c
@@ -0,0 +1,212 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright 2019 6WIND S.A.
+ * Copyright 2019 Mellanox Technologies, Ltd
+ */
+
+#include <stdio.h>
+#include <time.h>
+
+#include <rte_eal.h>
+#include <rte_ethdev_driver.h>
+#include <rte_string_fns.h>
+
+#include <mlx5_common_mp.h>
+#include <mlx5_common_mr.h>
+#include <mlx5_malloc.h>
+
+#include "mlx5.h"
+#include "mlx5_rxtx.h"
+#include "mlx5_utils.h"
+
+int
+mlx5_mp_os_primary_handle(const struct rte_mp_msg *mp_msg, const void *peer)
+{
+	struct rte_mp_msg mp_res;
+	struct mlx5_mp_param *res = (struct mlx5_mp_param *)mp_res.param;
+	const struct mlx5_mp_param *param =
+		(const struct mlx5_mp_param *)mp_msg->param;
+	struct rte_eth_dev *dev;
+	struct mlx5_priv *priv;
+	struct mr_cache_entry entry;
+	uint32_t lkey;
+	int ret;
+
+	MLX5_ASSERT(rte_eal_process_type() == RTE_PROC_PRIMARY);
+	if (!rte_eth_dev_is_valid_port(param->port_id)) {
+		rte_errno = ENODEV;
+		DRV_LOG(ERR, "port %u invalid port ID", param->port_id);
+		return -rte_errno;
+	}
+	dev = &rte_eth_devices[param->port_id];
+	priv = dev->data->dev_private;
+	switch (param->type) {
+	case MLX5_MP_REQ_CREATE_MR:
+		mp_init_msg(&priv->mp_id, &mp_res, param->type);
+		lkey = mlx5_mr_create_primary(priv->sh->pd,
+					      &priv->sh->share_cache,
+					      &entry, param->args.addr,
+					      priv->config.mr_ext_memseg_en);
+		if (lkey == UINT32_MAX)
+			res->result = -rte_errno;
+		ret = rte_mp_reply(&mp_res, peer);
+		break;
+	case MLX5_MP_REQ_VERBS_CMD_FD:
+		mp_init_msg(&priv->mp_id, &mp_res, param->type);
+		mp_res.num_fds = 1;
+		mp_res.fds[0] = ((struct ibv_context *)priv->sh->ctx)->cmd_fd;
+		res->result = 0;
+		ret = rte_mp_reply(&mp_res, peer);
+		break;
+	case MLX5_MP_REQ_QUEUE_STATE_MODIFY:
+		mp_init_msg(&priv->mp_id, &mp_res, param->type);
+		res->result = mlx5_queue_state_modify_primary
+					(dev, &param->args.state_modify);
+		ret = rte_mp_reply(&mp_res, peer);
+		break;
+	default:
+		rte_errno = EINVAL;
+		DRV_LOG(ERR, "port %u invalid mp request type",
+			dev->data->port_id);
+		return -rte_errno;
+	}
+	return ret;
+}
+
+/**
+ * IPC message handler of a secondary process.
+ *
+ * @param[in] dev
+ *   Pointer to Ethernet structure.
+ * @param[in] peer
+ *   Pointer to the peer socket path.
+ *
+ * @return
+ *   0 on success, a negative errno value otherwise and rte_errno is set.
+ */
+int
+mlx5_mp_os_secondary_handle(const struct rte_mp_msg *mp_msg, const void *peer)
+{
+	struct rte_mp_msg mp_res;
+	struct mlx5_mp_param *res = (struct mlx5_mp_param *)mp_res.param;
+	const struct mlx5_mp_param *param =
+		(const struct mlx5_mp_param *)mp_msg->param;
+	struct rte_eth_dev *dev;
+	struct mlx5_priv *priv;
+	int ret;
+
+	MLX5_ASSERT(rte_eal_process_type() == RTE_PROC_SECONDARY);
+	if (!rte_eth_dev_is_valid_port(param->port_id)) {
+		rte_errno = ENODEV;
+		DRV_LOG(ERR, "port %u invalid port ID", param->port_id);
+		return -rte_errno;
+	}
+	dev = &rte_eth_devices[param->port_id];
+	priv = dev->data->dev_private;
+	switch (param->type) {
+	case MLX5_MP_REQ_START_RXTX:
+		DRV_LOG(INFO, "port %u starting datapath", dev->data->port_id);
+		rte_mb();
+		dev->rx_pkt_burst = mlx5_select_rx_function(dev);
+		dev->tx_pkt_burst = mlx5_select_tx_function(dev);
+		mp_init_msg(&priv->mp_id, &mp_res, param->type);
+		res->result = 0;
+		ret = rte_mp_reply(&mp_res, peer);
+		break;
+	case MLX5_MP_REQ_STOP_RXTX:
+		DRV_LOG(INFO, "port %u stopping datapath", dev->data->port_id);
+		dev->rx_pkt_burst = removed_rx_burst;
+		dev->tx_pkt_burst = removed_tx_burst;
+		rte_mb();
+		mp_init_msg(&priv->mp_id, &mp_res, param->type);
+		res->result = 0;
+		ret = rte_mp_reply(&mp_res, peer);
+		break;
+	default:
+		rte_errno = EINVAL;
+		DRV_LOG(ERR, "port %u invalid mp request type",
+			dev->data->port_id);
+		return -rte_errno;
+	}
+	return ret;
+}
+
+/**
+ * Broadcast request of stopping/starting data-path to secondary processes.
+ *
+ * @param[in] dev
+ *   Pointer to Ethernet structure.
+ * @param[in] type
+ *   Request type.
+ */
+static void
+mp_req_on_rxtx(struct rte_eth_dev *dev, enum mlx5_mp_req_type type)
+{
+	struct rte_mp_msg mp_req;
+	struct rte_mp_msg *mp_res;
+	struct rte_mp_reply mp_rep;
+	struct mlx5_mp_param *res;
+	struct timespec ts = {.tv_sec = MLX5_MP_REQ_TIMEOUT_SEC, .tv_nsec = 0};
+	struct mlx5_priv *priv = dev->data->dev_private;
+	int ret;
+	int i;
+
+	MLX5_ASSERT(rte_eal_process_type() == RTE_PROC_PRIMARY);
+	if (!mlx5_shared_data->secondary_cnt)
+		return;
+	if (type != MLX5_MP_REQ_START_RXTX && type != MLX5_MP_REQ_STOP_RXTX) {
+		DRV_LOG(ERR, "port %u unknown request (req_type %d)",
+			dev->data->port_id, type);
+		return;
+	}
+	mp_init_msg(&priv->mp_id, &mp_req, type);
+	ret = rte_mp_request_sync(&mp_req, &mp_rep, &ts);
+	if (ret) {
+		if (rte_errno != ENOTSUP)
+			DRV_LOG(ERR, "port %u failed to request stop/start Rx/Tx (%d)",
+				dev->data->port_id, type);
+		goto exit;
+	}
+	if (mp_rep.nb_sent != mp_rep.nb_received) {
+		DRV_LOG(ERR,
+			"port %u not all secondaries responded (req_type %d)",
+			dev->data->port_id, type);
+		goto exit;
+	}
+	for (i = 0; i < mp_rep.nb_received; i++) {
+		mp_res = &mp_rep.msgs[i];
+		res = (struct mlx5_mp_param *)mp_res->param;
+		if (res->result) {
+			DRV_LOG(ERR, "port %u request failed on secondary #%d",
+				dev->data->port_id, i);
+			goto exit;
+		}
+	}
+exit:
+	mlx5_free(mp_rep.msgs);
+}
+
+/**
+ * Broadcast request of starting data-path to secondary processes. The request
+ * is synchronous.
+ *
+ * @param[in] dev
+ *   Pointer to Ethernet structure.
+ */
+void
+mlx5_mp_os_req_start_rxtx(struct rte_eth_dev *dev)
+{
+	mp_req_on_rxtx(dev, MLX5_MP_REQ_START_RXTX);
+}
+
+/**
+ * Broadcast request of stopping data-path to secondary processes. The request
+ * is synchronous.
+ *
+ * @param[in] dev
+ *   Pointer to Ethernet structure.
+ */
+void
+mlx5_mp_os_req_stop_rxtx(struct rte_eth_dev *dev)
+{
+	mp_req_on_rxtx(dev, MLX5_MP_REQ_STOP_RXTX);
+}
diff --git a/drivers/net/mlx5/linux/mlx5_os.c b/drivers/net/mlx5/linux/mlx5_os.c
index 4e21018..d5cf50c 100644
--- a/drivers/net/mlx5/linux/mlx5_os.c
+++ b/drivers/net/mlx5/linux/mlx5_os.c
@@ -67,6 +67,14 @@
 #define MLX5DV_CONTEXT_FLAGS_CQE_128B_COMP (1 << 4)
 #endif
 
+static const char *MZ_MLX5_PMD_SHARED_DATA = "mlx5_pmd_shared_data";
+
+/* Spinlock for mlx5_shared_data allocation. */
+static rte_spinlock_t mlx5_shared_data_lock = RTE_SPINLOCK_INITIALIZER;
+
+/* Process local data for secondary processes. */
+static struct mlx5_local_data mlx5_local_data;
+
 /**
  * Get mlx5 device attributes. The glue function query_device_ex() is called
  * with out parameter of type 'struct ibv_device_attr_ex *'. Then fill in mlx5
@@ -357,6 +365,109 @@ mlx5_os_free_shared_dr(struct mlx5_priv *priv)
 }
 
 /**
+ * Initialize shared data between primary and secondary process.
+ *
+ * A memzone is reserved by primary process and secondary processes attach to
+ * the memzone.
+ *
+ * @return
+ *   0 on success, a negative errno value otherwise and rte_errno is set.
+ */
+static int
+mlx5_init_shared_data(void)
+{
+	const struct rte_memzone *mz;
+	int ret = 0;
+
+	rte_spinlock_lock(&mlx5_shared_data_lock);
+	if (mlx5_shared_data == NULL) {
+		if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
+			/* Allocate shared memory. */
+			mz = rte_memzone_reserve(MZ_MLX5_PMD_SHARED_DATA,
+						 sizeof(*mlx5_shared_data),
+						 SOCKET_ID_ANY, 0);
+			if (mz == NULL) {
+				DRV_LOG(ERR,
+					"Cannot allocate mlx5 shared data");
+				ret = -rte_errno;
+				goto error;
+			}
+			mlx5_shared_data = mz->addr;
+			memset(mlx5_shared_data, 0, sizeof(*mlx5_shared_data));
+			rte_spinlock_init(&mlx5_shared_data->lock);
+		} else {
+			/* Lookup allocated shared memory. */
+			mz = rte_memzone_lookup(MZ_MLX5_PMD_SHARED_DATA);
+			if (mz == NULL) {
+				DRV_LOG(ERR,
+					"Cannot attach mlx5 shared data");
+				ret = -rte_errno;
+				goto error;
+			}
+			mlx5_shared_data = mz->addr;
+			memset(&mlx5_local_data, 0, sizeof(mlx5_local_data));
+		}
+	}
+error:
+	rte_spinlock_unlock(&mlx5_shared_data_lock);
+	return ret;
+}
+
+/**
+ * PMD global initialization.
+ *
+ * Independent from individual device, this function initializes global
+ * per-PMD data structures distinguishing primary and secondary processes.
+ * Hence, each initialization is called once per a process.
+ *
+ * @return
+ *   0 on success, a negative errno value otherwise and rte_errno is set.
+ */
+static int
+mlx5_init_once(void)
+{
+	struct mlx5_shared_data *sd;
+	struct mlx5_local_data *ld = &mlx5_local_data;
+	int ret = 0;
+
+	if (mlx5_init_shared_data())
+		return -rte_errno;
+	sd = mlx5_shared_data;
+	MLX5_ASSERT(sd);
+	rte_spinlock_lock(&sd->lock);
+	switch (rte_eal_process_type()) {
+	case RTE_PROC_PRIMARY:
+		if (sd->init_done)
+			break;
+		LIST_INIT(&sd->mem_event_cb_list);
+		rte_rwlock_init(&sd->mem_event_rwlock);
+		rte_mem_event_callback_register("MLX5_MEM_EVENT_CB",
+						mlx5_mr_mem_event_cb, NULL);
+		ret = mlx5_mp_init_primary(MLX5_MP_NAME,
+					   mlx5_mp_os_primary_handle);
+		if (ret)
+			goto out;
+		sd->init_done = true;
+		break;
+	case RTE_PROC_SECONDARY:
+		if (ld->init_done)
+			break;
+		ret = mlx5_mp_init_secondary(MLX5_MP_NAME,
+					     mlx5_mp_os_secondary_handle);
+		if (ret)
+			goto out;
+		++sd->secondary_cnt;
+		ld->init_done = true;
+		break;
+	default:
+		break;
+	}
+out:
+	rte_spinlock_unlock(&sd->lock);
+	return ret;
+}
+
+/**
  * Spawn an Ethernet device from Verbs information.
  *
  * @param dpdk_dev
diff --git a/drivers/net/mlx5/meson.build b/drivers/net/mlx5/meson.build
index e35d90b..3aefb85 100644
--- a/drivers/net/mlx5/meson.build
+++ b/drivers/net/mlx5/meson.build
@@ -22,7 +22,6 @@ sources = files(
 	'mlx5_rxmode.c',
 	'mlx5_rxq.c',
 	'mlx5_rxtx.c',
-	'mlx5_mp.c',
 	'mlx5_stats.c',
 	'mlx5_trigger.c',
 	'mlx5_txq.c',
diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c
index 517fbb4..f333338 100644
--- a/drivers/net/mlx5/mlx5.c
+++ b/drivers/net/mlx5/mlx5.c
@@ -185,16 +185,11 @@
 /* The default memory alloctor used in PMD. */
 #define MLX5_SYS_MEM_EN "sys_mem_en"
 
-static const char *MZ_MLX5_PMD_SHARED_DATA = "mlx5_pmd_shared_data";
-
 /* Shared memory between primary and secondary processes. */
 struct mlx5_shared_data *mlx5_shared_data;
 
-/* Spinlock for mlx5_shared_data allocation. */
-static rte_spinlock_t mlx5_shared_data_lock = RTE_SPINLOCK_INITIALIZER;
-
-/* Process local data for secondary processes. */
-static struct mlx5_local_data mlx5_local_data;
+/** Driver-specific log messages type. */
+int mlx5_logtype;
 
 static LIST_HEAD(, mlx5_dev_ctx_shared) mlx5_dev_ctx_list =
 						LIST_HEAD_INITIALIZER();
@@ -1116,55 +1111,6 @@ mlx5_alloc_table_hash_list(struct mlx5_priv *priv)
 }
 
 /**
- * Initialize shared data between primary and secondary process.
- *
- * A memzone is reserved by primary process and secondary processes attach to
- * the memzone.
- *
- * @return
- *   0 on success, a negative errno value otherwise and rte_errno is set.
- */
-static int
-mlx5_init_shared_data(void)
-{
-	const struct rte_memzone *mz;
-	int ret = 0;
-
-	rte_spinlock_lock(&mlx5_shared_data_lock);
-	if (mlx5_shared_data == NULL) {
-		if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
-			/* Allocate shared memory. */
-			mz = rte_memzone_reserve(MZ_MLX5_PMD_SHARED_DATA,
-						 sizeof(*mlx5_shared_data),
-						 SOCKET_ID_ANY, 0);
-			if (mz == NULL) {
-				DRV_LOG(ERR,
-					"Cannot allocate mlx5 shared data");
-				ret = -rte_errno;
-				goto error;
-			}
-			mlx5_shared_data = mz->addr;
-			memset(mlx5_shared_data, 0, sizeof(*mlx5_shared_data));
-			rte_spinlock_init(&mlx5_shared_data->lock);
-		} else {
-			/* Lookup allocated shared memory. */
-			mz = rte_memzone_lookup(MZ_MLX5_PMD_SHARED_DATA);
-			if (mz == NULL) {
-				DRV_LOG(ERR,
-					"Cannot attach mlx5 shared data");
-				ret = -rte_errno;
-				goto error;
-			}
-			mlx5_shared_data = mz->addr;
-			memset(&mlx5_local_data, 0, sizeof(mlx5_local_data));
-		}
-	}
-error:
-	rte_spinlock_unlock(&mlx5_shared_data_lock);
-	return ret;
-}
-
-/**
  * Retrieve integer value from environment variable.
  *
  * @param[in] name
@@ -1305,7 +1251,7 @@ mlx5_dev_close(struct rte_eth_dev *dev)
 	dev->tx_pkt_burst = removed_tx_burst;
 	rte_wmb();
 	/* Disable datapath on secondary process. */
-	mlx5_mp_req_stop_rxtx(dev);
+	mlx5_mp_os_req_stop_rxtx(dev);
 	/* Free the eCPRI flex parser resource. */
 	mlx5_flex_parser_ecpri_release(dev);
 	if (priv->rxqs != NULL) {
@@ -1635,60 +1581,6 @@ mlx5_args(struct mlx5_dev_config *config, struct rte_devargs *devargs)
 }
 
 /**
- * PMD global initialization.
- *
- * Independent from individual device, this function initializes global
- * per-PMD data structures distinguishing primary and secondary processes.
- * Hence, each initialization is called once per a process.
- *
- * @return
- *   0 on success, a negative errno value otherwise and rte_errno is set.
- */
-int
-mlx5_init_once(void)
-{
-	struct mlx5_shared_data *sd;
-	struct mlx5_local_data *ld = &mlx5_local_data;
-	int ret = 0;
-
-	if (mlx5_init_shared_data())
-		return -rte_errno;
-	sd = mlx5_shared_data;
-	MLX5_ASSERT(sd);
-	rte_spinlock_lock(&sd->lock);
-	switch (rte_eal_process_type()) {
-	case RTE_PROC_PRIMARY:
-		if (sd->init_done)
-			break;
-		LIST_INIT(&sd->mem_event_cb_list);
-		rte_rwlock_init(&sd->mem_event_rwlock);
-		rte_mem_event_callback_register("MLX5_MEM_EVENT_CB",
-						mlx5_mr_mem_event_cb, NULL);
-		ret = mlx5_mp_init_primary(MLX5_MP_NAME,
-					   mlx5_mp_primary_handle);
-		if (ret)
-			goto out;
-		sd->init_done = true;
-		break;
-	case RTE_PROC_SECONDARY:
-		if (ld->init_done)
-			break;
-		ret = mlx5_mp_init_secondary(MLX5_MP_NAME,
-					     mlx5_mp_secondary_handle);
-		if (ret)
-			goto out;
-		++sd->secondary_cnt;
-		ld->init_done = true;
-		break;
-	default:
-		break;
-	}
-out:
-	rte_spinlock_unlock(&sd->lock);
-	return ret;
-}
-
-/**
  * Configures the minimal amount of data to inline into WQE
  * while sending packets.
  *
diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h
index 147ff62..cc02531 100644
--- a/drivers/net/mlx5/mlx5.h
+++ b/drivers/net/mlx5/mlx5.h
@@ -792,7 +792,6 @@ void mlx5_set_min_inline(struct mlx5_dev_spawn_data *spawn,
 void mlx5_set_metadata_mask(struct rte_eth_dev *dev);
 int mlx5_dev_check_sibling_config(struct mlx5_priv *priv,
 				  struct mlx5_dev_config *config);
-int mlx5_init_once(void);
 int mlx5_dev_configure(struct rte_eth_dev *dev);
 int mlx5_dev_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *info);
 int mlx5_fw_version_get(struct rte_eth_dev *dev, char *fw_ver, size_t fw_size);
@@ -977,11 +976,13 @@ void mlx5_flow_rxq_dynf_metadata_set(struct rte_eth_dev *dev);
 int mlx5_flow_get_aged_flows(struct rte_eth_dev *dev, void **contexts,
 			uint32_t nb_contexts, struct rte_flow_error *error);
 
-/* mlx5_mp.c */
-int mlx5_mp_primary_handle(const struct rte_mp_msg *mp_msg, const void *peer);
-int mlx5_mp_secondary_handle(const struct rte_mp_msg *mp_msg, const void *peer);
-void mlx5_mp_req_start_rxtx(struct rte_eth_dev *dev);
-void mlx5_mp_req_stop_rxtx(struct rte_eth_dev *dev);
+/* mlx5_mp_os.c */
+int mlx5_mp_os_primary_handle(const struct rte_mp_msg *mp_msg,
+			      const void *peer);
+int mlx5_mp_os_secondary_handle(const struct rte_mp_msg *mp_msg,
+				const void *peer);
+void mlx5_mp_os_req_start_rxtx(struct rte_eth_dev *dev);
+void mlx5_mp_os_req_stop_rxtx(struct rte_eth_dev *dev);
 
 /* mlx5_socket.c */
 
diff --git a/drivers/net/mlx5/mlx5_mp.c b/drivers/net/mlx5/mlx5_mp.c
deleted file mode 100644
index cf6e33b..0000000
--- a/drivers/net/mlx5/mlx5_mp.c
+++ /dev/null
@@ -1,212 +0,0 @@
-/* SPDX-License-Identifier: BSD-3-Clause
- * Copyright 2019 6WIND S.A.
- * Copyright 2019 Mellanox Technologies, Ltd
- */
-
-#include <stdio.h>
-#include <time.h>
-
-#include <rte_eal.h>
-#include <rte_ethdev_driver.h>
-#include <rte_string_fns.h>
-
-#include <mlx5_common_mp.h>
-#include <mlx5_common_mr.h>
-#include <mlx5_malloc.h>
-
-#include "mlx5.h"
-#include "mlx5_rxtx.h"
-#include "mlx5_utils.h"
-
-int
-mlx5_mp_primary_handle(const struct rte_mp_msg *mp_msg, const void *peer)
-{
-	struct rte_mp_msg mp_res;
-	struct mlx5_mp_param *res = (struct mlx5_mp_param *)mp_res.param;
-	const struct mlx5_mp_param *param =
-		(const struct mlx5_mp_param *)mp_msg->param;
-	struct rte_eth_dev *dev;
-	struct mlx5_priv *priv;
-	struct mr_cache_entry entry;
-	uint32_t lkey;
-	int ret;
-
-	MLX5_ASSERT(rte_eal_process_type() == RTE_PROC_PRIMARY);
-	if (!rte_eth_dev_is_valid_port(param->port_id)) {
-		rte_errno = ENODEV;
-		DRV_LOG(ERR, "port %u invalid port ID", param->port_id);
-		return -rte_errno;
-	}
-	dev = &rte_eth_devices[param->port_id];
-	priv = dev->data->dev_private;
-	switch (param->type) {
-	case MLX5_MP_REQ_CREATE_MR:
-		mp_init_msg(&priv->mp_id, &mp_res, param->type);
-		lkey = mlx5_mr_create_primary(priv->sh->pd,
-					      &priv->sh->share_cache,
-					      &entry, param->args.addr,
-					      priv->config.mr_ext_memseg_en);
-		if (lkey == UINT32_MAX)
-			res->result = -rte_errno;
-		ret = rte_mp_reply(&mp_res, peer);
-		break;
-	case MLX5_MP_REQ_VERBS_CMD_FD:
-		mp_init_msg(&priv->mp_id, &mp_res, param->type);
-		mp_res.num_fds = 1;
-		mp_res.fds[0] = ((struct ibv_context *)priv->sh->ctx)->cmd_fd;
-		res->result = 0;
-		ret = rte_mp_reply(&mp_res, peer);
-		break;
-	case MLX5_MP_REQ_QUEUE_STATE_MODIFY:
-		mp_init_msg(&priv->mp_id, &mp_res, param->type);
-		res->result = mlx5_queue_state_modify_primary
-					(dev, &param->args.state_modify);
-		ret = rte_mp_reply(&mp_res, peer);
-		break;
-	default:
-		rte_errno = EINVAL;
-		DRV_LOG(ERR, "port %u invalid mp request type",
-			dev->data->port_id);
-		return -rte_errno;
-	}
-	return ret;
-}
-
-/**
- * IPC message handler of a secondary process.
- *
- * @param[in] dev
- *   Pointer to Ethernet structure.
- * @param[in] peer
- *   Pointer to the peer socket path.
- *
- * @return
- *   0 on success, a negative errno value otherwise and rte_errno is set.
- */
-int
-mlx5_mp_secondary_handle(const struct rte_mp_msg *mp_msg, const void *peer)
-{
-	struct rte_mp_msg mp_res;
-	struct mlx5_mp_param *res = (struct mlx5_mp_param *)mp_res.param;
-	const struct mlx5_mp_param *param =
-		(const struct mlx5_mp_param *)mp_msg->param;
-	struct rte_eth_dev *dev;
-	struct mlx5_priv *priv;
-	int ret;
-
-	MLX5_ASSERT(rte_eal_process_type() == RTE_PROC_SECONDARY);
-	if (!rte_eth_dev_is_valid_port(param->port_id)) {
-		rte_errno = ENODEV;
-		DRV_LOG(ERR, "port %u invalid port ID", param->port_id);
-		return -rte_errno;
-	}
-	dev = &rte_eth_devices[param->port_id];
-	priv = dev->data->dev_private;
-	switch (param->type) {
-	case MLX5_MP_REQ_START_RXTX:
-		DRV_LOG(INFO, "port %u starting datapath", dev->data->port_id);
-		rte_mb();
-		dev->rx_pkt_burst = mlx5_select_rx_function(dev);
-		dev->tx_pkt_burst = mlx5_select_tx_function(dev);
-		mp_init_msg(&priv->mp_id, &mp_res, param->type);
-		res->result = 0;
-		ret = rte_mp_reply(&mp_res, peer);
-		break;
-	case MLX5_MP_REQ_STOP_RXTX:
-		DRV_LOG(INFO, "port %u stopping datapath", dev->data->port_id);
-		dev->rx_pkt_burst = removed_rx_burst;
-		dev->tx_pkt_burst = removed_tx_burst;
-		rte_mb();
-		mp_init_msg(&priv->mp_id, &mp_res, param->type);
-		res->result = 0;
-		ret = rte_mp_reply(&mp_res, peer);
-		break;
-	default:
-		rte_errno = EINVAL;
-		DRV_LOG(ERR, "port %u invalid mp request type",
-			dev->data->port_id);
-		return -rte_errno;
-	}
-	return ret;
-}
-
-/**
- * Broadcast request of stopping/starting data-path to secondary processes.
- *
- * @param[in] dev
- *   Pointer to Ethernet structure.
- * @param[in] type
- *   Request type.
- */
-static void
-mp_req_on_rxtx(struct rte_eth_dev *dev, enum mlx5_mp_req_type type)
-{
-	struct rte_mp_msg mp_req;
-	struct rte_mp_msg *mp_res;
-	struct rte_mp_reply mp_rep;
-	struct mlx5_mp_param *res;
-	struct timespec ts = {.tv_sec = MLX5_MP_REQ_TIMEOUT_SEC, .tv_nsec = 0};
-	struct mlx5_priv *priv = dev->data->dev_private;
-	int ret;
-	int i;
-
-	MLX5_ASSERT(rte_eal_process_type() == RTE_PROC_PRIMARY);
-	if (!mlx5_shared_data->secondary_cnt)
-		return;
-	if (type != MLX5_MP_REQ_START_RXTX && type != MLX5_MP_REQ_STOP_RXTX) {
-		DRV_LOG(ERR, "port %u unknown request (req_type %d)",
-			dev->data->port_id, type);
-		return;
-	}
-	mp_init_msg(&priv->mp_id, &mp_req, type);
-	ret = rte_mp_request_sync(&mp_req, &mp_rep, &ts);
-	if (ret) {
-		if (rte_errno != ENOTSUP)
-			DRV_LOG(ERR, "port %u failed to request stop/start Rx/Tx (%d)",
-				dev->data->port_id, type);
-		goto exit;
-	}
-	if (mp_rep.nb_sent != mp_rep.nb_received) {
-		DRV_LOG(ERR,
-			"port %u not all secondaries responded (req_type %d)",
-			dev->data->port_id, type);
-		goto exit;
-	}
-	for (i = 0; i < mp_rep.nb_received; i++) {
-		mp_res = &mp_rep.msgs[i];
-		res = (struct mlx5_mp_param *)mp_res->param;
-		if (res->result) {
-			DRV_LOG(ERR, "port %u request failed on secondary #%d",
-				dev->data->port_id, i);
-			goto exit;
-		}
-	}
-exit:
-	mlx5_free(mp_rep.msgs);
-}
-
-/**
- * Broadcast request of starting data-path to secondary processes. The request
- * is synchronous.
- *
- * @param[in] dev
- *   Pointer to Ethernet structure.
- */
-void
-mlx5_mp_req_start_rxtx(struct rte_eth_dev *dev)
-{
-	mp_req_on_rxtx(dev, MLX5_MP_REQ_START_RXTX);
-}
-
-/**
- * Broadcast request of stopping data-path to secondary processes. The request
- * is synchronous.
- *
- * @param[in] dev
- *   Pointer to Ethernet structure.
- */
-void
-mlx5_mp_req_stop_rxtx(struct rte_eth_dev *dev)
-{
-	mp_req_on_rxtx(dev, MLX5_MP_REQ_STOP_RXTX);
-}
diff --git a/drivers/net/mlx5/mlx5_trigger.c b/drivers/net/mlx5/mlx5_trigger.c
index 6e5a730..6f1e6d4 100644
--- a/drivers/net/mlx5/mlx5_trigger.c
+++ b/drivers/net/mlx5/mlx5_trigger.c
@@ -350,7 +350,7 @@ mlx5_dev_start(struct rte_eth_dev *dev)
 	dev->tx_pkt_burst = mlx5_select_tx_function(dev);
 	dev->rx_pkt_burst = mlx5_select_rx_function(dev);
 	/* Enable datapath on secondary process. */
-	mlx5_mp_req_start_rxtx(dev);
+	mlx5_mp_os_req_start_rxtx(dev);
 	if (priv->sh->intr_handle.fd >= 0) {
 		priv->sh->port[priv->dev_port - 1].ih_port_id =
 					(uint32_t)dev->data->port_id;
@@ -396,7 +396,7 @@ mlx5_dev_stop(struct rte_eth_dev *dev)
 	dev->tx_pkt_burst = removed_tx_burst;
 	rte_wmb();
 	/* Disable datapath on secondary process. */
-	mlx5_mp_req_stop_rxtx(dev);
+	mlx5_mp_os_req_stop_rxtx(dev);
 	usleep(1000 * priv->rxqs_n);
 	DRV_LOG(DEBUG, "port %u stopping device", dev->data->port_id);
 	mlx5_flow_stop_default(dev);
-- 
2.8.4


^ permalink raw reply	[flat|nested] 28+ messages in thread

* [dpdk-dev] [PATCH v2 8/8] mlx5: remove inclusion of Verbs header files
  2020-07-19  7:11   ` [dpdk-dev] [PATCH v2 0/8] mlx5 PMD multi OS support - part #3 Ophir Munk
                       ` (6 preceding siblings ...)
  2020-07-19  7:11     ` [dpdk-dev] [PATCH v2 7/8] net/mlx5: refactor multi process communication Ophir Munk
@ 2020-07-19  7:11     ` Ophir Munk
  2020-07-19 10:18       ` [dpdk-dev] [PATCH v3 0/8] mlx5 PMD multi OS support - part #3 Ophir Munk
  7 siblings, 1 reply; 28+ messages in thread
From: Ophir Munk @ 2020-07-19  7:11 UTC (permalink / raw)
  To: dev; +Cc: Raslan Darawsheh, Ophir Munk, Matan Azrad

Several source files include Verbs header files as in (1). These source
files will not compile under non-Linux operating systems. This commit
removes this inclusion in two cases:

Case 1: There is no usage of ibv_* or mlx5dv_* symbols in the source
file so the inclusion in (1) can be safely removed.

Case 2: Verbs symbols are used. Please note the inclusion in (1) already
appears in file linux/mlx5_glue.h (which represents the interface
to the rdma-core library). Therefore, replace (1) in the source file
with (2).  Under non-Linux operating systems - file mlx5_glue.h will not
include (1).

(1)
 #include <infiniband/verbs.h>
 #include <infiniband/mlx5dv.h>

(2)
 #include <mlx5_glue.h>

Signed-off-by: Ophir Munk <ophirmu@mellanox.com>
Acked-by: Matan Azrad <matan@mellanox.com>
---
 drivers/common/mlx5/linux/mlx5_common_os.h    |  7 +------
 drivers/common/mlx5/linux/mlx5_common_verbs.c | 15 ---------------
 drivers/common/mlx5/mlx5_common_mp.h          | 11 +----------
 drivers/common/mlx5/mlx5_common_mr.h          | 11 +----------
 drivers/common/mlx5/mlx5_prm.h                | 11 +----------
 drivers/net/mlx5/linux/mlx5_os.c              | 10 ----------
 drivers/net/mlx5/linux/mlx5_verbs.c           | 14 --------------
 drivers/net/mlx5/mlx5.c                       | 10 ----------
 drivers/net/mlx5/mlx5.h                       | 10 ----------
 drivers/net/mlx5/mlx5_flow.c                  | 11 +----------
 drivers/net/mlx5/mlx5_flow.h                  | 11 +----------
 drivers/net/mlx5/mlx5_flow_dv.c               | 11 +----------
 drivers/net/mlx5/mlx5_flow_verbs.c            | 10 ----------
 drivers/net/mlx5/mlx5_mac.c                   | 10 ----------
 drivers/net/mlx5/mlx5_mr.c                    |  9 ---------
 drivers/net/mlx5/mlx5_mr.h                    | 11 -----------
 drivers/net/mlx5/mlx5_rss.c                   | 10 ----------
 drivers/net/mlx5/mlx5_rxmode.c                | 11 +----------
 drivers/net/mlx5/mlx5_rxq.c                   | 11 -----------
 drivers/net/mlx5/mlx5_rxtx.c                  | 12 +-----------
 drivers/net/mlx5/mlx5_rxtx.h                  | 11 -----------
 drivers/net/mlx5/mlx5_rxtx_vec.c              | 12 +-----------
 drivers/net/mlx5/mlx5_txq.c                   | 11 -----------
 drivers/net/mlx5/mlx5_vlan.c                  | 17 -----------------
 24 files changed, 10 insertions(+), 257 deletions(-)

diff --git a/drivers/common/mlx5/linux/mlx5_common_os.h b/drivers/common/mlx5/linux/mlx5_common_os.h
index 9a6872c..55c0902 100644
--- a/drivers/common/mlx5/linux/mlx5_common_os.h
+++ b/drivers/common/mlx5/linux/mlx5_common_os.h
@@ -15,12 +15,7 @@
 #include <rte_devargs.h>
 
 #include "mlx5_autoconf.h"
-#ifdef HAVE_INFINIBAND_VERBS_H
-#include <infiniband/verbs.h>
-#endif
-#ifdef HAVE_INFINIBAND_MLX5DV_H
-#include <infiniband/mlx5dv.h>
-#endif
+#include "mlx5_glue.h"
 
 /**
  * Get device name. Given an ibv_device pointer - return a
diff --git a/drivers/common/mlx5/linux/mlx5_common_verbs.c b/drivers/common/mlx5/linux/mlx5_common_verbs.c
index a2fc7a3..339535d 100644
--- a/drivers/common/mlx5/linux/mlx5_common_verbs.c
+++ b/drivers/common/mlx5/linux/mlx5_common_verbs.c
@@ -10,22 +10,7 @@
 #include <sys/mman.h>
 #include <inttypes.h>
 
-/* Verbs header. */
-/* ISO C doesn't support unnamed structs/unions, disabling -pedantic. */
 #include "mlx5_autoconf.h"
-#ifdef PEDANTIC
-#pragma GCC diagnostic ignored "-Wpedantic"
-#endif
-#ifdef HAVE_INFINIBAND_VERBS_H
-#include <infiniband/verbs.h>
-#endif
-#ifdef HAVE_INFINIBAND_MLX5DV_H
-#include <infiniband/mlx5dv.h>
-#endif
-#ifdef PEDANTIC
-#pragma GCC diagnostic error "-Wpedantic"
-#endif
-
 #include <mlx5_glue.h>
 #include <mlx5_common.h>
 #include <mlx5_common_mr.h>
diff --git a/drivers/common/mlx5/mlx5_common_mp.h b/drivers/common/mlx5/mlx5_common_mp.h
index 05466fd..64260c0 100644
--- a/drivers/common/mlx5/mlx5_common_mp.h
+++ b/drivers/common/mlx5/mlx5_common_mp.h
@@ -6,16 +6,7 @@
 #ifndef RTE_PMD_MLX5_COMMON_MP_H_
 #define RTE_PMD_MLX5_COMMON_MP_H_
 
-/* Verbs header. */
-/* ISO C doesn't support unnamed structs/unions, disabling -pedantic. */
-#ifdef PEDANTIC
-#pragma GCC diagnostic ignored "-Wpedantic"
-#endif
-#include <infiniband/verbs.h>
-#ifdef PEDANTIC
-#pragma GCC diagnostic error "-Wpedantic"
-#endif
-
+#include <mlx5_glue.h>
 #include <rte_eal.h>
 #include <rte_string_fns.h>
 
diff --git a/drivers/common/mlx5/mlx5_common_mr.h b/drivers/common/mlx5/mlx5_common_mr.h
index b23ee66..a2c426d 100644
--- a/drivers/common/mlx5/mlx5_common_mr.h
+++ b/drivers/common/mlx5/mlx5_common_mr.h
@@ -10,21 +10,12 @@
 #include <stdint.h>
 #include <sys/queue.h>
 
-/* Verbs header. */
-/* ISO C doesn't support unnamed structs/unions, disabling -pedantic. */
-#ifdef PEDANTIC
-#pragma GCC diagnostic ignored "-Wpedantic"
-#endif
-#include <infiniband/verbs.h>
-#include <infiniband/mlx5dv.h>
-#ifdef PEDANTIC
-#pragma GCC diagnostic error "-Wpedantic"
-#endif
 
 #include <rte_rwlock.h>
 #include <rte_bitmap.h>
 #include <rte_memory.h>
 
+#include "mlx5_glue.h"
 #include "mlx5_common_mp.h"
 
 /* Size of per-queue MR cache array for linear search. */
diff --git a/drivers/common/mlx5/mlx5_prm.h b/drivers/common/mlx5/mlx5_prm.h
index 83fe3af..b9c85c1 100644
--- a/drivers/common/mlx5/mlx5_prm.h
+++ b/drivers/common/mlx5/mlx5_prm.h
@@ -6,21 +6,12 @@
 #ifndef RTE_PMD_MLX5_PRM_H_
 #define RTE_PMD_MLX5_PRM_H_
 
-/* Verbs header. */
-/* ISO C doesn't support unnamed structs/unions, disabling -pedantic. */
-#ifdef PEDANTIC
-#pragma GCC diagnostic ignored "-Wpedantic"
-#endif
-#include <infiniband/mlx5dv.h>
-#ifdef PEDANTIC
-#pragma GCC diagnostic error "-Wpedantic"
-#endif
-
 #include <unistd.h>
 
 #include <rte_vect.h>
 #include <rte_byteorder.h>
 
+#include <mlx5_glue.h>
 #include "mlx5_autoconf.h"
 
 /* RSS hash key size. */
diff --git a/drivers/net/mlx5/linux/mlx5_os.c b/drivers/net/mlx5/linux/mlx5_os.c
index d5cf50c..d376021 100644
--- a/drivers/net/mlx5/linux/mlx5_os.c
+++ b/drivers/net/mlx5/linux/mlx5_os.c
@@ -15,16 +15,6 @@
 #include <linux/ethtool.h>
 #include <fcntl.h>
 
-/* Verbs header. */
-/* ISO C doesn't support unnamed structs/unions, disabling -pedantic. */
-#ifdef PEDANTIC
-#pragma GCC diagnostic ignored "-Wpedantic"
-#endif
-#include <infiniband/verbs.h>
-#ifdef PEDANTIC
-#pragma GCC diagnostic error "-Wpedantic"
-#endif
-
 #include <rte_malloc.h>
 #include <rte_ethdev_driver.h>
 #include <rte_ethdev_pci.h>
diff --git a/drivers/net/mlx5/linux/mlx5_verbs.c b/drivers/net/mlx5/linux/mlx5_verbs.c
index 5ac6982..d41b0fe 100644
--- a/drivers/net/mlx5/linux/mlx5_verbs.c
+++ b/drivers/net/mlx5/linux/mlx5_verbs.c
@@ -9,21 +9,7 @@
 #include <unistd.h>
 #include <inttypes.h>
 
-/* Verbs header. */
-/* ISO C doesn't support unnamed structs/unions, disabling -pedantic. */
 #include "mlx5_autoconf.h"
-#ifdef PEDANTIC
-#pragma GCC diagnostic ignored "-Wpedantic"
-#endif
-#ifdef HAVE_INFINIBAND_VERBS_H
-#include <infiniband/verbs.h>
-#endif
-#ifdef HAVE_INFINIBAND_MLX5DV_H
-#include <infiniband/mlx5dv.h>
-#endif
-#ifdef PEDANTIC
-#pragma GCC diagnostic error "-Wpedantic"
-#endif
 
 #include <rte_mbuf.h>
 #include <rte_malloc.h>
diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c
index f333338..d2f45a4 100644
--- a/drivers/net/mlx5/mlx5.c
+++ b/drivers/net/mlx5/mlx5.c
@@ -13,16 +13,6 @@
 #include <sys/mman.h>
 #include <linux/rtnetlink.h>
 
-/* Verbs header. */
-/* ISO C doesn't support unnamed structs/unions, disabling -pedantic. */
-#ifdef PEDANTIC
-#pragma GCC diagnostic ignored "-Wpedantic"
-#endif
-#include <infiniband/verbs.h>
-#ifdef PEDANTIC
-#pragma GCC diagnostic error "-Wpedantic"
-#endif
-
 #include <rte_malloc.h>
 #include <rte_ethdev_driver.h>
 #include <rte_ethdev_pci.h>
diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h
index cc02531..5a7893d 100644
--- a/drivers/net/mlx5/mlx5.h
+++ b/drivers/net/mlx5/mlx5.h
@@ -14,16 +14,6 @@
 #include <netinet/in.h>
 #include <sys/queue.h>
 
-/* Verbs header. */
-/* ISO C doesn't support unnamed structs/unions, disabling -pedantic. */
-#ifdef PEDANTIC
-#pragma GCC diagnostic ignored "-Wpedantic"
-#endif
-#include <infiniband/verbs.h>
-#ifdef PEDANTIC
-#pragma GCC diagnostic error "-Wpedantic"
-#endif
-
 #include <rte_pci.h>
 #include <rte_ether.h>
 #include <rte_ethdev_driver.h>
diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c
index 52047db..e83cf83 100644
--- a/drivers/net/mlx5/mlx5_flow.c
+++ b/drivers/net/mlx5/mlx5_flow.c
@@ -10,16 +10,6 @@
 #include <string.h>
 #include <stdbool.h>
 
-/* Verbs header. */
-/* ISO C doesn't support unnamed structs/unions, disabling -pedantic. */
-#ifdef PEDANTIC
-#pragma GCC diagnostic ignored "-Wpedantic"
-#endif
-#include <infiniband/verbs.h>
-#ifdef PEDANTIC
-#pragma GCC diagnostic error "-Wpedantic"
-#endif
-
 #include <rte_common.h>
 #include <rte_ether.h>
 #include <rte_ethdev_driver.h>
@@ -29,6 +19,7 @@
 #include <rte_malloc.h>
 #include <rte_ip.h>
 
+#include <mlx5_glue.h>
 #include <mlx5_devx_cmds.h>
 #include <mlx5_prm.h>
 #include <mlx5_malloc.h>
diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h
index 314b5e3..73cfa6e 100644
--- a/drivers/net/mlx5/mlx5_flow.h
+++ b/drivers/net/mlx5/mlx5_flow.h
@@ -11,20 +11,11 @@
 #include <stdint.h>
 #include <string.h>
 
-/* Verbs header. */
-/* ISO C doesn't support unnamed structs/unions, disabling -pedantic. */
-#ifdef PEDANTIC
-#pragma GCC diagnostic ignored "-Wpedantic"
-#endif
-#include <infiniband/verbs.h>
-#ifdef PEDANTIC
-#pragma GCC diagnostic error "-Wpedantic"
-#endif
-
 #include <rte_atomic.h>
 #include <rte_alarm.h>
 #include <rte_mtr.h>
 
+#include <mlx5_glue.h>
 #include <mlx5_prm.h>
 
 #include "mlx5.h"
diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c
index 4121f9d..bd0d244 100644
--- a/drivers/net/mlx5/mlx5_flow_dv.c
+++ b/drivers/net/mlx5/mlx5_flow_dv.c
@@ -8,16 +8,6 @@
 #include <string.h>
 #include <unistd.h>
 
-/* Verbs header. */
-/* ISO C doesn't support unnamed structs/unions, disabling -pedantic. */
-#ifdef PEDANTIC
-#pragma GCC diagnostic ignored "-Wpedantic"
-#endif
-#include <infiniband/verbs.h>
-#ifdef PEDANTIC
-#pragma GCC diagnostic error "-Wpedantic"
-#endif
-
 #include <rte_common.h>
 #include <rte_ether.h>
 #include <rte_ethdev_driver.h>
@@ -31,6 +21,7 @@
 #include <rte_gtp.h>
 #include <rte_eal_paging.h>
 
+#include <mlx5_glue.h>
 #include <mlx5_devx_cmds.h>
 #include <mlx5_prm.h>
 #include <mlx5_malloc.h>
diff --git a/drivers/net/mlx5/mlx5_flow_verbs.c b/drivers/net/mlx5/mlx5_flow_verbs.c
index 5d11ba7..905a122 100644
--- a/drivers/net/mlx5/mlx5_flow_verbs.c
+++ b/drivers/net/mlx5/mlx5_flow_verbs.c
@@ -8,16 +8,6 @@
 #include <stdint.h>
 #include <string.h>
 
-/* Verbs header. */
-/* ISO C doesn't support unnamed structs/unions, disabling -pedantic. */
-#ifdef PEDANTIC
-#pragma GCC diagnostic ignored "-Wpedantic"
-#endif
-#include <infiniband/verbs.h>
-#ifdef PEDANTIC
-#pragma GCC diagnostic error "-Wpedantic"
-#endif
-
 #include <rte_common.h>
 #include <rte_ether.h>
 #include <rte_ethdev_driver.h>
diff --git a/drivers/net/mlx5/mlx5_mac.c b/drivers/net/mlx5/mlx5_mac.c
index 2a88086..2d808d6 100644
--- a/drivers/net/mlx5/mlx5_mac.c
+++ b/drivers/net/mlx5/mlx5_mac.c
@@ -12,16 +12,6 @@
 #include <sys/ioctl.h>
 #include <arpa/inet.h>
 
-/* Verbs header. */
-/* ISO C doesn't support unnamed structs/unions, disabling -pedantic. */
-#ifdef PEDANTIC
-#pragma GCC diagnostic ignored "-Wpedantic"
-#endif
-#include <infiniband/verbs.h>
-#ifdef PEDANTIC
-#pragma GCC diagnostic error "-Wpedantic"
-#endif
-
 #include <rte_ether.h>
 #include <rte_ethdev_driver.h>
 #include <rte_common.h>
diff --git a/drivers/net/mlx5/mlx5_mr.c b/drivers/net/mlx5/mlx5_mr.c
index 3b781b6..dbcf0aa 100644
--- a/drivers/net/mlx5/mlx5_mr.c
+++ b/drivers/net/mlx5/mlx5_mr.c
@@ -3,21 +3,12 @@
  * Copyright 2016 Mellanox Technologies, Ltd
  */
 
-#ifdef PEDANTIC
-#pragma GCC diagnostic ignored "-Wpedantic"
-#endif
-#include <infiniband/verbs.h>
-#ifdef PEDANTIC
-#pragma GCC diagnostic error "-Wpedantic"
-#endif
-
 #include <rte_eal_memconfig.h>
 #include <rte_mempool.h>
 #include <rte_malloc.h>
 #include <rte_rwlock.h>
 #include <rte_bus_pci.h>
 
-#include <mlx5_glue.h>
 #include <mlx5_common_mp.h>
 #include <mlx5_common_mr.h>
 
diff --git a/drivers/net/mlx5/mlx5_mr.h b/drivers/net/mlx5/mlx5_mr.h
index 0c5877b..4a7fab6 100644
--- a/drivers/net/mlx5/mlx5_mr.h
+++ b/drivers/net/mlx5/mlx5_mr.h
@@ -10,17 +10,6 @@
 #include <stdint.h>
 #include <sys/queue.h>
 
-/* Verbs header. */
-/* ISO C doesn't support unnamed structs/unions, disabling -pedantic. */
-#ifdef PEDANTIC
-#pragma GCC diagnostic ignored "-Wpedantic"
-#endif
-#include <infiniband/verbs.h>
-#include <infiniband/mlx5dv.h>
-#ifdef PEDANTIC
-#pragma GCC diagnostic error "-Wpedantic"
-#endif
-
 #include <rte_ethdev.h>
 #include <rte_rwlock.h>
 #include <rte_bitmap.h>
diff --git a/drivers/net/mlx5/mlx5_rss.c b/drivers/net/mlx5/mlx5_rss.c
index a49edbc..a63cc8d 100644
--- a/drivers/net/mlx5/mlx5_rss.c
+++ b/drivers/net/mlx5/mlx5_rss.c
@@ -8,16 +8,6 @@
 #include <errno.h>
 #include <string.h>
 
-/* Verbs header. */
-/* ISO C doesn't support unnamed structs/unions, disabling -pedantic. */
-#ifdef PEDANTIC
-#pragma GCC diagnostic ignored "-Wpedantic"
-#endif
-#include <infiniband/verbs.h>
-#ifdef PEDANTIC
-#pragma GCC diagnostic error "-Wpedantic"
-#endif
-
 #include <rte_malloc.h>
 #include <rte_ethdev_driver.h>
 
diff --git a/drivers/net/mlx5/mlx5_rxmode.c b/drivers/net/mlx5/mlx5_rxmode.c
index 80b1256..7613ff7 100644
--- a/drivers/net/mlx5/mlx5_rxmode.c
+++ b/drivers/net/mlx5/mlx5_rxmode.c
@@ -7,18 +7,9 @@
 #include <errno.h>
 #include <string.h>
 
-/* Verbs header. */
-/* ISO C doesn't support unnamed structs/unions, disabling -pedantic. */
-#ifdef PEDANTIC
-#pragma GCC diagnostic ignored "-Wpedantic"
-#endif
-#include <infiniband/verbs.h>
-#ifdef PEDANTIC
-#pragma GCC diagnostic error "-Wpedantic"
-#endif
-
 #include <rte_ethdev_driver.h>
 
+#include <mlx5_glue.h>
 #include "mlx5.h"
 #include "mlx5_rxtx.h"
 #include "mlx5_utils.h"
diff --git a/drivers/net/mlx5/mlx5_rxq.c b/drivers/net/mlx5/mlx5_rxq.c
index 9e7df8e..9ef6bdd 100644
--- a/drivers/net/mlx5/mlx5_rxq.c
+++ b/drivers/net/mlx5/mlx5_rxq.c
@@ -10,17 +10,6 @@
 #include <fcntl.h>
 #include <sys/queue.h>
 
-/* Verbs header. */
-/* ISO C doesn't support unnamed structs/unions, disabling -pedantic. */
-#ifdef PEDANTIC
-#pragma GCC diagnostic ignored "-Wpedantic"
-#endif
-#include <infiniband/verbs.h>
-#include <infiniband/mlx5dv.h>
-#ifdef PEDANTIC
-#pragma GCC diagnostic error "-Wpedantic"
-#endif
-
 #include <rte_mbuf.h>
 #include <rte_malloc.h>
 #include <rte_ethdev_driver.h>
diff --git a/drivers/net/mlx5/mlx5_rxtx.c b/drivers/net/mlx5/mlx5_rxtx.c
index 65239f9..3eb0243 100644
--- a/drivers/net/mlx5/mlx5_rxtx.c
+++ b/drivers/net/mlx5/mlx5_rxtx.c
@@ -7,17 +7,6 @@
 #include <string.h>
 #include <stdlib.h>
 
-/* Verbs header. */
-/* ISO C doesn't support unnamed structs/unions, disabling -pedantic. */
-#ifdef PEDANTIC
-#pragma GCC diagnostic ignored "-Wpedantic"
-#endif
-#include <infiniband/verbs.h>
-#include <infiniband/mlx5dv.h>
-#ifdef PEDANTIC
-#pragma GCC diagnostic error "-Wpedantic"
-#endif
-
 #include <rte_mbuf.h>
 #include <rte_mempool.h>
 #include <rte_prefetch.h>
@@ -27,6 +16,7 @@
 #include <rte_cycles.h>
 #include <rte_flow.h>
 
+#include <mlx5_glue.h>
 #include <mlx5_devx_cmds.h>
 #include <mlx5_prm.h>
 #include <mlx5_common.h>
diff --git a/drivers/net/mlx5/mlx5_rxtx.h b/drivers/net/mlx5/mlx5_rxtx.h
index 5116a15..35a22b6 100644
--- a/drivers/net/mlx5/mlx5_rxtx.h
+++ b/drivers/net/mlx5/mlx5_rxtx.h
@@ -10,17 +10,6 @@
 #include <stdint.h>
 #include <sys/queue.h>
 
-/* Verbs header. */
-/* ISO C doesn't support unnamed structs/unions, disabling -pedantic. */
-#ifdef PEDANTIC
-#pragma GCC diagnostic ignored "-Wpedantic"
-#endif
-#include <infiniband/verbs.h>
-#include <infiniband/mlx5dv.h>
-#ifdef PEDANTIC
-#pragma GCC diagnostic error "-Wpedantic"
-#endif
-
 #include <rte_mbuf.h>
 #include <rte_mempool.h>
 #include <rte_common.h>
diff --git a/drivers/net/mlx5/mlx5_rxtx_vec.c b/drivers/net/mlx5/mlx5_rxtx_vec.c
index 7fae201..711dcd3 100644
--- a/drivers/net/mlx5/mlx5_rxtx_vec.c
+++ b/drivers/net/mlx5/mlx5_rxtx_vec.c
@@ -7,21 +7,11 @@
 #include <string.h>
 #include <stdlib.h>
 
-/* Verbs header. */
-/* ISO C doesn't support unnamed structs/unions, disabling -pedantic. */
-#ifdef PEDANTIC
-#pragma GCC diagnostic ignored "-Wpedantic"
-#endif
-#include <infiniband/verbs.h>
-#include <infiniband/mlx5dv.h>
-#ifdef PEDANTIC
-#pragma GCC diagnostic error "-Wpedantic"
-#endif
-
 #include <rte_mbuf.h>
 #include <rte_mempool.h>
 #include <rte_prefetch.h>
 
+#include <mlx5_glue.h>
 #include <mlx5_prm.h>
 
 #include "mlx5_defs.h"
diff --git a/drivers/net/mlx5/mlx5_txq.c b/drivers/net/mlx5/mlx5_txq.c
index 46034b5..3d90d66 100644
--- a/drivers/net/mlx5/mlx5_txq.c
+++ b/drivers/net/mlx5/mlx5_txq.c
@@ -10,17 +10,6 @@
 #include <unistd.h>
 #include <inttypes.h>
 
-/* Verbs header. */
-/* ISO C doesn't support unnamed structs/unions, disabling -pedantic. */
-#ifdef PEDANTIC
-#pragma GCC diagnostic ignored "-Wpedantic"
-#endif
-#include <infiniband/verbs.h>
-#include <infiniband/mlx5dv.h>
-#ifdef PEDANTIC
-#pragma GCC diagnostic error "-Wpedantic"
-#endif
-
 #include <rte_mbuf.h>
 #include <rte_malloc.h>
 #include <rte_ethdev_driver.h>
diff --git a/drivers/net/mlx5/mlx5_vlan.c b/drivers/net/mlx5/mlx5_vlan.c
index 4308b71..89983a4 100644
--- a/drivers/net/mlx5/mlx5_vlan.c
+++ b/drivers/net/mlx5/mlx5_vlan.c
@@ -8,23 +8,6 @@
 #include <stdint.h>
 #include <unistd.h>
 
-
-/*
- * Not needed by this file; included to work around the lack of off_t
- * definition for mlx5dv.h with unpatched rdma-core versions.
- */
-#include <sys/types.h>
-
-/* Verbs headers do not support -pedantic. */
-#ifdef PEDANTIC
-#pragma GCC diagnostic ignored "-Wpedantic"
-#endif
-#include <infiniband/mlx5dv.h>
-#include <infiniband/verbs.h>
-#ifdef PEDANTIC
-#pragma GCC diagnostic error "-Wpedantic"
-#endif
-
 #include <rte_ethdev_driver.h>
 #include <rte_common.h>
 #include <rte_malloc.h>
-- 
2.8.4


^ permalink raw reply	[flat|nested] 28+ messages in thread

* [dpdk-dev] [PATCH v3 0/8] mlx5 PMD multi OS support - part #3
  2020-07-19  7:11     ` [dpdk-dev] [PATCH v2 8/8] mlx5: remove inclusion of Verbs header files Ophir Munk
@ 2020-07-19 10:18       ` Ophir Munk
  2020-07-19 10:18         ` [dpdk-dev] [PATCH v3 1/8] net/mlx5: move flow prio discovery and adjust under Verbs Ophir Munk
                           ` (8 more replies)
  0 siblings, 9 replies; 28+ messages in thread
From: Ophir Munk @ 2020-07-19 10:18 UTC (permalink / raw)
  To: dev; +Cc: Raslan Darawsheh, Ophir Munk, Matan Azrad


This patch series is part of preparing mlx5 PMD to compile
and run under multiple OSs. Part #3

v1: Initial version
v2: Version rebased
v3: Fix coverity complain: BRANCH_PAST_INITIALIZATION

Ophir Munk (8):
  net/mlx5: move flow prio discovery and adjust under Verbs
  net/mlx5: replace Linux specific calls with rte API
  net/mlx5: refactor Linux MAC operations
  linux/mlx5: add setters for promiscuous and all-multi
  net/mlx5: eliminate dependency on Linux in shared header
  net/mlx5: header file cleanup
  net/mlx5: refactor multi process communication
  mlx5: remove inclusion of Verbs header files

 drivers/common/mlx5/linux/mlx5_common_os.h    |   7 +-
 drivers/common/mlx5/linux/mlx5_common_verbs.c |  15 -
 drivers/common/mlx5/mlx5_common_mp.h          |  11 +-
 drivers/common/mlx5/mlx5_common_mr.h          |  11 +-
 drivers/common/mlx5/mlx5_devx_cmds.c          |   9 +-
 drivers/common/mlx5/mlx5_prm.h                |  15 +-
 drivers/net/mlx5/Makefile                     |   2 +-
 drivers/net/mlx5/linux/meson.build            |   1 +
 drivers/net/mlx5/linux/mlx5_ethdev_os.c       | 416 +++++++++++++++++++---
 drivers/net/mlx5/linux/mlx5_mp_os.c           | 212 +++++++++++
 drivers/net/mlx5/linux/mlx5_os.c              | 490 +++++++++++---------------
 drivers/net/mlx5/linux/mlx5_verbs.c           |  15 -
 drivers/net/mlx5/meson.build                  |   1 -
 drivers/net/mlx5/mlx5.c                       | 124 +------
 drivers/net/mlx5/mlx5.h                       |  66 ++--
 drivers/net/mlx5/mlx5_flow.c                  | 121 -------
 drivers/net/mlx5/mlx5_flow.h                  |  12 +-
 drivers/net/mlx5/mlx5_flow_dv.c               |  20 +-
 drivers/net/mlx5/mlx5_flow_verbs.c            | 122 ++++++-
 drivers/net/mlx5/mlx5_mac.c                   |  59 +---
 drivers/net/mlx5/mlx5_mp.c                    | 212 -----------
 drivers/net/mlx5/mlx5_mr.c                    |   9 -
 drivers/net/mlx5/mlx5_mr.h                    |  11 -
 drivers/net/mlx5/mlx5_rss.c                   |  10 -
 drivers/net/mlx5/mlx5_rxmode.c                |  23 +-
 drivers/net/mlx5/mlx5_rxq.c                   |  20 +-
 drivers/net/mlx5/mlx5_rxtx.c                  |  12 +-
 drivers/net/mlx5/mlx5_rxtx.h                  |  11 -
 drivers/net/mlx5/mlx5_rxtx_vec.c              |  12 +-
 drivers/net/mlx5/mlx5_trigger.c               |   4 +-
 drivers/net/mlx5/mlx5_txpp.c                  |  15 +-
 drivers/net/mlx5/mlx5_txq.c                   |  57 +--
 drivers/net/mlx5/mlx5_vlan.c                  |  17 -
 33 files changed, 1030 insertions(+), 1112 deletions(-)
 create mode 100644 drivers/net/mlx5/linux/mlx5_mp_os.c
 delete mode 100644 drivers/net/mlx5/mlx5_mp.c

-- 
2.8.4


^ permalink raw reply	[flat|nested] 28+ messages in thread

* [dpdk-dev] [PATCH v3 1/8] net/mlx5: move flow prio discovery and adjust under Verbs
  2020-07-19 10:18       ` [dpdk-dev] [PATCH v3 0/8] mlx5 PMD multi OS support - part #3 Ophir Munk
@ 2020-07-19 10:18         ` Ophir Munk
  2020-07-19 10:18         ` [dpdk-dev] [PATCH v3 2/8] net/mlx5: replace Linux specific calls with rte API Ophir Munk
                           ` (7 subsequent siblings)
  8 siblings, 0 replies; 28+ messages in thread
From: Ophir Munk @ 2020-07-19 10:18 UTC (permalink / raw)
  To: dev; +Cc: Raslan Darawsheh, Ophir Munk, Matan Azrad

Function calls mlx5_flow_adjust_priority() and
mlx5_flow_discover_priorities() are Verbs based. Move them from file
mlx5_flow.c to file mlx5_flow_verbs.c

Signed-off-by: Ophir Munk <ophirmu@mellanox.com>
Acked-by: Matan Azrad <matan@mellanox.com>
---
 drivers/net/mlx5/mlx5.h            |   1 -
 drivers/net/mlx5/mlx5_flow.c       | 112 -------------------------------------
 drivers/net/mlx5/mlx5_flow.h       |   1 +
 drivers/net/mlx5/mlx5_flow_verbs.c | 112 +++++++++++++++++++++++++++++++++++++
 4 files changed, 113 insertions(+), 113 deletions(-)

diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h
index 9722662..3df4149 100644
--- a/drivers/net/mlx5/mlx5.h
+++ b/drivers/net/mlx5/mlx5.h
@@ -926,7 +926,6 @@ int mlx5_traffic_restart(struct rte_eth_dev *dev);
 
 int mlx5_flow_discover_mreg_c(struct rte_eth_dev *eth_dev);
 bool mlx5_flow_ext_mreg_supported(struct rte_eth_dev *dev);
-int mlx5_flow_discover_priorities(struct rte_eth_dev *dev);
 void mlx5_flow_print(struct rte_flow *flow);
 int mlx5_flow_validate(struct rte_eth_dev *dev,
 		       const struct rte_flow_attr *attr,
diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c
index d171ab0..52047db 100644
--- a/drivers/net/mlx5/mlx5_flow.c
+++ b/drivers/net/mlx5/mlx5_flow.c
@@ -29,7 +29,6 @@
 #include <rte_malloc.h>
 #include <rte_ip.h>
 
-#include <mlx5_glue.h>
 #include <mlx5_devx_cmds.h>
 #include <mlx5_prm.h>
 #include <mlx5_malloc.h>
@@ -267,17 +266,6 @@ struct mlx5_fdir {
 	struct rte_flow_action_queue queue;
 };
 
-/* Map of Verbs to Flow priority with 8 Verbs priorities. */
-static const uint32_t priority_map_3[][MLX5_PRIORITY_MAP_MAX] = {
-	{ 0, 1, 2 }, { 2, 3, 4 }, { 5, 6, 7 },
-};
-
-/* Map of Verbs to Flow priority with 16 Verbs priorities. */
-static const uint32_t priority_map_5[][MLX5_PRIORITY_MAP_MAX] = {
-	{ 0, 1, 2 }, { 3, 4, 5 }, { 6, 7, 8 },
-	{ 9, 10, 11 }, { 12, 13, 14 },
-};
-
 /* Tunnel information. */
 struct mlx5_flow_tunnel_info {
 	uint64_t tunnel; /**< Tunnel bit (see MLX5_FLOW_*). */
@@ -484,106 +472,6 @@ mlx5_flow_ext_mreg_supported(struct rte_eth_dev *dev)
 }
 
 /**
- * Discover the maximum number of priority available.
- *
- * @param[in] dev
- *   Pointer to the Ethernet device structure.
- *
- * @return
- *   number of supported flow priority on success, a negative errno
- *   value otherwise and rte_errno is set.
- */
-int
-mlx5_flow_discover_priorities(struct rte_eth_dev *dev)
-{
-	struct mlx5_priv *priv = dev->data->dev_private;
-	struct {
-		struct ibv_flow_attr attr;
-		struct ibv_flow_spec_eth eth;
-		struct ibv_flow_spec_action_drop drop;
-	} flow_attr = {
-		.attr = {
-			.num_of_specs = 2,
-			.port = (uint8_t)priv->dev_port,
-		},
-		.eth = {
-			.type = IBV_FLOW_SPEC_ETH,
-			.size = sizeof(struct ibv_flow_spec_eth),
-		},
-		.drop = {
-			.size = sizeof(struct ibv_flow_spec_action_drop),
-			.type = IBV_FLOW_SPEC_ACTION_DROP,
-		},
-	};
-	struct ibv_flow *flow;
-	struct mlx5_hrxq *drop = mlx5_hrxq_drop_new(dev);
-	uint16_t vprio[] = { 8, 16 };
-	int i;
-	int priority = 0;
-
-	if (!drop) {
-		rte_errno = ENOTSUP;
-		return -rte_errno;
-	}
-	for (i = 0; i != RTE_DIM(vprio); i++) {
-		flow_attr.attr.priority = vprio[i] - 1;
-		flow = mlx5_glue->create_flow(drop->qp, &flow_attr.attr);
-		if (!flow)
-			break;
-		claim_zero(mlx5_glue->destroy_flow(flow));
-		priority = vprio[i];
-	}
-	mlx5_hrxq_drop_release(dev);
-	switch (priority) {
-	case 8:
-		priority = RTE_DIM(priority_map_3);
-		break;
-	case 16:
-		priority = RTE_DIM(priority_map_5);
-		break;
-	default:
-		rte_errno = ENOTSUP;
-		DRV_LOG(ERR,
-			"port %u verbs maximum priority: %d expected 8/16",
-			dev->data->port_id, priority);
-		return -rte_errno;
-	}
-	DRV_LOG(INFO, "port %u flow maximum priority: %d",
-		dev->data->port_id, priority);
-	return priority;
-}
-
-/**
- * Adjust flow priority based on the highest layer and the request priority.
- *
- * @param[in] dev
- *   Pointer to the Ethernet device structure.
- * @param[in] priority
- *   The rule base priority.
- * @param[in] subpriority
- *   The priority based on the items.
- *
- * @return
- *   The new priority.
- */
-uint32_t mlx5_flow_adjust_priority(struct rte_eth_dev *dev, int32_t priority,
-				   uint32_t subpriority)
-{
-	uint32_t res = 0;
-	struct mlx5_priv *priv = dev->data->dev_private;
-
-	switch (priv->config.flow_prio) {
-	case RTE_DIM(priority_map_3):
-		res = priority_map_3[priority][subpriority];
-		break;
-	case RTE_DIM(priority_map_5):
-		res = priority_map_5[priority][subpriority];
-		break;
-	}
-	return  res;
-}
-
-/**
  * Verify the @p item specifications (spec, last, mask) are compatible with the
  * NIC capabilities.
  *
diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h
index 6dfeef3..314b5e3 100644
--- a/drivers/net/mlx5/mlx5_flow.h
+++ b/drivers/net/mlx5/mlx5_flow.h
@@ -922,6 +922,7 @@ int mlx5_flow_group_to_table(const struct rte_flow_attr *attributes,
 uint64_t mlx5_flow_hashfields_adjust(struct mlx5_flow_rss_desc *rss_desc,
 				     int tunnel, uint64_t layer_types,
 				     uint64_t hash_fields);
+int mlx5_flow_discover_priorities(struct rte_eth_dev *dev);
 uint32_t mlx5_flow_adjust_priority(struct rte_eth_dev *dev, int32_t priority,
 				   uint32_t subpriority);
 int mlx5_flow_get_reg_id(struct rte_eth_dev *dev,
diff --git a/drivers/net/mlx5/mlx5_flow_verbs.c b/drivers/net/mlx5/mlx5_flow_verbs.c
index 72106b4..5d11ba7 100644
--- a/drivers/net/mlx5/mlx5_flow_verbs.c
+++ b/drivers/net/mlx5/mlx5_flow_verbs.c
@@ -38,6 +38,118 @@
 #define VERBS_SPEC_INNER(item_flags) \
 	(!!((item_flags) & MLX5_FLOW_LAYER_TUNNEL) ? IBV_FLOW_SPEC_INNER : 0)
 
+/* Map of Verbs to Flow priority with 8 Verbs priorities. */
+static const uint32_t priority_map_3[][MLX5_PRIORITY_MAP_MAX] = {
+	{ 0, 1, 2 }, { 2, 3, 4 }, { 5, 6, 7 },
+};
+
+/* Map of Verbs to Flow priority with 16 Verbs priorities. */
+static const uint32_t priority_map_5[][MLX5_PRIORITY_MAP_MAX] = {
+	{ 0, 1, 2 }, { 3, 4, 5 }, { 6, 7, 8 },
+	{ 9, 10, 11 }, { 12, 13, 14 },
+};
+
+/**
+ * Discover the maximum number of priority available.
+ *
+ * @param[in] dev
+ *   Pointer to the Ethernet device structure.
+ *
+ * @return
+ *   number of supported flow priority on success, a negative errno
+ *   value otherwise and rte_errno is set.
+ */
+int
+mlx5_flow_discover_priorities(struct rte_eth_dev *dev)
+{
+	struct mlx5_priv *priv = dev->data->dev_private;
+	struct {
+		struct ibv_flow_attr attr;
+		struct ibv_flow_spec_eth eth;
+		struct ibv_flow_spec_action_drop drop;
+	} flow_attr = {
+		.attr = {
+			.num_of_specs = 2,
+			.port = (uint8_t)priv->dev_port,
+		},
+		.eth = {
+			.type = IBV_FLOW_SPEC_ETH,
+			.size = sizeof(struct ibv_flow_spec_eth),
+		},
+		.drop = {
+			.size = sizeof(struct ibv_flow_spec_action_drop),
+			.type = IBV_FLOW_SPEC_ACTION_DROP,
+		},
+	};
+	struct ibv_flow *flow;
+	struct mlx5_hrxq *drop = mlx5_hrxq_drop_new(dev);
+	uint16_t vprio[] = { 8, 16 };
+	int i;
+	int priority = 0;
+
+	if (!drop) {
+		rte_errno = ENOTSUP;
+		return -rte_errno;
+	}
+	for (i = 0; i != RTE_DIM(vprio); i++) {
+		flow_attr.attr.priority = vprio[i] - 1;
+		flow = mlx5_glue->create_flow(drop->qp, &flow_attr.attr);
+		if (!flow)
+			break;
+		claim_zero(mlx5_glue->destroy_flow(flow));
+		priority = vprio[i];
+	}
+	mlx5_hrxq_drop_release(dev);
+	switch (priority) {
+	case 8:
+		priority = RTE_DIM(priority_map_3);
+		break;
+	case 16:
+		priority = RTE_DIM(priority_map_5);
+		break;
+	default:
+		rte_errno = ENOTSUP;
+		DRV_LOG(ERR,
+			"port %u verbs maximum priority: %d expected 8/16",
+			dev->data->port_id, priority);
+		return -rte_errno;
+	}
+	DRV_LOG(INFO, "port %u flow maximum priority: %d",
+		dev->data->port_id, priority);
+	return priority;
+}
+
+/**
+ * Adjust flow priority based on the highest layer and the request priority.
+ *
+ * @param[in] dev
+ *   Pointer to the Ethernet device structure.
+ * @param[in] priority
+ *   The rule base priority.
+ * @param[in] subpriority
+ *   The priority based on the items.
+ *
+ * @return
+ *   The new priority.
+ */
+uint32_t
+mlx5_flow_adjust_priority(struct rte_eth_dev *dev, int32_t priority,
+				   uint32_t subpriority)
+{
+	uint32_t res = 0;
+	struct mlx5_priv *priv = dev->data->dev_private;
+
+	switch (priv->config.flow_prio) {
+	case RTE_DIM(priority_map_3):
+		res = priority_map_3[priority][subpriority];
+		break;
+	case RTE_DIM(priority_map_5):
+		res = priority_map_5[priority][subpriority];
+		break;
+	}
+	return  res;
+}
+
 /**
  * Get Verbs flow counter by index.
  *
-- 
2.8.4


^ permalink raw reply	[flat|nested] 28+ messages in thread

* [dpdk-dev] [PATCH v3 2/8] net/mlx5: replace Linux specific calls with rte API
  2020-07-19 10:18       ` [dpdk-dev] [PATCH v3 0/8] mlx5 PMD multi OS support - part #3 Ophir Munk
  2020-07-19 10:18         ` [dpdk-dev] [PATCH v3 1/8] net/mlx5: move flow prio discovery and adjust under Verbs Ophir Munk
@ 2020-07-19 10:18         ` Ophir Munk
  2020-07-19 10:18         ` [dpdk-dev] [PATCH v3 3/8] net/mlx5: refactor Linux MAC operations Ophir Munk
                           ` (6 subsequent siblings)
  8 siblings, 0 replies; 28+ messages in thread
From: Ophir Munk @ 2020-07-19 10:18 UTC (permalink / raw)
  To: dev; +Cc: Raslan Darawsheh, Ophir Munk, Matan Azrad

The following Linux calls are replaced by their matching rte APIs.

mmap ==> rte_mem_map()
munmap == >rte_mem_unmap()
sysconf(_SC_PAGESIZE) ==> rte_mem_page_size()

Signed-off-by: Ophir Munk <ophirmu@mellanox.com>
Acked-by: Matan Azrad <matan@mellanox.com>
---
 drivers/common/mlx5/mlx5_devx_cmds.c |  9 ++++++-
 drivers/common/mlx5/mlx5_prm.h       |  4 ++--
 drivers/net/mlx5/linux/mlx5_os.c     | 11 ++++++---
 drivers/net/mlx5/linux/mlx5_verbs.c  |  1 -
 drivers/net/mlx5/mlx5_flow_dv.c      |  9 ++++++-
 drivers/net/mlx5/mlx5_rxq.c          |  9 ++++++-
 drivers/net/mlx5/mlx5_txpp.c         | 15 ++++++++++--
 drivers/net/mlx5/mlx5_txq.c          | 46 ++++++++++++++++++++++++++++--------
 8 files changed, 83 insertions(+), 21 deletions(-)

diff --git a/drivers/common/mlx5/mlx5_devx_cmds.c b/drivers/common/mlx5/mlx5_devx_cmds.c
index 757c55e..972f804 100644
--- a/drivers/common/mlx5/mlx5_devx_cmds.c
+++ b/drivers/common/mlx5/mlx5_devx_cmds.c
@@ -5,6 +5,7 @@
 
 #include <rte_errno.h>
 #include <rte_malloc.h>
+#include <rte_eal_paging.h>
 
 #include "mlx5_prm.h"
 #include "mlx5_devx_cmds.h"
@@ -222,7 +223,13 @@ mlx5_devx_cmd_mkey_create(void *ctx,
 		return NULL;
 	}
 	memset(in, 0, in_size_dw * 4);
-	pgsize = sysconf(_SC_PAGESIZE);
+	pgsize = rte_mem_page_size();
+	if (pgsize == (size_t)-1) {
+		mlx5_free(mkey);
+		DRV_LOG(ERR, "Failed to get page size");
+		rte_errno = ENOMEM;
+		return NULL;
+	}
 	MLX5_SET(create_mkey_in, in, opcode, MLX5_CMD_OP_CREATE_MKEY);
 	mkc = MLX5_ADDR_OF(create_mkey_in, in, memory_key_mkey_entry);
 	if (klm_num > 0) {
diff --git a/drivers/common/mlx5/mlx5_prm.h b/drivers/common/mlx5/mlx5_prm.h
index d7d6cf8..4847c6e 100644
--- a/drivers/common/mlx5/mlx5_prm.h
+++ b/drivers/common/mlx5/mlx5_prm.h
@@ -267,10 +267,10 @@
 #define MLX5_MAX_LOG_RQ_SEGS 5u
 
 /* The alignment needed for WQ buffer. */
-#define MLX5_WQE_BUF_ALIGNMENT sysconf(_SC_PAGESIZE)
+#define MLX5_WQE_BUF_ALIGNMENT rte_mem_page_size()
 
 /* The alignment needed for CQ buffer. */
-#define MLX5_CQE_BUF_ALIGNMENT sysconf(_SC_PAGESIZE)
+#define MLX5_CQE_BUF_ALIGNMENT rte_mem_page_size()
 
 /* Completion mode. */
 enum mlx5_completion_mode {
diff --git a/drivers/net/mlx5/linux/mlx5_os.c b/drivers/net/mlx5/linux/mlx5_os.c
index 7c29a29..68420af 100644
--- a/drivers/net/mlx5/linux/mlx5_os.c
+++ b/drivers/net/mlx5/linux/mlx5_os.c
@@ -10,7 +10,6 @@
 #include <stdlib.h>
 #include <errno.h>
 #include <net/if.h>
-#include <sys/mman.h>
 #include <linux/rtnetlink.h>
 #include <linux/sockios.h>
 #include <linux/ethtool.h>
@@ -37,6 +36,7 @@
 #include <rte_spinlock.h>
 #include <rte_string_fns.h>
 #include <rte_alarm.h>
+#include <rte_eal_paging.h>
 
 #include <mlx5_glue.h>
 #include <mlx5_devx_cmds.h>
@@ -134,7 +134,7 @@ mlx5_os_get_dev_attr(void *ctx, struct mlx5_dev_attr *device_attr)
  * Verbs callback to allocate a memory. This function should allocate the space
  * according to the size provided residing inside a huge page.
  * Please note that all allocation must respect the alignment from libmlx5
- * (i.e. currently sysconf(_SC_PAGESIZE)).
+ * (i.e. currently rte_mem_page_size()).
  *
  * @param[in] size
  *   The size in bytes of the memory to allocate.
@@ -149,8 +149,13 @@ mlx5_alloc_verbs_buf(size_t size, void *data)
 {
 	struct mlx5_priv *priv = data;
 	void *ret;
-	size_t alignment = sysconf(_SC_PAGESIZE);
 	unsigned int socket = SOCKET_ID_ANY;
+	size_t alignment = rte_mem_page_size();
+	if (alignment == (size_t)-1) {
+		DRV_LOG(ERR, "Failed to get mem page size");
+		rte_errno = ENOMEM;
+		return NULL;
+	}
 
 	if (priv->verbs_alloc_ctx.type == MLX5_VERBS_ALLOC_TYPE_TX_QUEUE) {
 		const struct mlx5_txq_ctrl *ctrl = priv->verbs_alloc_ctx.obj;
diff --git a/drivers/net/mlx5/linux/mlx5_verbs.c b/drivers/net/mlx5/linux/mlx5_verbs.c
index 6b59fa1..5ac6982 100644
--- a/drivers/net/mlx5/linux/mlx5_verbs.c
+++ b/drivers/net/mlx5/linux/mlx5_verbs.c
@@ -7,7 +7,6 @@
 #include <string.h>
 #include <stdint.h>
 #include <unistd.h>
-#include <sys/mman.h>
 #include <inttypes.h>
 
 /* Verbs header. */
diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c
index 3ab2931..68dff23 100644
--- a/drivers/net/mlx5/mlx5_flow_dv.c
+++ b/drivers/net/mlx5/mlx5_flow_dv.c
@@ -29,6 +29,7 @@
 #include <rte_gre.h>
 #include <rte_vxlan.h>
 #include <rte_gtp.h>
+#include <rte_eal_paging.h>
 
 #include <mlx5_devx_cmds.h>
 #include <mlx5_prm.h>
@@ -4182,7 +4183,13 @@ flow_dv_create_counter_stat_mem_mng(struct rte_eth_dev *dev, int raws_n)
 			MLX5_COUNTERS_PER_POOL +
 			sizeof(struct mlx5_counter_stats_raw)) * raws_n +
 			sizeof(struct mlx5_counter_stats_mem_mng);
-	uint8_t *mem = mlx5_malloc(MLX5_MEM_ZERO, size, sysconf(_SC_PAGESIZE),
+	size_t pgsize = rte_mem_page_size();
+	if (pgsize == (size_t)-1) {
+		DRV_LOG(ERR, "Failed to get mem page size");
+		rte_errno = ENOMEM;
+		return NULL;
+	}
+	uint8_t *mem = mlx5_malloc(MLX5_MEM_ZERO, size, pgsize,
 				  SOCKET_ID_ANY);
 	int i;
 
diff --git a/drivers/net/mlx5/mlx5_rxq.c b/drivers/net/mlx5/mlx5_rxq.c
index 67d996c..9e7df8e 100644
--- a/drivers/net/mlx5/mlx5_rxq.c
+++ b/drivers/net/mlx5/mlx5_rxq.c
@@ -28,6 +28,7 @@
 #include <rte_interrupts.h>
 #include <rte_debug.h>
 #include <rte_io.h>
+#include <rte_eal_paging.h>
 
 #include <mlx5_glue.h>
 #include <mlx5_devx_cmds.h>
@@ -1233,8 +1234,14 @@ mlx5_devx_rq_new(struct rte_eth_dev *dev, uint16_t idx, uint32_t cqn)
 	/* Calculate and allocate WQ memory space. */
 	wqe_size = 1 << log_wqe_size; /* round up power of two.*/
 	wq_size = wqe_n * wqe_size;
+	size_t alignment = MLX5_WQE_BUF_ALIGNMENT;
+	if (alignment == (size_t)-1) {
+		DRV_LOG(ERR, "Failed to get mem page size");
+		rte_errno = ENOMEM;
+		return NULL;
+	}
 	buf = mlx5_malloc(MLX5_MEM_RTE | MLX5_MEM_ZERO, wq_size,
-			  MLX5_WQE_BUF_ALIGNMENT, rxq_ctrl->socket);
+			  alignment, rxq_ctrl->socket);
 	if (!buf)
 		return NULL;
 	rxq_data->wqes = buf;
diff --git a/drivers/net/mlx5/mlx5_txpp.c b/drivers/net/mlx5/mlx5_txpp.c
index f840551..14d4a66 100644
--- a/drivers/net/mlx5/mlx5_txpp.c
+++ b/drivers/net/mlx5/mlx5_txpp.c
@@ -10,6 +10,7 @@
 #include <rte_alarm.h>
 #include <rte_malloc.h>
 #include <rte_cycles.h>
+#include <rte_eal_paging.h>
 
 #include <mlx5_malloc.h>
 
@@ -249,10 +250,15 @@ mlx5_txpp_create_rearm_queue(struct mlx5_dev_ctx_shared *sh)
 	struct mlx5_devx_modify_sq_attr msq_attr = { 0 };
 	struct mlx5_devx_cq_attr cq_attr = { 0 };
 	struct mlx5_txpp_wq *wq = &sh->txpp.rearm_queue;
-	size_t page_size = sysconf(_SC_PAGESIZE);
+	size_t page_size;
 	uint32_t umem_size, umem_dbrec;
 	int ret;
 
+	page_size = rte_mem_page_size();
+	if (page_size == (size_t)-1) {
+		DRV_LOG(ERR, "Failed to get mem page size");
+		return -ENOMEM;
+	}
 	/* Allocate memory buffer for CQEs and doorbell record. */
 	umem_size = sizeof(struct mlx5_cqe) * MLX5_TXPP_REARM_CQ_SIZE;
 	umem_dbrec = RTE_ALIGN(umem_size, MLX5_DBR_SIZE);
@@ -472,10 +478,15 @@ mlx5_txpp_create_clock_queue(struct mlx5_dev_ctx_shared *sh)
 	struct mlx5_devx_modify_sq_attr msq_attr = { 0 };
 	struct mlx5_devx_cq_attr cq_attr = { 0 };
 	struct mlx5_txpp_wq *wq = &sh->txpp.clock_queue;
-	size_t page_size = sysconf(_SC_PAGESIZE);
+	size_t page_size;
 	uint32_t umem_size, umem_dbrec;
 	int ret;
 
+	page_size = rte_mem_page_size();
+	if (page_size == (size_t)-1) {
+		DRV_LOG(ERR, "Failed to get mem page size");
+		return -ENOMEM;
+	}
 	sh->txpp.tsa = mlx5_malloc(MLX5_MEM_RTE | MLX5_MEM_ZERO,
 				   MLX5_TXPP_REARM_SQ_SIZE *
 				   sizeof(struct mlx5_txpp_ts),
diff --git a/drivers/net/mlx5/mlx5_txq.c b/drivers/net/mlx5/mlx5_txq.c
index 4a73299..d245a54 100644
--- a/drivers/net/mlx5/mlx5_txq.c
+++ b/drivers/net/mlx5/mlx5_txq.c
@@ -8,7 +8,6 @@
 #include <string.h>
 #include <stdint.h>
 #include <unistd.h>
-#include <sys/mman.h>
 #include <inttypes.h>
 
 /* Verbs header. */
@@ -26,6 +25,7 @@
 #include <rte_malloc.h>
 #include <rte_ethdev_driver.h>
 #include <rte_common.h>
+#include <rte_eal_paging.h>
 
 #include <mlx5_glue.h>
 #include <mlx5_devx_cmds.h>
@@ -344,10 +344,14 @@ txq_uar_init(struct mlx5_txq_ctrl *txq_ctrl)
 {
 	struct mlx5_priv *priv = txq_ctrl->priv;
 	struct mlx5_proc_priv *ppriv = MLX5_PROC_PRIV(PORT_ID(priv));
-	const size_t page_size = sysconf(_SC_PAGESIZE);
 #ifndef RTE_ARCH_64
 	unsigned int lock_idx;
 #endif
+	const size_t page_size = rte_mem_page_size();
+	if (page_size == (size_t)-1) {
+		DRV_LOG(ERR, "Failed to get mem page size");
+		rte_errno = ENOMEM;
+	}
 
 	if (txq_ctrl->type != MLX5_TXQ_TYPE_STANDARD)
 		return;
@@ -386,7 +390,12 @@ txq_uar_init_secondary(struct mlx5_txq_ctrl *txq_ctrl, int fd)
 	void *addr;
 	uintptr_t uar_va;
 	uintptr_t offset;
-	const size_t page_size = sysconf(_SC_PAGESIZE);
+	const size_t page_size = rte_mem_page_size();
+	if (page_size == (size_t)-1) {
+		DRV_LOG(ERR, "Failed to get mem page size");
+		rte_errno = ENOMEM;
+		return -rte_errno;
+	}
 
 	if (txq_ctrl->type != MLX5_TXQ_TYPE_STANDARD)
 		return 0;
@@ -397,9 +406,9 @@ txq_uar_init_secondary(struct mlx5_txq_ctrl *txq_ctrl, int fd)
 	 */
 	uar_va = (uintptr_t)txq_ctrl->bf_reg;
 	offset = uar_va & (page_size - 1); /* Offset in page. */
-	addr = mmap(NULL, page_size, PROT_WRITE, MAP_SHARED, fd,
-			txq_ctrl->uar_mmap_offset);
-	if (addr == MAP_FAILED) {
+	addr = rte_mem_map(NULL, page_size, RTE_PROT_WRITE, RTE_MAP_SHARED,
+			    fd, txq_ctrl->uar_mmap_offset);
+	if (!addr) {
 		DRV_LOG(ERR,
 			"port %u mmap failed for BF reg of txq %u",
 			txq->port_id, txq->idx);
@@ -422,13 +431,17 @@ static void
 txq_uar_uninit_secondary(struct mlx5_txq_ctrl *txq_ctrl)
 {
 	struct mlx5_proc_priv *ppriv = MLX5_PROC_PRIV(PORT_ID(txq_ctrl->priv));
-	const size_t page_size = sysconf(_SC_PAGESIZE);
 	void *addr;
+	const size_t page_size = rte_mem_page_size();
+	if (page_size == (size_t)-1) {
+		DRV_LOG(ERR, "Failed to get mem page size");
+		rte_errno = ENOMEM;
+	}
 
 	if (txq_ctrl->type != MLX5_TXQ_TYPE_STANDARD)
 		return;
 	addr = ppriv->uar_table[txq_ctrl->txq.idx];
-	munmap(RTE_PTR_ALIGN_FLOOR(addr, page_size), page_size);
+	rte_mem_unmap(RTE_PTR_ALIGN_FLOOR(addr, page_size), page_size);
 }
 
 /**
@@ -642,13 +655,20 @@ mlx5_txq_obj_devx_new(struct rte_eth_dev *dev, uint16_t idx)
 	struct mlx5_devx_modify_sq_attr msq_attr = { 0 };
 	struct mlx5_devx_cq_attr cq_attr = { 0 };
 	struct mlx5_txq_obj *txq_obj = NULL;
-	size_t page_size = sysconf(_SC_PAGESIZE);
+	size_t page_size;
 	struct mlx5_cqe *cqe;
 	uint32_t i, nqe;
+	size_t alignment = (size_t)-1;
 	int ret = 0;
 
 	MLX5_ASSERT(txq_data);
 	MLX5_ASSERT(!txq_ctrl->obj);
+	page_size = rte_mem_page_size();
+	if (page_size == (size_t)-1) {
+		DRV_LOG(ERR, "Failed to get mem page size");
+		rte_errno = ENOMEM;
+		return NULL;
+	}
 	txq_obj = mlx5_malloc(MLX5_MEM_RTE | MLX5_MEM_ZERO,
 			      sizeof(struct mlx5_txq_obj), 0,
 			      txq_ctrl->socket);
@@ -674,9 +694,15 @@ mlx5_txq_obj_devx_new(struct rte_eth_dev *dev, uint16_t idx)
 		goto error;
 	}
 	/* Allocate memory buffer for CQEs. */
+	alignment = MLX5_CQE_BUF_ALIGNMENT;
+	if (alignment == (size_t)-1) {
+		DRV_LOG(ERR, "Failed to get mem page size");
+		rte_errno = ENOMEM;
+		goto error;
+	}
 	txq_obj->cq_buf = mlx5_malloc(MLX5_MEM_RTE | MLX5_MEM_ZERO,
 				      nqe * sizeof(struct mlx5_cqe),
-				      MLX5_CQE_BUF_ALIGNMENT,
+				      alignment,
 				      sh->numa_node);
 	if (!txq_obj->cq_buf) {
 		DRV_LOG(ERR,
-- 
2.8.4


^ permalink raw reply	[flat|nested] 28+ messages in thread

* [dpdk-dev] [PATCH v3 3/8] net/mlx5: refactor Linux MAC operations
  2020-07-19 10:18       ` [dpdk-dev] [PATCH v3 0/8] mlx5 PMD multi OS support - part #3 Ophir Munk
  2020-07-19 10:18         ` [dpdk-dev] [PATCH v3 1/8] net/mlx5: move flow prio discovery and adjust under Verbs Ophir Munk
  2020-07-19 10:18         ` [dpdk-dev] [PATCH v3 2/8] net/mlx5: replace Linux specific calls with rte API Ophir Munk
@ 2020-07-19 10:18         ` Ophir Munk
  2020-07-19 10:18         ` [dpdk-dev] [PATCH v3 4/8] linux/mlx5: add setters for promiscuous and all-multi Ophir Munk
                           ` (5 subsequent siblings)
  8 siblings, 0 replies; 28+ messages in thread
From: Ophir Munk @ 2020-07-19 10:18 UTC (permalink / raw)
  To: dev; +Cc: Raslan Darawsheh, Ophir Munk, Matan Azrad

Move OS specific MAC operations add, remove, modify VF into file
linux/mlx5_os.c.
Remove unused function mlx5_get_mac().

Signed-off-by: Ophir Munk <ophirmu@mellanox.com>
Acked-by: Matan Azrad <matan@mellanox.com>
---
 drivers/net/mlx5/linux/mlx5_os.c | 97 ++++++++++++++++++++++++++++++++++++++++
 drivers/net/mlx5/mlx5.h          |  7 ++-
 drivers/net/mlx5/mlx5_mac.c      | 49 +++-----------------
 3 files changed, 110 insertions(+), 43 deletions(-)

diff --git a/drivers/net/mlx5/linux/mlx5_os.c b/drivers/net/mlx5/linux/mlx5_os.c
index 68420af..9a35ccc 100644
--- a/drivers/net/mlx5/linux/mlx5_os.c
+++ b/drivers/net/mlx5/linux/mlx5_os.c
@@ -68,6 +68,30 @@
 #endif
 
 /**
+ * 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.
+ */
+static int
+mlx5_get_mac(struct rte_eth_dev *dev, uint8_t (*mac)[RTE_ETHER_ADDR_LEN])
+{
+	struct ifreq request;
+	int ret;
+
+	ret = mlx5_ifreq(dev, SIOCGIFHWADDR, &request);
+	if (ret)
+		return ret;
+	memcpy(mac, request.ifr_hwaddr.sa_data, RTE_ETHER_ADDR_LEN);
+	return 0;
+}
+
+/**
  * Get mlx5 device attributes. The glue function query_device_ex() is called
  * with out parameter of type 'struct ibv_device_attr_ex *'. Then fill in mlx5
  * device attributes from the glue out parameter.
@@ -2359,6 +2383,79 @@ mlx5_os_set_reg_mr_cb(mlx5_reg_mr_t *reg_mr_cb,
 	*dereg_mr_cb = mlx5_verbs_ops.dereg_mr;
 }
 
+/**
+ * Remove a MAC address from device
+ *
+ * @param dev
+ *   Pointer to Ethernet device structure.
+ * @param index
+ *   MAC address index.
+ */
+void
+mlx5_os_mac_addr_remove(struct rte_eth_dev *dev, uint32_t index)
+{
+	struct mlx5_priv *priv = dev->data->dev_private;
+	const int vf = priv->config.vf;
+
+	if (vf)
+		mlx5_nl_mac_addr_remove(priv->nl_socket_route,
+					mlx5_ifindex(dev), priv->mac_own,
+					&dev->data->mac_addrs[index], index);
+}
+
+/**
+ * Adds a MAC address to the device
+ *
+ * @param dev
+ *   Pointer to Ethernet device structure.
+ * @param mac_addr
+ *   MAC address to register.
+ * @param index
+ *   MAC address index.
+ *
+ * @return
+ *   0 on success, a negative errno value otherwise
+ */
+int
+mlx5_os_mac_addr_add(struct rte_eth_dev *dev, struct rte_ether_addr *mac,
+		     uint32_t index)
+{
+	struct mlx5_priv *priv = dev->data->dev_private;
+	const int vf = priv->config.vf;
+	int ret = 0;
+
+	if (vf)
+		ret = mlx5_nl_mac_addr_add(priv->nl_socket_route,
+					   mlx5_ifindex(dev), priv->mac_own,
+					   mac, index);
+	return ret;
+}
+
+/**
+ * Modify a VF MAC address
+ *
+ * @param priv
+ *   Pointer to device private data.
+ * @param mac_addr
+ *   MAC address to modify into.
+ * @param iface_idx
+ *   Net device interface index
+ * @param vf_index
+ *   VF index
+ *
+ * @return
+ *   0 on success, a negative errno value otherwise
+ */
+int
+mlx5_os_vf_mac_addr_modify(struct mlx5_priv *priv,
+			   unsigned int iface_idx,
+			   struct rte_ether_addr *mac_addr,
+			   int vf_index)
+{
+	return mlx5_nl_vf_mac_addr_modify
+		(priv->nl_socket_route, iface_idx, mac_addr, vf_index);
+}
+
 const struct eth_dev_ops mlx5_os_dev_ops = {
 	.dev_configure = mlx5_dev_configure,
 	.dev_start = mlx5_dev_start,
diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h
index 3df4149..a3c7824 100644
--- a/drivers/net/mlx5/mlx5.h
+++ b/drivers/net/mlx5/mlx5.h
@@ -860,7 +860,6 @@ int mlx5_dev_configure_rss_reta(struct rte_eth_dev *dev);
 
 /* mlx5_mac.c */
 
-int mlx5_get_mac(struct rte_eth_dev *dev, uint8_t (*mac)[RTE_ETHER_ADDR_LEN]);
 void mlx5_mac_addr_remove(struct rte_eth_dev *dev, uint32_t index);
 int mlx5_mac_addr_add(struct rte_eth_dev *dev, struct rte_ether_addr *mac,
 		      uint32_t index, uint32_t vmdq);
@@ -1025,6 +1024,12 @@ int mlx5_os_get_stats_n(struct rte_eth_dev *dev);
 void mlx5_os_stats_init(struct rte_eth_dev *dev);
 void mlx5_os_set_reg_mr_cb(mlx5_reg_mr_t *reg_mr_cb,
 			   mlx5_dereg_mr_t *dereg_mr_cb);
+void mlx5_os_mac_addr_remove(struct rte_eth_dev *dev, uint32_t index);
+int mlx5_os_mac_addr_add(struct rte_eth_dev *dev, struct rte_ether_addr *mac,
+			 uint32_t index);
+int mlx5_os_vf_mac_addr_modify(struct mlx5_priv *priv, unsigned int iface_idx,
+			       struct rte_ether_addr *mac_addr,
+			       int vf_index);
 
 /* mlx5_txpp.c */
 
diff --git a/drivers/net/mlx5/mlx5_mac.c b/drivers/net/mlx5/mlx5_mac.c
index 291f772..2a88086 100644
--- a/drivers/net/mlx5/mlx5_mac.c
+++ b/drivers/net/mlx5/mlx5_mac.c
@@ -32,30 +32,6 @@
 #include "mlx5_rxtx.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 ifreq request;
-	int ret;
-
-	ret = mlx5_ifreq(dev, SIOCGIFHWADDR, &request);
-	if (ret)
-		return ret;
-	memcpy(mac, request.ifr_hwaddr.sa_data, RTE_ETHER_ADDR_LEN);
-	return 0;
-}
-
-/**
  * Remove a MAC address from the internal array.
  *
  * @param dev
@@ -66,16 +42,10 @@ mlx5_get_mac(struct rte_eth_dev *dev, uint8_t (*mac)[RTE_ETHER_ADDR_LEN])
 static void
 mlx5_internal_mac_addr_remove(struct rte_eth_dev *dev, uint32_t index)
 {
-	struct mlx5_priv *priv = dev->data->dev_private;
-	const int vf = priv->config.vf;
-
 	MLX5_ASSERT(index < MLX5_MAX_MAC_ADDRESSES);
 	if (rte_is_zero_ether_addr(&dev->data->mac_addrs[index]))
 		return;
-	if (vf)
-		mlx5_nl_mac_addr_remove(priv->nl_socket_route,
-					mlx5_ifindex(dev), priv->mac_own,
-					&dev->data->mac_addrs[index], index);
+	mlx5_os_mac_addr_remove(dev, index);
 	memset(&dev->data->mac_addrs[index], 0, sizeof(struct rte_ether_addr));
 }
 
@@ -96,9 +66,8 @@ static int
 mlx5_internal_mac_addr_add(struct rte_eth_dev *dev, struct rte_ether_addr *mac,
 			   uint32_t index)
 {
-	struct mlx5_priv *priv = dev->data->dev_private;
-	const int vf = priv->config.vf;
 	unsigned int i;
+	int ret;
 
 	MLX5_ASSERT(index < MLX5_MAX_MAC_ADDRESSES);
 	if (rte_is_zero_ether_addr(mac)) {
@@ -116,14 +85,10 @@ mlx5_internal_mac_addr_add(struct rte_eth_dev *dev, struct rte_ether_addr *mac,
 		rte_errno = EADDRINUSE;
 		return -rte_errno;
 	}
-	if (vf) {
-		int ret = mlx5_nl_mac_addr_add(priv->nl_socket_route,
-					       mlx5_ifindex(dev), priv->mac_own,
-					       mac, index);
+	ret = mlx5_os_mac_addr_add(dev, mac, index);
+	if (ret)
+		return ret;
 
-		if (ret)
-			return ret;
-	}
 	dev->data->mac_addrs[index] = *mac;
 	return 0;
 }
@@ -210,8 +175,8 @@ mlx5_mac_addr_set(struct rte_eth_dev *dev, struct rte_ether_addr *mac_addr)
 			priv = rte_eth_devices[port_id].data->dev_private;
 			if (priv->master == 1) {
 				priv = dev->data->dev_private;
-				return mlx5_nl_vf_mac_addr_modify
-				       (priv->nl_socket_route,
+				return mlx5_os_vf_mac_addr_modify
+				       (priv,
 					mlx5_ifindex(&rte_eth_devices[port_id]),
 					mac_addr, priv->representor_id);
 			}
-- 
2.8.4


^ permalink raw reply	[flat|nested] 28+ messages in thread

* [dpdk-dev] [PATCH v3 4/8] linux/mlx5: add setters for promiscuous and all-multi
  2020-07-19 10:18       ` [dpdk-dev] [PATCH v3 0/8] mlx5 PMD multi OS support - part #3 Ophir Munk
                           ` (2 preceding siblings ...)
  2020-07-19 10:18         ` [dpdk-dev] [PATCH v3 3/8] net/mlx5: refactor Linux MAC operations Ophir Munk
@ 2020-07-19 10:18         ` Ophir Munk
  2020-07-19 10:18         ` [dpdk-dev] [PATCH v3 5/8] net/mlx5: eliminate dependency on Linux in shared header Ophir Munk
                           ` (4 subsequent siblings)
  8 siblings, 0 replies; 28+ messages in thread
From: Ophir Munk @ 2020-07-19 10:18 UTC (permalink / raw)
  To: dev; +Cc: Raslan Darawsheh, Ophir Munk, Matan Azrad

This commit adds Linux implementation of routines mlx5_os_set_promisc()
and mlx5_os_set_promisc(). The routines call netlink APIs.

Signed-off-by: Ophir Munk <ophirmu@mellanox.com>
Acked-by: Matan Azrad <matan@mellanox.com>
---
 drivers/net/mlx5/linux/mlx5_os.c | 40 ++++++++++++++++++++++++++++++++++++++++
 drivers/net/mlx5/mlx5.h          |  2 ++
 drivers/net/mlx5/mlx5_rxmode.c   | 12 ++++--------
 3 files changed, 46 insertions(+), 8 deletions(-)

diff --git a/drivers/net/mlx5/linux/mlx5_os.c b/drivers/net/mlx5/linux/mlx5_os.c
index 9a35ccc..1f82f0a 100644
--- a/drivers/net/mlx5/linux/mlx5_os.c
+++ b/drivers/net/mlx5/linux/mlx5_os.c
@@ -2456,6 +2456,46 @@ mlx5_os_vf_mac_addr_modify(struct mlx5_priv *priv,
 		(priv->nl_socket_route, iface_idx, mac_addr, vf_index);
 }
 
+/**
+ * Set device promiscuous mode
+ *
+ * @param dev
+ *   Pointer to Ethernet device structure.
+ * @param enable
+ *   0 - promiscuous is disabled, otherwise - enabled
+ *
+ * @return
+ *   0 on success, a negative error value otherwise
+ */
+int
+mlx5_os_set_promisc(struct rte_eth_dev *dev, int enable)
+{
+	struct mlx5_priv *priv = dev->data->dev_private;
+
+	return mlx5_nl_promisc(priv->nl_socket_route,
+			       mlx5_ifindex(dev), !!enable);
+}
+
+/**
+ * Set device promiscuous mode
+ *
+ * @param dev
+ *   Pointer to Ethernet device structure.
+ * @param enable
+ *   0 - all multicase is disabled, otherwise - enabled
+ *
+ * @return
+ *   0 on success, a negative error value otherwise
+ */
+int
+mlx5_os_set_allmulti(struct rte_eth_dev *dev, int enable)
+{
+	struct mlx5_priv *priv = dev->data->dev_private;
+
+	return mlx5_nl_allmulti(priv->nl_socket_route,
+				mlx5_ifindex(dev), !!enable);
+}
+
 const struct eth_dev_ops mlx5_os_dev_ops = {
 	.dev_configure = mlx5_dev_configure,
 	.dev_start = mlx5_dev_start,
diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h
index a3c7824..24a668b 100644
--- a/drivers/net/mlx5/mlx5.h
+++ b/drivers/net/mlx5/mlx5.h
@@ -1030,6 +1030,8 @@ int mlx5_os_mac_addr_add(struct rte_eth_dev *dev, struct rte_ether_addr *mac,
 int mlx5_os_vf_mac_addr_modify(struct mlx5_priv *priv, unsigned int iface_idx,
 			       struct rte_ether_addr *mac_addr,
 			       int vf_index);
+int mlx5_os_set_promisc(struct rte_eth_dev *dev, int enable);
+int mlx5_os_set_allmulti(struct rte_eth_dev *dev, int enable);
 
 /* mlx5_txpp.c */
 
diff --git a/drivers/net/mlx5/mlx5_rxmode.c b/drivers/net/mlx5/mlx5_rxmode.c
index 84c8b05..80b1256 100644
--- a/drivers/net/mlx5/mlx5_rxmode.c
+++ b/drivers/net/mlx5/mlx5_rxmode.c
@@ -47,8 +47,7 @@ mlx5_promiscuous_enable(struct rte_eth_dev *dev)
 		return 0;
 	}
 	if (priv->config.vf) {
-		ret = mlx5_nl_promisc(priv->nl_socket_route, mlx5_ifindex(dev),
-				      1);
+		ret = mlx5_os_set_promisc(dev, 1);
 		if (ret)
 			return ret;
 	}
@@ -81,8 +80,7 @@ mlx5_promiscuous_disable(struct rte_eth_dev *dev)
 
 	dev->data->promiscuous = 0;
 	if (priv->config.vf) {
-		ret = mlx5_nl_promisc(priv->nl_socket_route, mlx5_ifindex(dev),
-				      0);
+		ret = mlx5_os_set_promisc(dev, 0);
 		if (ret)
 			return ret;
 	}
@@ -122,8 +120,7 @@ mlx5_allmulticast_enable(struct rte_eth_dev *dev)
 		return 0;
 	}
 	if (priv->config.vf) {
-		ret = mlx5_nl_allmulti(priv->nl_socket_route, mlx5_ifindex(dev),
-				       1);
+		ret = mlx5_os_set_allmulti(dev, 1);
 		if (ret)
 			goto error;
 	}
@@ -156,8 +153,7 @@ mlx5_allmulticast_disable(struct rte_eth_dev *dev)
 
 	dev->data->all_multicast = 0;
 	if (priv->config.vf) {
-		ret = mlx5_nl_allmulti(priv->nl_socket_route, mlx5_ifindex(dev),
-				       0);
+		ret = mlx5_os_set_allmulti(dev, 0);
 		if (ret)
 			goto error;
 	}
-- 
2.8.4


^ permalink raw reply	[flat|nested] 28+ messages in thread

* [dpdk-dev] [PATCH v3 5/8] net/mlx5: eliminate dependency on Linux in shared header
  2020-07-19 10:18       ` [dpdk-dev] [PATCH v3 0/8] mlx5 PMD multi OS support - part #3 Ophir Munk
                           ` (3 preceding siblings ...)
  2020-07-19 10:18         ` [dpdk-dev] [PATCH v3 4/8] linux/mlx5: add setters for promiscuous and all-multi Ophir Munk
@ 2020-07-19 10:18         ` Ophir Munk
  2020-07-19 10:18         ` [dpdk-dev] [PATCH v3 6/8] net/mlx5: header file cleanup Ophir Munk
                           ` (3 subsequent siblings)
  8 siblings, 0 replies; 28+ messages in thread
From: Ophir Munk @ 2020-07-19 10:18 UTC (permalink / raw)
  To: dev; +Cc: Raslan Darawsheh, Ophir Munk, Matan Azrad

This commit eliminates Linux dependencies in shared file mlx5.h.

1. All functions using 'struct ifreq' are moved to file
linux/mlx5_ethdev_os.c such that this struct can be removed from mlx5.h.
2. Function mlx5_set_flags() that uses Linux flags (e.g. IFF_UP) is
changed to static and its prototype is removed from mlx5.h.
3. Remove redundant member verbs_action from 'struct mlx5_priv'.

Signed-off-by: Ophir Munk <ophirmu@mellanox.com>
Acked-by: Matan Azrad <matan@mellanox.com>
---
 drivers/net/mlx5/linux/mlx5_ethdev_os.c | 314 +++++++++++++++++++++++++++++++-
 drivers/net/mlx5/linux/mlx5_os.c        | 309 -------------------------------
 drivers/net/mlx5/mlx5.h                 |  15 +-
 3 files changed, 318 insertions(+), 320 deletions(-)

diff --git a/drivers/net/mlx5/linux/mlx5_ethdev_os.c b/drivers/net/mlx5/linux/mlx5_ethdev_os.c
index 6b8a151..e79d576 100644
--- a/drivers/net/mlx5/linux/mlx5_ethdev_os.c
+++ b/drivers/net/mlx5/linux/mlx5_ethdev_os.c
@@ -178,7 +178,7 @@ mlx5_get_ifname(const struct rte_eth_dev *dev, char (*ifname)[IF_NAMESIZE])
  * @return
  *   0 on success, a negative errno value otherwise and rte_errno is set.
  */
-int
+static int
 mlx5_ifreq(const struct rte_eth_dev *dev, int req, struct ifreq *ifr)
 {
 	int sock = socket(PF_INET, SOCK_DGRAM, IPPROTO_IP);
@@ -258,7 +258,7 @@ mlx5_set_mtu(struct rte_eth_dev *dev, uint16_t mtu)
  * @return
  *   0 on success, a negative errno value otherwise and rte_errno is set.
  */
-int
+static int
 mlx5_set_flags(struct rte_eth_dev *dev, unsigned int keep, unsigned int flags)
 {
 	struct ifreq request;
@@ -1187,3 +1187,313 @@ int mlx5_get_module_eeprom(struct rte_eth_dev *dev,
 	mlx5_free(eeprom);
 	return ret;
 }
+
+/**
+ * Read device counters table.
+ *
+ * @param dev
+ *   Pointer to Ethernet device.
+ * @param[out] stats
+ *   Counters table output buffer.
+ *
+ * @return
+ *   0 on success and stats is filled, negative errno value otherwise and
+ *   rte_errno is set.
+ */
+int
+mlx5_os_read_dev_counters(struct rte_eth_dev *dev, uint64_t *stats)
+{
+	struct mlx5_priv *priv = dev->data->dev_private;
+	struct mlx5_xstats_ctrl *xstats_ctrl = &priv->xstats_ctrl;
+	unsigned int i;
+	struct ifreq ifr;
+	unsigned int stats_sz = xstats_ctrl->stats_n * sizeof(uint64_t);
+	unsigned char et_stat_buf[sizeof(struct ethtool_stats) + stats_sz];
+	struct ethtool_stats *et_stats = (struct ethtool_stats *)et_stat_buf;
+	int ret;
+
+	et_stats->cmd = ETHTOOL_GSTATS;
+	et_stats->n_stats = xstats_ctrl->stats_n;
+	ifr.ifr_data = (caddr_t)et_stats;
+	ret = mlx5_ifreq(dev, SIOCETHTOOL, &ifr);
+	if (ret) {
+		DRV_LOG(WARNING,
+			"port %u unable to read statistic values from device",
+			dev->data->port_id);
+		return ret;
+	}
+	for (i = 0; i != xstats_ctrl->mlx5_stats_n; ++i) {
+		if (xstats_ctrl->info[i].dev) {
+			ret = mlx5_os_read_dev_stat(priv,
+					    xstats_ctrl->info[i].ctr_name,
+					    &stats[i]);
+			/* return last xstats counter if fail to read. */
+			if (ret == 0)
+				xstats_ctrl->xstats[i] = stats[i];
+			else
+				stats[i] = xstats_ctrl->xstats[i];
+		} else {
+			stats[i] = (uint64_t)
+				et_stats->data[xstats_ctrl->dev_table_idx[i]];
+		}
+	}
+	return 0;
+}
+
+/**
+ * Query the number of statistics provided by ETHTOOL.
+ *
+ * @param dev
+ *   Pointer to Ethernet device.
+ *
+ * @return
+ *   Number of statistics on success, negative errno value otherwise and
+ *   rte_errno is set.
+ */
+int
+mlx5_os_get_stats_n(struct rte_eth_dev *dev)
+{
+	struct ethtool_drvinfo drvinfo;
+	struct ifreq ifr;
+	int ret;
+
+	drvinfo.cmd = ETHTOOL_GDRVINFO;
+	ifr.ifr_data = (caddr_t)&drvinfo;
+	ret = mlx5_ifreq(dev, SIOCETHTOOL, &ifr);
+	if (ret) {
+		DRV_LOG(WARNING, "port %u unable to query number of statistics",
+			dev->data->port_id);
+		return ret;
+	}
+	return drvinfo.n_stats;
+}
+
+static const struct mlx5_counter_ctrl mlx5_counters_init[] = {
+	{
+		.dpdk_name = "rx_port_unicast_bytes",
+		.ctr_name = "rx_vport_unicast_bytes",
+	},
+	{
+		.dpdk_name = "rx_port_multicast_bytes",
+		.ctr_name = "rx_vport_multicast_bytes",
+	},
+	{
+		.dpdk_name = "rx_port_broadcast_bytes",
+		.ctr_name = "rx_vport_broadcast_bytes",
+	},
+	{
+		.dpdk_name = "rx_port_unicast_packets",
+		.ctr_name = "rx_vport_unicast_packets",
+	},
+	{
+		.dpdk_name = "rx_port_multicast_packets",
+		.ctr_name = "rx_vport_multicast_packets",
+	},
+	{
+		.dpdk_name = "rx_port_broadcast_packets",
+		.ctr_name = "rx_vport_broadcast_packets",
+	},
+	{
+		.dpdk_name = "tx_port_unicast_bytes",
+		.ctr_name = "tx_vport_unicast_bytes",
+	},
+	{
+		.dpdk_name = "tx_port_multicast_bytes",
+		.ctr_name = "tx_vport_multicast_bytes",
+	},
+	{
+		.dpdk_name = "tx_port_broadcast_bytes",
+		.ctr_name = "tx_vport_broadcast_bytes",
+	},
+	{
+		.dpdk_name = "tx_port_unicast_packets",
+		.ctr_name = "tx_vport_unicast_packets",
+	},
+	{
+		.dpdk_name = "tx_port_multicast_packets",
+		.ctr_name = "tx_vport_multicast_packets",
+	},
+	{
+		.dpdk_name = "tx_port_broadcast_packets",
+		.ctr_name = "tx_vport_broadcast_packets",
+	},
+	{
+		.dpdk_name = "rx_wqe_err",
+		.ctr_name = "rx_wqe_err",
+	},
+	{
+		.dpdk_name = "rx_crc_errors_phy",
+		.ctr_name = "rx_crc_errors_phy",
+	},
+	{
+		.dpdk_name = "rx_in_range_len_errors_phy",
+		.ctr_name = "rx_in_range_len_errors_phy",
+	},
+	{
+		.dpdk_name = "rx_symbol_err_phy",
+		.ctr_name = "rx_symbol_err_phy",
+	},
+	{
+		.dpdk_name = "tx_errors_phy",
+		.ctr_name = "tx_errors_phy",
+	},
+	{
+		.dpdk_name = "rx_out_of_buffer",
+		.ctr_name = "out_of_buffer",
+		.dev = 1,
+	},
+	{
+		.dpdk_name = "tx_packets_phy",
+		.ctr_name = "tx_packets_phy",
+	},
+	{
+		.dpdk_name = "rx_packets_phy",
+		.ctr_name = "rx_packets_phy",
+	},
+	{
+		.dpdk_name = "tx_discards_phy",
+		.ctr_name = "tx_discards_phy",
+	},
+	{
+		.dpdk_name = "rx_discards_phy",
+		.ctr_name = "rx_discards_phy",
+	},
+	{
+		.dpdk_name = "tx_bytes_phy",
+		.ctr_name = "tx_bytes_phy",
+	},
+	{
+		.dpdk_name = "rx_bytes_phy",
+		.ctr_name = "rx_bytes_phy",
+	},
+	/* Representor only */
+	{
+		.dpdk_name = "rx_packets",
+		.ctr_name = "vport_rx_packets",
+	},
+	{
+		.dpdk_name = "rx_bytes",
+		.ctr_name = "vport_rx_bytes",
+	},
+	{
+		.dpdk_name = "tx_packets",
+		.ctr_name = "vport_tx_packets",
+	},
+	{
+		.dpdk_name = "tx_bytes",
+		.ctr_name = "vport_tx_bytes",
+	},
+};
+
+static const unsigned int xstats_n = RTE_DIM(mlx5_counters_init);
+
+/**
+ * Init the structures to read device counters.
+ *
+ * @param dev
+ *   Pointer to Ethernet device.
+ */
+void
+mlx5_os_stats_init(struct rte_eth_dev *dev)
+{
+	struct mlx5_priv *priv = dev->data->dev_private;
+	struct mlx5_xstats_ctrl *xstats_ctrl = &priv->xstats_ctrl;
+	struct mlx5_stats_ctrl *stats_ctrl = &priv->stats_ctrl;
+	unsigned int i;
+	unsigned int j;
+	struct ifreq ifr;
+	struct ethtool_gstrings *strings = NULL;
+	unsigned int dev_stats_n;
+	unsigned int str_sz;
+	int ret;
+
+	/* So that it won't aggregate for each init. */
+	xstats_ctrl->mlx5_stats_n = 0;
+	ret = mlx5_os_get_stats_n(dev);
+	if (ret < 0) {
+		DRV_LOG(WARNING, "port %u no extended statistics available",
+			dev->data->port_id);
+		return;
+	}
+	dev_stats_n = ret;
+	/* Allocate memory to grab stat names and values. */
+	str_sz = dev_stats_n * ETH_GSTRING_LEN;
+	strings = (struct ethtool_gstrings *)
+		  mlx5_malloc(0, str_sz + sizeof(struct ethtool_gstrings), 0,
+			      SOCKET_ID_ANY);
+	if (!strings) {
+		DRV_LOG(WARNING, "port %u unable to allocate memory for xstats",
+		     dev->data->port_id);
+		return;
+	}
+	strings->cmd = ETHTOOL_GSTRINGS;
+	strings->string_set = ETH_SS_STATS;
+	strings->len = dev_stats_n;
+	ifr.ifr_data = (caddr_t)strings;
+	ret = mlx5_ifreq(dev, SIOCETHTOOL, &ifr);
+	if (ret) {
+		DRV_LOG(WARNING, "port %u unable to get statistic names",
+			dev->data->port_id);
+		goto free;
+	}
+	for (i = 0; i != dev_stats_n; ++i) {
+		const char *curr_string = (const char *)
+			&strings->data[i * ETH_GSTRING_LEN];
+
+		for (j = 0; j != xstats_n; ++j) {
+			if (!strcmp(mlx5_counters_init[j].ctr_name,
+				    curr_string)) {
+				unsigned int idx = xstats_ctrl->mlx5_stats_n++;
+
+				xstats_ctrl->dev_table_idx[idx] = i;
+				xstats_ctrl->info[idx] = mlx5_counters_init[j];
+				break;
+			}
+		}
+	}
+	/* Add dev counters. */
+	for (i = 0; i != xstats_n; ++i) {
+		if (mlx5_counters_init[i].dev) {
+			unsigned int idx = xstats_ctrl->mlx5_stats_n++;
+
+			xstats_ctrl->info[idx] = mlx5_counters_init[i];
+			xstats_ctrl->hw_stats[idx] = 0;
+		}
+	}
+	MLX5_ASSERT(xstats_ctrl->mlx5_stats_n <= MLX5_MAX_XSTATS);
+	xstats_ctrl->stats_n = dev_stats_n;
+	/* Copy to base at first time. */
+	ret = mlx5_os_read_dev_counters(dev, xstats_ctrl->base);
+	if (ret)
+		DRV_LOG(ERR, "port %u cannot read device counters: %s",
+			dev->data->port_id, strerror(rte_errno));
+	mlx5_os_read_dev_stat(priv, "out_of_buffer", &stats_ctrl->imissed_base);
+	stats_ctrl->imissed = 0;
+free:
+	mlx5_free(strings);
+}
+
+/**
+ * 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 ifreq request;
+	int ret;
+
+	ret = mlx5_ifreq(dev, SIOCGIFHWADDR, &request);
+	if (ret)
+		return ret;
+	memcpy(mac, request.ifr_hwaddr.sa_data, RTE_ETHER_ADDR_LEN);
+	return 0;
+}
+
diff --git a/drivers/net/mlx5/linux/mlx5_os.c b/drivers/net/mlx5/linux/mlx5_os.c
index 1f82f0a..d3ae3ad 100644
--- a/drivers/net/mlx5/linux/mlx5_os.c
+++ b/drivers/net/mlx5/linux/mlx5_os.c
@@ -68,30 +68,6 @@
 #endif
 
 /**
- * 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.
- */
-static int
-mlx5_get_mac(struct rte_eth_dev *dev, uint8_t (*mac)[RTE_ETHER_ADDR_LEN])
-{
-	struct ifreq request;
-	int ret;
-
-	ret = mlx5_ifreq(dev, SIOCGIFHWADDR, &request);
-	if (ret)
-		return ret;
-	memcpy(mac, request.ifr_hwaddr.sa_data, RTE_ETHER_ADDR_LEN);
-	return 0;
-}
-
-/**
  * Get mlx5 device attributes. The glue function query_device_ex() is called
  * with out parameter of type 'struct ibv_device_attr_ex *'. Then fill in mlx5
  * device attributes from the glue out parameter.
@@ -2082,291 +2058,6 @@ mlx5_os_read_dev_stat(struct mlx5_priv *priv, const char *ctr_name,
 }
 
 /**
- * Read device counters table.
- *
- * @param dev
- *   Pointer to Ethernet device.
- * @param[out] stats
- *   Counters table output buffer.
- *
- * @return
- *   0 on success and stats is filled, negative errno value otherwise and
- *   rte_errno is set.
- */
-int
-mlx5_os_read_dev_counters(struct rte_eth_dev *dev, uint64_t *stats)
-{
-	struct mlx5_priv *priv = dev->data->dev_private;
-	struct mlx5_xstats_ctrl *xstats_ctrl = &priv->xstats_ctrl;
-	unsigned int i;
-	struct ifreq ifr;
-	unsigned int stats_sz = xstats_ctrl->stats_n * sizeof(uint64_t);
-	unsigned char et_stat_buf[sizeof(struct ethtool_stats) + stats_sz];
-	struct ethtool_stats *et_stats = (struct ethtool_stats *)et_stat_buf;
-	int ret;
-
-	et_stats->cmd = ETHTOOL_GSTATS;
-	et_stats->n_stats = xstats_ctrl->stats_n;
-	ifr.ifr_data = (caddr_t)et_stats;
-	ret = mlx5_ifreq(dev, SIOCETHTOOL, &ifr);
-	if (ret) {
-		DRV_LOG(WARNING,
-			"port %u unable to read statistic values from device",
-			dev->data->port_id);
-		return ret;
-	}
-	for (i = 0; i != xstats_ctrl->mlx5_stats_n; ++i) {
-		if (xstats_ctrl->info[i].dev) {
-			ret = mlx5_os_read_dev_stat(priv,
-					    xstats_ctrl->info[i].ctr_name,
-					    &stats[i]);
-			/* return last xstats counter if fail to read. */
-			if (ret == 0)
-				xstats_ctrl->xstats[i] = stats[i];
-			else
-				stats[i] = xstats_ctrl->xstats[i];
-		} else {
-			stats[i] = (uint64_t)
-				et_stats->data[xstats_ctrl->dev_table_idx[i]];
-		}
-	}
-	return 0;
-}
-
-/**
- * Query the number of statistics provided by ETHTOOL.
- *
- * @param dev
- *   Pointer to Ethernet device.
- *
- * @return
- *   Number of statistics on success, negative errno value otherwise and
- *   rte_errno is set.
- */
-int
-mlx5_os_get_stats_n(struct rte_eth_dev *dev)
-{
-	struct ethtool_drvinfo drvinfo;
-	struct ifreq ifr;
-	int ret;
-
-	drvinfo.cmd = ETHTOOL_GDRVINFO;
-	ifr.ifr_data = (caddr_t)&drvinfo;
-	ret = mlx5_ifreq(dev, SIOCETHTOOL, &ifr);
-	if (ret) {
-		DRV_LOG(WARNING, "port %u unable to query number of statistics",
-			dev->data->port_id);
-		return ret;
-	}
-	return drvinfo.n_stats;
-}
-
-static const struct mlx5_counter_ctrl mlx5_counters_init[] = {
-	{
-		.dpdk_name = "rx_port_unicast_bytes",
-		.ctr_name = "rx_vport_unicast_bytes",
-	},
-	{
-		.dpdk_name = "rx_port_multicast_bytes",
-		.ctr_name = "rx_vport_multicast_bytes",
-	},
-	{
-		.dpdk_name = "rx_port_broadcast_bytes",
-		.ctr_name = "rx_vport_broadcast_bytes",
-	},
-	{
-		.dpdk_name = "rx_port_unicast_packets",
-		.ctr_name = "rx_vport_unicast_packets",
-	},
-	{
-		.dpdk_name = "rx_port_multicast_packets",
-		.ctr_name = "rx_vport_multicast_packets",
-	},
-	{
-		.dpdk_name = "rx_port_broadcast_packets",
-		.ctr_name = "rx_vport_broadcast_packets",
-	},
-	{
-		.dpdk_name = "tx_port_unicast_bytes",
-		.ctr_name = "tx_vport_unicast_bytes",
-	},
-	{
-		.dpdk_name = "tx_port_multicast_bytes",
-		.ctr_name = "tx_vport_multicast_bytes",
-	},
-	{
-		.dpdk_name = "tx_port_broadcast_bytes",
-		.ctr_name = "tx_vport_broadcast_bytes",
-	},
-	{
-		.dpdk_name = "tx_port_unicast_packets",
-		.ctr_name = "tx_vport_unicast_packets",
-	},
-	{
-		.dpdk_name = "tx_port_multicast_packets",
-		.ctr_name = "tx_vport_multicast_packets",
-	},
-	{
-		.dpdk_name = "tx_port_broadcast_packets",
-		.ctr_name = "tx_vport_broadcast_packets",
-	},
-	{
-		.dpdk_name = "rx_wqe_err",
-		.ctr_name = "rx_wqe_err",
-	},
-	{
-		.dpdk_name = "rx_crc_errors_phy",
-		.ctr_name = "rx_crc_errors_phy",
-	},
-	{
-		.dpdk_name = "rx_in_range_len_errors_phy",
-		.ctr_name = "rx_in_range_len_errors_phy",
-	},
-	{
-		.dpdk_name = "rx_symbol_err_phy",
-		.ctr_name = "rx_symbol_err_phy",
-	},
-	{
-		.dpdk_name = "tx_errors_phy",
-		.ctr_name = "tx_errors_phy",
-	},
-	{
-		.dpdk_name = "rx_out_of_buffer",
-		.ctr_name = "out_of_buffer",
-		.dev = 1,
-	},
-	{
-		.dpdk_name = "tx_packets_phy",
-		.ctr_name = "tx_packets_phy",
-	},
-	{
-		.dpdk_name = "rx_packets_phy",
-		.ctr_name = "rx_packets_phy",
-	},
-	{
-		.dpdk_name = "tx_discards_phy",
-		.ctr_name = "tx_discards_phy",
-	},
-	{
-		.dpdk_name = "rx_discards_phy",
-		.ctr_name = "rx_discards_phy",
-	},
-	{
-		.dpdk_name = "tx_bytes_phy",
-		.ctr_name = "tx_bytes_phy",
-	},
-	{
-		.dpdk_name = "rx_bytes_phy",
-		.ctr_name = "rx_bytes_phy",
-	},
-	/* Representor only */
-	{
-		.dpdk_name = "rx_packets",
-		.ctr_name = "vport_rx_packets",
-	},
-	{
-		.dpdk_name = "rx_bytes",
-		.ctr_name = "vport_rx_bytes",
-	},
-	{
-		.dpdk_name = "tx_packets",
-		.ctr_name = "vport_tx_packets",
-	},
-	{
-		.dpdk_name = "tx_bytes",
-		.ctr_name = "vport_tx_bytes",
-	},
-};
-
-static const unsigned int xstats_n = RTE_DIM(mlx5_counters_init);
-
-/**
- * Init the structures to read device counters.
- *
- * @param dev
- *   Pointer to Ethernet device.
- */
-void
-mlx5_os_stats_init(struct rte_eth_dev *dev)
-{
-	struct mlx5_priv *priv = dev->data->dev_private;
-	struct mlx5_xstats_ctrl *xstats_ctrl = &priv->xstats_ctrl;
-	struct mlx5_stats_ctrl *stats_ctrl = &priv->stats_ctrl;
-	unsigned int i;
-	unsigned int j;
-	struct ifreq ifr;
-	struct ethtool_gstrings *strings = NULL;
-	unsigned int dev_stats_n;
-	unsigned int str_sz;
-	int ret;
-
-	/* So that it won't aggregate for each init. */
-	xstats_ctrl->mlx5_stats_n = 0;
-	ret = mlx5_os_get_stats_n(dev);
-	if (ret < 0) {
-		DRV_LOG(WARNING, "port %u no extended statistics available",
-			dev->data->port_id);
-		return;
-	}
-	dev_stats_n = ret;
-	/* Allocate memory to grab stat names and values. */
-	str_sz = dev_stats_n * ETH_GSTRING_LEN;
-	strings = (struct ethtool_gstrings *)
-		  mlx5_malloc(0, str_sz + sizeof(struct ethtool_gstrings), 0,
-			      SOCKET_ID_ANY);
-	if (!strings) {
-		DRV_LOG(WARNING, "port %u unable to allocate memory for xstats",
-		     dev->data->port_id);
-		return;
-	}
-	strings->cmd = ETHTOOL_GSTRINGS;
-	strings->string_set = ETH_SS_STATS;
-	strings->len = dev_stats_n;
-	ifr.ifr_data = (caddr_t)strings;
-	ret = mlx5_ifreq(dev, SIOCETHTOOL, &ifr);
-	if (ret) {
-		DRV_LOG(WARNING, "port %u unable to get statistic names",
-			dev->data->port_id);
-		goto free;
-	}
-	for (i = 0; i != dev_stats_n; ++i) {
-		const char *curr_string = (const char *)
-			&strings->data[i * ETH_GSTRING_LEN];
-
-		for (j = 0; j != xstats_n; ++j) {
-			if (!strcmp(mlx5_counters_init[j].ctr_name,
-				    curr_string)) {
-				unsigned int idx = xstats_ctrl->mlx5_stats_n++;
-
-				xstats_ctrl->dev_table_idx[idx] = i;
-				xstats_ctrl->info[idx] = mlx5_counters_init[j];
-				break;
-			}
-		}
-	}
-	/* Add dev counters. */
-	for (i = 0; i != xstats_n; ++i) {
-		if (mlx5_counters_init[i].dev) {
-			unsigned int idx = xstats_ctrl->mlx5_stats_n++;
-
-			xstats_ctrl->info[idx] = mlx5_counters_init[i];
-			xstats_ctrl->hw_stats[idx] = 0;
-		}
-	}
-	MLX5_ASSERT(xstats_ctrl->mlx5_stats_n <= MLX5_MAX_XSTATS);
-	xstats_ctrl->stats_n = dev_stats_n;
-	/* Copy to base at first time. */
-	ret = mlx5_os_read_dev_counters(dev, xstats_ctrl->base);
-	if (ret)
-		DRV_LOG(ERR, "port %u cannot read device counters: %s",
-			dev->data->port_id, strerror(rte_errno));
-	mlx5_os_read_dev_stat(priv, "out_of_buffer", &stats_ctrl->imissed_base);
-	stats_ctrl->imissed = 0;
-free:
-	mlx5_free(strings);
-}
-
-/**
  * Set the reg_mr and dereg_mr call backs
  *
  * @param reg_mr_cb[out]
diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h
index 24a668b..9fa7e47 100644
--- a/drivers/net/mlx5/mlx5.h
+++ b/drivers/net/mlx5/mlx5.h
@@ -737,7 +737,6 @@ struct mlx5_priv {
 	LIST_HEAD(ind_tables, mlx5_ind_table_obj) ind_tbls;
 	/* Pointer to next element. */
 	rte_atomic32_t refcnt; /**< Reference counter. */
-	struct ibv_flow_action *verbs_action;
 	/**< Verbs modify header action object. */
 	uint8_t ft_type; /**< Flow table type, Rx or Tx. */
 	uint8_t max_lro_msg_size;
@@ -820,10 +819,8 @@ int mlx5_hairpin_cap_get(struct rte_eth_dev *dev,
 
 int mlx5_get_ifname(const struct rte_eth_dev *dev, char (*ifname)[IF_NAMESIZE]);
 unsigned int mlx5_ifindex(const struct rte_eth_dev *dev);
-int mlx5_ifreq(const struct rte_eth_dev *dev, int req, struct ifreq *ifr);
+int mlx5_get_mac(struct rte_eth_dev *dev, uint8_t (*mac)[RTE_ETHER_ADDR_LEN]);
 int mlx5_get_mtu(struct rte_eth_dev *dev, uint16_t *mtu);
-int mlx5_set_flags(struct rte_eth_dev *dev, unsigned int keep,
-		   unsigned int flags);
 int mlx5_set_mtu(struct rte_eth_dev *dev, uint16_t mtu);
 int mlx5_read_clock(struct rte_eth_dev *dev, uint64_t *clock);
 int mlx5_link_update(struct rte_eth_dev *dev, int wait_to_complete);
@@ -857,6 +854,11 @@ int mlx5_get_module_info(struct rte_eth_dev *dev,
 int mlx5_get_module_eeprom(struct rte_eth_dev *dev,
 			   struct rte_dev_eeprom_info *info);
 int mlx5_dev_configure_rss_reta(struct rte_eth_dev *dev);
+int mlx5_os_read_dev_stat(struct mlx5_priv *priv,
+			  const char *ctr_name, uint64_t *stat);
+int mlx5_os_read_dev_counters(struct rte_eth_dev *dev, uint64_t *stats);
+int mlx5_os_get_stats_n(struct rte_eth_dev *dev);
+void mlx5_os_stats_init(struct rte_eth_dev *dev);
 
 /* mlx5_mac.c */
 
@@ -1017,11 +1019,6 @@ int mlx5_os_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
 		       struct rte_pci_device *pci_dev);
 void mlx5_os_dev_shared_handler_install(struct mlx5_dev_ctx_shared *sh);
 void mlx5_os_dev_shared_handler_uninstall(struct mlx5_dev_ctx_shared *sh);
-int mlx5_os_read_dev_stat(struct mlx5_priv *priv,
-			  const char *ctr_name, uint64_t *stat);
-int mlx5_os_read_dev_counters(struct rte_eth_dev *dev, uint64_t *stats);
-int mlx5_os_get_stats_n(struct rte_eth_dev *dev);
-void mlx5_os_stats_init(struct rte_eth_dev *dev);
 void mlx5_os_set_reg_mr_cb(mlx5_reg_mr_t *reg_mr_cb,
 			   mlx5_dereg_mr_t *dereg_mr_cb);
 void mlx5_os_mac_addr_remove(struct rte_eth_dev *dev, uint32_t index);
-- 
2.8.4


^ permalink raw reply	[flat|nested] 28+ messages in thread

* [dpdk-dev] [PATCH v3 6/8] net/mlx5: header file cleanup
  2020-07-19 10:18       ` [dpdk-dev] [PATCH v3 0/8] mlx5 PMD multi OS support - part #3 Ophir Munk
                           ` (4 preceding siblings ...)
  2020-07-19 10:18         ` [dpdk-dev] [PATCH v3 5/8] net/mlx5: eliminate dependency on Linux in shared header Ophir Munk
@ 2020-07-19 10:18         ` Ophir Munk
  2020-07-19 10:18         ` [dpdk-dev] [PATCH v3 7/8] net/mlx5: refactor multi process communication Ophir Munk
                           ` (2 subsequent siblings)
  8 siblings, 0 replies; 28+ messages in thread
From: Ophir Munk @ 2020-07-19 10:18 UTC (permalink / raw)
  To: dev; +Cc: Raslan Darawsheh, Ophir Munk, Matan Azrad

The cleanup refers to header file mlx5.h.
1. Remove unused prototypes.
2. Move prototypes under their correct title.
3. Change functions to static and remove their prototye from the header
file.

Signed-off-by: Ophir Munk <ophirmu@mellanox.com>
Acked-by: Matan Azrad <matan@mellanox.com>
---
 drivers/net/mlx5/linux/mlx5_ethdev_os.c | 102 ++++++++++++++++----------------
 drivers/net/mlx5/mlx5.h                 |  18 +++---
 2 files changed, 58 insertions(+), 62 deletions(-)

diff --git a/drivers/net/mlx5/linux/mlx5_ethdev_os.c b/drivers/net/mlx5/linux/mlx5_ethdev_os.c
index e79d576..1735157 100644
--- a/drivers/net/mlx5/linux/mlx5_ethdev_os.c
+++ b/drivers/net/mlx5/linux/mlx5_ethdev_os.c
@@ -973,6 +973,57 @@ mlx5_is_removed(struct rte_eth_dev *dev)
 }
 
 /**
+ * Analyze gathered port parameters via sysfs to recognize master
+ * and representor devices for E-Switch configuration.
+ *
+ * @param[in] device_dir
+ *   flag of presence of "device" directory under port device key.
+ * @param[inout] switch_info
+ *   Port information, including port name as a number and port name
+ *   type if recognized
+ *
+ * @return
+ *   master and representor flags are set in switch_info according to
+ *   recognized parameters (if any).
+ */
+static void
+mlx5_sysfs_check_switch_info(bool device_dir,
+			     struct mlx5_switch_info *switch_info)
+{
+	switch (switch_info->name_type) {
+	case MLX5_PHYS_PORT_NAME_TYPE_UNKNOWN:
+		/*
+		 * Name is not recognized, assume the master,
+		 * check the device directory presence.
+		 */
+		switch_info->master = device_dir;
+		break;
+	case MLX5_PHYS_PORT_NAME_TYPE_NOTSET:
+		/*
+		 * Name is not set, this assumes the legacy naming
+		 * schema for master, just check if there is
+		 * a device directory.
+		 */
+		switch_info->master = device_dir;
+		break;
+	case MLX5_PHYS_PORT_NAME_TYPE_UPLINK:
+		/* New uplink naming schema recognized. */
+		switch_info->master = 1;
+		break;
+	case MLX5_PHYS_PORT_NAME_TYPE_LEGACY:
+		/* Legacy representors naming schema. */
+		switch_info->representor = !device_dir;
+		break;
+	case MLX5_PHYS_PORT_NAME_TYPE_PFHPF:
+		/* Fallthrough */
+	case MLX5_PHYS_PORT_NAME_TYPE_PFVF:
+		/* New representors naming schema. */
+		switch_info->representor = 1;
+		break;
+	}
+}
+
+/**
  * Get switch information associated with network interface.
  *
  * @param ifindex
@@ -1051,57 +1102,6 @@ mlx5_sysfs_switch_info(unsigned int ifindex, struct mlx5_switch_info *info)
 }
 
 /**
- * Analyze gathered port parameters via sysfs to recognize master
- * and representor devices for E-Switch configuration.
- *
- * @param[in] device_dir
- *   flag of presence of "device" directory under port device key.
- * @param[inout] switch_info
- *   Port information, including port name as a number and port name
- *   type if recognized
- *
- * @return
- *   master and representor flags are set in switch_info according to
- *   recognized parameters (if any).
- */
-void
-mlx5_sysfs_check_switch_info(bool device_dir,
-			     struct mlx5_switch_info *switch_info)
-{
-	switch (switch_info->name_type) {
-	case MLX5_PHYS_PORT_NAME_TYPE_UNKNOWN:
-		/*
-		 * Name is not recognized, assume the master,
-		 * check the device directory presence.
-		 */
-		switch_info->master = device_dir;
-		break;
-	case MLX5_PHYS_PORT_NAME_TYPE_NOTSET:
-		/*
-		 * Name is not set, this assumes the legacy naming
-		 * schema for master, just check if there is
-		 * a device directory.
-		 */
-		switch_info->master = device_dir;
-		break;
-	case MLX5_PHYS_PORT_NAME_TYPE_UPLINK:
-		/* New uplink naming schema recognized. */
-		switch_info->master = 1;
-		break;
-	case MLX5_PHYS_PORT_NAME_TYPE_LEGACY:
-		/* Legacy representors naming schema. */
-		switch_info->representor = !device_dir;
-		break;
-	case MLX5_PHYS_PORT_NAME_TYPE_PFHPF:
-		/* Fallthrough */
-	case MLX5_PHYS_PORT_NAME_TYPE_PFVF:
-		/* New representors naming schema. */
-		switch_info->representor = 1;
-		break;
-	}
-}
-
-/**
  * DPDK callback to retrieve plug-in module EEPROM information (type and size).
  *
  * @param dev
diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h
index 9fa7e47..911fd33 100644
--- a/drivers/net/mlx5/mlx5.h
+++ b/drivers/net/mlx5/mlx5.h
@@ -814,6 +814,10 @@ const uint32_t *mlx5_dev_supported_ptypes_get(struct rte_eth_dev *dev);
 int mlx5_dev_set_mtu(struct rte_eth_dev *dev, uint16_t mtu);
 int mlx5_hairpin_cap_get(struct rte_eth_dev *dev,
 			 struct rte_eth_hairpin_cap *cap);
+eth_rx_burst_t mlx5_select_rx_function(struct rte_eth_dev *dev);
+struct mlx5_priv *mlx5_port_to_eswitch_info(uint16_t port, bool valid);
+struct mlx5_priv *mlx5_dev_to_eswitch_info(struct rte_eth_dev *dev);
+int mlx5_dev_configure_rss_reta(struct rte_eth_dev *dev);
 
 /* mlx5_ethdev_os.c */
 
@@ -824,27 +828,17 @@ int mlx5_get_mtu(struct rte_eth_dev *dev, uint16_t *mtu);
 int mlx5_set_mtu(struct rte_eth_dev *dev, uint16_t mtu);
 int mlx5_read_clock(struct rte_eth_dev *dev, uint64_t *clock);
 int mlx5_link_update(struct rte_eth_dev *dev, int wait_to_complete);
-int mlx5_force_link_status_change(struct rte_eth_dev *dev, int status);
 int mlx5_dev_get_flow_ctrl(struct rte_eth_dev *dev,
 			   struct rte_eth_fc_conf *fc_conf);
 int mlx5_dev_set_flow_ctrl(struct rte_eth_dev *dev,
 			   struct rte_eth_fc_conf *fc_conf);
-void mlx5_dev_link_status_handler(void *arg);
 void mlx5_dev_interrupt_handler(void *arg);
 void mlx5_dev_interrupt_handler_devx(void *arg);
-void mlx5_dev_interrupt_handler_uninstall(struct rte_eth_dev *dev);
-void mlx5_dev_interrupt_handler_install(struct rte_eth_dev *dev);
 int mlx5_set_link_down(struct rte_eth_dev *dev);
 int mlx5_set_link_up(struct rte_eth_dev *dev);
 int mlx5_is_removed(struct rte_eth_dev *dev);
-eth_tx_burst_t mlx5_select_tx_function(struct rte_eth_dev *dev);
-eth_rx_burst_t mlx5_select_rx_function(struct rte_eth_dev *dev);
-struct mlx5_priv *mlx5_port_to_eswitch_info(uint16_t port, bool valid);
-struct mlx5_priv *mlx5_dev_to_eswitch_info(struct rte_eth_dev *dev);
 int mlx5_sysfs_switch_info(unsigned int ifindex,
 			   struct mlx5_switch_info *info);
-void mlx5_sysfs_check_switch_info(bool device_dir,
-				  struct mlx5_switch_info *switch_info);
 void mlx5_translate_port_name(const char *port_name_in,
 			      struct mlx5_switch_info *port_info_out);
 void mlx5_intr_callback_unregister(const struct rte_intr_handle *handle,
@@ -853,7 +847,6 @@ int mlx5_get_module_info(struct rte_eth_dev *dev,
 			 struct rte_eth_dev_module_info *modinfo);
 int mlx5_get_module_eeprom(struct rte_eth_dev *dev,
 			   struct rte_dev_eeprom_info *info);
-int mlx5_dev_configure_rss_reta(struct rte_eth_dev *dev);
 int mlx5_os_read_dev_stat(struct mlx5_priv *priv,
 			  const char *ctr_name, uint64_t *stat);
 int mlx5_os_read_dev_counters(struct rte_eth_dev *dev, uint64_t *stats);
@@ -1044,4 +1037,7 @@ int mlx5_txpp_xstats_get_names(struct rte_eth_dev *dev,
 			       unsigned int n, unsigned int n_used);
 void mlx5_txpp_interrupt_handler(void *cb_arg);
 
+/* mlx5_rxtx.c */
+
+eth_tx_burst_t mlx5_select_tx_function(struct rte_eth_dev *dev);
 #endif /* RTE_PMD_MLX5_H_ */
-- 
2.8.4


^ permalink raw reply	[flat|nested] 28+ messages in thread

* [dpdk-dev] [PATCH v3 7/8] net/mlx5: refactor multi process communication
  2020-07-19 10:18       ` [dpdk-dev] [PATCH v3 0/8] mlx5 PMD multi OS support - part #3 Ophir Munk
                           ` (5 preceding siblings ...)
  2020-07-19 10:18         ` [dpdk-dev] [PATCH v3 6/8] net/mlx5: header file cleanup Ophir Munk
@ 2020-07-19 10:18         ` Ophir Munk
  2020-07-19 10:18         ` [dpdk-dev] [PATCH v3 8/8] mlx5: remove inclusion of Verbs header files Ophir Munk
  2020-07-19 14:56         ` [dpdk-dev] [PATCH v3 0/8] mlx5 PMD multi OS support - part #3 Raslan Darawsheh
  8 siblings, 0 replies; 28+ messages in thread
From: Ophir Munk @ 2020-07-19 10:18 UTC (permalink / raw)
  To: dev; +Cc: Raslan Darawsheh, Ophir Munk, Matan Azrad

1. The shared data communication between the primary and the secondary
processes is implemented using Linux API. Move the Linux API code under
linux directory (file linux/mlx5_os.c).

2. File net/mlx5/mlx5_mp.c handles requests to the primary and secondary
processes (e.g. start_rxtx, stop_rxtx). It is Linux based so it is moved
under linux (new file linux/mlx5_mp_os.c).

Signed-off-by: Ophir Munk <ophirmu@mellanox.com>
Acked-by: Matan Azrad <matan@mellanox.com>
---
 drivers/net/mlx5/Makefile           |   2 +-
 drivers/net/mlx5/linux/meson.build  |   1 +
 drivers/net/mlx5/linux/mlx5_mp_os.c | 212 ++++++++++++++++++++++++++++++++++++
 drivers/net/mlx5/linux/mlx5_os.c    | 111 +++++++++++++++++++
 drivers/net/mlx5/meson.build        |   1 -
 drivers/net/mlx5/mlx5.c             | 114 +------------------
 drivers/net/mlx5/mlx5.h             |  13 ++-
 drivers/net/mlx5/mlx5_mp.c          | 212 ------------------------------------
 drivers/net/mlx5/mlx5_trigger.c     |   4 +-
 9 files changed, 337 insertions(+), 333 deletions(-)
 create mode 100644 drivers/net/mlx5/linux/mlx5_mp_os.c
 delete mode 100644 drivers/net/mlx5/mlx5_mp.c

diff --git a/drivers/net/mlx5/Makefile b/drivers/net/mlx5/Makefile
index 3c5f486..cca7c9e 100644
--- a/drivers/net/mlx5/Makefile
+++ b/drivers/net/mlx5/Makefile
@@ -30,12 +30,12 @@ SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5_flow.c
 SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5_flow_meter.c
 SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5_flow_dv.c
 SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5_flow_verbs.c
-SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5_mp.c
 SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5_utils.c
 SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += linux/mlx5_socket.c
 SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += linux/mlx5_os.c
 SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += linux/mlx5_ethdev_os.c
 SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += linux/mlx5_verbs.c
+SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += linux/mlx5_mp_os.c
 
 # Basic CFLAGS.
 CFLAGS += -O3
diff --git a/drivers/net/mlx5/linux/meson.build b/drivers/net/mlx5/linux/meson.build
index 14eed03..2def8e3 100644
--- a/drivers/net/mlx5/linux/meson.build
+++ b/drivers/net/mlx5/linux/meson.build
@@ -7,5 +7,6 @@ sources += files(
 	'mlx5_os.c',
 	'mlx5_ethdev_os.c',
 	'mlx5_verbs.c',
+	'mlx5_mp_os.c',
 )
 
diff --git a/drivers/net/mlx5/linux/mlx5_mp_os.c b/drivers/net/mlx5/linux/mlx5_mp_os.c
new file mode 100644
index 0000000..dd9a2c2
--- /dev/null
+++ b/drivers/net/mlx5/linux/mlx5_mp_os.c
@@ -0,0 +1,212 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright 2019 6WIND S.A.
+ * Copyright 2019 Mellanox Technologies, Ltd
+ */
+
+#include <stdio.h>
+#include <time.h>
+
+#include <rte_eal.h>
+#include <rte_ethdev_driver.h>
+#include <rte_string_fns.h>
+
+#include <mlx5_common_mp.h>
+#include <mlx5_common_mr.h>
+#include <mlx5_malloc.h>
+
+#include "mlx5.h"
+#include "mlx5_rxtx.h"
+#include "mlx5_utils.h"
+
+int
+mlx5_mp_os_primary_handle(const struct rte_mp_msg *mp_msg, const void *peer)
+{
+	struct rte_mp_msg mp_res;
+	struct mlx5_mp_param *res = (struct mlx5_mp_param *)mp_res.param;
+	const struct mlx5_mp_param *param =
+		(const struct mlx5_mp_param *)mp_msg->param;
+	struct rte_eth_dev *dev;
+	struct mlx5_priv *priv;
+	struct mr_cache_entry entry;
+	uint32_t lkey;
+	int ret;
+
+	MLX5_ASSERT(rte_eal_process_type() == RTE_PROC_PRIMARY);
+	if (!rte_eth_dev_is_valid_port(param->port_id)) {
+		rte_errno = ENODEV;
+		DRV_LOG(ERR, "port %u invalid port ID", param->port_id);
+		return -rte_errno;
+	}
+	dev = &rte_eth_devices[param->port_id];
+	priv = dev->data->dev_private;
+	switch (param->type) {
+	case MLX5_MP_REQ_CREATE_MR:
+		mp_init_msg(&priv->mp_id, &mp_res, param->type);
+		lkey = mlx5_mr_create_primary(priv->sh->pd,
+					      &priv->sh->share_cache,
+					      &entry, param->args.addr,
+					      priv->config.mr_ext_memseg_en);
+		if (lkey == UINT32_MAX)
+			res->result = -rte_errno;
+		ret = rte_mp_reply(&mp_res, peer);
+		break;
+	case MLX5_MP_REQ_VERBS_CMD_FD:
+		mp_init_msg(&priv->mp_id, &mp_res, param->type);
+		mp_res.num_fds = 1;
+		mp_res.fds[0] = ((struct ibv_context *)priv->sh->ctx)->cmd_fd;
+		res->result = 0;
+		ret = rte_mp_reply(&mp_res, peer);
+		break;
+	case MLX5_MP_REQ_QUEUE_STATE_MODIFY:
+		mp_init_msg(&priv->mp_id, &mp_res, param->type);
+		res->result = mlx5_queue_state_modify_primary
+					(dev, &param->args.state_modify);
+		ret = rte_mp_reply(&mp_res, peer);
+		break;
+	default:
+		rte_errno = EINVAL;
+		DRV_LOG(ERR, "port %u invalid mp request type",
+			dev->data->port_id);
+		return -rte_errno;
+	}
+	return ret;
+}
+
+/**
+ * IPC message handler of a secondary process.
+ *
+ * @param[in] dev
+ *   Pointer to Ethernet structure.
+ * @param[in] peer
+ *   Pointer to the peer socket path.
+ *
+ * @return
+ *   0 on success, a negative errno value otherwise and rte_errno is set.
+ */
+int
+mlx5_mp_os_secondary_handle(const struct rte_mp_msg *mp_msg, const void *peer)
+{
+	struct rte_mp_msg mp_res;
+	struct mlx5_mp_param *res = (struct mlx5_mp_param *)mp_res.param;
+	const struct mlx5_mp_param *param =
+		(const struct mlx5_mp_param *)mp_msg->param;
+	struct rte_eth_dev *dev;
+	struct mlx5_priv *priv;
+	int ret;
+
+	MLX5_ASSERT(rte_eal_process_type() == RTE_PROC_SECONDARY);
+	if (!rte_eth_dev_is_valid_port(param->port_id)) {
+		rte_errno = ENODEV;
+		DRV_LOG(ERR, "port %u invalid port ID", param->port_id);
+		return -rte_errno;
+	}
+	dev = &rte_eth_devices[param->port_id];
+	priv = dev->data->dev_private;
+	switch (param->type) {
+	case MLX5_MP_REQ_START_RXTX:
+		DRV_LOG(INFO, "port %u starting datapath", dev->data->port_id);
+		rte_mb();
+		dev->rx_pkt_burst = mlx5_select_rx_function(dev);
+		dev->tx_pkt_burst = mlx5_select_tx_function(dev);
+		mp_init_msg(&priv->mp_id, &mp_res, param->type);
+		res->result = 0;
+		ret = rte_mp_reply(&mp_res, peer);
+		break;
+	case MLX5_MP_REQ_STOP_RXTX:
+		DRV_LOG(INFO, "port %u stopping datapath", dev->data->port_id);
+		dev->rx_pkt_burst = removed_rx_burst;
+		dev->tx_pkt_burst = removed_tx_burst;
+		rte_mb();
+		mp_init_msg(&priv->mp_id, &mp_res, param->type);
+		res->result = 0;
+		ret = rte_mp_reply(&mp_res, peer);
+		break;
+	default:
+		rte_errno = EINVAL;
+		DRV_LOG(ERR, "port %u invalid mp request type",
+			dev->data->port_id);
+		return -rte_errno;
+	}
+	return ret;
+}
+
+/**
+ * Broadcast request of stopping/starting data-path to secondary processes.
+ *
+ * @param[in] dev
+ *   Pointer to Ethernet structure.
+ * @param[in] type
+ *   Request type.
+ */
+static void
+mp_req_on_rxtx(struct rte_eth_dev *dev, enum mlx5_mp_req_type type)
+{
+	struct rte_mp_msg mp_req;
+	struct rte_mp_msg *mp_res;
+	struct rte_mp_reply mp_rep;
+	struct mlx5_mp_param *res;
+	struct timespec ts = {.tv_sec = MLX5_MP_REQ_TIMEOUT_SEC, .tv_nsec = 0};
+	struct mlx5_priv *priv = dev->data->dev_private;
+	int ret;
+	int i;
+
+	MLX5_ASSERT(rte_eal_process_type() == RTE_PROC_PRIMARY);
+	if (!mlx5_shared_data->secondary_cnt)
+		return;
+	if (type != MLX5_MP_REQ_START_RXTX && type != MLX5_MP_REQ_STOP_RXTX) {
+		DRV_LOG(ERR, "port %u unknown request (req_type %d)",
+			dev->data->port_id, type);
+		return;
+	}
+	mp_init_msg(&priv->mp_id, &mp_req, type);
+	ret = rte_mp_request_sync(&mp_req, &mp_rep, &ts);
+	if (ret) {
+		if (rte_errno != ENOTSUP)
+			DRV_LOG(ERR, "port %u failed to request stop/start Rx/Tx (%d)",
+				dev->data->port_id, type);
+		goto exit;
+	}
+	if (mp_rep.nb_sent != mp_rep.nb_received) {
+		DRV_LOG(ERR,
+			"port %u not all secondaries responded (req_type %d)",
+			dev->data->port_id, type);
+		goto exit;
+	}
+	for (i = 0; i < mp_rep.nb_received; i++) {
+		mp_res = &mp_rep.msgs[i];
+		res = (struct mlx5_mp_param *)mp_res->param;
+		if (res->result) {
+			DRV_LOG(ERR, "port %u request failed on secondary #%d",
+				dev->data->port_id, i);
+			goto exit;
+		}
+	}
+exit:
+	mlx5_free(mp_rep.msgs);
+}
+
+/**
+ * Broadcast request of starting data-path to secondary processes. The request
+ * is synchronous.
+ *
+ * @param[in] dev
+ *   Pointer to Ethernet structure.
+ */
+void
+mlx5_mp_os_req_start_rxtx(struct rte_eth_dev *dev)
+{
+	mp_req_on_rxtx(dev, MLX5_MP_REQ_START_RXTX);
+}
+
+/**
+ * Broadcast request of stopping data-path to secondary processes. The request
+ * is synchronous.
+ *
+ * @param[in] dev
+ *   Pointer to Ethernet structure.
+ */
+void
+mlx5_mp_os_req_stop_rxtx(struct rte_eth_dev *dev)
+{
+	mp_req_on_rxtx(dev, MLX5_MP_REQ_STOP_RXTX);
+}
diff --git a/drivers/net/mlx5/linux/mlx5_os.c b/drivers/net/mlx5/linux/mlx5_os.c
index d3ae3ad..70460ee 100644
--- a/drivers/net/mlx5/linux/mlx5_os.c
+++ b/drivers/net/mlx5/linux/mlx5_os.c
@@ -67,6 +67,14 @@
 #define MLX5DV_CONTEXT_FLAGS_CQE_128B_COMP (1 << 4)
 #endif
 
+static const char *MZ_MLX5_PMD_SHARED_DATA = "mlx5_pmd_shared_data";
+
+/* Spinlock for mlx5_shared_data allocation. */
+static rte_spinlock_t mlx5_shared_data_lock = RTE_SPINLOCK_INITIALIZER;
+
+/* Process local data for secondary processes. */
+static struct mlx5_local_data mlx5_local_data;
+
 /**
  * Get mlx5 device attributes. The glue function query_device_ex() is called
  * with out parameter of type 'struct ibv_device_attr_ex *'. Then fill in mlx5
@@ -357,6 +365,109 @@ mlx5_os_free_shared_dr(struct mlx5_priv *priv)
 }
 
 /**
+ * Initialize shared data between primary and secondary process.
+ *
+ * A memzone is reserved by primary process and secondary processes attach to
+ * the memzone.
+ *
+ * @return
+ *   0 on success, a negative errno value otherwise and rte_errno is set.
+ */
+static int
+mlx5_init_shared_data(void)
+{
+	const struct rte_memzone *mz;
+	int ret = 0;
+
+	rte_spinlock_lock(&mlx5_shared_data_lock);
+	if (mlx5_shared_data == NULL) {
+		if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
+			/* Allocate shared memory. */
+			mz = rte_memzone_reserve(MZ_MLX5_PMD_SHARED_DATA,
+						 sizeof(*mlx5_shared_data),
+						 SOCKET_ID_ANY, 0);
+			if (mz == NULL) {
+				DRV_LOG(ERR,
+					"Cannot allocate mlx5 shared data");
+				ret = -rte_errno;
+				goto error;
+			}
+			mlx5_shared_data = mz->addr;
+			memset(mlx5_shared_data, 0, sizeof(*mlx5_shared_data));
+			rte_spinlock_init(&mlx5_shared_data->lock);
+		} else {
+			/* Lookup allocated shared memory. */
+			mz = rte_memzone_lookup(MZ_MLX5_PMD_SHARED_DATA);
+			if (mz == NULL) {
+				DRV_LOG(ERR,
+					"Cannot attach mlx5 shared data");
+				ret = -rte_errno;
+				goto error;
+			}
+			mlx5_shared_data = mz->addr;
+			memset(&mlx5_local_data, 0, sizeof(mlx5_local_data));
+		}
+	}
+error:
+	rte_spinlock_unlock(&mlx5_shared_data_lock);
+	return ret;
+}
+
+/**
+ * PMD global initialization.
+ *
+ * Independent from individual device, this function initializes global
+ * per-PMD data structures distinguishing primary and secondary processes.
+ * Hence, each initialization is called once per a process.
+ *
+ * @return
+ *   0 on success, a negative errno value otherwise and rte_errno is set.
+ */
+static int
+mlx5_init_once(void)
+{
+	struct mlx5_shared_data *sd;
+	struct mlx5_local_data *ld = &mlx5_local_data;
+	int ret = 0;
+
+	if (mlx5_init_shared_data())
+		return -rte_errno;
+	sd = mlx5_shared_data;
+	MLX5_ASSERT(sd);
+	rte_spinlock_lock(&sd->lock);
+	switch (rte_eal_process_type()) {
+	case RTE_PROC_PRIMARY:
+		if (sd->init_done)
+			break;
+		LIST_INIT(&sd->mem_event_cb_list);
+		rte_rwlock_init(&sd->mem_event_rwlock);
+		rte_mem_event_callback_register("MLX5_MEM_EVENT_CB",
+						mlx5_mr_mem_event_cb, NULL);
+		ret = mlx5_mp_init_primary(MLX5_MP_NAME,
+					   mlx5_mp_os_primary_handle);
+		if (ret)
+			goto out;
+		sd->init_done = true;
+		break;
+	case RTE_PROC_SECONDARY:
+		if (ld->init_done)
+			break;
+		ret = mlx5_mp_init_secondary(MLX5_MP_NAME,
+					     mlx5_mp_os_secondary_handle);
+		if (ret)
+			goto out;
+		++sd->secondary_cnt;
+		ld->init_done = true;
+		break;
+	default:
+		break;
+	}
+out:
+	rte_spinlock_unlock(&sd->lock);
+	return ret;
+}
+
+/**
  * Spawn an Ethernet device from Verbs information.
  *
  * @param dpdk_dev
diff --git a/drivers/net/mlx5/meson.build b/drivers/net/mlx5/meson.build
index e35d90b..3aefb85 100644
--- a/drivers/net/mlx5/meson.build
+++ b/drivers/net/mlx5/meson.build
@@ -22,7 +22,6 @@ sources = files(
 	'mlx5_rxmode.c',
 	'mlx5_rxq.c',
 	'mlx5_rxtx.c',
-	'mlx5_mp.c',
 	'mlx5_stats.c',
 	'mlx5_trigger.c',
 	'mlx5_txq.c',
diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c
index ab9cb8a..b6d5953 100644
--- a/drivers/net/mlx5/mlx5.c
+++ b/drivers/net/mlx5/mlx5.c
@@ -187,16 +187,11 @@
 /* Decap will be used or not. */
 #define MLX5_DECAP_EN "decap_en"
 
-static const char *MZ_MLX5_PMD_SHARED_DATA = "mlx5_pmd_shared_data";
-
 /* Shared memory between primary and secondary processes. */
 struct mlx5_shared_data *mlx5_shared_data;
 
-/* Spinlock for mlx5_shared_data allocation. */
-static rte_spinlock_t mlx5_shared_data_lock = RTE_SPINLOCK_INITIALIZER;
-
-/* Process local data for secondary processes. */
-static struct mlx5_local_data mlx5_local_data;
+/** Driver-specific log messages type. */
+int mlx5_logtype;
 
 static LIST_HEAD(, mlx5_dev_ctx_shared) mlx5_dev_ctx_list =
 						LIST_HEAD_INITIALIZER();
@@ -1118,55 +1113,6 @@ mlx5_alloc_table_hash_list(struct mlx5_priv *priv)
 }
 
 /**
- * Initialize shared data between primary and secondary process.
- *
- * A memzone is reserved by primary process and secondary processes attach to
- * the memzone.
- *
- * @return
- *   0 on success, a negative errno value otherwise and rte_errno is set.
- */
-static int
-mlx5_init_shared_data(void)
-{
-	const struct rte_memzone *mz;
-	int ret = 0;
-
-	rte_spinlock_lock(&mlx5_shared_data_lock);
-	if (mlx5_shared_data == NULL) {
-		if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
-			/* Allocate shared memory. */
-			mz = rte_memzone_reserve(MZ_MLX5_PMD_SHARED_DATA,
-						 sizeof(*mlx5_shared_data),
-						 SOCKET_ID_ANY, 0);
-			if (mz == NULL) {
-				DRV_LOG(ERR,
-					"Cannot allocate mlx5 shared data");
-				ret = -rte_errno;
-				goto error;
-			}
-			mlx5_shared_data = mz->addr;
-			memset(mlx5_shared_data, 0, sizeof(*mlx5_shared_data));
-			rte_spinlock_init(&mlx5_shared_data->lock);
-		} else {
-			/* Lookup allocated shared memory. */
-			mz = rte_memzone_lookup(MZ_MLX5_PMD_SHARED_DATA);
-			if (mz == NULL) {
-				DRV_LOG(ERR,
-					"Cannot attach mlx5 shared data");
-				ret = -rte_errno;
-				goto error;
-			}
-			mlx5_shared_data = mz->addr;
-			memset(&mlx5_local_data, 0, sizeof(mlx5_local_data));
-		}
-	}
-error:
-	rte_spinlock_unlock(&mlx5_shared_data_lock);
-	return ret;
-}
-
-/**
  * Retrieve integer value from environment variable.
  *
  * @param[in] name
@@ -1307,7 +1253,7 @@ mlx5_dev_close(struct rte_eth_dev *dev)
 	dev->tx_pkt_burst = removed_tx_burst;
 	rte_wmb();
 	/* Disable datapath on secondary process. */
-	mlx5_mp_req_stop_rxtx(dev);
+	mlx5_mp_os_req_stop_rxtx(dev);
 	/* Free the eCPRI flex parser resource. */
 	mlx5_flex_parser_ecpri_release(dev);
 	if (priv->rxqs != NULL) {
@@ -1640,60 +1586,6 @@ mlx5_args(struct mlx5_dev_config *config, struct rte_devargs *devargs)
 }
 
 /**
- * PMD global initialization.
- *
- * Independent from individual device, this function initializes global
- * per-PMD data structures distinguishing primary and secondary processes.
- * Hence, each initialization is called once per a process.
- *
- * @return
- *   0 on success, a negative errno value otherwise and rte_errno is set.
- */
-int
-mlx5_init_once(void)
-{
-	struct mlx5_shared_data *sd;
-	struct mlx5_local_data *ld = &mlx5_local_data;
-	int ret = 0;
-
-	if (mlx5_init_shared_data())
-		return -rte_errno;
-	sd = mlx5_shared_data;
-	MLX5_ASSERT(sd);
-	rte_spinlock_lock(&sd->lock);
-	switch (rte_eal_process_type()) {
-	case RTE_PROC_PRIMARY:
-		if (sd->init_done)
-			break;
-		LIST_INIT(&sd->mem_event_cb_list);
-		rte_rwlock_init(&sd->mem_event_rwlock);
-		rte_mem_event_callback_register("MLX5_MEM_EVENT_CB",
-						mlx5_mr_mem_event_cb, NULL);
-		ret = mlx5_mp_init_primary(MLX5_MP_NAME,
-					   mlx5_mp_primary_handle);
-		if (ret)
-			goto out;
-		sd->init_done = true;
-		break;
-	case RTE_PROC_SECONDARY:
-		if (ld->init_done)
-			break;
-		ret = mlx5_mp_init_secondary(MLX5_MP_NAME,
-					     mlx5_mp_secondary_handle);
-		if (ret)
-			goto out;
-		++sd->secondary_cnt;
-		ld->init_done = true;
-		break;
-	default:
-		break;
-	}
-out:
-	rte_spinlock_unlock(&sd->lock);
-	return ret;
-}
-
-/**
  * Configures the minimal amount of data to inline into WQE
  * while sending packets.
  *
diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h
index 911fd33..ae9f5ff 100644
--- a/drivers/net/mlx5/mlx5.h
+++ b/drivers/net/mlx5/mlx5.h
@@ -793,7 +793,6 @@ void mlx5_set_min_inline(struct mlx5_dev_spawn_data *spawn,
 void mlx5_set_metadata_mask(struct rte_eth_dev *dev);
 int mlx5_dev_check_sibling_config(struct mlx5_priv *priv,
 				  struct mlx5_dev_config *config);
-int mlx5_init_once(void);
 int mlx5_dev_configure(struct rte_eth_dev *dev);
 int mlx5_dev_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *info);
 int mlx5_fw_version_get(struct rte_eth_dev *dev, char *fw_ver, size_t fw_size);
@@ -978,11 +977,13 @@ void mlx5_flow_rxq_dynf_metadata_set(struct rte_eth_dev *dev);
 int mlx5_flow_get_aged_flows(struct rte_eth_dev *dev, void **contexts,
 			uint32_t nb_contexts, struct rte_flow_error *error);
 
-/* mlx5_mp.c */
-int mlx5_mp_primary_handle(const struct rte_mp_msg *mp_msg, const void *peer);
-int mlx5_mp_secondary_handle(const struct rte_mp_msg *mp_msg, const void *peer);
-void mlx5_mp_req_start_rxtx(struct rte_eth_dev *dev);
-void mlx5_mp_req_stop_rxtx(struct rte_eth_dev *dev);
+/* mlx5_mp_os.c */
+int mlx5_mp_os_primary_handle(const struct rte_mp_msg *mp_msg,
+			      const void *peer);
+int mlx5_mp_os_secondary_handle(const struct rte_mp_msg *mp_msg,
+				const void *peer);
+void mlx5_mp_os_req_start_rxtx(struct rte_eth_dev *dev);
+void mlx5_mp_os_req_stop_rxtx(struct rte_eth_dev *dev);
 
 /* mlx5_socket.c */
 
diff --git a/drivers/net/mlx5/mlx5_mp.c b/drivers/net/mlx5/mlx5_mp.c
deleted file mode 100644
index cf6e33b..0000000
--- a/drivers/net/mlx5/mlx5_mp.c
+++ /dev/null
@@ -1,212 +0,0 @@
-/* SPDX-License-Identifier: BSD-3-Clause
- * Copyright 2019 6WIND S.A.
- * Copyright 2019 Mellanox Technologies, Ltd
- */
-
-#include <stdio.h>
-#include <time.h>
-
-#include <rte_eal.h>
-#include <rte_ethdev_driver.h>
-#include <rte_string_fns.h>
-
-#include <mlx5_common_mp.h>
-#include <mlx5_common_mr.h>
-#include <mlx5_malloc.h>
-
-#include "mlx5.h"
-#include "mlx5_rxtx.h"
-#include "mlx5_utils.h"
-
-int
-mlx5_mp_primary_handle(const struct rte_mp_msg *mp_msg, const void *peer)
-{
-	struct rte_mp_msg mp_res;
-	struct mlx5_mp_param *res = (struct mlx5_mp_param *)mp_res.param;
-	const struct mlx5_mp_param *param =
-		(const struct mlx5_mp_param *)mp_msg->param;
-	struct rte_eth_dev *dev;
-	struct mlx5_priv *priv;
-	struct mr_cache_entry entry;
-	uint32_t lkey;
-	int ret;
-
-	MLX5_ASSERT(rte_eal_process_type() == RTE_PROC_PRIMARY);
-	if (!rte_eth_dev_is_valid_port(param->port_id)) {
-		rte_errno = ENODEV;
-		DRV_LOG(ERR, "port %u invalid port ID", param->port_id);
-		return -rte_errno;
-	}
-	dev = &rte_eth_devices[param->port_id];
-	priv = dev->data->dev_private;
-	switch (param->type) {
-	case MLX5_MP_REQ_CREATE_MR:
-		mp_init_msg(&priv->mp_id, &mp_res, param->type);
-		lkey = mlx5_mr_create_primary(priv->sh->pd,
-					      &priv->sh->share_cache,
-					      &entry, param->args.addr,
-					      priv->config.mr_ext_memseg_en);
-		if (lkey == UINT32_MAX)
-			res->result = -rte_errno;
-		ret = rte_mp_reply(&mp_res, peer);
-		break;
-	case MLX5_MP_REQ_VERBS_CMD_FD:
-		mp_init_msg(&priv->mp_id, &mp_res, param->type);
-		mp_res.num_fds = 1;
-		mp_res.fds[0] = ((struct ibv_context *)priv->sh->ctx)->cmd_fd;
-		res->result = 0;
-		ret = rte_mp_reply(&mp_res, peer);
-		break;
-	case MLX5_MP_REQ_QUEUE_STATE_MODIFY:
-		mp_init_msg(&priv->mp_id, &mp_res, param->type);
-		res->result = mlx5_queue_state_modify_primary
-					(dev, &param->args.state_modify);
-		ret = rte_mp_reply(&mp_res, peer);
-		break;
-	default:
-		rte_errno = EINVAL;
-		DRV_LOG(ERR, "port %u invalid mp request type",
-			dev->data->port_id);
-		return -rte_errno;
-	}
-	return ret;
-}
-
-/**
- * IPC message handler of a secondary process.
- *
- * @param[in] dev
- *   Pointer to Ethernet structure.
- * @param[in] peer
- *   Pointer to the peer socket path.
- *
- * @return
- *   0 on success, a negative errno value otherwise and rte_errno is set.
- */
-int
-mlx5_mp_secondary_handle(const struct rte_mp_msg *mp_msg, const void *peer)
-{
-	struct rte_mp_msg mp_res;
-	struct mlx5_mp_param *res = (struct mlx5_mp_param *)mp_res.param;
-	const struct mlx5_mp_param *param =
-		(const struct mlx5_mp_param *)mp_msg->param;
-	struct rte_eth_dev *dev;
-	struct mlx5_priv *priv;
-	int ret;
-
-	MLX5_ASSERT(rte_eal_process_type() == RTE_PROC_SECONDARY);
-	if (!rte_eth_dev_is_valid_port(param->port_id)) {
-		rte_errno = ENODEV;
-		DRV_LOG(ERR, "port %u invalid port ID", param->port_id);
-		return -rte_errno;
-	}
-	dev = &rte_eth_devices[param->port_id];
-	priv = dev->data->dev_private;
-	switch (param->type) {
-	case MLX5_MP_REQ_START_RXTX:
-		DRV_LOG(INFO, "port %u starting datapath", dev->data->port_id);
-		rte_mb();
-		dev->rx_pkt_burst = mlx5_select_rx_function(dev);
-		dev->tx_pkt_burst = mlx5_select_tx_function(dev);
-		mp_init_msg(&priv->mp_id, &mp_res, param->type);
-		res->result = 0;
-		ret = rte_mp_reply(&mp_res, peer);
-		break;
-	case MLX5_MP_REQ_STOP_RXTX:
-		DRV_LOG(INFO, "port %u stopping datapath", dev->data->port_id);
-		dev->rx_pkt_burst = removed_rx_burst;
-		dev->tx_pkt_burst = removed_tx_burst;
-		rte_mb();
-		mp_init_msg(&priv->mp_id, &mp_res, param->type);
-		res->result = 0;
-		ret = rte_mp_reply(&mp_res, peer);
-		break;
-	default:
-		rte_errno = EINVAL;
-		DRV_LOG(ERR, "port %u invalid mp request type",
-			dev->data->port_id);
-		return -rte_errno;
-	}
-	return ret;
-}
-
-/**
- * Broadcast request of stopping/starting data-path to secondary processes.
- *
- * @param[in] dev
- *   Pointer to Ethernet structure.
- * @param[in] type
- *   Request type.
- */
-static void
-mp_req_on_rxtx(struct rte_eth_dev *dev, enum mlx5_mp_req_type type)
-{
-	struct rte_mp_msg mp_req;
-	struct rte_mp_msg *mp_res;
-	struct rte_mp_reply mp_rep;
-	struct mlx5_mp_param *res;
-	struct timespec ts = {.tv_sec = MLX5_MP_REQ_TIMEOUT_SEC, .tv_nsec = 0};
-	struct mlx5_priv *priv = dev->data->dev_private;
-	int ret;
-	int i;
-
-	MLX5_ASSERT(rte_eal_process_type() == RTE_PROC_PRIMARY);
-	if (!mlx5_shared_data->secondary_cnt)
-		return;
-	if (type != MLX5_MP_REQ_START_RXTX && type != MLX5_MP_REQ_STOP_RXTX) {
-		DRV_LOG(ERR, "port %u unknown request (req_type %d)",
-			dev->data->port_id, type);
-		return;
-	}
-	mp_init_msg(&priv->mp_id, &mp_req, type);
-	ret = rte_mp_request_sync(&mp_req, &mp_rep, &ts);
-	if (ret) {
-		if (rte_errno != ENOTSUP)
-			DRV_LOG(ERR, "port %u failed to request stop/start Rx/Tx (%d)",
-				dev->data->port_id, type);
-		goto exit;
-	}
-	if (mp_rep.nb_sent != mp_rep.nb_received) {
-		DRV_LOG(ERR,
-			"port %u not all secondaries responded (req_type %d)",
-			dev->data->port_id, type);
-		goto exit;
-	}
-	for (i = 0; i < mp_rep.nb_received; i++) {
-		mp_res = &mp_rep.msgs[i];
-		res = (struct mlx5_mp_param *)mp_res->param;
-		if (res->result) {
-			DRV_LOG(ERR, "port %u request failed on secondary #%d",
-				dev->data->port_id, i);
-			goto exit;
-		}
-	}
-exit:
-	mlx5_free(mp_rep.msgs);
-}
-
-/**
- * Broadcast request of starting data-path to secondary processes. The request
- * is synchronous.
- *
- * @param[in] dev
- *   Pointer to Ethernet structure.
- */
-void
-mlx5_mp_req_start_rxtx(struct rte_eth_dev *dev)
-{
-	mp_req_on_rxtx(dev, MLX5_MP_REQ_START_RXTX);
-}
-
-/**
- * Broadcast request of stopping data-path to secondary processes. The request
- * is synchronous.
- *
- * @param[in] dev
- *   Pointer to Ethernet structure.
- */
-void
-mlx5_mp_req_stop_rxtx(struct rte_eth_dev *dev)
-{
-	mp_req_on_rxtx(dev, MLX5_MP_REQ_STOP_RXTX);
-}
diff --git a/drivers/net/mlx5/mlx5_trigger.c b/drivers/net/mlx5/mlx5_trigger.c
index 6e5a730..6f1e6d4 100644
--- a/drivers/net/mlx5/mlx5_trigger.c
+++ b/drivers/net/mlx5/mlx5_trigger.c
@@ -350,7 +350,7 @@ mlx5_dev_start(struct rte_eth_dev *dev)
 	dev->tx_pkt_burst = mlx5_select_tx_function(dev);
 	dev->rx_pkt_burst = mlx5_select_rx_function(dev);
 	/* Enable datapath on secondary process. */
-	mlx5_mp_req_start_rxtx(dev);
+	mlx5_mp_os_req_start_rxtx(dev);
 	if (priv->sh->intr_handle.fd >= 0) {
 		priv->sh->port[priv->dev_port - 1].ih_port_id =
 					(uint32_t)dev->data->port_id;
@@ -396,7 +396,7 @@ mlx5_dev_stop(struct rte_eth_dev *dev)
 	dev->tx_pkt_burst = removed_tx_burst;
 	rte_wmb();
 	/* Disable datapath on secondary process. */
-	mlx5_mp_req_stop_rxtx(dev);
+	mlx5_mp_os_req_stop_rxtx(dev);
 	usleep(1000 * priv->rxqs_n);
 	DRV_LOG(DEBUG, "port %u stopping device", dev->data->port_id);
 	mlx5_flow_stop_default(dev);
-- 
2.8.4


^ permalink raw reply	[flat|nested] 28+ messages in thread

* [dpdk-dev] [PATCH v3 8/8] mlx5: remove inclusion of Verbs header files
  2020-07-19 10:18       ` [dpdk-dev] [PATCH v3 0/8] mlx5 PMD multi OS support - part #3 Ophir Munk
                           ` (6 preceding siblings ...)
  2020-07-19 10:18         ` [dpdk-dev] [PATCH v3 7/8] net/mlx5: refactor multi process communication Ophir Munk
@ 2020-07-19 10:18         ` Ophir Munk
  2020-07-19 14:56         ` [dpdk-dev] [PATCH v3 0/8] mlx5 PMD multi OS support - part #3 Raslan Darawsheh
  8 siblings, 0 replies; 28+ messages in thread
From: Ophir Munk @ 2020-07-19 10:18 UTC (permalink / raw)
  To: dev; +Cc: Raslan Darawsheh, Ophir Munk, Matan Azrad

Several source files include Verbs header files as in (1). These source
files will not compile under non-Linux operating systems. This commit
removes this inclusion in two cases:

Case 1: There is no usage of ibv_* or mlx5dv_* symbols in the source
file so the inclusion in (1) can be safely removed.

Case 2: Verbs symbols are used. Please note the inclusion in (1) already
appears in file linux/mlx5_glue.h (which represents the interface
to the rdma-core library). Therefore, replace (1) in the source file
with (2).  Under non-Linux operating systems - file mlx5_glue.h will not
include (1).

(1)
 #include <infiniband/verbs.h>
 #include <infiniband/mlx5dv.h>

(2)
 #include <mlx5_glue.h>

Signed-off-by: Ophir Munk <ophirmu@mellanox.com>
Acked-by: Matan Azrad <matan@mellanox.com>
---
 drivers/common/mlx5/linux/mlx5_common_os.h    |  7 +------
 drivers/common/mlx5/linux/mlx5_common_verbs.c | 15 ---------------
 drivers/common/mlx5/mlx5_common_mp.h          | 11 +----------
 drivers/common/mlx5/mlx5_common_mr.h          | 11 +----------
 drivers/common/mlx5/mlx5_prm.h                | 11 +----------
 drivers/net/mlx5/linux/mlx5_os.c              | 10 ----------
 drivers/net/mlx5/linux/mlx5_verbs.c           | 14 --------------
 drivers/net/mlx5/mlx5.c                       | 10 ----------
 drivers/net/mlx5/mlx5.h                       | 10 ----------
 drivers/net/mlx5/mlx5_flow.c                  | 11 +----------
 drivers/net/mlx5/mlx5_flow.h                  | 11 +----------
 drivers/net/mlx5/mlx5_flow_dv.c               | 11 +----------
 drivers/net/mlx5/mlx5_flow_verbs.c            | 10 ----------
 drivers/net/mlx5/mlx5_mac.c                   | 10 ----------
 drivers/net/mlx5/mlx5_mr.c                    |  9 ---------
 drivers/net/mlx5/mlx5_mr.h                    | 11 -----------
 drivers/net/mlx5/mlx5_rss.c                   | 10 ----------
 drivers/net/mlx5/mlx5_rxmode.c                | 11 +----------
 drivers/net/mlx5/mlx5_rxq.c                   | 11 -----------
 drivers/net/mlx5/mlx5_rxtx.c                  | 12 +-----------
 drivers/net/mlx5/mlx5_rxtx.h                  | 11 -----------
 drivers/net/mlx5/mlx5_rxtx_vec.c              | 12 +-----------
 drivers/net/mlx5/mlx5_txq.c                   | 11 -----------
 drivers/net/mlx5/mlx5_vlan.c                  | 17 -----------------
 24 files changed, 10 insertions(+), 257 deletions(-)

diff --git a/drivers/common/mlx5/linux/mlx5_common_os.h b/drivers/common/mlx5/linux/mlx5_common_os.h
index 9a6872c..55c0902 100644
--- a/drivers/common/mlx5/linux/mlx5_common_os.h
+++ b/drivers/common/mlx5/linux/mlx5_common_os.h
@@ -15,12 +15,7 @@
 #include <rte_devargs.h>
 
 #include "mlx5_autoconf.h"
-#ifdef HAVE_INFINIBAND_VERBS_H
-#include <infiniband/verbs.h>
-#endif
-#ifdef HAVE_INFINIBAND_MLX5DV_H
-#include <infiniband/mlx5dv.h>
-#endif
+#include "mlx5_glue.h"
 
 /**
  * Get device name. Given an ibv_device pointer - return a
diff --git a/drivers/common/mlx5/linux/mlx5_common_verbs.c b/drivers/common/mlx5/linux/mlx5_common_verbs.c
index a2fc7a3..339535d 100644
--- a/drivers/common/mlx5/linux/mlx5_common_verbs.c
+++ b/drivers/common/mlx5/linux/mlx5_common_verbs.c
@@ -10,22 +10,7 @@
 #include <sys/mman.h>
 #include <inttypes.h>
 
-/* Verbs header. */
-/* ISO C doesn't support unnamed structs/unions, disabling -pedantic. */
 #include "mlx5_autoconf.h"
-#ifdef PEDANTIC
-#pragma GCC diagnostic ignored "-Wpedantic"
-#endif
-#ifdef HAVE_INFINIBAND_VERBS_H
-#include <infiniband/verbs.h>
-#endif
-#ifdef HAVE_INFINIBAND_MLX5DV_H
-#include <infiniband/mlx5dv.h>
-#endif
-#ifdef PEDANTIC
-#pragma GCC diagnostic error "-Wpedantic"
-#endif
-
 #include <mlx5_glue.h>
 #include <mlx5_common.h>
 #include <mlx5_common_mr.h>
diff --git a/drivers/common/mlx5/mlx5_common_mp.h b/drivers/common/mlx5/mlx5_common_mp.h
index 05466fd..64260c0 100644
--- a/drivers/common/mlx5/mlx5_common_mp.h
+++ b/drivers/common/mlx5/mlx5_common_mp.h
@@ -6,16 +6,7 @@
 #ifndef RTE_PMD_MLX5_COMMON_MP_H_
 #define RTE_PMD_MLX5_COMMON_MP_H_
 
-/* Verbs header. */
-/* ISO C doesn't support unnamed structs/unions, disabling -pedantic. */
-#ifdef PEDANTIC
-#pragma GCC diagnostic ignored "-Wpedantic"
-#endif
-#include <infiniband/verbs.h>
-#ifdef PEDANTIC
-#pragma GCC diagnostic error "-Wpedantic"
-#endif
-
+#include <mlx5_glue.h>
 #include <rte_eal.h>
 #include <rte_string_fns.h>
 
diff --git a/drivers/common/mlx5/mlx5_common_mr.h b/drivers/common/mlx5/mlx5_common_mr.h
index b23ee66..a2c426d 100644
--- a/drivers/common/mlx5/mlx5_common_mr.h
+++ b/drivers/common/mlx5/mlx5_common_mr.h
@@ -10,21 +10,12 @@
 #include <stdint.h>
 #include <sys/queue.h>
 
-/* Verbs header. */
-/* ISO C doesn't support unnamed structs/unions, disabling -pedantic. */
-#ifdef PEDANTIC
-#pragma GCC diagnostic ignored "-Wpedantic"
-#endif
-#include <infiniband/verbs.h>
-#include <infiniband/mlx5dv.h>
-#ifdef PEDANTIC
-#pragma GCC diagnostic error "-Wpedantic"
-#endif
 
 #include <rte_rwlock.h>
 #include <rte_bitmap.h>
 #include <rte_memory.h>
 
+#include "mlx5_glue.h"
 #include "mlx5_common_mp.h"
 
 /* Size of per-queue MR cache array for linear search. */
diff --git a/drivers/common/mlx5/mlx5_prm.h b/drivers/common/mlx5/mlx5_prm.h
index 4847c6e..cb5f968 100644
--- a/drivers/common/mlx5/mlx5_prm.h
+++ b/drivers/common/mlx5/mlx5_prm.h
@@ -6,21 +6,12 @@
 #ifndef RTE_PMD_MLX5_PRM_H_
 #define RTE_PMD_MLX5_PRM_H_
 
-/* Verbs header. */
-/* ISO C doesn't support unnamed structs/unions, disabling -pedantic. */
-#ifdef PEDANTIC
-#pragma GCC diagnostic ignored "-Wpedantic"
-#endif
-#include <infiniband/mlx5dv.h>
-#ifdef PEDANTIC
-#pragma GCC diagnostic error "-Wpedantic"
-#endif
-
 #include <unistd.h>
 
 #include <rte_vect.h>
 #include <rte_byteorder.h>
 
+#include <mlx5_glue.h>
 #include "mlx5_autoconf.h"
 
 /* RSS hash key size. */
diff --git a/drivers/net/mlx5/linux/mlx5_os.c b/drivers/net/mlx5/linux/mlx5_os.c
index 70460ee..6d15ee2 100644
--- a/drivers/net/mlx5/linux/mlx5_os.c
+++ b/drivers/net/mlx5/linux/mlx5_os.c
@@ -15,16 +15,6 @@
 #include <linux/ethtool.h>
 #include <fcntl.h>
 
-/* Verbs header. */
-/* ISO C doesn't support unnamed structs/unions, disabling -pedantic. */
-#ifdef PEDANTIC
-#pragma GCC diagnostic ignored "-Wpedantic"
-#endif
-#include <infiniband/verbs.h>
-#ifdef PEDANTIC
-#pragma GCC diagnostic error "-Wpedantic"
-#endif
-
 #include <rte_malloc.h>
 #include <rte_ethdev_driver.h>
 #include <rte_ethdev_pci.h>
diff --git a/drivers/net/mlx5/linux/mlx5_verbs.c b/drivers/net/mlx5/linux/mlx5_verbs.c
index 5ac6982..d41b0fe 100644
--- a/drivers/net/mlx5/linux/mlx5_verbs.c
+++ b/drivers/net/mlx5/linux/mlx5_verbs.c
@@ -9,21 +9,7 @@
 #include <unistd.h>
 #include <inttypes.h>
 
-/* Verbs header. */
-/* ISO C doesn't support unnamed structs/unions, disabling -pedantic. */
 #include "mlx5_autoconf.h"
-#ifdef PEDANTIC
-#pragma GCC diagnostic ignored "-Wpedantic"
-#endif
-#ifdef HAVE_INFINIBAND_VERBS_H
-#include <infiniband/verbs.h>
-#endif
-#ifdef HAVE_INFINIBAND_MLX5DV_H
-#include <infiniband/mlx5dv.h>
-#endif
-#ifdef PEDANTIC
-#pragma GCC diagnostic error "-Wpedantic"
-#endif
 
 #include <rte_mbuf.h>
 #include <rte_malloc.h>
diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c
index b6d5953..466fa0f 100644
--- a/drivers/net/mlx5/mlx5.c
+++ b/drivers/net/mlx5/mlx5.c
@@ -13,16 +13,6 @@
 #include <sys/mman.h>
 #include <linux/rtnetlink.h>
 
-/* Verbs header. */
-/* ISO C doesn't support unnamed structs/unions, disabling -pedantic. */
-#ifdef PEDANTIC
-#pragma GCC diagnostic ignored "-Wpedantic"
-#endif
-#include <infiniband/verbs.h>
-#ifdef PEDANTIC
-#pragma GCC diagnostic error "-Wpedantic"
-#endif
-
 #include <rte_malloc.h>
 #include <rte_ethdev_driver.h>
 #include <rte_ethdev_pci.h>
diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h
index ae9f5ff..c00d527 100644
--- a/drivers/net/mlx5/mlx5.h
+++ b/drivers/net/mlx5/mlx5.h
@@ -14,16 +14,6 @@
 #include <netinet/in.h>
 #include <sys/queue.h>
 
-/* Verbs header. */
-/* ISO C doesn't support unnamed structs/unions, disabling -pedantic. */
-#ifdef PEDANTIC
-#pragma GCC diagnostic ignored "-Wpedantic"
-#endif
-#include <infiniband/verbs.h>
-#ifdef PEDANTIC
-#pragma GCC diagnostic error "-Wpedantic"
-#endif
-
 #include <rte_pci.h>
 #include <rte_ether.h>
 #include <rte_ethdev_driver.h>
diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c
index 52047db..e83cf83 100644
--- a/drivers/net/mlx5/mlx5_flow.c
+++ b/drivers/net/mlx5/mlx5_flow.c
@@ -10,16 +10,6 @@
 #include <string.h>
 #include <stdbool.h>
 
-/* Verbs header. */
-/* ISO C doesn't support unnamed structs/unions, disabling -pedantic. */
-#ifdef PEDANTIC
-#pragma GCC diagnostic ignored "-Wpedantic"
-#endif
-#include <infiniband/verbs.h>
-#ifdef PEDANTIC
-#pragma GCC diagnostic error "-Wpedantic"
-#endif
-
 #include <rte_common.h>
 #include <rte_ether.h>
 #include <rte_ethdev_driver.h>
@@ -29,6 +19,7 @@
 #include <rte_malloc.h>
 #include <rte_ip.h>
 
+#include <mlx5_glue.h>
 #include <mlx5_devx_cmds.h>
 #include <mlx5_prm.h>
 #include <mlx5_malloc.h>
diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h
index 314b5e3..73cfa6e 100644
--- a/drivers/net/mlx5/mlx5_flow.h
+++ b/drivers/net/mlx5/mlx5_flow.h
@@ -11,20 +11,11 @@
 #include <stdint.h>
 #include <string.h>
 
-/* Verbs header. */
-/* ISO C doesn't support unnamed structs/unions, disabling -pedantic. */
-#ifdef PEDANTIC
-#pragma GCC diagnostic ignored "-Wpedantic"
-#endif
-#include <infiniband/verbs.h>
-#ifdef PEDANTIC
-#pragma GCC diagnostic error "-Wpedantic"
-#endif
-
 #include <rte_atomic.h>
 #include <rte_alarm.h>
 #include <rte_mtr.h>
 
+#include <mlx5_glue.h>
 #include <mlx5_prm.h>
 
 #include "mlx5.h"
diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c
index 68dff23..ee66a44 100644
--- a/drivers/net/mlx5/mlx5_flow_dv.c
+++ b/drivers/net/mlx5/mlx5_flow_dv.c
@@ -8,16 +8,6 @@
 #include <string.h>
 #include <unistd.h>
 
-/* Verbs header. */
-/* ISO C doesn't support unnamed structs/unions, disabling -pedantic. */
-#ifdef PEDANTIC
-#pragma GCC diagnostic ignored "-Wpedantic"
-#endif
-#include <infiniband/verbs.h>
-#ifdef PEDANTIC
-#pragma GCC diagnostic error "-Wpedantic"
-#endif
-
 #include <rte_common.h>
 #include <rte_ether.h>
 #include <rte_ethdev_driver.h>
@@ -31,6 +21,7 @@
 #include <rte_gtp.h>
 #include <rte_eal_paging.h>
 
+#include <mlx5_glue.h>
 #include <mlx5_devx_cmds.h>
 #include <mlx5_prm.h>
 #include <mlx5_malloc.h>
diff --git a/drivers/net/mlx5/mlx5_flow_verbs.c b/drivers/net/mlx5/mlx5_flow_verbs.c
index 5d11ba7..905a122 100644
--- a/drivers/net/mlx5/mlx5_flow_verbs.c
+++ b/drivers/net/mlx5/mlx5_flow_verbs.c
@@ -8,16 +8,6 @@
 #include <stdint.h>
 #include <string.h>
 
-/* Verbs header. */
-/* ISO C doesn't support unnamed structs/unions, disabling -pedantic. */
-#ifdef PEDANTIC
-#pragma GCC diagnostic ignored "-Wpedantic"
-#endif
-#include <infiniband/verbs.h>
-#ifdef PEDANTIC
-#pragma GCC diagnostic error "-Wpedantic"
-#endif
-
 #include <rte_common.h>
 #include <rte_ether.h>
 #include <rte_ethdev_driver.h>
diff --git a/drivers/net/mlx5/mlx5_mac.c b/drivers/net/mlx5/mlx5_mac.c
index 2a88086..2d808d6 100644
--- a/drivers/net/mlx5/mlx5_mac.c
+++ b/drivers/net/mlx5/mlx5_mac.c
@@ -12,16 +12,6 @@
 #include <sys/ioctl.h>
 #include <arpa/inet.h>
 
-/* Verbs header. */
-/* ISO C doesn't support unnamed structs/unions, disabling -pedantic. */
-#ifdef PEDANTIC
-#pragma GCC diagnostic ignored "-Wpedantic"
-#endif
-#include <infiniband/verbs.h>
-#ifdef PEDANTIC
-#pragma GCC diagnostic error "-Wpedantic"
-#endif
-
 #include <rte_ether.h>
 #include <rte_ethdev_driver.h>
 #include <rte_common.h>
diff --git a/drivers/net/mlx5/mlx5_mr.c b/drivers/net/mlx5/mlx5_mr.c
index 3b781b6..dbcf0aa 100644
--- a/drivers/net/mlx5/mlx5_mr.c
+++ b/drivers/net/mlx5/mlx5_mr.c
@@ -3,21 +3,12 @@
  * Copyright 2016 Mellanox Technologies, Ltd
  */
 
-#ifdef PEDANTIC
-#pragma GCC diagnostic ignored "-Wpedantic"
-#endif
-#include <infiniband/verbs.h>
-#ifdef PEDANTIC
-#pragma GCC diagnostic error "-Wpedantic"
-#endif
-
 #include <rte_eal_memconfig.h>
 #include <rte_mempool.h>
 #include <rte_malloc.h>
 #include <rte_rwlock.h>
 #include <rte_bus_pci.h>
 
-#include <mlx5_glue.h>
 #include <mlx5_common_mp.h>
 #include <mlx5_common_mr.h>
 
diff --git a/drivers/net/mlx5/mlx5_mr.h b/drivers/net/mlx5/mlx5_mr.h
index 0c5877b..4a7fab6 100644
--- a/drivers/net/mlx5/mlx5_mr.h
+++ b/drivers/net/mlx5/mlx5_mr.h
@@ -10,17 +10,6 @@
 #include <stdint.h>
 #include <sys/queue.h>
 
-/* Verbs header. */
-/* ISO C doesn't support unnamed structs/unions, disabling -pedantic. */
-#ifdef PEDANTIC
-#pragma GCC diagnostic ignored "-Wpedantic"
-#endif
-#include <infiniband/verbs.h>
-#include <infiniband/mlx5dv.h>
-#ifdef PEDANTIC
-#pragma GCC diagnostic error "-Wpedantic"
-#endif
-
 #include <rte_ethdev.h>
 #include <rte_rwlock.h>
 #include <rte_bitmap.h>
diff --git a/drivers/net/mlx5/mlx5_rss.c b/drivers/net/mlx5/mlx5_rss.c
index a49edbc..a63cc8d 100644
--- a/drivers/net/mlx5/mlx5_rss.c
+++ b/drivers/net/mlx5/mlx5_rss.c
@@ -8,16 +8,6 @@
 #include <errno.h>
 #include <string.h>
 
-/* Verbs header. */
-/* ISO C doesn't support unnamed structs/unions, disabling -pedantic. */
-#ifdef PEDANTIC
-#pragma GCC diagnostic ignored "-Wpedantic"
-#endif
-#include <infiniband/verbs.h>
-#ifdef PEDANTIC
-#pragma GCC diagnostic error "-Wpedantic"
-#endif
-
 #include <rte_malloc.h>
 #include <rte_ethdev_driver.h>
 
diff --git a/drivers/net/mlx5/mlx5_rxmode.c b/drivers/net/mlx5/mlx5_rxmode.c
index 80b1256..7613ff7 100644
--- a/drivers/net/mlx5/mlx5_rxmode.c
+++ b/drivers/net/mlx5/mlx5_rxmode.c
@@ -7,18 +7,9 @@
 #include <errno.h>
 #include <string.h>
 
-/* Verbs header. */
-/* ISO C doesn't support unnamed structs/unions, disabling -pedantic. */
-#ifdef PEDANTIC
-#pragma GCC diagnostic ignored "-Wpedantic"
-#endif
-#include <infiniband/verbs.h>
-#ifdef PEDANTIC
-#pragma GCC diagnostic error "-Wpedantic"
-#endif
-
 #include <rte_ethdev_driver.h>
 
+#include <mlx5_glue.h>
 #include "mlx5.h"
 #include "mlx5_rxtx.h"
 #include "mlx5_utils.h"
diff --git a/drivers/net/mlx5/mlx5_rxq.c b/drivers/net/mlx5/mlx5_rxq.c
index 9e7df8e..9ef6bdd 100644
--- a/drivers/net/mlx5/mlx5_rxq.c
+++ b/drivers/net/mlx5/mlx5_rxq.c
@@ -10,17 +10,6 @@
 #include <fcntl.h>
 #include <sys/queue.h>
 
-/* Verbs header. */
-/* ISO C doesn't support unnamed structs/unions, disabling -pedantic. */
-#ifdef PEDANTIC
-#pragma GCC diagnostic ignored "-Wpedantic"
-#endif
-#include <infiniband/verbs.h>
-#include <infiniband/mlx5dv.h>
-#ifdef PEDANTIC
-#pragma GCC diagnostic error "-Wpedantic"
-#endif
-
 #include <rte_mbuf.h>
 #include <rte_malloc.h>
 #include <rte_ethdev_driver.h>
diff --git a/drivers/net/mlx5/mlx5_rxtx.c b/drivers/net/mlx5/mlx5_rxtx.c
index 65239f9..3eb0243 100644
--- a/drivers/net/mlx5/mlx5_rxtx.c
+++ b/drivers/net/mlx5/mlx5_rxtx.c
@@ -7,17 +7,6 @@
 #include <string.h>
 #include <stdlib.h>
 
-/* Verbs header. */
-/* ISO C doesn't support unnamed structs/unions, disabling -pedantic. */
-#ifdef PEDANTIC
-#pragma GCC diagnostic ignored "-Wpedantic"
-#endif
-#include <infiniband/verbs.h>
-#include <infiniband/mlx5dv.h>
-#ifdef PEDANTIC
-#pragma GCC diagnostic error "-Wpedantic"
-#endif
-
 #include <rte_mbuf.h>
 #include <rte_mempool.h>
 #include <rte_prefetch.h>
@@ -27,6 +16,7 @@
 #include <rte_cycles.h>
 #include <rte_flow.h>
 
+#include <mlx5_glue.h>
 #include <mlx5_devx_cmds.h>
 #include <mlx5_prm.h>
 #include <mlx5_common.h>
diff --git a/drivers/net/mlx5/mlx5_rxtx.h b/drivers/net/mlx5/mlx5_rxtx.h
index 5116a15..35a22b6 100644
--- a/drivers/net/mlx5/mlx5_rxtx.h
+++ b/drivers/net/mlx5/mlx5_rxtx.h
@@ -10,17 +10,6 @@
 #include <stdint.h>
 #include <sys/queue.h>
 
-/* Verbs header. */
-/* ISO C doesn't support unnamed structs/unions, disabling -pedantic. */
-#ifdef PEDANTIC
-#pragma GCC diagnostic ignored "-Wpedantic"
-#endif
-#include <infiniband/verbs.h>
-#include <infiniband/mlx5dv.h>
-#ifdef PEDANTIC
-#pragma GCC diagnostic error "-Wpedantic"
-#endif
-
 #include <rte_mbuf.h>
 #include <rte_mempool.h>
 #include <rte_common.h>
diff --git a/drivers/net/mlx5/mlx5_rxtx_vec.c b/drivers/net/mlx5/mlx5_rxtx_vec.c
index 7fae201..711dcd3 100644
--- a/drivers/net/mlx5/mlx5_rxtx_vec.c
+++ b/drivers/net/mlx5/mlx5_rxtx_vec.c
@@ -7,21 +7,11 @@
 #include <string.h>
 #include <stdlib.h>
 
-/* Verbs header. */
-/* ISO C doesn't support unnamed structs/unions, disabling -pedantic. */
-#ifdef PEDANTIC
-#pragma GCC diagnostic ignored "-Wpedantic"
-#endif
-#include <infiniband/verbs.h>
-#include <infiniband/mlx5dv.h>
-#ifdef PEDANTIC
-#pragma GCC diagnostic error "-Wpedantic"
-#endif
-
 #include <rte_mbuf.h>
 #include <rte_mempool.h>
 #include <rte_prefetch.h>
 
+#include <mlx5_glue.h>
 #include <mlx5_prm.h>
 
 #include "mlx5_defs.h"
diff --git a/drivers/net/mlx5/mlx5_txq.c b/drivers/net/mlx5/mlx5_txq.c
index d245a54..7da5c70 100644
--- a/drivers/net/mlx5/mlx5_txq.c
+++ b/drivers/net/mlx5/mlx5_txq.c
@@ -10,17 +10,6 @@
 #include <unistd.h>
 #include <inttypes.h>
 
-/* Verbs header. */
-/* ISO C doesn't support unnamed structs/unions, disabling -pedantic. */
-#ifdef PEDANTIC
-#pragma GCC diagnostic ignored "-Wpedantic"
-#endif
-#include <infiniband/verbs.h>
-#include <infiniband/mlx5dv.h>
-#ifdef PEDANTIC
-#pragma GCC diagnostic error "-Wpedantic"
-#endif
-
 #include <rte_mbuf.h>
 #include <rte_malloc.h>
 #include <rte_ethdev_driver.h>
diff --git a/drivers/net/mlx5/mlx5_vlan.c b/drivers/net/mlx5/mlx5_vlan.c
index 4308b71..89983a4 100644
--- a/drivers/net/mlx5/mlx5_vlan.c
+++ b/drivers/net/mlx5/mlx5_vlan.c
@@ -8,23 +8,6 @@
 #include <stdint.h>
 #include <unistd.h>
 
-
-/*
- * Not needed by this file; included to work around the lack of off_t
- * definition for mlx5dv.h with unpatched rdma-core versions.
- */
-#include <sys/types.h>
-
-/* Verbs headers do not support -pedantic. */
-#ifdef PEDANTIC
-#pragma GCC diagnostic ignored "-Wpedantic"
-#endif
-#include <infiniband/mlx5dv.h>
-#include <infiniband/verbs.h>
-#ifdef PEDANTIC
-#pragma GCC diagnostic error "-Wpedantic"
-#endif
-
 #include <rte_ethdev_driver.h>
 #include <rte_common.h>
 #include <rte_malloc.h>
-- 
2.8.4


^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [dpdk-dev] [PATCH v3 0/8] mlx5 PMD multi OS support - part #3
  2020-07-19 10:18       ` [dpdk-dev] [PATCH v3 0/8] mlx5 PMD multi OS support - part #3 Ophir Munk
                           ` (7 preceding siblings ...)
  2020-07-19 10:18         ` [dpdk-dev] [PATCH v3 8/8] mlx5: remove inclusion of Verbs header files Ophir Munk
@ 2020-07-19 14:56         ` Raslan Darawsheh
  8 siblings, 0 replies; 28+ messages in thread
From: Raslan Darawsheh @ 2020-07-19 14:56 UTC (permalink / raw)
  To: Ophir Munk, dev; +Cc: Matan Azrad

Hi,

> -----Original Message-----
> From: Ophir Munk <ophirmu@mellanox.com>
> Sent: Sunday, July 19, 2020 1:18 PM
> To: dev@dpdk.org
> Cc: Raslan Darawsheh <rasland@mellanox.com>; Ophir Munk
> <ophirmu@mellanox.com>; Matan Azrad <matan@mellanox.com>
> Subject: [PATCH v3 0/8] mlx5 PMD multi OS support - part #3
> 
> 
> This patch series is part of preparing mlx5 PMD to compile
> and run under multiple OSs. Part #3
> 
> v1: Initial version
> v2: Version rebased
> v3: Fix coverity complain: BRANCH_PAST_INITIALIZATION
> 
> Ophir Munk (8):
>   net/mlx5: move flow prio discovery and adjust under Verbs
>   net/mlx5: replace Linux specific calls with rte API
>   net/mlx5: refactor Linux MAC operations
>   linux/mlx5: add setters for promiscuous and all-multi
>   net/mlx5: eliminate dependency on Linux in shared header
>   net/mlx5: header file cleanup
>   net/mlx5: refactor multi process communication
>   mlx5: remove inclusion of Verbs header files
> 
>  drivers/common/mlx5/linux/mlx5_common_os.h    |   7 +-
>  drivers/common/mlx5/linux/mlx5_common_verbs.c |  15 -
>  drivers/common/mlx5/mlx5_common_mp.h          |  11 +-
>  drivers/common/mlx5/mlx5_common_mr.h          |  11 +-
>  drivers/common/mlx5/mlx5_devx_cmds.c          |   9 +-
>  drivers/common/mlx5/mlx5_prm.h                |  15 +-
>  drivers/net/mlx5/Makefile                     |   2 +-
>  drivers/net/mlx5/linux/meson.build            |   1 +
>  drivers/net/mlx5/linux/mlx5_ethdev_os.c       | 416
> +++++++++++++++++++---
>  drivers/net/mlx5/linux/mlx5_mp_os.c           | 212 +++++++++++
>  drivers/net/mlx5/linux/mlx5_os.c              | 490 +++++++++++---------------
>  drivers/net/mlx5/linux/mlx5_verbs.c           |  15 -
>  drivers/net/mlx5/meson.build                  |   1 -
>  drivers/net/mlx5/mlx5.c                       | 124 +------
>  drivers/net/mlx5/mlx5.h                       |  66 ++--
>  drivers/net/mlx5/mlx5_flow.c                  | 121 -------
>  drivers/net/mlx5/mlx5_flow.h                  |  12 +-
>  drivers/net/mlx5/mlx5_flow_dv.c               |  20 +-
>  drivers/net/mlx5/mlx5_flow_verbs.c            | 122 ++++++-
>  drivers/net/mlx5/mlx5_mac.c                   |  59 +---
>  drivers/net/mlx5/mlx5_mp.c                    | 212 -----------
>  drivers/net/mlx5/mlx5_mr.c                    |   9 -
>  drivers/net/mlx5/mlx5_mr.h                    |  11 -
>  drivers/net/mlx5/mlx5_rss.c                   |  10 -
>  drivers/net/mlx5/mlx5_rxmode.c                |  23 +-
>  drivers/net/mlx5/mlx5_rxq.c                   |  20 +-
>  drivers/net/mlx5/mlx5_rxtx.c                  |  12 +-
>  drivers/net/mlx5/mlx5_rxtx.h                  |  11 -
>  drivers/net/mlx5/mlx5_rxtx_vec.c              |  12 +-
>  drivers/net/mlx5/mlx5_trigger.c               |   4 +-
>  drivers/net/mlx5/mlx5_txpp.c                  |  15 +-
>  drivers/net/mlx5/mlx5_txq.c                   |  57 +--
>  drivers/net/mlx5/mlx5_vlan.c                  |  17 -
>  33 files changed, 1030 insertions(+), 1112 deletions(-)
>  create mode 100644 drivers/net/mlx5/linux/mlx5_mp_os.c
>  delete mode 100644 drivers/net/mlx5/mlx5_mp.c
> 
> --
> 2.8.4

Series applied to next-net-mlx,

Kindest regards,
Raslan Darawsheh

^ permalink raw reply	[flat|nested] 28+ messages in thread

end of thread, other threads:[~2020-07-19 14:56 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-14 14:20 [dpdk-dev] [PATCH v1 0/8] mlx5 PMD multi OS support - part #3 Ophir Munk
2020-07-14 14:20 ` [dpdk-dev] [PATCH v1 1/8] net/mlx5: move flow prio discovery and adjust under verbs Ophir Munk
2020-07-14 14:20 ` [dpdk-dev] [PATCH v1 2/8] net/mlx5: replace Linux specific calls with rte API Ophir Munk
2020-07-14 14:20 ` [dpdk-dev] [PATCH v1 3/8] net/mlx5: refactor Linux MAC operations Ophir Munk
2020-07-14 14:20 ` [dpdk-dev] [PATCH v1 4/8] linux/mlx5: add setters for promiscuous and all-multi Ophir Munk
2020-07-14 14:20 ` [dpdk-dev] [PATCH v1 5/8] net/mlx5: eliminate dependency on Linux in shared header Ophir Munk
2020-07-14 14:21 ` [dpdk-dev] [PATCH v1 6/8] net/mlx5: header file cleanup Ophir Munk
2020-07-14 14:21 ` [dpdk-dev] [PATCH v1 7/8] net/mlx5: refactor multi process communication Ophir Munk
2020-07-14 14:21 ` [dpdk-dev] [PATCH v1 8/8] mlx5: remove inclusion of verbs header files Ophir Munk
2020-07-19  7:11   ` [dpdk-dev] [PATCH v2 0/8] mlx5 PMD multi OS support - part #3 Ophir Munk
2020-07-19  7:11     ` [dpdk-dev] [PATCH v2 1/8] net/mlx5: move flow prio discovery and adjust under Verbs Ophir Munk
2020-07-19  7:11     ` [dpdk-dev] [PATCH v2 2/8] net/mlx5: replace Linux specific calls with rte API Ophir Munk
2020-07-19  7:11     ` [dpdk-dev] [PATCH v2 3/8] net/mlx5: refactor Linux MAC operations Ophir Munk
2020-07-19  7:11     ` [dpdk-dev] [PATCH v2 4/8] linux/mlx5: add setters for promiscuous and all-multi Ophir Munk
2020-07-19  7:11     ` [dpdk-dev] [PATCH v2 5/8] net/mlx5: eliminate dependency on Linux in shared header Ophir Munk
2020-07-19  7:11     ` [dpdk-dev] [PATCH v2 6/8] net/mlx5: header file cleanup Ophir Munk
2020-07-19  7:11     ` [dpdk-dev] [PATCH v2 7/8] net/mlx5: refactor multi process communication Ophir Munk
2020-07-19  7:11     ` [dpdk-dev] [PATCH v2 8/8] mlx5: remove inclusion of Verbs header files Ophir Munk
2020-07-19 10:18       ` [dpdk-dev] [PATCH v3 0/8] mlx5 PMD multi OS support - part #3 Ophir Munk
2020-07-19 10:18         ` [dpdk-dev] [PATCH v3 1/8] net/mlx5: move flow prio discovery and adjust under Verbs Ophir Munk
2020-07-19 10:18         ` [dpdk-dev] [PATCH v3 2/8] net/mlx5: replace Linux specific calls with rte API Ophir Munk
2020-07-19 10:18         ` [dpdk-dev] [PATCH v3 3/8] net/mlx5: refactor Linux MAC operations Ophir Munk
2020-07-19 10:18         ` [dpdk-dev] [PATCH v3 4/8] linux/mlx5: add setters for promiscuous and all-multi Ophir Munk
2020-07-19 10:18         ` [dpdk-dev] [PATCH v3 5/8] net/mlx5: eliminate dependency on Linux in shared header Ophir Munk
2020-07-19 10:18         ` [dpdk-dev] [PATCH v3 6/8] net/mlx5: header file cleanup Ophir Munk
2020-07-19 10:18         ` [dpdk-dev] [PATCH v3 7/8] net/mlx5: refactor multi process communication Ophir Munk
2020-07-19 10:18         ` [dpdk-dev] [PATCH v3 8/8] mlx5: remove inclusion of Verbs header files Ophir Munk
2020-07-19 14:56         ` [dpdk-dev] [PATCH v3 0/8] mlx5 PMD multi OS support - part #3 Raslan Darawsheh

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).