Skip to contentSkip to conversation

mlx5 Windows support - part #5

PATCH In review Ophir Munk 6 participants 235 messages Oct 27, 2020 – Jan 13, 2021 Page 1 of 2

Subsystems (4)
lore
Share & tools
lore

Ophir Munk

author
#0 lore raw

cover mlx5 Windows support - part #5

This patch series is part of preparing mlx5 PMD to compile and run under Windows OS. Part #5

v1: initial version

Ophir Munk (46):
net/mlx5: fix flow sample definitions net/mlx5/linux: extend device attributes getter net/mlx5: remove Linux files from Windows compilation net/mlx5: fix freeing packet pacing
net/mlx5: replace Linux sleep with rte sleep net/mlx5: define mprq functions as static inline net/mlx5: do not define static_assert in Windows net/mlx5: move static_assert calls to global scope net/mlx5: wrap glue alloc/dealloc PD with OS calls net/mlx5: fix adding destroy flow action wrapper common/mlx5: add definition HAVE_INFINIBAND_VERBS_H common/mlx5/linux: handle memory allocations with alignment common/mlx5/windows: handle memory allocations with alignment mlx5/windows: add initialization routine for external lib mlx5/windows: generate file mlx5_autoconf.h common/mlx5/windows: add getter functions
net/mlx5: update MR prototypes for DevX common/mlx5/windows: add OS reg/dereg MR drivers/common: enable Windows common mlx5 compilation net/mlx5/windows: implement device attribute getter net/mlx5/windows: add mlx5_os.c stubs
net/mlx5: refactor eth dev ops for Windows common/mlx5/windows: add missing DV and IBV definitions mlx5/windows: add mlx5_os header file under net net/mlx5/windows: add pthread initializer definition net/mlx5/windows: define epoll API to do nothing net/mlx5/windows: define errno ETOOMANYREFS common/mlx5: add rte compatibility header file common/mlx5/windows: add DevX UAR getters net/mlx5/windows: add memory region callbacks net/mlx5/windows: add stubs for MP requests net/mlx5/windows: add ethdev stub operations net/mlx5/windws: add VLAN stubs
net/mlx5: exclude rte_intr_callback_register call net/mlx5/windows: support open device net/mlx5/windws: spawn eth devices
net/mlx5/linux: wrap adjust flow priority with OS calls net/mlx5/linux: add OS default miss flow action net/mlx5/linux: fix add OS dest_devx_tir action drivers/net: enable Windows net/mlx5 compilation net/mlx5/windows: introduce flow support net/mlx5/windows: create flow matcher object net/mlx5/windows: create flow action dest TIR object net/mlx5/windows: create flow rule
net/mlx5: use HAVE_INFINIBAND_VERBS_H in shared code net/mlx5: fix separating eth_dev_ops per OS

Tal Shnaiderman (26):
mlx5: fix relaxed ordering DevX flow
net/mlx5: fix folding constant array error net/mlx5: wrap glue reg/dereg UMEM with OS calls common/mlx5/linux: wrap event channel APIs with OS calls common/mlx5: add Windows exports file common/mlx5: extend DevX query hca attributes command common/mlx5: add DevX alloc PD command common/mlx5/windows: add glue functions APIs mlx5/windows: add mlx5 meson file common/mlx5/windows: extend PRM match_param_bits struct common/mlx5/windows: add OS alloc/dealloc pd common/mlx5/windows: add OS umem reg/dereg API net/mlx5/windows: implement mlx5 mac addr add common/mlx5/windows: wrap event channel APIs with OS calls net/mlx5/windows: support get mac net/mlx5/windows: support link update net/mlx5/windows: support read clock net/mlx5/windows: support get mtu net/mlx5/windows: support get interface name net/mlx5/windows: support is removed net/mlx5/windows: support get pdn net/mlx5/windows: initial probing implementation net/mlx5/windows: support VF PCI address common/mlx5: fix Windows warnings on missing enum net/mlx5: fix Windows warnings on get_if_name
mlx5: build pmd only with the clang compiler

 drivers/common/meson.build                      |    8 +-
 drivers/common/mlx5/linux/meson.build           |    2 +
 drivers/common/mlx5/linux/mlx5_common_os.h      |   83 ++
 drivers/common/mlx5/meson.build                 |    4 +-
 drivers/common/mlx5/mlx5_common.c               |    4 +-
 drivers/common/mlx5/mlx5_common_mp.h            |    2 +-
 drivers/common/mlx5/mlx5_common_mr.h            |    1 +
 drivers/common/mlx5/mlx5_devx_cmds.c            |   54 +-
 drivers/common/mlx5/mlx5_devx_cmds.h            |   17 +-
 drivers/common/mlx5/mlx5_malloc.c               |   14 +-
 drivers/common/mlx5/mlx5_prm.h                  |   94 ++
 drivers/common/mlx5/rte_common_mlx5_exports.def |   67 ++
 drivers/common/mlx5/version.map                 |    1 +
 drivers/common/mlx5/windows/meson.build         |   46 +
 drivers/common/mlx5/windows/mlx5_common_os.c    |  209 ++++
 drivers/common/mlx5/windows/mlx5_common_os.h    |  257 +++++
 drivers/common/mlx5/windows/mlx5_glue.c         |  354 +++++++
 drivers/common/mlx5/windows/mlx5_glue.h         |   60 ++
 drivers/common/mlx5/windows/mlx5_win_defs.h     |  250 +++++
 drivers/common/mlx5/windows/mlx5_win_ext.h      |   46 +
 drivers/net/meson.build                         |    9 +-
 drivers/net/mlx5/linux/mlx5_flow_os.h           |   62 ++
 drivers/net/mlx5/linux/mlx5_os.c                |  175 +---
 drivers/net/mlx5/linux/mlx5_os.h                |    4 -
 drivers/net/mlx5/linux/mlx5_verbs.c             |    2 +-
 drivers/net/mlx5/linux/mlx5_verbs.h             |    8 +-
 drivers/net/mlx5/meson.build                    |   20 +-
 drivers/net/mlx5/mlx5.c                         |  168 +++-
 drivers/net/mlx5/mlx5.h                         |   25 +-
 drivers/net/mlx5/mlx5_defs.h                    |    7 +-
 drivers/net/mlx5/mlx5_devx.c                    |   39 +-
 drivers/net/mlx5/mlx5_flow.c                    |   26 +-
 drivers/net/mlx5/mlx5_flow.h                    |   16 +-
 drivers/net/mlx5/mlx5_flow_dv.c                 |   53 +-
 drivers/net/mlx5/mlx5_flow_verbs.c              |    6 +
 drivers/net/mlx5/mlx5_rxq.c                     |   71 --
 drivers/net/mlx5/mlx5_rxtx.c                    |   98 +-
 drivers/net/mlx5/mlx5_rxtx.h                    |   73 +-
 drivers/net/mlx5/mlx5_trigger.c                 |    3 +-
 drivers/net/mlx5/mlx5_txpp.c                    |   36 +-
 drivers/net/mlx5/windows/meson.build            |   12 +
 drivers/net/mlx5/windows/mlx5_ethdev_os.c       |  386 ++++++++
 drivers/net/mlx5/windows/mlx5_flow_os.c         |  237 +++++
 drivers/net/mlx5/windows/mlx5_flow_os.h         |  364 +++++++
 drivers/net/mlx5/windows/mlx5_mp_os.c           |   71 ++
 drivers/net/mlx5/windows/mlx5_os.c              | 1180 +++++++++++++++++++++++
 drivers/net/mlx5/windows/mlx5_os.h              |   27 +
 drivers/net/mlx5/windows/mlx5_vlan_os.c         |   83 ++
 drivers/vdpa/mlx5/mlx5_vdpa_event.c             |    7 +-
 drivers/vdpa/mlx5/mlx5_vdpa_lm.c                |    3 +-
 drivers/vdpa/mlx5/mlx5_vdpa_mem.c               |    3 +-
 51 files changed, 4433 insertions(+), 414 deletions(-)
 create mode 100644 drivers/common/mlx5/rte_common_mlx5_exports.def
 create mode 100644 drivers/common/mlx5/windows/meson.build
 create mode 100644 drivers/common/mlx5/windows/mlx5_common_os.c
 create mode 100644 drivers/common/mlx5/windows/mlx5_common_os.h
 create mode 100644 drivers/common/mlx5/windows/mlx5_glue.c
 create mode 100644 drivers/common/mlx5/windows/mlx5_glue.h
 create mode 100644 drivers/common/mlx5/windows/mlx5_win_defs.h
 create mode 100644 drivers/common/mlx5/windows/mlx5_win_ext.h
 create mode 100644 drivers/net/mlx5/windows/meson.build
 create mode 100644 drivers/net/mlx5/windows/mlx5_ethdev_os.c
 create mode 100644 drivers/net/mlx5/windows/mlx5_flow_os.c
 create mode 100644 drivers/net/mlx5/windows/mlx5_flow_os.h
 create mode 100644 drivers/net/mlx5/windows/mlx5_mp_os.c
 create mode 100644 drivers/net/mlx5/windows/mlx5_os.c
 create mode 100644 drivers/net/mlx5/windows/mlx5_os.h
 create mode 100644 drivers/net/mlx5/windows/mlx5_vlan_os.c
Signature · 1 line
2.8.4
author
#1 lore raw

PATCH 1/72 mlx5: fix relaxed ordering DevX flow

From: Tal Shnaiderman <[email protected]>

The current DevX implementation of the relaxed ordering feature is enabling relaxed ordering usage only if both relaxed ordering read AND write are supported. In that case both relaxed ordering read and write are activated.

This commit will optimize the usage of relaxed ordering by enabling it when the read OR write features are supported. Each relaxed ordering type will be activated according to it's own capability bit.

This will align the DevX flow with the verbs implementation of ibv_reg_mr when using the flag IBV_ACCESS_RELAXED_ORDERING

Fixes 53ac93f71ad1 ("net/mlx5: create relaxed ordering memory regions")
Fixes d4322061770b ("net/mlx5: synchronize flow counter pool creation")
---
 drivers/common/mlx5/mlx5_devx_cmds.c |  8 ++++----
 drivers/common/mlx5/mlx5_devx_cmds.h |  3 ++-
 drivers/net/mlx5/linux/mlx5_os.c     | 12 ++++++++----
 drivers/net/mlx5/mlx5.h              |  3 ++-
 drivers/net/mlx5/mlx5_flow.c         |  3 ++-
 drivers/vdpa/mlx5/mlx5_vdpa_lm.c     |  3 ++-
 drivers/vdpa/mlx5/mlx5_vdpa_mem.c    |  3 ++-
 7 files changed, 22 insertions(+), 13 deletions(-)
drivers/common/mlx5/mlx5_devx_cmds.c +4 -4
index 8aee12d..27eff5f 100644
@@ -267,10 +267,10 @@ mlx5_devx_cmd_mkey_create(void *ctx,
 	MLX5_SET(mkc, mkc, pd, attr->pd);
 	MLX5_SET(mkc, mkc, mkey_7_0, attr->umem_id & 0xFF);
 	MLX5_SET(mkc, mkc, translations_octword_size, translation_size);
-	if (attr->relaxed_ordering == 1) {
-		MLX5_SET(mkc, mkc, relaxed_ordering_write, 0x1);
-		MLX5_SET(mkc, mkc, relaxed_ordering_read, 0x1);
-	}
+	MLX5_SET(mkc, mkc, relaxed_ordering_write,
+		attr->relaxed_ordering_write);
+	MLX5_SET(mkc, mkc, relaxed_ordering_read,
+		attr->relaxed_ordering_read);
 	MLX5_SET64(mkc, mkc, start_addr, attr->addr);
 	MLX5_SET64(mkc, mkc, len, attr->size);
 	mkey->obj = mlx5_glue->devx_obj_create(ctx, in, in_size_dw * 4, out,
drivers/common/mlx5/mlx5_devx_cmds.h +2 -1
index abbea67..25cf12e 100644
@@ -20,7 +20,8 @@ struct mlx5_devx_mkey_attr {
 	uint32_t pd;
 	uint32_t log_entity_size;
 	uint32_t pg_access:1;
-	uint32_t relaxed_ordering:1;
+	uint32_t relaxed_ordering_write:1;
+	uint32_t relaxed_ordering_read:1;
 	struct mlx5_klm *klm_array;
 	int klm_num;
 };
drivers/net/mlx5/linux/mlx5_os.c +8 -4
index c890998..25897d9 100644
@@ -1078,10 +1078,14 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,
 			goto error;
 		}
 		/* Check relax ordering support. */
-		if (config->hca_attr.relaxed_ordering_write &&
-		    config->hca_attr.relaxed_ordering_read  &&
-		    !haswell_broadwell_cpu)
-			sh->cmng.relaxed_ordering = 1;
+		sh->cmng.relaxed_ordering_read = 0;
+		sh->cmng.relaxed_ordering_write = 0;
+		if (!haswell_broadwell_cpu) {
+			sh->cmng.relaxed_ordering_write =
+				config->hca_attr.relaxed_ordering_write;
+			sh->cmng.relaxed_ordering_read =
+				config->hca_attr.relaxed_ordering_read;
+		}
 		/* Check for LRO support. */
 		if (config->dest_tir && config->hca_attr.lro_cap &&
 		    config->dv_flow_en) {
drivers/net/mlx5/mlx5.h +2 -1
index 88bbd31..c148e8e 100644
@@ -455,7 +455,8 @@ struct mlx5_flow_counter_mng {
 	uint8_t pending_queries;
 	uint16_t pool_index;
 	uint8_t query_thread_on;
-	bool relaxed_ordering;
+	bool relaxed_ordering_read;
+	bool relaxed_ordering_write;
 	bool counter_fallback; /* Use counter fallback management. */
 	LIST_HEAD(mem_mngs, mlx5_counter_stats_mem_mng) mem_mngs;
 	LIST_HEAD(stat_raws, mlx5_counter_stats_raw) free_stat_raws;
drivers/net/mlx5/mlx5_flow.c +2 -1
index 082d886..89d6d70 100644
@@ -7221,7 +7221,8 @@ mlx5_flow_create_counter_stat_mem_mng(struct mlx5_dev_ctx_shared *sh)
 	mkey_attr.pg_access = 0;
 	mkey_attr.klm_array = NULL;
 	mkey_attr.klm_num = 0;
-	mkey_attr.relaxed_ordering = sh->cmng.relaxed_ordering;
+	mkey_attr.relaxed_ordering_write = sh->cmng.relaxed_ordering_write;
+	mkey_attr.relaxed_ordering_read = sh->cmng.relaxed_ordering_read;
 	mem_mng->dm = mlx5_devx_cmd_mkey_create(sh->ctx, &mkey_attr);
 	if (!mem_mng->dm) {
 		mlx5_glue->devx_umem_dereg(mem_mng->umem);
drivers/vdpa/mlx5/mlx5_vdpa_lm.c +2 -1
index 273c46f..6c4284f 100644
@@ -43,7 +43,8 @@ mlx5_vdpa_dirty_bitmap_set(struct mlx5_vdpa_priv *priv, uint64_t log_base,
 			.pg_access = 1,
 			.klm_array = NULL,
 			.klm_num = 0,
-			.relaxed_ordering = 0,
+			.relaxed_ordering_read = 0,
+			.relaxed_ordering_write = 0,
 	};
 	struct mlx5_devx_virtq_attr attr = {
 		.type = MLX5_VIRTQ_MODIFY_TYPE_DIRTY_BITMAP_PARAMS,
drivers/vdpa/mlx5/mlx5_vdpa_mem.c +2 -1
index b6c7cb8..f8861d5 100644
@@ -223,7 +223,8 @@ mlx5_vdpa_mem_register(struct mlx5_vdpa_priv *priv)
 		mkey_attr.pg_access = 1;
 		mkey_attr.klm_array = NULL;
 		mkey_attr.klm_num = 0;
-		mkey_attr.relaxed_ordering = 0;
+		mkey_attr.relaxed_ordering_read = 0;
+		mkey_attr.relaxed_ordering_write = 0;
 		entry->mkey = mlx5_devx_cmd_mkey_create(priv->ctx, &mkey_attr);
 		if (!entry->mkey) {
 			DRV_LOG(ERR, "Failed to create direct Mkey.");
Signature · 1 line
2.8.4
#2 lore raw

v2 cover mlx5 Windows support - part #5

This patch series is part of preparing mlx5 PMD to compile and run under Windows OS. Part #5

v1: initial version
v2: Fixes after CR and rebase, also patchset was split and part of the commits sent in v1 will be sent later on.

Ophir Munk (21):
net/mlx5/linux: extend device attributes getter net/mlx5: remove Linux files from Windows compilation net/mlx5: fix freeing packet pacing
net/mlx5: replace Linux sleep with rte sleep net/mlx5: define mprq functions as static inline net/mlx5: do not define static_assert in Windows net/mlx5: move static_assert calls to global scope net/mlx5: wrap glue alloc/dealloc PD with OS calls net/mlx5: fix adding destroy flow action wrapper common/mlx5: add definition HAVE_INFINIBAND_VERBS_H common/mlx5/linux: handle memory allocations with alignment common/mlx5/windows: handle memory allocations with alignment mlx5/windows: add initialization routine for external lib mlx5/windows: generate file mlx5_autoconf.h common/mlx5/windows: add getter functions
net/mlx5: update MR prototypes for DevX common/mlx5/windows: add OS reg/dereg MR drivers/common: enable Windows common mlx5 compilation net/mlx5/windows: implement device attribute getter net/mlx5/windows: add mlx5_os.c stubs
net/mlx5: refactor eth dev ops for Windows

Tal Shnaiderman (12):
net/mlx5: fix folding constant array error net/mlx5: wrap glue reg/dereg UMEM with OS calls common/mlx5/linux: wrap event channel APIs with OS calls common/mlx5: add Windows exports file common/mlx5: extend DevX query hca attributes command common/mlx5: add DevX alloc PD command common/mlx5/windows: add glue functions APIs mlx5/windows: add mlx5 meson file common/mlx5/windows: extend PRM match_param_bits struct common/mlx5/windows: add OS alloc/dealloc pd common/mlx5/windows: add OS umem reg/dereg API net/mlx5/windows: implement mlx5 mac addr add

 drivers/common/meson.build                      |   8 +-
 drivers/common/mlx5/linux/meson.build           |   6 +-
 drivers/common/mlx5/linux/mlx5_common_os.h      |  83 +++++
 drivers/common/mlx5/meson.build                 |   4 +-
 drivers/common/mlx5/mlx5_common.c               |   4 +-
 drivers/common/mlx5/mlx5_common_mr.h            |   1 +
 drivers/common/mlx5/mlx5_devx_cmds.c            |  46 +++
 drivers/common/mlx5/mlx5_devx_cmds.h            |  12 +-
 drivers/common/mlx5/mlx5_malloc.c               |  14 +-
 drivers/common/mlx5/mlx5_prm.h                  |  87 +++++
 drivers/common/mlx5/rte_common_mlx5_exports.def |  69 ++++
 drivers/common/mlx5/version.map                 |   1 +
 drivers/common/mlx5/windows/meson.build         |  46 +++
 drivers/common/mlx5/windows/mlx5_common_os.c    | 210 ++++++++++++
 drivers/common/mlx5/windows/mlx5_common_os.h    | 154 +++++++++
 drivers/common/mlx5/windows/mlx5_glue.c         | 307 ++++++++++++++++++
 drivers/common/mlx5/windows/mlx5_glue.h         |  58 ++++
 drivers/common/mlx5/windows/mlx5_win_defs.h     |  25 ++
 drivers/common/mlx5/windows/mlx5_win_ext.h      |  40 +++
 drivers/net/mlx5/linux/mlx5_os.c                |   9 +-
 drivers/net/mlx5/linux/mlx5_verbs.c             |   2 +-
 drivers/net/mlx5/linux/mlx5_verbs.h             |   8 +-
 drivers/net/mlx5/meson.build                    |  16 +-
 drivers/net/mlx5/mlx5.c                         |  18 +-
 drivers/net/mlx5/mlx5.h                         |  11 +
 drivers/net/mlx5/mlx5_defs.h                    |   7 +-
 drivers/net/mlx5/mlx5_devx.c                    |  24 +-
 drivers/net/mlx5/mlx5_flow.c                    |  17 +-
 drivers/net/mlx5/mlx5_flow_dv.c                 |   6 +-
 drivers/net/mlx5/mlx5_rxq.c                     |  71 -----
 drivers/net/mlx5/mlx5_rxtx.c                    |  98 +++---
 drivers/net/mlx5/mlx5_rxtx.h                    |  73 ++++-
 drivers/net/mlx5/mlx5_trigger.c                 |   3 +-
 drivers/net/mlx5/mlx5_txpp.c                    |  34 +-
 drivers/net/mlx5/windows/meson.build            |   8 +
 drivers/net/mlx5/windows/mlx5_os.c              | 406 ++++++++++++++++++++++++
 drivers/vdpa/mlx5/mlx5_vdpa_event.c             |   7 +-
 37 files changed, 1783 insertions(+), 210 deletions(-)
 create mode 100644 drivers/common/mlx5/rte_common_mlx5_exports.def
 create mode 100644 drivers/common/mlx5/windows/meson.build
 create mode 100644 drivers/common/mlx5/windows/mlx5_common_os.c
 create mode 100644 drivers/common/mlx5/windows/mlx5_common_os.h
 create mode 100644 drivers/common/mlx5/windows/mlx5_glue.c
 create mode 100644 drivers/common/mlx5/windows/mlx5_glue.h
 create mode 100644 drivers/common/mlx5/windows/mlx5_win_defs.h
 create mode 100644 drivers/common/mlx5/windows/mlx5_win_ext.h
 create mode 100644 drivers/net/mlx5/windows/meson.build
 create mode 100644 drivers/net/mlx5/windows/mlx5_os.c
Signature · 1 line
2.16.1.windows.4
#3 lore raw

PATCH v2 1/33 net/mlx5: fix folding constant array error

Before this commit the PMD used:
const int elt_n = 8
const int *stack[elt_n];

In Windows clang compiler complains:
net/mlx5/mlx5_flow.c:215:19: error: variable length array folded to constant array as an extension [-Werror,-Wgnu-folding-constant]

Fix it by using a constant macro definition instead of a variable:
#define MLX5_RSS_EXP_ELT_N 8
const int *stack[MLX5_RSS_EXP_ELT_N];

Fixes c7870bfe09dc ("ethdev: move RSS expansion code to mlx5 driver")
---
 drivers/net/mlx5/mlx5_flow.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)
drivers/net/mlx5/mlx5_flow.c +7 -6
index 82e24d7067..bf86aaaa39 100644
@@ -212,6 +212,8 @@ mlx5_flow_expand_rss_item_complete(const struct rte_flow_item *item)
 	return ret;
 }
 
+#define MLX5_RSS_EXP_ELT_N 8
+
 /**
  * Expand RSS flows into several possible flows according to the RSS hash
  * fields requested and the driver capabilities.
@@ -242,13 +244,12 @@ mlx5_flow_expand_rss(struct mlx5_flow_expand_rss *buf, size_t size,
 		     const struct mlx5_flow_expand_node graph[],
 		     int graph_root_index)
 {
-	const int elt_n = 8;
 	const struct rte_flow_item *item;
 	const struct mlx5_flow_expand_node *node = &graph[graph_root_index];
 	const int *next_node;
-	const int *stack[elt_n];
+	const int *stack[MLX5_RSS_EXP_ELT_N];
 	int stack_pos = 0;
-	struct rte_flow_item flow_items[elt_n];
+	struct rte_flow_item flow_items[MLX5_RSS_EXP_ELT_N];
 	unsigned int i;
 	size_t lsize;
 	size_t user_pattern_size = 0;
@@ -261,10 +262,10 @@ mlx5_flow_expand_rss(struct mlx5_flow_expand_rss *buf, size_t size,
 
 	memset(&missed_item, 0, sizeof(missed_item));
 	lsize = offsetof(struct mlx5_flow_expand_rss, entry) +
-		elt_n * sizeof(buf->entry[0]);
+		MLX5_RSS_EXP_ELT_N * sizeof(buf->entry[0]);
 	if (lsize <= size) {
 		buf->entry[0].priority = 0;
-		buf->entry[0].pattern = (void *)&buf->entry[elt_n];
+		buf->entry[0].pattern = (void *)&buf->entry[MLX5_RSS_EXP_ELT_N];
 		buf->entries = 0;
 		addr = buf->entry[0].pattern;
 	}
@@ -367,7 +368,7 @@ mlx5_flow_expand_rss(struct mlx5_flow_expand_rss *buf, size_t size,
 		/* Go deeper. */
 		if (node->next) {
 			next_node = node->next;
-			if (stack_pos++ == elt_n) {
+			if (stack_pos++ == MLX5_RSS_EXP_ELT_N) {
 				rte_errno = E2BIG;
 				return -rte_errno;
 			}
Signature · 1 line
2.16.1.windows.4
#4 lore raw

v3 cover mlx5 Windows support - part #5

This patch series is part of preparing mlx5 PMD to compile and run under Windows OS. Part #5

v1: initial version
v2: Fixes after CR and rebase, also patchset was split and part of the commits sent in v1 will be sent later on.
v3: Remove common compilation as it depends on upcoming patches [DmitryK].

Ophir Munk (20):
net/mlx5/linux: extend device attributes getter net/mlx5: remove Linux files from Windows compilation net/mlx5: fix freeing packet pacing
net/mlx5: replace Linux sleep with rte sleep net/mlx5: define mprq functions as static inline net/mlx5: do not define static_assert in Windows net/mlx5: move static_assert calls to global scope net/mlx5: wrap glue alloc/dealloc PD with OS calls net/mlx5: fix adding destroy flow action wrapper common/mlx5: add definition HAVE_INFINIBAND_VERBS_H common/mlx5/linux: handle memory allocations with alignment common/mlx5/windows: handle memory allocations with alignment mlx5/windows: add initialization routine for external lib mlx5/windows: generate file mlx5_autoconf.h common/mlx5/windows: add getter functions
net/mlx5: update MR prototypes for DevX common/mlx5/windows: add OS reg/dereg MR net/mlx5/windows: implement device attribute getter net/mlx5/windows: add mlx5_os.c stubs
net/mlx5: refactor eth dev ops for Windows

Tal Shnaiderman (12):
net/mlx5: fix folding constant array error net/mlx5: wrap glue reg/dereg UMEM with OS calls common/mlx5/linux: wrap event channel APIs with OS calls common/mlx5: add Windows exports file common/mlx5: extend DevX query hca attributes command common/mlx5: add DevX alloc PD command common/mlx5/windows: add glue functions APIs mlx5/windows: add mlx5 meson file common/mlx5/windows: extend PRM match_param_bits struct common/mlx5/windows: add OS alloc/dealloc pd common/mlx5/windows: add OS umem reg/dereg API net/mlx5/windows: implement mlx5 mac addr add

 drivers/common/mlx5/linux/meson.build           |   6 +-
 drivers/common/mlx5/linux/mlx5_common_os.h      |  83 +++++
 drivers/common/mlx5/mlx5_common.c               |   4 +-
 drivers/common/mlx5/mlx5_common_mr.h            |   1 +
 drivers/common/mlx5/mlx5_devx_cmds.c            |  46 +++
 drivers/common/mlx5/mlx5_devx_cmds.h            |  12 +-
 drivers/common/mlx5/mlx5_malloc.c               |  14 +-
 drivers/common/mlx5/mlx5_prm.h                  |  87 +++++
 drivers/common/mlx5/rte_common_mlx5_exports.def |  69 ++++
 drivers/common/mlx5/version.map                 |   1 +
 drivers/common/mlx5/windows/meson.build         |  46 +++
 drivers/common/mlx5/windows/mlx5_common_os.c    | 210 ++++++++++++
 drivers/common/mlx5/windows/mlx5_common_os.h    | 154 +++++++++
 drivers/common/mlx5/windows/mlx5_glue.c         | 307 ++++++++++++++++++
 drivers/common/mlx5/windows/mlx5_glue.h         |  58 ++++
 drivers/common/mlx5/windows/mlx5_win_defs.h     |  25 ++
 drivers/common/mlx5/windows/mlx5_win_ext.h      |  40 +++
 drivers/net/mlx5/linux/mlx5_os.c                |   9 +-
 drivers/net/mlx5/linux/mlx5_verbs.c             |   2 +-
 drivers/net/mlx5/linux/mlx5_verbs.h             |   8 +-
 drivers/net/mlx5/meson.build                    |  16 +-
 drivers/net/mlx5/mlx5.c                         |  18 +-
 drivers/net/mlx5/mlx5.h                         |  11 +
 drivers/net/mlx5/mlx5_defs.h                    |   7 +-
 drivers/net/mlx5/mlx5_devx.c                    |  24 +-
 drivers/net/mlx5/mlx5_flow.c                    |  17 +-
 drivers/net/mlx5/mlx5_flow_dv.c                 |   6 +-
 drivers/net/mlx5/mlx5_rxq.c                     |  71 -----
 drivers/net/mlx5/mlx5_rxtx.c                    |  98 +++---
 drivers/net/mlx5/mlx5_rxtx.h                    |  73 ++++-
 drivers/net/mlx5/mlx5_trigger.c                 |   3 +-
 drivers/net/mlx5/mlx5_txpp.c                    |  34 +-
 drivers/net/mlx5/windows/meson.build            |   8 +
 drivers/net/mlx5/windows/mlx5_os.c              | 406 ++++++++++++++++++++++++
 drivers/vdpa/mlx5/mlx5_vdpa_event.c             |   7 +-
 35 files changed, 1778 insertions(+), 203 deletions(-)
 create mode 100644 drivers/common/mlx5/rte_common_mlx5_exports.def
 create mode 100644 drivers/common/mlx5/windows/meson.build
 create mode 100644 drivers/common/mlx5/windows/mlx5_common_os.c
 create mode 100644 drivers/common/mlx5/windows/mlx5_common_os.h
 create mode 100644 drivers/common/mlx5/windows/mlx5_glue.c
 create mode 100644 drivers/common/mlx5/windows/mlx5_glue.h
 create mode 100644 drivers/common/mlx5/windows/mlx5_win_defs.h
 create mode 100644 drivers/common/mlx5/windows/mlx5_win_ext.h
 create mode 100644 drivers/net/mlx5/windows/meson.build
 create mode 100644 drivers/net/mlx5/windows/mlx5_os.c
Signature · 1 line
2.16.1.windows.4
#5 lore raw

PATCH v3 1/32 net/mlx5: fix folding constant array error

Before this commit the PMD used:
const int elt_n = 8
const int *stack[elt_n];

In Windows clang compiler complains:
net/mlx5/mlx5_flow.c:215:19: error: variable length array folded to constant array as an extension [-Werror,-Wgnu-folding-constant]

Fix it by using a constant macro definition instead of a variable:
#define MLX5_RSS_EXP_ELT_N 8
const int *stack[MLX5_RSS_EXP_ELT_N];

Fixes c7870bfe09dc ("ethdev: move RSS expansion code to mlx5 driver")
---
 drivers/net/mlx5/mlx5_flow.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)
drivers/net/mlx5/mlx5_flow.c +7 -6
index 82e24d7067..bf86aaaa39 100644
@@ -212,6 +212,8 @@ mlx5_flow_expand_rss_item_complete(const struct rte_flow_item *item)
 	return ret;
 }
 
+#define MLX5_RSS_EXP_ELT_N 8
+
 /**
  * Expand RSS flows into several possible flows according to the RSS hash
  * fields requested and the driver capabilities.
@@ -242,13 +244,12 @@ mlx5_flow_expand_rss(struct mlx5_flow_expand_rss *buf, size_t size,
 		     const struct mlx5_flow_expand_node graph[],
 		     int graph_root_index)
 {
-	const int elt_n = 8;
 	const struct rte_flow_item *item;
 	const struct mlx5_flow_expand_node *node = &graph[graph_root_index];
 	const int *next_node;
-	const int *stack[elt_n];
+	const int *stack[MLX5_RSS_EXP_ELT_N];
 	int stack_pos = 0;
-	struct rte_flow_item flow_items[elt_n];
+	struct rte_flow_item flow_items[MLX5_RSS_EXP_ELT_N];
 	unsigned int i;
 	size_t lsize;
 	size_t user_pattern_size = 0;
@@ -261,10 +262,10 @@ mlx5_flow_expand_rss(struct mlx5_flow_expand_rss *buf, size_t size,
 
 	memset(&missed_item, 0, sizeof(missed_item));
 	lsize = offsetof(struct mlx5_flow_expand_rss, entry) +
-		elt_n * sizeof(buf->entry[0]);
+		MLX5_RSS_EXP_ELT_N * sizeof(buf->entry[0]);
 	if (lsize <= size) {
 		buf->entry[0].priority = 0;
-		buf->entry[0].pattern = (void *)&buf->entry[elt_n];
+		buf->entry[0].pattern = (void *)&buf->entry[MLX5_RSS_EXP_ELT_N];
 		buf->entries = 0;
 		addr = buf->entry[0].pattern;
 	}
@@ -367,7 +368,7 @@ mlx5_flow_expand_rss(struct mlx5_flow_expand_rss *buf, size_t size,
 		/* Go deeper. */
 		if (node->next) {
 			next_node = node->next;
-			if (stack_pos++ == elt_n) {
+			if (stack_pos++ == MLX5_RSS_EXP_ELT_N) {
 				rte_errno = E2BIG;
 				return -rte_errno;
 			}
Signature · 1 line
2.16.1.windows.4
#6 lore raw

v4 cover mlx5 Windows support - part #5

This patch series is part of preparing mlx5 PMD to compile and run under Windows OS. Part #5

v1: initial version
v2: Fixes after CR and rebase, also patchset was split and part of the commits sent in v1 will be sent later on.
v3: Remove common compilation as it depends on upcoming patches [DmitryK].
v4: Fix syntax error in warning message.

Ophir Munk (20):
net/mlx5/linux: extend device attributes getter net/mlx5: remove Linux files from Windows compilation net/mlx5: fix freeing packet pacing
net/mlx5: replace Linux sleep with rte sleep net/mlx5: define mprq functions as static inline net/mlx5: do not define static_assert in Windows net/mlx5: move static_assert calls to global scope net/mlx5: wrap glue alloc/dealloc PD with OS calls net/mlx5: fix adding destroy flow action wrapper common/mlx5: add definition HAVE_INFINIBAND_VERBS_H common/mlx5/linux: handle memory allocations with alignment common/mlx5/windows: handle memory allocations with alignment mlx5/windows: add initialization routine for external lib mlx5/windows: generate file mlx5_autoconf.h common/mlx5/windows: add getter functions
net/mlx5: update MR prototypes for DevX common/mlx5/windows: add OS reg/dereg MR net/mlx5/windows: implement device attribute getter net/mlx5/windows: add mlx5_os.c stubs
net/mlx5: refactor eth dev ops for Windows

Tal Shnaiderman (12):
net/mlx5: fix folding constant array error net/mlx5: wrap glue reg/dereg UMEM with OS calls common/mlx5/linux: wrap event channel APIs with OS calls common/mlx5: add Windows exports file common/mlx5: extend DevX query hca attributes command common/mlx5: add DevX alloc PD command common/mlx5/windows: add glue functions APIs mlx5/windows: add mlx5 meson file common/mlx5/windows: extend PRM match_param_bits struct common/mlx5/windows: add OS alloc/dealloc pd common/mlx5/windows: add OS umem reg/dereg API net/mlx5/windows: implement mlx5 mac addr add

 drivers/common/mlx5/linux/meson.build           |   6 +-
 drivers/common/mlx5/linux/mlx5_common_os.h      |  83 +++++
 drivers/common/mlx5/mlx5_common.c               |   4 +-
 drivers/common/mlx5/mlx5_common_mr.h            |   1 +
 drivers/common/mlx5/mlx5_devx_cmds.c            |  46 +++
 drivers/common/mlx5/mlx5_devx_cmds.h            |  12 +-
 drivers/common/mlx5/mlx5_malloc.c               |  14 +-
 drivers/common/mlx5/mlx5_prm.h                  |  87 +++++
 drivers/common/mlx5/rte_common_mlx5_exports.def |  69 ++++
 drivers/common/mlx5/version.map                 |   1 +
 drivers/common/mlx5/windows/meson.build         |  46 +++
 drivers/common/mlx5/windows/mlx5_common_os.c    | 210 ++++++++++++
 drivers/common/mlx5/windows/mlx5_common_os.h    | 154 +++++++++
 drivers/common/mlx5/windows/mlx5_glue.c         | 307 ++++++++++++++++++
 drivers/common/mlx5/windows/mlx5_glue.h         |  58 ++++
 drivers/common/mlx5/windows/mlx5_win_defs.h     |  25 ++
 drivers/common/mlx5/windows/mlx5_win_ext.h      |  40 +++
 drivers/net/mlx5/linux/mlx5_os.c                |   9 +-
 drivers/net/mlx5/linux/mlx5_verbs.c             |   2 +-
 drivers/net/mlx5/linux/mlx5_verbs.h             |   8 +-
 drivers/net/mlx5/meson.build                    |  16 +-
 drivers/net/mlx5/mlx5.c                         |  18 +-
 drivers/net/mlx5/mlx5.h                         |  11 +
 drivers/net/mlx5/mlx5_defs.h                    |   7 +-
 drivers/net/mlx5/mlx5_devx.c                    |  24 +-
 drivers/net/mlx5/mlx5_flow.c                    |  17 +-
 drivers/net/mlx5/mlx5_flow_dv.c                 |   6 +-
 drivers/net/mlx5/mlx5_rxq.c                     |  71 -----
 drivers/net/mlx5/mlx5_rxtx.c                    |  98 +++---
 drivers/net/mlx5/mlx5_rxtx.h                    |  73 ++++-
 drivers/net/mlx5/mlx5_trigger.c                 |   3 +-
 drivers/net/mlx5/mlx5_txpp.c                    |  34 +-
 drivers/net/mlx5/windows/meson.build            |   8 +
 drivers/net/mlx5/windows/mlx5_os.c              | 406 ++++++++++++++++++++++++
 drivers/vdpa/mlx5/mlx5_vdpa_event.c             |   7 +-
 35 files changed, 1778 insertions(+), 203 deletions(-)
 create mode 100644 drivers/common/mlx5/rte_common_mlx5_exports.def
 create mode 100644 drivers/common/mlx5/windows/meson.build
 create mode 100644 drivers/common/mlx5/windows/mlx5_common_os.c
 create mode 100644 drivers/common/mlx5/windows/mlx5_common_os.h
 create mode 100644 drivers/common/mlx5/windows/mlx5_glue.c
 create mode 100644 drivers/common/mlx5/windows/mlx5_glue.h
 create mode 100644 drivers/common/mlx5/windows/mlx5_win_defs.h
 create mode 100644 drivers/common/mlx5/windows/mlx5_win_ext.h
 create mode 100644 drivers/net/mlx5/windows/meson.build
 create mode 100644 drivers/net/mlx5/windows/mlx5_os.c
Signature · 1 line
2.16.1.windows.4
#7 lore raw

PATCH v4 1/32 net/mlx5: fix folding constant array error

Before this commit the PMD used:
const int elt_n = 8
const int *stack[elt_n];

In Windows clang compiler complains:
net/mlx5/mlx5_flow.c:215:19: error: variable length array folded to constant array as an extension [-Werror,-Wgnu-folding-constant]

Fix it by using a constant macro definition instead of a variable:
#define MLX5_RSS_EXP_ELT_N 8
const int *stack[MLX5_RSS_EXP_ELT_N];

Fixes c7870bfe09dc ("ethdev: move RSS expansion code to mlx5 driver")
---
 drivers/net/mlx5/mlx5_flow.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)
drivers/net/mlx5/mlx5_flow.c +7 -6
index 82e24d7067..bf86aaaa39 100644
@@ -212,6 +212,8 @@ mlx5_flow_expand_rss_item_complete(const struct rte_flow_item *item)
 	return ret;
 }
 
+#define MLX5_RSS_EXP_ELT_N 8
+
 /**
  * Expand RSS flows into several possible flows according to the RSS hash
  * fields requested and the driver capabilities.
@@ -242,13 +244,12 @@ mlx5_flow_expand_rss(struct mlx5_flow_expand_rss *buf, size_t size,
 		     const struct mlx5_flow_expand_node graph[],
 		     int graph_root_index)
 {
-	const int elt_n = 8;
 	const struct rte_flow_item *item;
 	const struct mlx5_flow_expand_node *node = &graph[graph_root_index];
 	const int *next_node;
-	const int *stack[elt_n];
+	const int *stack[MLX5_RSS_EXP_ELT_N];
 	int stack_pos = 0;
-	struct rte_flow_item flow_items[elt_n];
+	struct rte_flow_item flow_items[MLX5_RSS_EXP_ELT_N];
 	unsigned int i;
 	size_t lsize;
 	size_t user_pattern_size = 0;
@@ -261,10 +262,10 @@ mlx5_flow_expand_rss(struct mlx5_flow_expand_rss *buf, size_t size,
 
 	memset(&missed_item, 0, sizeof(missed_item));
 	lsize = offsetof(struct mlx5_flow_expand_rss, entry) +
-		elt_n * sizeof(buf->entry[0]);
+		MLX5_RSS_EXP_ELT_N * sizeof(buf->entry[0]);
 	if (lsize <= size) {
 		buf->entry[0].priority = 0;
-		buf->entry[0].pattern = (void *)&buf->entry[elt_n];
+		buf->entry[0].pattern = (void *)&buf->entry[MLX5_RSS_EXP_ELT_N];
 		buf->entries = 0;
 		addr = buf->entry[0].pattern;
 	}
@@ -367,7 +368,7 @@ mlx5_flow_expand_rss(struct mlx5_flow_expand_rss *buf, size_t size,
 		/* Go deeper. */
 		if (node->next) {
 			next_node = node->next;
-			if (stack_pos++ == elt_n) {
+			if (stack_pos++ == MLX5_RSS_EXP_ELT_N) {
 				rte_errno = E2BIG;
 				return -rte_errno;
 			}
Signature · 1 line
2.16.1.windows.4
#8 lore raw

v5 cover mlx5 Windows support - part #5

This patch series is part of preparing mlx5 PMD to compile and run under Windows OS. Part #5

v1: initial version
v2: Fixes after CR and rebase, also patchset was split and part of the commits sent in v1 will be sent later on.
v3: Remove common compilation as it depends on upcoming patches [DmitryK].
v4: Fix syntax error in warning message.
v5: Fix style issues.

Ophir Munk (20):
net/mlx5/linux: extend device attributes getter net/mlx5: remove Linux files from Windows compilation net/mlx5: fix freeing packet pacing
net/mlx5: replace Linux sleep with rte sleep net/mlx5: define mprq functions as static inline net/mlx5: do not define static_assert in Windows net/mlx5: move static_assert calls to global scope net/mlx5: wrap glue alloc/dealloc PD with OS calls net/mlx5: fix adding destroy flow action wrapper common/mlx5: add definition HAVE_INFINIBAND_VERBS_H common/mlx5/linux: handle memory allocations with alignment common/mlx5/windows: handle memory allocations with alignment mlx5/windows: add initialization routine for external lib mlx5/windows: generate file mlx5_autoconf.h common/mlx5/windows: add getter functions
net/mlx5: update MR prototypes for DevX common/mlx5/windows: add OS reg/dereg MR net/mlx5/windows: implement device attribute getter net/mlx5/windows: add mlx5_os.c stubs
net/mlx5: refactor eth dev ops for Windows

Tal Shnaiderman (12):
net/mlx5: fix folding constant array error net/mlx5: wrap glue reg/dereg UMEM with OS calls common/mlx5/linux: wrap event channel APIs with OS calls common/mlx5: add Windows exports file common/mlx5: extend DevX query hca attributes command common/mlx5: add DevX alloc PD command common/mlx5/windows: add glue functions APIs mlx5/windows: add mlx5 meson file common/mlx5/windows: extend PRM match_param_bits struct common/mlx5/windows: add OS alloc/dealloc pd common/mlx5/windows: add OS umem reg/dereg API net/mlx5/windows: implement mlx5 mac addr add

 drivers/common/mlx5/linux/meson.build           |   6 +-
 drivers/common/mlx5/linux/mlx5_common_os.h      |  83 +++++
 drivers/common/mlx5/mlx5_common.c               |   4 +-
 drivers/common/mlx5/mlx5_common_mr.h            |   1 +
 drivers/common/mlx5/mlx5_devx_cmds.c            |  46 +++
 drivers/common/mlx5/mlx5_devx_cmds.h            |  12 +-
 drivers/common/mlx5/mlx5_malloc.c               |  14 +-
 drivers/common/mlx5/mlx5_prm.h                  |  87 +++++
 drivers/common/mlx5/rte_common_mlx5_exports.def |  69 ++++
 drivers/common/mlx5/version.map                 |   1 +
 drivers/common/mlx5/windows/meson.build         |  45 +++
 drivers/common/mlx5/windows/mlx5_common_os.c    | 210 ++++++++++++
 drivers/common/mlx5/windows/mlx5_common_os.h    | 154 +++++++++
 drivers/common/mlx5/windows/mlx5_glue.c         | 307 ++++++++++++++++++
 drivers/common/mlx5/windows/mlx5_glue.h         |  58 ++++
 drivers/common/mlx5/windows/mlx5_win_defs.h     |  25 ++
 drivers/common/mlx5/windows/mlx5_win_ext.h      |  40 +++
 drivers/net/mlx5/linux/mlx5_os.c                |   9 +-
 drivers/net/mlx5/linux/mlx5_verbs.c             |   2 +-
 drivers/net/mlx5/linux/mlx5_verbs.h             |   8 +-
 drivers/net/mlx5/meson.build                    |  16 +-
 drivers/net/mlx5/mlx5.c                         |  20 +-
 drivers/net/mlx5/mlx5.h                         |  11 +
 drivers/net/mlx5/mlx5_defs.h                    |   7 +-
 drivers/net/mlx5/mlx5_devx.c                    |  24 +-
 drivers/net/mlx5/mlx5_flow.c                    |  17 +-
 drivers/net/mlx5/mlx5_flow_dv.c                 |   6 +-
 drivers/net/mlx5/mlx5_rxq.c                     |  71 -----
 drivers/net/mlx5/mlx5_rxtx.c                    |  98 +++---
 drivers/net/mlx5/mlx5_rxtx.h                    |  73 ++++-
 drivers/net/mlx5/mlx5_trigger.c                 |   3 +-
 drivers/net/mlx5/mlx5_txpp.c                    |  34 +-
 drivers/net/mlx5/windows/meson.build            |   8 +
 drivers/net/mlx5/windows/mlx5_os.c              | 406 ++++++++++++++++++++++++
 drivers/vdpa/mlx5/mlx5_vdpa_event.c             |   7 +-
 35 files changed, 1778 insertions(+), 204 deletions(-)
 create mode 100644 drivers/common/mlx5/rte_common_mlx5_exports.def
 create mode 100644 drivers/common/mlx5/windows/meson.build
 create mode 100644 drivers/common/mlx5/windows/mlx5_common_os.c
 create mode 100644 drivers/common/mlx5/windows/mlx5_common_os.h
 create mode 100644 drivers/common/mlx5/windows/mlx5_glue.c
 create mode 100644 drivers/common/mlx5/windows/mlx5_glue.h
 create mode 100644 drivers/common/mlx5/windows/mlx5_win_defs.h
 create mode 100644 drivers/common/mlx5/windows/mlx5_win_ext.h
 create mode 100644 drivers/net/mlx5/windows/meson.build
 create mode 100644 drivers/net/mlx5/windows/mlx5_os.c
Signature · 1 line
2.16.1.windows.4
#9 lore raw

PATCH v5 1/32 net/mlx5: fix folding constant array error

Before this commit the PMD used:
const int elt_n = 8
const int *stack[elt_n];

In Windows clang compiler complains:
net/mlx5/mlx5_flow.c:215:19: error: variable length array folded to constant array as an extension [-Werror,-Wgnu-folding-constant]

Fix it by using a constant macro definition instead of a variable:
#define MLX5_RSS_EXP_ELT_N 8
const int *stack[MLX5_RSS_EXP_ELT_N];

Fixes c7870bfe09dc ("ethdev: move RSS expansion code to mlx5 driver")
---
 drivers/net/mlx5/mlx5_flow.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)
drivers/net/mlx5/mlx5_flow.c +7 -6
index 82e24d7067..bf86aaaa39 100644
@@ -212,6 +212,8 @@ mlx5_flow_expand_rss_item_complete(const struct rte_flow_item *item)
 	return ret;
 }
 
+#define MLX5_RSS_EXP_ELT_N 8
+
 /**
  * Expand RSS flows into several possible flows according to the RSS hash
  * fields requested and the driver capabilities.
@@ -242,13 +244,12 @@ mlx5_flow_expand_rss(struct mlx5_flow_expand_rss *buf, size_t size,
 		     const struct mlx5_flow_expand_node graph[],
 		     int graph_root_index)
 {
-	const int elt_n = 8;
 	const struct rte_flow_item *item;
 	const struct mlx5_flow_expand_node *node = &graph[graph_root_index];
 	const int *next_node;
-	const int *stack[elt_n];
+	const int *stack[MLX5_RSS_EXP_ELT_N];
 	int stack_pos = 0;
-	struct rte_flow_item flow_items[elt_n];
+	struct rte_flow_item flow_items[MLX5_RSS_EXP_ELT_N];
 	unsigned int i;
 	size_t lsize;
 	size_t user_pattern_size = 0;
@@ -261,10 +262,10 @@ mlx5_flow_expand_rss(struct mlx5_flow_expand_rss *buf, size_t size,
 
 	memset(&missed_item, 0, sizeof(missed_item));
 	lsize = offsetof(struct mlx5_flow_expand_rss, entry) +
-		elt_n * sizeof(buf->entry[0]);
+		MLX5_RSS_EXP_ELT_N * sizeof(buf->entry[0]);
 	if (lsize <= size) {
 		buf->entry[0].priority = 0;
-		buf->entry[0].pattern = (void *)&buf->entry[elt_n];
+		buf->entry[0].pattern = (void *)&buf->entry[MLX5_RSS_EXP_ELT_N];
 		buf->entries = 0;
 		addr = buf->entry[0].pattern;
 	}
@@ -367,7 +368,7 @@ mlx5_flow_expand_rss(struct mlx5_flow_expand_rss *buf, size_t size,
 		/* Go deeper. */
 		if (node->next) {
 			next_node = node->next;
-			if (stack_pos++ == elt_n) {
+			if (stack_pos++ == MLX5_RSS_EXP_ELT_N) {
 				rte_errno = E2BIG;
 				return -rte_errno;
 			}
Signature · 1 line
2.16.1.windows.4
#10 lore raw

PATCH v5 2/32 net/mlx5/linux: extend device attributes getter

In reply to Tal Shnaiderman

From: Ophir Munk <[email protected]>

This commit adds device attributes parameters to be reported by mlx5_os_get_dev_attr(): max_cqe, max_mr, max_pd, max_srq, max_srq_wr

---
 drivers/net/mlx5/linux/mlx5_os.c | 5 +++++
 drivers/net/mlx5/mlx5.h          | 5 +++++
 2 files changed, 10 insertions(+)
drivers/net/mlx5/linux/mlx5_os.c +5 -0
index 917d6be7b8..a6c1eba640 100644
@@ -116,7 +116,12 @@ mlx5_os_get_dev_attr(void *ctx, struct mlx5_dev_attr *device_attr)
 	device_attr->max_qp_wr = attr_ex.orig_attr.max_qp_wr;
 	device_attr->max_sge = attr_ex.orig_attr.max_sge;
 	device_attr->max_cq = attr_ex.orig_attr.max_cq;
+	device_attr->max_cqe = attr_ex.orig_attr.max_cqe;
+	device_attr->max_mr = attr_ex.orig_attr.max_mr;
+	device_attr->max_pd = attr_ex.orig_attr.max_pd;
 	device_attr->max_qp = attr_ex.orig_attr.max_qp;
+	device_attr->max_srq = attr_ex.orig_attr.max_srq;
+	device_attr->max_srq_wr = attr_ex.orig_attr.max_srq_wr;
 	device_attr->raw_packet_caps = attr_ex.raw_packet_caps;
 	device_attr->max_rwq_indirection_table_size =
 		attr_ex.rss_caps.max_rwq_indirection_table_size;
drivers/net/mlx5/mlx5.h +5 -0
index 121d726405..2186677810 100644
@@ -83,6 +83,11 @@ struct mlx5_dev_attr {
 	int		max_sge;
 	int		max_cq;
 	int		max_qp;
+	int		max_cqe;
+	uint32_t	max_pd;
+	uint32_t	max_mr;
+	uint32_t	max_srq;
+	uint32_t	max_srq_wr;
 	uint32_t	raw_packet_caps;
 	uint32_t	max_rwq_indirection_table_size;
 	uint32_t	max_tso;
Signature · 1 line
2.16.1.windows.4
#11 lore raw

PATCH v5 3/32 net/mlx5: remove Linux files from Windows compilation

In reply to Tal Shnaiderman

From: Ophir Munk <[email protected]>

This commit removes Linux files flow_verbs.c and mlx5_rxtx_vec.c from Windows compilation.

---
 drivers/net/mlx5/meson.build | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)
drivers/net/mlx5/meson.build +11 -5
index e7495a764a..f2fafbdd05 100644
@@ -15,7 +15,6 @@ sources = files(
 	'mlx5_flow.c',
 	'mlx5_flow_meter.c',
 	'mlx5_flow_dv.c',
-	'mlx5_flow_verbs.c',
         'mlx5_flow_age.c',
 	'mlx5_mac.c',
 	'mlx5_mr.c',
@@ -31,11 +30,18 @@ sources = files(
 	'mlx5_utils.c',
 	'mlx5_devx.c',
 )
-if (dpdk_conf.has('RTE_ARCH_X86_64')
-	or dpdk_conf.has('RTE_ARCH_ARM64')
-	or dpdk_conf.has('RTE_ARCH_PPC_64'))
-	sources += files('mlx5_rxtx_vec.c')
+
+if is_linux
+	sources += files(
+		'mlx5_flow_verbs.c',
+	)
+	if (dpdk_conf.has('RTE_ARCH_X86_64')
+		or dpdk_conf.has('RTE_ARCH_ARM64')
+		or dpdk_conf.has('RTE_ARCH_PPC_64'))
+		sources += files('mlx5_rxtx_vec.c')
+	endif
 endif
+
 cflags_options = [
 	'-std=c11',
 	'-Wno-strict-prototypes',
Signature · 1 line
2.16.1.windows.4
#12 lore raw

PATCH v5 4/32 net/mlx5: fix freeing packet pacing

In reply to Tal Shnaiderman

From: Ophir Munk <[email protected]>

Packet pacing is allocated under condition #ifdef HAVE_MLX5DV_PP_ALLOC. In a similar way - free packet pacing index under the same condition. This update is required to successfully compile under operating systems which do not support packet pacing.

Fixes aef1e20ebeb2 ("net/mlx5: allocate packet pacing context")
---
 drivers/net/mlx5/mlx5_txpp.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/net/mlx5/mlx5_txpp.c +5 -0
index 2438bf1f1d..21675ab17a 100644
@@ -57,11 +57,16 @@ mlx5_txpp_create_event_channel(struct mlx5_dev_ctx_shared *sh)
 static void
 mlx5_txpp_free_pp_index(struct mlx5_dev_ctx_shared *sh)
 {
+#ifdef HAVE_MLX5DV_PP_ALLOC
 	if (sh->txpp.pp) {
 		mlx5_glue->dv_free_pp(sh->txpp.pp);
 		sh->txpp.pp = NULL;
 		sh->txpp.pp_id = 0;
 	}
+#else
+	RTE_SET_USED(sh);
+	DRV_LOG(ERR, "Freeing pacing index is not supported.");
+#endif
 }
 
 /* Allocate Packet Pacing index from kernel via mlx5dv call. */
Signature · 1 line
2.16.1.windows.4
#13 lore raw

PATCH v5 5/32 net/mlx5: replace Linux sleep with rte sleep

In reply to Tal Shnaiderman

From: Ophir Munk <[email protected]>

Replace Linux API usleep() and nanosleep() with rte_delay_us_sleep(). The replacement occurs in shared files compiled under different operating systems.

---
 drivers/net/mlx5/mlx5.c         | 5 +++--
 drivers/net/mlx5/mlx5_trigger.c | 3 ++-
 drivers/net/mlx5/mlx5_txpp.c    | 6 +-----
 3 files changed, 6 insertions(+), 8 deletions(-)
drivers/net/mlx5/mlx5.c +3 -2
index 52a8a252d4..8e9df6abcf 100644
@@ -21,6 +21,7 @@
 #include <rte_spinlock.h>
 #include <rte_string_fns.h>
 #include <rte_alarm.h>
+#include <rte_cycles.h>
 
 #include <mlx5_glue.h>
 #include <mlx5_devx_cmds.h>
@@ -1330,7 +1331,7 @@ mlx5_dev_close(struct rte_eth_dev *dev)
 	mlx5_flex_parser_ecpri_release(dev);
 	if (priv->rxqs != NULL) {
 		/* XXX race condition if mlx5_rx_burst() is still running. */
-		usleep(1000);
+		rte_delay_us_sleep(1000);
 		for (i = 0; (i != priv->rxqs_n); ++i)
 			mlx5_rxq_release(dev, i);
 		priv->rxqs_n = 0;
@@ -1338,7 +1339,7 @@ mlx5_dev_close(struct rte_eth_dev *dev)
 	}
 	if (priv->txqs != NULL) {
 		/* XXX race condition if mlx5_tx_burst() is still running. */
-		usleep(1000);
+		rte_delay_us_sleep(1000);
 		for (i = 0; (i != priv->txqs_n); ++i)
 			mlx5_txq_release(dev, i);
 		priv->txqs_n = 0;
drivers/net/mlx5/mlx5_trigger.c +2 -1
index bd029154f8..646f29b923 100644
@@ -9,6 +9,7 @@
 #include <rte_ethdev_driver.h>
 #include <rte_interrupts.h>
 #include <rte_alarm.h>
+#include <rte_cycles.h>
 
 #include <mlx5_malloc.h>
 
@@ -1171,7 +1172,7 @@ mlx5_dev_stop(struct rte_eth_dev *dev)
 	rte_wmb();
 	/* Disable datapath on secondary process. */
 	mlx5_mp_os_req_stop_rxtx(dev);
-	usleep(1000 * priv->rxqs_n);
+	rte_delay_us_sleep(1000 * priv->rxqs_n);
 	DRV_LOG(DEBUG, "port %u stopping device", dev->data->port_id);
 	mlx5_flow_stop_default(dev);
 	/* Control flows for default traffic can be removed firstly. */
drivers/net/mlx5/mlx5_txpp.c +1 -5
index 21675ab17a..a1ec294942 100644
@@ -769,15 +769,11 @@ mlx5_txpp_init_timestamp(struct mlx5_dev_ctx_shared *sh)
 	sh->txpp.ts_p = 0;
 	sh->txpp.ts_n = 0;
 	for (wait = 0; wait < MLX5_TXPP_WAIT_INIT_TS; wait++) {
-		struct timespec onems;
-
 		mlx5_txpp_update_timestamp(sh);
 		if (wq->sq_ci)
 			return;
 		/* Wait one millisecond and try again. */
-		onems.tv_sec = 0;
-		onems.tv_nsec = NS_PER_S / MS_PER_S;
-		nanosleep(&onems, 0);
+		rte_delay_us_sleep(US_PER_S / MS_PER_S);
 	}
 	DRV_LOG(ERR, "Unable to initialize timestamp.");
 	sh->txpp.sync_lost = 1;
Signature · 1 line
2.16.1.windows.4
#14 lore raw

PATCH v5 6/32 net/mlx5: define mprq functions as static inline

In reply to Tal Shnaiderman

From: Ophir Munk <[email protected]>

Functions mlx5_check_mprq_support(), mlx5_rxq_mprq_enabled(), mlx5_mprq_enabled() are moved from source file mlx5_rxq.c to header file mlx5_rxtx.h and their type is updated to 'static __rte_always_inline'. Previously the functions were declared as 'inline' in the source file which was reported as 'unresolved external symbol' error by some Windows linkers.

---
 drivers/net/mlx5/mlx5_rxq.c  | 71 ------------------------------------------
 drivers/net/mlx5/mlx5_rxtx.h | 73 ++++++++++++++++++++++++++++++++++++++++++--
 2 files changed, 70 insertions(+), 74 deletions(-)
drivers/net/mlx5/mlx5_rxq.c +0 -71
index da7a8b3cd7..c89e55b1c0 100644
@@ -48,77 +48,6 @@ static_assert(MLX5_RSS_HASH_KEY_LEN ==
 	      (unsigned int)sizeof(rss_hash_default_key),
 	      "wrong RSS default key size.");
 
-/**
- * Check whether Multi-Packet RQ can be enabled for the device.
- *
- * @param dev
- *   Pointer to Ethernet device.
- *
- * @return
- *   1 if supported, negative errno value if not.
- */
-inline int
-mlx5_check_mprq_support(struct rte_eth_dev *dev)
-{
-	struct mlx5_priv *priv = dev->data->dev_private;
-
-	if (priv->config.mprq.enabled &&
-	    priv->rxqs_n >= priv->config.mprq.min_rxqs_num)
-		return 1;
-	return -ENOTSUP;
-}
-
-/**
- * Check whether Multi-Packet RQ is enabled for the Rx queue.
- *
- *  @param rxq
- *     Pointer to receive queue structure.
- *
- * @return
- *   0 if disabled, otherwise enabled.
- */
-inline int
-mlx5_rxq_mprq_enabled(struct mlx5_rxq_data *rxq)
-{
-	return rxq->strd_num_n > 0;
-}
-
-/**
- * Check whether Multi-Packet RQ is enabled for the device.
- *
- * @param dev
- *   Pointer to Ethernet device.
- *
- * @return
- *   0 if disabled, otherwise enabled.
- */
-inline int
-mlx5_mprq_enabled(struct rte_eth_dev *dev)
-{
-	struct mlx5_priv *priv = dev->data->dev_private;
-	uint32_t i;
-	uint16_t n = 0;
-	uint16_t n_ibv = 0;
-
-	if (mlx5_check_mprq_support(dev) < 0)
-		return 0;
-	/* All the configured queues should be enabled. */
-	for (i = 0; i < priv->rxqs_n; ++i) {
-		struct mlx5_rxq_data *rxq = (*priv->rxqs)[i];
-		struct mlx5_rxq_ctrl *rxq_ctrl = container_of
-			(rxq, struct mlx5_rxq_ctrl, rxq);
-
-		if (rxq == NULL || rxq_ctrl->type != MLX5_RXQ_TYPE_STANDARD)
-			continue;
-		n_ibv++;
-		if (mlx5_rxq_mprq_enabled(rxq))
-			++n;
-	}
-	/* Multi-Packet RQ can't be partially configured. */
-	MLX5_ASSERT(n == 0 || n == n_ibv);
-	return n == n_ibv;
-}
-
 /**
  * Calculate the number of CQEs in CQ for the Rx queue.
  *
drivers/net/mlx5/mlx5_rxtx.h +70 -3

83 lines not on this page · raw message

Signature · 1 line
2.16.1.windows.4
#15 lore raw

PATCH v5 7/32 net/mlx5: do not define static_assert in Windows

In reply to Tal Shnaiderman

From: Ophir Munk <[email protected]>

In Linux 'static_assert' is defined in file mlx5_defs.h:

 #ifndef HAVE_STATIC_ASSERT
    #define static_assert _Static_assert

#endif

The same definition can originate from Linux file /usr/include/assert.h.

In Windows static_assert is used while _Static_assert is unknown. Therefore update the definition condition to be:

 #if !defined(HAVE_STATIC_ASSERT) && !defined(RTE_EXEC_ENV_WINDOWS)
    #define static_assert _Static_assert

#endif

---
 drivers/net/mlx5/mlx5_defs.h | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/net/mlx5/mlx5_defs.h +5 -2
index aa55db3750..85a0979653 100644
@@ -199,8 +199,11 @@
 /* Maximum number of shared actions supported by rte_flow */
 #define MLX5_MAX_SHARED_ACTIONS 2
 
-/* Definition of static_assert found in /usr/include/assert.h */
-#ifndef HAVE_STATIC_ASSERT
+/*
+ * Linux definition of static_assert is found in /usr/include/assert.h.
+ * Windows does not require a redefinition.
+ */
+#if !defined(HAVE_STATIC_ASSERT) && !defined(RTE_EXEC_ENV_WINDOWS)
 #define static_assert _Static_assert
 #endif
 
Signature · 1 line
2.16.1.windows.4
#16 lore raw

PATCH v5 8/32 net/mlx5: move static_assert calls to global scope

In reply to Tal Shnaiderman

From: Ophir Munk <[email protected]>

Some Windows compilers consider static_assert() as calls to another function rather than a compiler directive which allows checking type information at compile time. This only occurs if the static_assert call appears inside another function scope. To solve it move the static_assert calls to global scope in the files where they are used.

---
 drivers/net/mlx5/mlx5_rxtx.c | 98 ++++++++++++++++++++++----------------------
 drivers/net/mlx5/mlx5_txpp.c |  5 ++-
 2 files changed, 53 insertions(+), 50 deletions(-)
drivers/net/mlx5/mlx5_rxtx.c +50 -48
index d12d746c2f..65a1f997e9 100644
@@ -79,6 +79,56 @@ static uint16_t mlx5_tx_burst_##func(void *txq, \
 
 #define MLX5_TXOFF_INFO(func, olx) {mlx5_tx_burst_##func, olx},
 
+/* static asserts */
+static_assert(MLX5_CQE_STATUS_HW_OWN < 0, "Must be negative value");
+static_assert(MLX5_CQE_STATUS_SW_OWN < 0, "Must be negative value");
+static_assert(MLX5_ESEG_MIN_INLINE_SIZE ==
+		(sizeof(uint16_t) +
+		 sizeof(rte_v128u32_t)),
+		"invalid Ethernet Segment data size");
+static_assert(MLX5_ESEG_MIN_INLINE_SIZE ==
+		(sizeof(uint16_t) +
+		 sizeof(struct rte_vlan_hdr) +
+		 2 * RTE_ETHER_ADDR_LEN),
+		"invalid Ethernet Segment data size");
+static_assert(MLX5_ESEG_MIN_INLINE_SIZE ==
+		(sizeof(uint16_t) +
+		 sizeof(rte_v128u32_t)),
+		"invalid Ethernet Segment data size");
+static_assert(MLX5_ESEG_MIN_INLINE_SIZE ==
+		(sizeof(uint16_t) +
+		 sizeof(struct rte_vlan_hdr) +
+		 2 * RTE_ETHER_ADDR_LEN),
+		"invalid Ethernet Segment data size");
+static_assert(MLX5_ESEG_MIN_INLINE_SIZE ==
+		(sizeof(uint16_t) +
+		 sizeof(rte_v128u32_t)),
+		"invalid Ethernet Segment data size");
+static_assert(MLX5_ESEG_MIN_INLINE_SIZE ==
+		(sizeof(uint16_t) +
+		 sizeof(struct rte_vlan_hdr) +
+		 2 * RTE_ETHER_ADDR_LEN),
+		"invalid Ethernet Segment data size");
+static_assert(MLX5_DSEG_MIN_INLINE_SIZE ==
+		(2 * RTE_ETHER_ADDR_LEN),
+		"invalid Data Segment data size");
+static_assert(MLX5_EMPW_MIN_PACKETS >= 2, "invalid min size");
+static_assert(MLX5_EMPW_MIN_PACKETS >= 2, "invalid min size");
+static_assert((sizeof(struct rte_vlan_hdr) +
+			sizeof(struct rte_ether_hdr)) ==
+		MLX5_ESEG_MIN_INLINE_SIZE,
+		"invalid min inline data size");
+static_assert(MLX5_WQE_SIZE_MAX / MLX5_WSEG_SIZE <=
+		MLX5_DSEG_MAX, "invalid WQE max size");
+static_assert(MLX5_WQE_CSEG_SIZE == MLX5_WSEG_SIZE,
+		"invalid WQE Control Segment size");
+static_assert(MLX5_WQE_ESEG_SIZE == MLX5_WSEG_SIZE,
+		"invalid WQE Ethernet Segment size");
+static_assert(MLX5_WQE_DSEG_SIZE == MLX5_WSEG_SIZE,
+		"invalid WQE Data Segment size");
+static_assert(MLX5_WQE_SIZE == 4 * MLX5_WSEG_SIZE,
+		"invalid WQE size");
+
 static __rte_always_inline uint32_t
 rxq_cq_to_pkt_type(struct mlx5_rxq_data *rxq, volatile struct mlx5_cqe *cqe,
 				   volatile struct mlx5_mini_cqe8 *mcqe);
@@ -2070,8 +2120,6 @@ mlx5_tx_handle_completion(struct mlx5_txq_data *__rte_restrict txq,
 	bool ring_doorbell = false;
 	int ret;
 
-	static_assert(MLX5_CQE_STATUS_HW_OWN < 0, "Must be negative value");
-	static_assert(MLX5_CQE_STATUS_SW_OWN < 0, "Must be negative value");
 	do {
 		volatile struct mlx5_cqe *cqe;
 
@@ -2381,15 +2429,6 @@ mlx5_tx_eseg_dmin(struct mlx5_txq_data *__rte_restrict txq __rte_unused,
 	es->metadata = MLX5_TXOFF_CONFIG(METADATA) ?
 		       loc->mbuf->ol_flags & PKT_TX_DYNF_METADATA ?
 		       *RTE_FLOW_DYNF_METADATA(loc->mbuf) : 0 : 0;
-	static_assert(MLX5_ESEG_MIN_INLINE_SIZE ==
-				(sizeof(uint16_t) +
-				 sizeof(rte_v128u32_t)),
-		      "invalid Ethernet Segment data size");
-	static_assert(MLX5_ESEG_MIN_INLINE_SIZE ==
-				(sizeof(uint16_t) +
-				 sizeof(struct rte_vlan_hdr) +
-				 2 * RTE_ETHER_ADDR_LEN),
-		      "invalid Ethernet Segment data size");
 	psrc = rte_pktmbuf_mtod(loc->mbuf, uint8_t *);
 	es->inline_hdr_sz = RTE_BE16(MLX5_ESEG_MIN_INLINE_SIZE);
 	es->inline_data = *(unaligned_uint16_t *)psrc;
@@ -2474,15 +2513,6 @@ mlx5_tx_eseg_data(struct mlx5_txq_data *__rte_restrict txq,
 	es->metadata = MLX5_TXOFF_CONFIG(METADATA) ?
 		       loc->mbuf->ol_flags & PKT_TX_DYNF_METADATA ?
 		       *RTE_FLOW_DYNF_METADATA(loc->mbuf) : 0 : 0;
-	static_assert(MLX5_ESEG_MIN_INLINE_SIZE ==
-				(sizeof(uint16_t) +
-				 sizeof(rte_v128u32_t)),
-		      "invalid Ethernet Segment data size");
-	static_assert(MLX5_ESEG_MIN_INLINE_SIZE ==
-				(sizeof(uint16_t) +
-				 sizeof(struct rte_vlan_hdr) +
-				 2 * RTE_ETHER_ADDR_LEN),
-		      "invalid Ethernet Segment data size");
 	psrc = rte_pktmbuf_mtod(loc->mbuf, uint8_t *);
 	es->inline_hdr_sz = rte_cpu_to_be_16(inlen);
 	es->inline_data = *(unaligned_uint16_t *)psrc;
@@ -2697,15 +2727,6 @@ mlx5_tx_eseg_mdat(struct mlx5_txq_data *__rte_restrict txq,
 	es->metadata = MLX5_TXOFF_CONFIG(METADATA) ?
 		       loc->mbuf->ol_flags & PKT_TX_DYNF_METADATA ?
 		       *RTE_FLOW_DYNF_METADATA(loc->mbuf) : 0 : 0;
-	static_assert(MLX5_ESEG_MIN_INLINE_SIZE ==
-				(sizeof(uint16_t) +
-				 sizeof(rte_v128u32_t)),
-		      "invalid Ethernet Segment data size");
-	static_assert(MLX5_ESEG_MIN_INLINE_SIZE ==
-				(sizeof(uint16_t) +
-				 sizeof(struct rte_vlan_hdr) +
-				 2 * RTE_ETHER_ADDR_LEN),
-		      "invalid Ethernet Segment data size");
 	MLX5_ASSERT(inlen >= MLX5_ESEG_MIN_INLINE_SIZE);
 	pdst = (uint8_t *)&es->inline_data;
 	if (MLX5_TXOFF_CONFIG(VLAN) && vlan) {
@@ -2952,9 +2973,6 @@ mlx5_tx_dseg_vlan(struct mlx5_txq_data *__rte_restrict txq,
 	uint8_t *pdst;
 
 	MLX5_ASSERT(len > MLX5_ESEG_MIN_INLINE_SIZE);
-	static_assert(MLX5_DSEG_MIN_INLINE_SIZE ==
-				 (2 * RTE_ETHER_ADDR_LEN),
-		      "invalid Data Segment data size");
 	if (!MLX5_TXOFF_CONFIG(MPW)) {
 		/* Store the descriptor byte counter for eMPW sessions. */
 		dseg->bcount = rte_cpu_to_be_32
@@ -4070,7 +4088,6 @@ mlx5_tx_burst_empw_simple(struct mlx5_txq_data *__rte_restrict txq,
 	MLX5_ASSERT(MLX5_TXOFF_CONFIG(EMPW));
 	MLX5_ASSERT(loc->elts_free && loc->wqe_free);
 	MLX5_ASSERT(pkts_n > loc->pkts_sent);
-	static_assert(MLX5_EMPW_MIN_PACKETS >= 2, "invalid min size");
 	pkts += loc->pkts_sent + 1;
 	pkts_n -= loc->pkts_sent;
 	for (;;) {
@@ -4247,7 +4264,6 @@ mlx5_tx_burst_empw_inline(struct mlx5_txq_data *__rte_restrict txq,
 	MLX5_ASSERT(MLX5_TXOFF_CONFIG(EMPW));
 	MLX5_ASSERT(loc->elts_free && loc->wqe_free);
 	MLX5_ASSERT(pkts_n > loc->pkts_sent);
-	static_assert(MLX5_EMPW_MIN_PACKETS >= 2, "invalid min size");
 	pkts += loc->pkts_sent + 1;
 	pkts_n -= loc->pkts_sent;
 	for (;;) {
@@ -4561,10 +4577,6 @@ mlx5_tx_burst_single_send(struct mlx5_txq_data *__rte_restrict txq,
 			    loc->mbuf->ol_flags & PKT_TX_VLAN_PKT) {
 				vlan = sizeof(struct rte_vlan_hdr);
 				inlen += vlan;
-				static_assert((sizeof(struct rte_vlan_hdr) +
-					       sizeof(struct rte_ether_hdr)) ==
-					       MLX5_ESEG_MIN_INLINE_SIZE,
-					       "invalid min inline data size");
 			}
 			/*
 			 * If inlining is enabled at configuration time
@@ -5567,16 +5579,6 @@ mlx5_select_tx_function(struct rte_eth_dev *dev)
 	uint64_t tx_offloads = dev->data->dev_conf.txmode.offloads;
 	unsigned int diff = 0, olx = 0, i, m;
 
-	static_assert(MLX5_WQE_SIZE_MAX / MLX5_WSEG_SIZE <=
-		      MLX5_DSEG_MAX, "invalid WQE max size");
-	static_assert(MLX5_WQE_CSEG_SIZE == MLX5_WSEG_SIZE,
-		      "invalid WQE Control Segment size");
-	static_assert(MLX5_WQE_ESEG_SIZE == MLX5_WSEG_SIZE,
-		      "invalid WQE Ethernet Segment size");
-	static_assert(MLX5_WQE_DSEG_SIZE == MLX5_WSEG_SIZE,
-		      "invalid WQE Data Segment size");
-	static_assert(MLX5_WQE_SIZE == 4 * MLX5_WSEG_SIZE,
-		      "invalid WQE size");
 	MLX5_ASSERT(priv);
 	if (tx_offloads & DEV_TX_OFFLOAD_MULTI_SEGS) {
 		/* We should support Multi-Segment Packets. */
drivers/net/mlx5/mlx5_txpp.c +3 -2
index a1ec294942..d61e43e55d 100644
@@ -18,6 +18,9 @@
 #include "mlx5_rxtx.h"
 #include "mlx5_common_os.h"
 
+static_assert(sizeof(struct mlx5_cqe_ts) == sizeof(rte_int128_t),
+		"Wrong timestamp CQE part size");
+
 static const char * const mlx5_txpp_stat_names[] = {
 	"tx_pp_missed_interrupt_errors", /* Missed service interrupt. */
 	"tx_pp_rearm_queue_errors", /* Rearm Queue errors. */
@@ -741,8 +744,6 @@ mlx5_txpp_update_timestamp(struct mlx5_dev_ctx_shared *sh)
 	uint64_t ts;
 	uint16_t ci;
 
-	static_assert(sizeof(struct mlx5_cqe_ts) == sizeof(rte_int128_t),
-		      "Wrong timestamp CQE part size");
 	mlx5_atomic_read_cqe((rte_int128_t *)&cqe->timestamp, &to.u128);
 	if (to.cts.op_own >> 4) {
 		DRV_LOG(DEBUG, "Clock Queue error sync lost.");
Signature · 1 line
2.16.1.windows.4
#17 lore raw

PATCH v5 9/32 net/mlx5: wrap glue alloc/dealloc PD with OS calls

In reply to Tal Shnaiderman

From: Ophir Munk <[email protected]>

Wrap glue calls alloc_pd() and dealloc_pd() with generic OS calls. In Linux - protection domain allocations are implemented by Verbs glue API while in Windows it is by DevX API.

---
 drivers/common/mlx5/linux/mlx5_common_os.h | 11 +++++++++++
 drivers/net/mlx5/mlx5.c                    |  6 +++---
 2 files changed, 14 insertions(+), 3 deletions(-)
drivers/common/mlx5/linux/mlx5_common_os.h +11 -0
index 3420937859..c9f8d7cbc1 100644
@@ -201,4 +201,15 @@ mlx5_os_get_devx_uar_page_id(void *uar)
 #endif
 }
 
+static inline void *
+mlx5_os_alloc_pd(void *ctx)
+{
+	return mlx5_glue->alloc_pd(ctx);
+}
+
+static inline int
+mlx5_os_dealloc_pd(void *pd)
+{
+	return mlx5_glue->dealloc_pd(pd);
+}
 #endif /* RTE_PMD_MLX5_COMMON_OS_H_ */
drivers/net/mlx5/mlx5.c +3 -3
index 8e9df6abcf..7d1b4fbdc0 100644
@@ -932,7 +932,7 @@ mlx5_alloc_shared_dev_ctx(const struct mlx5_dev_spawn_data *spawn,
 		sh->port[i].ih_port_id = RTE_MAX_ETHPORTS;
 		sh->port[i].devx_ih_port_id = RTE_MAX_ETHPORTS;
 	}
-	sh->pd = mlx5_glue->alloc_pd(sh->ctx);
+	sh->pd = mlx5_os_alloc_pd(sh->ctx);
 	if (sh->pd == NULL) {
 		DRV_LOG(ERR, "PD allocation failure");
 		err = ENOMEM;
@@ -1032,7 +1032,7 @@ mlx5_alloc_shared_dev_ctx(const struct mlx5_dev_spawn_data *spawn,
 	if (sh->tx_uar)
 		mlx5_glue->devx_free_uar(sh->tx_uar);
 	if (sh->pd)
-		claim_zero(mlx5_glue->dealloc_pd(sh->pd));
+		claim_zero(mlx5_os_dealloc_pd(sh->pd));
 	if (sh->ctx)
 		claim_zero(mlx5_glue->close_device(sh->ctx));
 	mlx5_free(sh);
@@ -1100,7 +1100,7 @@ mlx5_free_shared_dev_ctx(struct mlx5_dev_ctx_shared *sh)
 		sh->tx_uar = NULL;
 	}
 	if (sh->pd)
-		claim_zero(mlx5_glue->dealloc_pd(sh->pd));
+		claim_zero(mlx5_os_dealloc_pd(sh->pd));
 	if (sh->tis)
 		claim_zero(mlx5_devx_cmd_destroy(sh->tis));
 	if (sh->td)
Signature · 1 line
2.16.1.windows.4
#18 lore raw

PATCH v5 10/32 net/mlx5: wrap glue reg/dereg UMEM with OS calls

In reply to Tal Shnaiderman

Wrap glue calls for UMEM registration and deregistration with generic OS calls since each OS (Linux or Windows) has a different glue API parameters.

---
 drivers/common/mlx5/linux/mlx5_common_os.h | 12 ++++++++++++
 drivers/common/mlx5/mlx5_common.c          |  4 ++--
 drivers/net/mlx5/mlx5.c                    |  2 +-
 drivers/net/mlx5/mlx5_devx.c               | 16 ++++++++--------
 drivers/net/mlx5/mlx5_flow.c               |  4 ++--
 drivers/net/mlx5/mlx5_txpp.c               | 12 ++++++------
 6 files changed, 31 insertions(+), 19 deletions(-)
drivers/common/mlx5/linux/mlx5_common_os.h +12 -0
index c9f8d7cbc1..f8b215cc29 100644
@@ -212,4 +212,16 @@ mlx5_os_dealloc_pd(void *pd)
 {
 	return mlx5_glue->dealloc_pd(pd);
 }
+
+static inline void *
+mlx5_os_umem_reg(void *ctx, void *addr, size_t size, uint32_t access)
+{
+	return mlx5_glue->devx_umem_reg(ctx, addr, size, access);
+}
+
+static inline int
+mlx5_os_umem_dereg(void *pumem)
+{
+	return mlx5_glue->devx_umem_dereg(pumem);
+}
 #endif /* RTE_PMD_MLX5_COMMON_OS_H_ */
drivers/common/mlx5/mlx5_common.c +2 -2
index 044513223c..a00ffcb833 100644
@@ -148,7 +148,7 @@ mlx5_alloc_dbr_page(void *ctx)
 		return NULL;
 	}
 	/* Register allocated memory. */
-	page->umem = mlx5_glue->devx_umem_reg(ctx, page->dbrs,
+	page->umem = mlx5_os_umem_reg(ctx, page->dbrs,
 					      MLX5_DBR_PAGE_SIZE, 0);
 	if (!page->umem) {
 		DRV_LOG(ERR, "cannot umem reg dbr page");
@@ -232,7 +232,7 @@ mlx5_release_dbr(struct mlx5_dbr_page_list *head, uint32_t umem_id,
 		/* Page not used, free it and remove from list. */
 		LIST_REMOVE(page, next);
 		if (page->umem)
-			ret = -mlx5_glue->devx_umem_dereg(page->umem);
+			ret = -mlx5_os_umem_dereg(page->umem);
 		mlx5_free(page);
 	} else {
 		/* Mark in bitmap that this door-bell is not in use. */
drivers/net/mlx5/mlx5.c +1 -1
index 7d1b4fbdc0..84123f8e3d 100644
@@ -482,7 +482,7 @@ mlx5_flow_destroy_counter_stat_mem_mng(struct mlx5_counter_stats_mem_mng *mng)
 
 	LIST_REMOVE(mng, next);
 	claim_zero(mlx5_devx_cmd_destroy(mng->dm));
-	claim_zero(mlx5_glue->devx_umem_dereg(mng->umem));
+	claim_zero(mlx5_os_umem_dereg(mng->umem));
 	mlx5_free(mem);
 }
 
drivers/net/mlx5/mlx5_devx.c +8 -8
index de9b204075..235fd5798d 100644
@@ -155,7 +155,7 @@ mlx5_rxq_release_devx_rq_resources(struct mlx5_rxq_ctrl *rxq_ctrl)
 	struct mlx5_devx_dbr_page *dbr_page = rxq_ctrl->rq_dbrec_page;
 
 	if (rxq_ctrl->wq_umem) {
-		mlx5_glue->devx_umem_dereg(rxq_ctrl->wq_umem);
+		mlx5_os_umem_dereg(rxq_ctrl->wq_umem);
 		rxq_ctrl->wq_umem = NULL;
 	}
 	if (rxq_ctrl->rxq.wqes) {
@@ -182,7 +182,7 @@ mlx5_rxq_release_devx_cq_resources(struct mlx5_rxq_ctrl *rxq_ctrl)
 	struct mlx5_devx_dbr_page *dbr_page = rxq_ctrl->cq_dbrec_page;
 
 	if (rxq_ctrl->cq_umem) {
-		mlx5_glue->devx_umem_dereg(rxq_ctrl->cq_umem);
+		mlx5_os_umem_dereg(rxq_ctrl->cq_umem);
 		rxq_ctrl->cq_umem = NULL;
 	}
 	if (rxq_ctrl->rxq.cqes) {
@@ -375,7 +375,7 @@ mlx5_rxq_create_devx_rq_resources(struct rte_eth_dev *dev, uint16_t idx)
 	if (!buf)
 		return NULL;
 	rxq_data->wqes = buf;
-	rxq_ctrl->wq_umem = mlx5_glue->devx_umem_reg(priv->sh->ctx,
+	rxq_ctrl->wq_umem = mlx5_os_umem_reg(priv->sh->ctx,
 						     buf, wq_size, 0);
 	if (!rxq_ctrl->wq_umem)
 		goto error;
@@ -497,7 +497,7 @@ mlx5_rxq_create_devx_cq_resources(struct rte_eth_dev *dev, uint16_t idx)
 		goto error;
 	}
 	rxq_data->cqes = (volatile struct mlx5_cqe (*)[])(uintptr_t)buf;
-	rxq_ctrl->cq_umem = mlx5_glue->devx_umem_reg(priv->sh->ctx, buf,
+	rxq_ctrl->cq_umem = mlx5_os_umem_reg(priv->sh->ctx, buf,
 						     cq_size,
 						     IBV_ACCESS_LOCAL_WRITE);
 	if (!rxq_ctrl->cq_umem) {
@@ -1127,7 +1127,7 @@ mlx5_txq_release_devx_sq_resources(struct mlx5_txq_obj *txq_obj)
 		txq_obj->sq_devx = NULL;
 	}
 	if (txq_obj->sq_umem) {
-		claim_zero(mlx5_glue->devx_umem_dereg(txq_obj->sq_umem));
+		claim_zero(mlx5_os_umem_dereg(txq_obj->sq_umem));
 		txq_obj->sq_umem = NULL;
 	}
 	if (txq_obj->sq_buf) {
@@ -1155,7 +1155,7 @@ mlx5_txq_release_devx_cq_resources(struct mlx5_txq_obj *txq_obj)
 	if (txq_obj->cq_devx)
 		claim_zero(mlx5_devx_cmd_destroy(txq_obj->cq_devx));
 	if (txq_obj->cq_umem)
-		claim_zero(mlx5_glue->devx_umem_dereg(txq_obj->cq_umem));
+		claim_zero(mlx5_os_umem_dereg(txq_obj->cq_umem));
 	if (txq_obj->cq_buf)
 		mlx5_free(txq_obj->cq_buf);
 	if (txq_obj->cq_dbrec_page)
@@ -1243,7 +1243,7 @@ mlx5_txq_create_devx_cq_resources(struct rte_eth_dev *dev, uint16_t idx)
 		return 0;
 	}
 	/* Register allocated buffer in user space with DevX. */
-	txq_obj->cq_umem = mlx5_glue->devx_umem_reg(priv->sh->ctx,
+	txq_obj->cq_umem = mlx5_os_umem_reg(priv->sh->ctx,
 						(void *)txq_obj->cq_buf,
 						cqe_n * sizeof(struct mlx5_cqe),
 						IBV_ACCESS_LOCAL_WRITE);
@@ -1342,7 +1342,7 @@ mlx5_txq_create_devx_sq_resources(struct rte_eth_dev *dev, uint16_t idx)
 		goto error;
 	}
 	/* Register allocated buffer in user space with DevX. */
-	txq_obj->sq_umem = mlx5_glue->devx_umem_reg
+	txq_obj->sq_umem = mlx5_os_umem_reg
 					(priv->sh->ctx,
 					 (void *)txq_obj->sq_buf,
 					 wqe_n * sizeof(struct mlx5_wqe),
drivers/net/mlx5/mlx5_flow.c +2 -2
index bf86aaaa39..66491bbf78 100644
@@ -6446,7 +6446,7 @@ mlx5_flow_create_counter_stat_mem_mng(struct mlx5_dev_ctx_shared *sh)
 	}
 	mem_mng = (struct mlx5_counter_stats_mem_mng *)(mem + size) - 1;
 	size = sizeof(*raw_data) * MLX5_COUNTERS_PER_POOL * raws_n;
-	mem_mng->umem = mlx5_glue->devx_umem_reg(sh->ctx, mem, size,
+	mem_mng->umem = mlx5_os_umem_reg(sh->ctx, mem, size,
 						 IBV_ACCESS_LOCAL_WRITE);
 	if (!mem_mng->umem) {
 		rte_errno = errno;
@@ -6465,7 +6465,7 @@ mlx5_flow_create_counter_stat_mem_mng(struct mlx5_dev_ctx_shared *sh)
 	mkey_attr.relaxed_ordering_read = sh->cmng.relaxed_ordering_read;
 	mem_mng->dm = mlx5_devx_cmd_mkey_create(sh->ctx, &mkey_attr);
 	if (!mem_mng->dm) {
-		mlx5_glue->devx_umem_dereg(mem_mng->umem);
+		mlx5_os_umem_dereg(mem_mng->umem);
 		rte_errno = errno;
 		mlx5_free(mem);
 		return -rte_errno;
drivers/net/mlx5/mlx5_txpp.c +6 -6
index d61e43e55d..749529c410 100644
@@ -131,13 +131,13 @@ mlx5_txpp_destroy_send_queue(struct mlx5_txpp_wq *wq)
 	if (wq->sq)
 		claim_zero(mlx5_devx_cmd_destroy(wq->sq));
 	if (wq->sq_umem)
-		claim_zero(mlx5_glue->devx_umem_dereg(wq->sq_umem));
+		claim_zero(mlx5_os_umem_dereg(wq->sq_umem));
 	if (wq->sq_buf)
 		mlx5_free((void *)(uintptr_t)wq->sq_buf);
 	if (wq->cq)
 		claim_zero(mlx5_devx_cmd_destroy(wq->cq));
 	if (wq->cq_umem)
-		claim_zero(mlx5_glue->devx_umem_dereg(wq->cq_umem));
+		claim_zero(mlx5_os_umem_dereg(wq->cq_umem));
 	if (wq->cq_buf)
 		mlx5_free((void *)(uintptr_t)wq->cq_buf);
 	memset(wq, 0, sizeof(*wq));
@@ -268,7 +268,7 @@ mlx5_txpp_create_rearm_queue(struct mlx5_dev_ctx_shared *sh)
 		return -ENOMEM;
 	}
 	/* Register allocated buffer in user space with DevX. */
-	wq->cq_umem = mlx5_glue->devx_umem_reg(sh->ctx,
+	wq->cq_umem = mlx5_os_umem_reg(sh->ctx,
 					       (void *)(uintptr_t)wq->cq_buf,
 					       umem_size,
 					       IBV_ACCESS_LOCAL_WRITE);
@@ -318,7 +318,7 @@ mlx5_txpp_create_rearm_queue(struct mlx5_dev_ctx_shared *sh)
 		goto error;
 	}
 	/* Register allocated buffer in user space with DevX. */
-	wq->sq_umem = mlx5_glue->devx_umem_reg(sh->ctx,
+	wq->sq_umem = mlx5_os_umem_reg(sh->ctx,
 					       (void *)(uintptr_t)wq->sq_buf,
 					       umem_size,
 					       IBV_ACCESS_LOCAL_WRITE);
@@ -506,7 +506,7 @@ mlx5_txpp_create_clock_queue(struct mlx5_dev_ctx_shared *sh)
 		return -ENOMEM;
 	}
 	/* Register allocated buffer in user space with DevX. */
-	wq->cq_umem = mlx5_glue->devx_umem_reg(sh->ctx,
+	wq->cq_umem = mlx5_os_umem_reg(sh->ctx,
 					       (void *)(uintptr_t)wq->cq_buf,
 					       umem_size,
 					       IBV_ACCESS_LOCAL_WRITE);
@@ -562,7 +562,7 @@ mlx5_txpp_create_clock_queue(struct mlx5_dev_ctx_shared *sh)
 		goto error;
 	}
 	/* Register allocated buffer in user space with DevX. */
-	wq->sq_umem = mlx5_glue->devx_umem_reg(sh->ctx,
+	wq->sq_umem = mlx5_os_umem_reg(sh->ctx,
 					       (void *)(uintptr_t)wq->sq_buf,
 					       umem_size,
 					       IBV_ACCESS_LOCAL_WRITE);
Signature · 1 line
2.16.1.windows.4
#19 lore raw

PATCH v5 11/32 net/mlx5: fix adding destroy flow action wrapper

In reply to Tal Shnaiderman

From: Ophir Munk <[email protected]>

Glue function destroy_flow_action() was wrapped by OS specific operation mlx5_flow_os_destroy_flow_action(). It was skipped in file mlx5.c.

Fixes b293fbf9672b ("net/mlx5: add OS specific flow actions operations")
---
 drivers/net/mlx5/mlx5.c         | 7 ++++---
 drivers/net/mlx5/mlx5_flow_dv.c | 6 +++---
 2 files changed, 7 insertions(+), 6 deletions(-)
drivers/net/mlx5/mlx5.c +4 -3
index 84123f8e3d..60301d3244 100644
@@ -38,6 +38,7 @@
 #include "mlx5_autoconf.h"
 #include "mlx5_mr.h"
 #include "mlx5_flow.h"
+#include "mlx5_flow_os.h"
 #include "rte_pmd_mlx5.h"
 
 /* Device parameter to enable RX completion queue compression. */
@@ -415,8 +416,8 @@ mlx5_flow_aso_age_mng_close(struct mlx5_dev_ctx_shared *sh)
 			for (j = 0; j < MLX5_COUNTERS_PER_POOL; ++j)
 				if (pool->actions[j].dr_action)
 					claim_zero
-						(mlx5_glue->destroy_flow_action
-						  (pool->actions[j].dr_action));
+					    (mlx5_flow_os_destroy_flow_action
+					      (pool->actions[j].dr_action));
 			mlx5_free(pool);
 		}
 		mlx5_free(sh->aso_age_mng->pools);
@@ -523,7 +524,7 @@ mlx5_flow_counters_mng_close(struct mlx5_dev_ctx_shared *sh)
 
 				if (cnt->action)
 					claim_zero
-					 (mlx5_glue->destroy_flow_action
+					 (mlx5_flow_os_destroy_flow_action
 					  (cnt->action));
 				if (fallback && MLX5_POOL_GET_CNT
 				    (pool, j)->dcs_when_free)
drivers/net/mlx5/mlx5_flow_dv.c +3 -3
index c31737652c..78b5a6b338 100644
@@ -11117,11 +11117,11 @@ flow_dv_sample_remove_cb(struct mlx5_cache_list *list __rte_unused,
 	struct mlx5_priv *priv = dev->data->dev_private;
 
 	if (cache_resource->verbs_action)
-		claim_zero(mlx5_glue->destroy_flow_action
+		claim_zero(mlx5_flow_os_destroy_flow_action
 				(cache_resource->verbs_action));
 	if (cache_resource->ft_type == MLX5DV_FLOW_TABLE_TYPE_FDB) {
 		if (cache_resource->default_miss)
-			claim_zero(mlx5_glue->destroy_flow_action
+			claim_zero(mlx5_flow_os_destroy_flow_action
 			  (cache_resource->default_miss));
 	}
 	if (cache_resource->normal_path_tbl)
@@ -11174,7 +11174,7 @@ flow_dv_dest_array_remove_cb(struct mlx5_cache_list *list __rte_unused,
 
 	MLX5_ASSERT(cache_resource->action);
 	if (cache_resource->action)
-		claim_zero(mlx5_glue->destroy_flow_action
+		claim_zero(mlx5_flow_os_destroy_flow_action
 					(cache_resource->action));
 	for (; i < cache_resource->num_of_dest; i++)
 		flow_dv_sample_sub_actions_release(dev,
Signature · 1 line
2.16.1.windows.4
#20 lore raw

PATCH v5 12/32 common/mlx5: add definition HAVE_INFINIBAND_VERBS_H

In reply to Tal Shnaiderman

From: Ophir Munk <[email protected]>

Add a Verbs file presence indication. Under Linux it is required that file infiniband/verbs.h is installed for building DPDK. Other operating systems (e.g. Windows) ignore Verbs completely. This commit adds definition HAVE_INFINIBAND_VERBS_H (file mlx5_autoconf.h) to indicate whether DPDK compiles with Verbs or not.

---
 drivers/common/mlx5/linux/meson.build | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/common/mlx5/linux/meson.build +4 -2
index 63b78e4bce..580419e6d9 100644
@@ -181,8 +181,10 @@ has_sym_args = [
 	[ 'HAVE_MLX5_DR_CREATE_ACTION_DEST_ARRAY', 'infiniband/mlx5dv.h',
 	'mlx5dv_dr_action_create_dest_array'],
 	[ 'HAVE_DEVLINK', 'linux/devlink.h', 'DEVLINK_GENL_NAME' ],
-        [ 'HAVE_MLX5_DR_CREATE_ACTION_ASO', 'infiniband/mlx5dv.h',
-        'mlx5dv_dr_action_create_aso' ],
+	[ 'HAVE_MLX5_DR_CREATE_ACTION_ASO', 'infiniband/mlx5dv.h',
+	'mlx5dv_dr_action_create_aso' ],
+	[ 'HAVE_INFINIBAND_VERBS_H', 'infiniband/verbs.h',
+	'INFINIBAND_VERBS_H' ],
 ]
 config = configuration_data()
 foreach arg:has_sym_args
Signature · 1 line
2.16.1.windows.4
#21 lore raw

PATCH v5 13/32 common/mlx5/linux: handle memory allocations with alignment

In reply to Tal Shnaiderman

From: Ophir Munk <[email protected]>

mlx5_malloc() API has an alignment parameter for system memory allocations. malloc() is called for non-aligned allocations and posix_memalign() is called for aligned allocations. When calling mlx5_free() there is no distinction whether the memory was originally allocated with or without alignment. Freeing a memory may be handled differently by operating systems. Therefore this commit wraps these APIs with OS specific calls: mlx5_os_malloc(), mlx5_os_free().

---
 drivers/common/mlx5/linux/mlx5_common_os.h | 38 ++++++++++++++++++++++++++++++
 drivers/common/mlx5/mlx5_malloc.c          | 14 +++++------
 2 files changed, 44 insertions(+), 8 deletions(-)
drivers/common/mlx5/linux/mlx5_common_os.h +38 -0
index f8b215cc29..bd44ecb7d6 100644
@@ -6,6 +6,7 @@
 #define RTE_PMD_MLX5_COMMON_OS_H_
 
 #include <stdio.h>
+#include <malloc.h>
 
 #include <rte_pci.h>
 #include <rte_debug.h>
@@ -16,6 +17,7 @@
 
 #include "mlx5_autoconf.h"
 #include "mlx5_glue.h"
+#include "mlx5_malloc.h"
 
 /**
  * Get device name. Given an ibv_device pointer - return a
@@ -224,4 +226,40 @@ mlx5_os_umem_dereg(void *pumem)
 {
 	return mlx5_glue->devx_umem_dereg(pumem);
 }
+
+/**
+ * Memory allocation optionally with alignment.
+ *
+ * @param[in] align
+ *    Alignment size (may be zero)
+ * @param[in] size
+ *    Size in bytes to allocate
+ *
+ * @return
+ *    Valid pointer to allocated memory, NULL in case of failure
+ */
+static inline void *
+mlx5_os_malloc(size_t align, size_t size)
+{
+	void *buf;
+
+	if (posix_memalign(&buf, align, size))
+		return NULL;
+	return buf;
+}
+
+/**
+ * This API de-allocates a memory that originally could have been
+ * allocated aligned or non-aligned. In Linux it is a wrapper
+ * around free().
+ *
+ * @param[in] addr
+ *    Pointer to address to free
+ *
+ */
+static inline void
+mlx5_os_free(void *addr)
+{
+	free(addr);
+}
 #endif /* RTE_PMD_MLX5_COMMON_OS_H_ */
drivers/common/mlx5/mlx5_malloc.c +6 -8
index 5a3267f730..9d30cedbaa 100644
@@ -9,6 +9,7 @@
 #include <string.h>
 
 #include "mlx5_common_utils.h"
+#include "mlx5_common_os.h"
 #include "mlx5_malloc.h"
 
 struct mlx5_sys_mem {
@@ -148,14 +149,11 @@ static void *
 mlx5_alloc_align(size_t size, unsigned int align, unsigned int zero)
 {
 	void *buf;
-	int ret;
-
-	ret = posix_memalign(&buf, align, size);
-	if (ret) {
-		DRV_LOG(ERR,
-			"Couldn't allocate buf size=%zu align=%u. Err=%d\n",
-			size, align, ret);
 
+	buf = mlx5_os_malloc(align, size);
+	if (!buf) {
+		DRV_LOG(ERR, "Couldn't allocate buf size=%zu align=%u.",
+			size, align);
 		return NULL;
 	}
 	if (zero)
@@ -264,7 +262,7 @@ mlx5_free(void *addr)
 		__atomic_add_fetch(&mlx5_sys_mem.free_sys, 1,
 				   __ATOMIC_RELAXED);
 #endif
-		free(addr);
+		mlx5_os_free(addr);
 	} else {
 #ifdef RTE_LIBRTE_MLX5_DEBUG
 		__atomic_add_fetch(&mlx5_sys_mem.free_rte, 1,
Signature · 1 line
2.16.1.windows.4
#22 lore raw

PATCH v5 14/32 common/mlx5/windows: handle memory allocations with alignment

In reply to Tal Shnaiderman

From: Ophir Munk <[email protected]>

This commit is the Windows equivalent of the Linux implementation. The APIs included in this commit: mlx5_os_malloc(), mlx5_os_free(). For memory allocations (with or without alignment) we always call _aligned_malloc(). Even if zero alignment was requested in the first place - we always select a minimal alignment value. In this way when the memory is free - it is always safe to call _aligned_free().

---
 drivers/common/mlx5/windows/mlx5_common_os.h | 51 ++++++++++++++++++++++++++++
 1 file changed, 51 insertions(+)
 create mode 100644 drivers/common/mlx5/windows/mlx5_common_os.h
drivers/common/mlx5/windows/mlx5_common_os.h new file +51 -0
new file mode 100644
index 0000000000..cce7c88c6a
@@ -0,0 +1,51 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright 2020 Mellanox Technologies, Ltd
+ */
+
+#ifndef RTE_PMD_MLX5_COMMON_OS_H_
+#define RTE_PMD_MLX5_COMMON_OS_H_
+
+#include <stdio.h>
+
+#include "mlx5_autoconf.h"
+#include "mlx5_glue.h"
+#include "mlx5_malloc.h"
+
+/**
+ * This API allocates aligned or non-aligned memory.  The free can be on either
+ * aligned or nonaligned memory.  To be protected - even though there may be no
+ * alignment - in Windows this API will unconditioanlly call _aligned_malloc()
+ * with at least a minimal alignment size.
+ *
+ * @param[in] align
+ *    The alignment value, which must be an integer power of 2 (or 0 for
+ *    non-alignment)
+ * @param[in] size
+ *    Size in bytes to allocate
+ *
+ * @return
+ *    Valid pointer to allocated memory, NULL in case of failure
+ */
+static inline void *
+mlx5_os_malloc(size_t align, size_t size)
+{
+	if (align < MLX5_MALLOC_ALIGNMENT)
+		align = MLX5_MALLOC_ALIGNMENT;
+	return _aligned_malloc(size, align);
+}
+
+/**
+ * This API de-allocates a memory that originally could have been allocated
+ * aligned or non-aligned. In Windows since the allocation was with
+ * _aligned_malloc() - it is safe to always call _aligned_free().
+ *
+ * @param[in] addr
+ *    Pointer to address to free
+ *
+ */
+static inline void
+mlx5_os_free(void *addr)
+{
+	_aligned_free(addr);
+}
+#endif /* RTE_PMD_MLX5_COMMON_OS_H_ */
Signature · 1 line
2.16.1.windows.4
#23 lore raw

PATCH v5 15/32 common/mlx5/linux: wrap event channel APIs with OS calls

In reply to Tal Shnaiderman

Wrap the API to create/destroy event channel and to subscribe an event with OS calls. In Linux those calls are implemented by glue functions while in Windows they are not supported.

---
 drivers/common/mlx5/linux/mlx5_common_os.h | 22 ++++++++++++++++++++++
 drivers/net/mlx5/mlx5_devx.c               |  8 ++++----
 drivers/net/mlx5/mlx5_txpp.c               |  6 +++---
 drivers/vdpa/mlx5/mlx5_vdpa_event.c        |  7 ++++---
 4 files changed, 33 insertions(+), 10 deletions(-)
drivers/common/mlx5/linux/mlx5_common_os.h +22 -0
index bd44ecb7d6..63f070d9c4 100644
@@ -227,6 +227,28 @@ mlx5_os_umem_dereg(void *pumem)
 	return mlx5_glue->devx_umem_dereg(pumem);
 }
 
+static inline void *
+mlx5_os_devx_create_event_channel(void *ctx, int flags)
+{
+	return mlx5_glue->devx_create_event_channel(ctx, flags);
+}
+
+static inline void
+mlx5_os_devx_destroy_event_channel(void *eventc)
+{
+	mlx5_glue->devx_destroy_event_channel(eventc);
+}
+
+static inline int
+mlx5_os_devx_subscribe_devx_event(void *eventc,
+				  void *obj,
+				  uint16_t events_sz, uint16_t events_num[],
+				  uint64_t cookie)
+{
+	return mlx5_glue->devx_subscribe_devx_event(eventc, obj, events_sz,
+						    events_num, cookie);
+}
+
 /**
  * Memory allocation optionally with alignment.
  *
drivers/net/mlx5/mlx5_devx.c +4 -4
index 235fd5798d..84a5c55ee0 100644
@@ -216,7 +216,7 @@ mlx5_rxq_devx_obj_release(struct mlx5_rxq_obj *rxq_obj)
 		claim_zero(mlx5_devx_cmd_destroy(rxq_obj->rq));
 		claim_zero(mlx5_devx_cmd_destroy(rxq_obj->devx_cq));
 		if (rxq_obj->devx_channel)
-			mlx5_glue->devx_destroy_event_channel
+			mlx5_os_devx_destroy_event_channel
 							(rxq_obj->devx_channel);
 		mlx5_rxq_release_devx_rq_resources(rxq_obj->rxq_ctrl);
 		mlx5_rxq_release_devx_cq_resources(rxq_obj->rxq_ctrl);
@@ -533,7 +533,7 @@ mlx5_rxq_create_devx_cq_resources(struct rte_eth_dev *dev, uint16_t idx)
 	rxq_data->cqe_n = log_cqe_n;
 	rxq_data->cqn = cq_obj->id;
 	if (rxq_ctrl->obj->devx_channel) {
-		ret = mlx5_glue->devx_subscribe_devx_event
+		ret = mlx5_os_devx_subscribe_devx_event
 						(rxq_ctrl->obj->devx_channel,
 						 cq_obj->obj,
 						 sizeof(event_nums),
@@ -644,7 +644,7 @@ mlx5_rxq_devx_obj_new(struct rte_eth_dev *dev, uint16_t idx)
 		int devx_ev_flag =
 			  MLX5DV_DEVX_CREATE_EVENT_CHANNEL_FLAGS_OMIT_EV_DATA;
 
-		tmpl->devx_channel = mlx5_glue->devx_create_event_channel
+		tmpl->devx_channel = mlx5_os_devx_create_event_channel
 								(priv->sh->ctx,
 								 devx_ev_flag);
 		if (!tmpl->devx_channel) {
@@ -686,7 +686,7 @@ mlx5_rxq_devx_obj_new(struct rte_eth_dev *dev, uint16_t idx)
 	if (tmpl->devx_cq)
 		claim_zero(mlx5_devx_cmd_destroy(tmpl->devx_cq));
 	if (tmpl->devx_channel)
-		mlx5_glue->devx_destroy_event_channel(tmpl->devx_channel);
+		mlx5_os_devx_destroy_event_channel(tmpl->devx_channel);
 	mlx5_rxq_release_devx_rq_resources(rxq_ctrl);
 	mlx5_rxq_release_devx_cq_resources(rxq_ctrl);
 	rte_errno = ret; /* Restore rte_errno. */
drivers/net/mlx5/mlx5_txpp.c +3 -3
index 749529c410..726bdc6ae1 100644
@@ -37,7 +37,7 @@ static void
 mlx5_txpp_destroy_event_channel(struct mlx5_dev_ctx_shared *sh)
 {
 	if (sh->txpp.echan) {
-		mlx5_glue->devx_destroy_event_channel(sh->txpp.echan);
+		mlx5_os_devx_destroy_event_channel(sh->txpp.echan);
 		sh->txpp.echan = NULL;
 	}
 }
@@ -47,7 +47,7 @@ static int
 mlx5_txpp_create_event_channel(struct mlx5_dev_ctx_shared *sh)
 {
 	MLX5_ASSERT(!sh->txpp.echan);
-	sh->txpp.echan = mlx5_glue->devx_create_event_channel(sh->ctx,
+	sh->txpp.echan = mlx5_os_devx_create_event_channel(sh->ctx,
 			MLX5DV_DEVX_CREATE_EVENT_CHANNEL_FLAGS_OMIT_EV_DATA);
 	if (!sh->txpp.echan) {
 		rte_errno = errno;
@@ -937,7 +937,7 @@ mlx5_txpp_start_service(struct mlx5_dev_ctx_shared *sh)
 		return -rte_errno;
 	}
 	/* Subscribe CQ event to the event channel controlled by the driver. */
-	ret = mlx5_glue->devx_subscribe_devx_event(sh->txpp.echan,
+	ret = mlx5_os_devx_subscribe_devx_event(sh->txpp.echan,
 						   sh->txpp.rearm_queue.cq->obj,
 						   sizeof(event_nums),
 						   event_nums, 0);
drivers/vdpa/mlx5/mlx5_vdpa_event.c +4 -3
index 3aeaeb893f..fd6150928b 100644
@@ -15,6 +15,7 @@
 #include <rte_alarm.h>
 
 #include <mlx5_common.h>
+#include <mlx5_common_os.h>
 #include <mlx5_glue.h>
 
 #include "mlx5_vdpa_utils.h"
@@ -43,7 +44,7 @@ mlx5_vdpa_event_qp_global_release(struct mlx5_vdpa_priv *priv)
 		       sizeof(out.buf)) >=
 		       (ssize_t)sizeof(out.event_resp.cookie))
 			;
-		mlx5_glue->devx_destroy_event_channel(priv->eventc);
+		mlx5_os_devx_destroy_event_channel(priv->eventc);
 		priv->eventc = NULL;
 	}
 #endif
@@ -63,7 +64,7 @@ mlx5_vdpa_event_qp_global_prepare(struct mlx5_vdpa_priv *priv)
 		DRV_LOG(ERR, "Failed to query EQ number %d.", rte_errno);
 		return -1;
 	}
-	priv->eventc = mlx5_glue->devx_create_event_channel(priv->ctx,
+	priv->eventc = mlx5_os_devx_create_event_channel(priv->ctx,
 			   MLX5DV_DEVX_CREATE_EVENT_CHANNEL_FLAGS_OMIT_EV_DATA);
 	if (!priv->eventc) {
 		rte_errno = errno;
@@ -176,7 +177,7 @@ mlx5_vdpa_cq_create(struct mlx5_vdpa_priv *priv, uint16_t log_desc_n,
 	cq->cq_ci = 0;
 	rte_spinlock_init(&cq->sl);
 	/* Subscribe CQ event to the event channel controlled by the driver. */
-	ret = mlx5_glue->devx_subscribe_devx_event(priv->eventc, cq->cq->obj,
+	ret = mlx5_os_devx_subscribe_devx_event(priv->eventc, cq->cq->obj,
 						   sizeof(event_nums),
 						   event_nums,
 						   (uint64_t)(uintptr_t)cq);
Signature · 1 line
2.16.1.windows.4
#24 lore raw

PATCH v5 16/32 common/mlx5: add Windows exports file

In reply to Tal Shnaiderman

File drivers/common/mlx5/rte_common_mlx5_exports.def contains mlx5 Windows exported symbols under common/mlx5 directory (DLL file name librte_common_mlx5*.dll). It is the equivalent of Linux map file rte_common_mlx5_version.map but the list of symbols may be different between the two operating systems.

---
 drivers/common/mlx5/rte_common_mlx5_exports.def | 62 +++++++++++++++++++++++++
 1 file changed, 62 insertions(+)
 create mode 100644 drivers/common/mlx5/rte_common_mlx5_exports.def
drivers/common/mlx5/rte_common_mlx5_exports.def new file +62 -0
new file mode 100644
index 0000000000..23984b7abd
@@ -0,0 +1,62 @@
+EXPORTS
+	haswell_broadwell_cpu
+
+	mlx5_common_init
+
+	mlx5_create_mr_ext
+
+	mlx5_devx_cmd_create_cq
+	mlx5_devx_cmd_create_flex_parser
+	mlx5_devx_cmd_create_qp
+	mlx5_devx_cmd_create_rq
+	mlx5_devx_cmd_create_rqt
+	mlx5_devx_cmd_create_sq
+	mlx5_devx_cmd_create_tir
+	mlx5_devx_cmd_create_td
+	mlx5_devx_cmd_create_tis
+	mlx5_devx_cmd_create_virtq
+	mlx5_devx_cmd_destroy
+	mlx5_devx_cmd_flow_counter_alloc
+	mlx5_devx_cmd_flow_counter_query
+	mlx5_devx_cmd_flow_dump
+	mlx5_devx_cmd_mkey_create
+	mlx5_devx_cmd_modify_qp_state
+	mlx5_devx_cmd_modify_rq
+	mlx5_devx_cmd_modify_rqt
+	mlx5_devx_cmd_modify_sq
+	mlx5_devx_cmd_modify_tir
+	mlx5_devx_cmd_modify_virtq
+	mlx5_devx_cmd_qp_query_tis_td
+	mlx5_devx_cmd_query_hca_attr
+	mlx5_devx_cmd_query_parse_samples
+	mlx5_devx_cmd_query_virtq
+	mlx5_devx_cmd_register_read
+	mlx5_devx_get_out_command_status
+	mlx5_devx_cmd_create_flow_hit_aso_obj
+
+	mlx5_get_dbr
+
+	mlx5_malloc_mem_select
+	mlx5_mr_btree_init
+	mlx5_mr_btree_free
+	mlx5_mr_btree_dump
+	mlx5_mr_addr2mr_bh
+	mlx5_mr_release_cache
+	mlx5_mr_dump_cache
+	mlx5_mr_rebuild_cache
+	mlx5_mr_insert_cache
+	mlx5_mr_lookup_cache
+	mlx5_mr_lookup_list
+	mlx5_mr_create_primary
+	mlx5_mr_flush_local_cache
+	mlx5_mp_req_queue_state_modify
+	mlx5_mr_free
+
+	mlx5_pci_driver_register
+
+	mlx5_release_dbr
+
+	mlx5_malloc
+	mlx5_realloc
+	mlx5_free
+
Signature · 1 line
2.16.1.windows.4
#25 lore raw

PATCH v5 17/32 common/mlx5: extend DevX query hca attributes command

In reply to Tal Shnaiderman

Extend DevX API mlx5_devx_cmd_query_hca_attr() to report on max number of available objects including: CQ, QP, PD, SRQ.

---
 drivers/common/mlx5/mlx5_devx_cmds.c | 11 +++++++++++
 drivers/common/mlx5/mlx5_devx_cmds.h | 10 +++++++++-
 drivers/common/mlx5/mlx5_prm.h       |  1 +
 3 files changed, 21 insertions(+), 1 deletion(-)
drivers/common/mlx5/mlx5_devx_cmds.c +11 -0
index 9c1d1883ea..36d3a421aa 100644
@@ -720,6 +720,14 @@ mlx5_devx_cmd_query_hca_attr(void *ctx,
 	attr->flow_hit_aso = !!(MLX5_GET64(cmd_hca_cap, hcattr,
 					   general_obj_types) &
 				MLX5_GENERAL_OBJ_TYPES_CAP_FLOW_HIT_ASO);
+	attr->log_max_cq = MLX5_GET(cmd_hca_cap, hcattr, log_max_cq);
+	attr->log_max_qp = MLX5_GET(cmd_hca_cap, hcattr, log_max_qp);
+	attr->log_max_cq_sz = MLX5_GET(cmd_hca_cap, hcattr, log_max_cq_sz);
+	attr->log_max_qp_sz = MLX5_GET(cmd_hca_cap, hcattr, log_max_qp_sz);
+	attr->log_max_mrw_sz = MLX5_GET(cmd_hca_cap, hcattr, log_max_mrw_sz);
+	attr->log_max_pd = MLX5_GET(cmd_hca_cap, hcattr, log_max_pd);
+	attr->log_max_srq = MLX5_GET(cmd_hca_cap, hcattr, log_max_srq);
+	attr->log_max_srq_sz = MLX5_GET(cmd_hca_cap, hcattr, log_max_srq_sz);
 	if (attr->qos.sup) {
 		MLX5_SET(query_hca_cap_in, in, op_mod,
 			 MLX5_GET_HCA_CAP_OP_MOD_QOS_CAP |
@@ -834,6 +842,9 @@ mlx5_devx_cmd_query_hca_attr(void *ctx,
 	attr->tunnel_stateless_gtp = MLX5_GET
 					(per_protocol_networking_offload_caps,
 					 hcattr, tunnel_stateless_gtp);
+	attr->rss_ind_tbl_cap = MLX5_GET
+					(per_protocol_networking_offload_caps,
+					 hcattr, rss_ind_tbl_cap);
 	if (attr->wqe_inline_mode != MLX5_CAP_INLINE_MODE_VPORT_CONTEXT)
 		return 0;
 	if (attr->eth_virt) {
drivers/common/mlx5/mlx5_devx_cmds.h +9 -1
index 726e9f5192..5056d86ed9 100644
@@ -117,6 +117,15 @@ struct mlx5_hca_attr {
 	uint32_t log_max_ft_sampler_num:8;
 	struct mlx5_hca_qos_attr qos;
 	struct mlx5_hca_vdpa_attr vdpa;
+	int log_max_qp_sz;
+	int log_max_cq_sz;
+	int log_max_qp;
+	int log_max_cq;
+	uint32_t log_max_pd;
+	uint32_t log_max_mrw_sz;
+	uint32_t log_max_srq;
+	uint32_t log_max_srq_sz;
+	uint32_t rss_ind_tbl_cap;
 };
 
 struct mlx5_devx_wq_attr {
@@ -495,7 +504,6 @@ struct mlx5_devx_obj *mlx5_devx_cmd_create_virtio_q_counters(void *ctx);
 __rte_internal
 int mlx5_devx_cmd_query_virtio_q_counters(struct mlx5_devx_obj *couners_obj,
 				  struct mlx5_devx_virtio_q_couners_attr *attr);
-
 __rte_internal
 struct mlx5_devx_obj *mlx5_devx_cmd_create_flow_hit_aso_obj(void *ctx,
 							    uint32_t pd);
drivers/common/mlx5/mlx5_prm.h +1 -0
index 58d180486e..585e9d1c05 100644
@@ -665,6 +665,7 @@ typedef uint8_t u8;
 #define MLX5_GET64(typ, p, fld) rte_be_to_cpu_64(*((rte_be64_t *)(p) + \
 						   __mlx5_64_off(typ, fld)))
 #define MLX5_FLD_SZ_BYTES(typ, fld) (__mlx5_bit_sz(typ, fld) / 8)
+#define MLX5_UN_SZ_BYTES(typ) (sizeof(union mlx5_ifc_##typ##_bits) / 8)
 
 struct mlx5_ifc_fte_match_set_misc_bits {
 	u8 gre_c_present[0x1];
Signature · 1 line
2.16.1.windows.4
#26 lore raw

PATCH v5 18/32 common/mlx5: add DevX alloc PD command

In reply to Tal Shnaiderman

Add a new DevX API mlx5_devx_cmd_alloc_pd() that creates a new protection domain (PD).

---
 drivers/common/mlx5/mlx5_devx_cmds.c            | 35 ++++++++++++++++++++++++
 drivers/common/mlx5/mlx5_devx_cmds.h            |  2 ++
 drivers/common/mlx5/mlx5_prm.h                  | 36 +++++++++++++++++++++++++
 drivers/common/mlx5/rte_common_mlx5_exports.def |  1 +
 drivers/common/mlx5/version.map                 |  1 +
 5 files changed, 75 insertions(+)
drivers/common/mlx5/mlx5_devx_cmds.c +35 -0
index 36d3a421aa..12f51a940c 100644
@@ -2055,3 +2055,38 @@ mlx5_devx_cmd_create_flow_hit_aso_obj(void *ctx, uint32_t pd)
 	flow_hit_aso_obj->id = MLX5_GET(general_obj_out_cmd_hdr, out, obj_id);
 	return flow_hit_aso_obj;
 }
+
+/*
+ * Create PD using DevX API.
+ *
+ * @param[in] ctx
+ *   Context returned from mlx5 open_device() glue function.
+ *
+ * @return
+ *   The DevX object created, NULL otherwise and rte_errno is set.
+ */
+struct mlx5_devx_obj *
+mlx5_devx_cmd_alloc_pd(void *ctx)
+{
+	struct mlx5_devx_obj *ppd =
+		mlx5_malloc(MLX5_MEM_ZERO, sizeof(*ppd), 0, SOCKET_ID_ANY);
+	u32 in[MLX5_ST_SZ_DW(alloc_pd_in)] = {0};
+	u32 out[MLX5_ST_SZ_DW(alloc_pd_out)] = {0};
+
+	if (!ppd) {
+		DRV_LOG(ERR, "Failed to allocate PD data.");
+		rte_errno = ENOMEM;
+		return NULL;
+	}
+	MLX5_SET(alloc_pd_in, in, opcode, MLX5_CMD_OP_ALLOC_PD);
+	ppd->obj = mlx5_glue->devx_obj_create(ctx, in, sizeof(in),
+				out, sizeof(out));
+	if (!ppd->obj) {
+		mlx5_free(ppd);
+		DRV_LOG(ERR, "Failed to allocate PD Obj using DevX.");
+		rte_errno = errno;
+		return NULL;
+	}
+	ppd->id = MLX5_GET(alloc_pd_out, out, pd);
+	return ppd;
+}
drivers/common/mlx5/mlx5_devx_cmds.h +2 -0
index 5056d86ed9..8277fdbc39 100644
@@ -508,4 +508,6 @@ __rte_internal
 struct mlx5_devx_obj *mlx5_devx_cmd_create_flow_hit_aso_obj(void *ctx,
 							    uint32_t pd);
 
+__rte_internal
+struct mlx5_devx_obj *mlx5_devx_cmd_alloc_pd(void *ctx);
 #endif /* RTE_PMD_MLX5_DEVX_CMDS_H_ */
drivers/common/mlx5/mlx5_prm.h +36 -0
index 585e9d1c05..4ddf865743 100644
@@ -844,6 +844,8 @@ enum {
 	MLX5_CMD_OP_SUSPEND_QP = 0x50F,
 	MLX5_CMD_OP_RESUME_QP = 0x510,
 	MLX5_CMD_OP_QUERY_NIC_VPORT_CONTEXT = 0x754,
+	MLX5_CMD_OP_ALLOC_PD = 0x800,
+	MLX5_CMD_OP_DEALLOC_PD = 0x801,
 	MLX5_CMD_OP_ACCESS_REGISTER = 0x805,
 	MLX5_CMD_OP_ALLOC_TRANSPORT_DOMAIN = 0x816,
 	MLX5_CMD_OP_CREATE_TIR = 0x900,
@@ -2772,6 +2774,40 @@ struct mlx5_ifc_init2init_qp_in_bits {
 	u8 reserved_at_800[0x80];
 };
 
+struct mlx5_ifc_dealloc_pd_out_bits {
+	u8 status[0x8];
+	u8 reserved_0[0x18];
+	u8 syndrome[0x20];
+	u8 reserved_1[0x40];
+};
+
+struct mlx5_ifc_dealloc_pd_in_bits {
+	u8 opcode[0x10];
+	u8 reserved_0[0x10];
+	u8 reserved_1[0x10];
+	u8 op_mod[0x10];
+	u8 reserved_2[0x8];
+	u8 pd[0x18];
+	u8 reserved_3[0x20];
+};
+
+struct mlx5_ifc_alloc_pd_out_bits {
+	u8 status[0x8];
+	u8 reserved_0[0x18];
+	u8 syndrome[0x20];
+	u8 reserved_1[0x8];
+	u8 pd[0x18];
+	u8 reserved_2[0x20];
+};
+
+struct mlx5_ifc_alloc_pd_in_bits {
+	u8 opcode[0x10];
+	u8 reserved_0[0x10];
+	u8 reserved_1[0x10];
+	u8 op_mod[0x10];
+	u8 reserved_2[0x40];
+};
+
 #ifdef PEDANTIC
 #pragma GCC diagnostic ignored "-Wpedantic"
 #endif
drivers/common/mlx5/rte_common_mlx5_exports.def +1 -0
index 23984b7abd..15aafc3809 100644
@@ -5,6 +5,7 @@ EXPORTS
 
 	mlx5_create_mr_ext
 
+	mlx5_devx_cmd_alloc_pd
 	mlx5_devx_cmd_create_cq
 	mlx5_devx_cmd_create_flex_parser
 	mlx5_devx_cmd_create_qp
drivers/common/mlx5/version.map +1 -0
index 17dd11f635..fb3952bbc6 100644
@@ -10,6 +10,7 @@ INTERNAL {
 
 	mlx5_dev_to_pci_addr;
 
+	mlx5_devx_cmd_alloc_pd;
 	mlx5_devx_cmd_create_cq;
 	mlx5_devx_cmd_create_flex_parser;
 	mlx5_devx_cmd_create_qp;
Signature · 1 line
2.16.1.windows.4
#27 lore raw

PATCH v5 19/32 common/mlx5/windows: add glue functions APIs

In reply to Tal Shnaiderman

Windows glue functions are added to file mlx5/windows/mlx5_glue.c. The following APIs are supported:
get_device_list, free_device_list, open_device, close_device, query_device, query_hca_iseg, devx_obj_create, devx_obj_destroy, devx_obj_query, devx_obj_modify, devx_general_cmd, devx_umem_reg, devx_umem_dereg, devx_alloc_uar, devx_free_uar, devx_fs_rule_add, devx_fs_rule_del, devx_query_eqn
New added files:
mlx5_win_defs.h - this file imports missing definitions from Linux rdma-core library and Linux OS.
mlx5_win_ext.h - this file contains structs that enable a unified Linux/Windows API. Each struct has an equivalent (but different) Linux struct. By calling with 'void *' pointers - the Linux/Windows API is identical.

---
 drivers/common/mlx5/rte_common_mlx5_exports.def |   1 +
 drivers/common/mlx5/windows/mlx5_glue.c         | 304 ++++++++++++++++++++++++
 drivers/common/mlx5/windows/mlx5_glue.h         |  58 +++++
 drivers/common/mlx5/windows/mlx5_win_defs.h     |  25 ++
 drivers/common/mlx5/windows/mlx5_win_ext.h      |  34 +++
 5 files changed, 422 insertions(+)
 create mode 100644 drivers/common/mlx5/windows/mlx5_glue.c
 create mode 100644 drivers/common/mlx5/windows/mlx5_glue.h
 create mode 100644 drivers/common/mlx5/windows/mlx5_win_defs.h
 create mode 100644 drivers/common/mlx5/windows/mlx5_win_ext.h
drivers/common/mlx5/rte_common_mlx5_exports.def +1 -0
index 15aafc3809..2f6aab133b 100644
@@ -36,6 +36,7 @@ EXPORTS
 	mlx5_devx_cmd_create_flow_hit_aso_obj
 
 	mlx5_get_dbr
+	mlx5_glue
 
 	mlx5_malloc_mem_select
 	mlx5_mr_btree_init
drivers/common/mlx5/windows/mlx5_glue.c new file +304 -0

304 lines not on this page · raw message

drivers/common/mlx5/windows/mlx5_glue.h new file +58 -0

58 lines not on this page · raw message

drivers/common/mlx5/windows/mlx5_win_defs.h new file +25 -0
new file mode 100644
index 0000000000..72a3131f5e
@@ -0,0 +1,25 @@
+/*
+ * Copyright (C) Mellanox Technologies, Ltd. 2001-2020.
+ *
+ */
+#ifndef __MLX5_WIN_DEFS_H__
+#define __MLX5_WIN_DEFS_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+enum {
+	MLX5_CQE_OWNER_MASK	= 1,
+	MLX5_CQE_REQ		= 0,
+	MLX5_CQE_RESP_WR_IMM	= 1,
+	MLX5_CQE_RESP_SEND	= 2,
+	MLX5_CQE_RESP_SEND_IMM	= 3,
+	MLX5_CQE_RESP_SEND_INV	= 4,
+	MLX5_CQE_RESIZE_CQ	= 5,
+	MLX5_CQE_NO_PACKET	= 6,
+	MLX5_CQE_REQ_ERR	= 13,
+	MLX5_CQE_RESP_ERR	= 14,
+	MLX5_CQE_INVALID	= 15,
+};
+#endif /* __MLX5_WIN_DEFS_H__ */
drivers/common/mlx5/windows/mlx5_win_ext.h new file +34 -0
new file mode 100644
index 0000000000..0e74910e9d
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) Mellanox Technologies, Ltd. 2001-2020.
+ *
+ */
+#ifndef __MLX5_WIN_ETX_H__
+#define __MLX5_WIN_ETX_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "mlx5devx.h"
+
+typedef struct mlx5_context {
+	devx_device_ctx        *devx_ctx;
+	struct devx_device mlx5_dev;
+
+} mlx5_context_st;
+
+typedef struct {
+	devx_device_ctx *devx_ctx;
+	struct devx_obj_handle *obj;
+} mlx5_devx_obj_st;
+
+struct mlx5_devx_umem {
+	void                   *addr;
+	struct devx_obj_handle *umem_hdl;
+	uint32_t                umem_id;
+};
+
+#define GET_DEVX_CTX(ctx) (((mlx5_context_st *)ctx)->devx_ctx)
+#define GET_OBJ_CTX(obj)  (((mlx5_devx_obj_st *)obj)->devx_ctx)
+
+#endif /* __MLX5_WIN_ETX_H__ */
Signature · 1 line
2.16.1.windows.4
#28 lore raw

PATCH v5 20/32 mlx5/windows: add mlx5 meson file

In reply to Tal Shnaiderman

File drivers/common/mlx5/windows/meson.build is added to enable mlx5 source files compilation under common windows directory.
A Devx SDK tool must be installed to export two external H files:
mlx5devx.h and mlx5_ifc_devx.h. The installation is based on environment variable DEVX_INC_PATH. In addition a DLL lib file is installed based on environment variable DEVX_LIB_PATH. The meson file is using the environment variables for compilation and linkage.

---
 drivers/common/mlx5/windows/meson.build | 41 +++++++++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)
 create mode 100644 drivers/common/mlx5/windows/meson.build
drivers/common/mlx5/windows/meson.build new file +41 -0
new file mode 100644
index 0000000000..4f9825ea19
@@ -0,0 +1,41 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright 2019 Mellanox Technologies, Ltd
+
+includes += include_directories('.')
+
+sources += files(
+	'mlx5_glue.c',
+)
+
+res_lib = run_command(python3, '-c', 'import os; print(os.environ["DEVX_LIB_PATH"])')
+res_inc = run_command(python3, '-c', 'import os; print(os.environ["DEVX_INC_PATH"])')
+
+if (res_lib.returncode() != 0 or res_inc.returncode() != 0)
+	build = false
+	reason = 'DevX environment variables are not set, DEVX_LIB_PATH and DEVX_INC_PATH vars must be exported'
+	subdir_done()
+endif
+
+devx_lib_dir = res_lib.stdout().strip()
+devx_inc_dir = res_inc.stdout().strip()
+
+ext_deps += cc.find_library('mlx5devx', dirs: devx_lib_dir, required: true)
+includes += include_directories(devx_inc_dir)
+cflags_options = [
+	'-std=c11',
+	'-Wno-strict-prototypes',
+	'-D_BSD_SOURCE',
+	'-D_DEFAULT_SOURCE',
+	'-D_XOPEN_SOURCE=600'
+]
+foreach option:cflags_options
+	if cc.has_argument(option)
+		cflags += option
+	endif
+endforeach
+if get_option('buildtype').contains('debug')
+	cflags += [ '-pedantic', '-DPEDANTIC' ]
+else
+	cflags += [ '-UPEDANTIC' ]
+endif
+
Signature · 1 line
2.16.1.windows.4
#29 lore raw

PATCH v5 21/32 mlx5/windows: add initialization routine for external lib

In reply to Tal Shnaiderman

From: Ophir Munk <[email protected]>

Add function mlx5_glue_constructor() as an initialization routine for run-time dependency on external lib. Currently the routine has an empty body. It is used for compatibility with Linux.

---
 drivers/common/mlx5/windows/meson.build      |  1 +
 drivers/common/mlx5/windows/mlx5_common_os.c | 24 ++++++++++++++++++++++++
 2 files changed, 25 insertions(+)
 create mode 100644 drivers/common/mlx5/windows/mlx5_common_os.c
drivers/common/mlx5/windows/meson.build +1 -0
index 4f9825ea19..e5a5be0708 100644
@@ -5,6 +5,7 @@ includes += include_directories('.')
 
 sources += files(
 	'mlx5_glue.c',
+	'mlx5_common_os.c',
 )
 
 res_lib = run_command(python3, '-c', 'import os; print(os.environ["DEVX_LIB_PATH"])')
drivers/common/mlx5/windows/mlx5_common_os.c new file +24 -0
new file mode 100644
index 0000000000..5707fb60c3
@@ -0,0 +1,24 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright 2020 Mellanox Technologies, Ltd
+ */
+
+#include <unistd.h>
+#include <string.h>
+#include <stdio.h>
+
+#include <rte_errno.h>
+#include <rte_mempool.h>
+#include <rte_malloc.h>
+#include <rte_errno.h>
+
+#include "mlx5_devx_cmds.h"
+#include "mlx5_common_utils.h"
+#include <mlx5_common.h>
+
+/**
+ * Initialization routine for run-time dependency on external lib
+ */
+void
+mlx5_glue_constructor(void)
+{
+}
Signature · 1 line
2.16.1.windows.4
#30 lore raw

PATCH v5 22/32 mlx5/windows: generate file mlx5_autoconf.h

In reply to Tal Shnaiderman

From: Ophir Munk <[email protected]>

File mlx5_autoconf.h is generated under Windows to maintain compatibility with the Linux build system. This file is included in Linux/Windows shared source files therefore it is required. Currently the file is created empty.

---
 drivers/common/mlx5/windows/meson.build | 3 +++
 1 file changed, 3 insertions(+)
drivers/common/mlx5/windows/meson.build +3 -0
index e5a5be0708..16349c34f1 100644
@@ -40,3 +40,6 @@ else
 	cflags += [ '-UPEDANTIC' ]
 endif
 
+# Generate an empty mlx5_autoconf.h file for compatibility with Linux
+config = configuration_data()
+configure_file(output : 'mlx5_autoconf.h', configuration : config)
Signature · 1 line
2.16.1.windows.4
#31 lore raw

PATCH v5 23/32 common/mlx5/windows: extend PRM match_param_bits struct

In reply to Tal Shnaiderman

Add reserved size to PRM 'struct mlx5_ifc_fte_match_param_bits' for non Linux OS. Windows drivers require this extension since their expected size should match the actual struct size. Linux drivers do not require this extension and already use calculations based on the shorter size. Use a static assert to verify that the PRM fte_match_param struct size remains correct.

---
 drivers/common/mlx5/mlx5_prm.h          | 7 +++++++
 drivers/common/mlx5/windows/mlx5_glue.c | 3 +++
 2 files changed, 10 insertions(+)
drivers/common/mlx5/mlx5_prm.h +7 -0
index 4ddf865743..27a4e4f0f1 100644
@@ -815,6 +815,13 @@ struct mlx5_ifc_fte_match_param_bits {
 	struct mlx5_ifc_fte_match_set_misc2_bits misc_parameters_2;
 	struct mlx5_ifc_fte_match_set_misc3_bits misc_parameters_3;
 	struct mlx5_ifc_fte_match_set_misc4_bits misc_parameters_4;
+/*
+ * Add reserved bit to match the struct size with the size defined in PRM.
+ * This extension is not required in Linux.
+ */
+#ifndef HAVE_INFINIBAND_VERBS_H
+	u8 reserved_0[0x400];
+#endif
 };
 
 enum {
drivers/common/mlx5/windows/mlx5_glue.c +3 -0
index 7f8a00aaa7..3896cf0932 100644
@@ -256,6 +256,9 @@ mlx5_glue_devx_free_uar(void *uar)
 	devx_free_uar((devx_uar_handle *)uar);
 }
 
+static_assert(MLX5_ST_SZ_BYTES(fte_match_param) == 0x200,
+	"PRM size of fte_match_param is broken! cannot compile Windows!");
+
 static void*
 mlx5_glue_devx_fs_rule_add(void *ctx, void *in, uint32_t inlen)
 
Signature · 1 line
2.16.1.windows.4
#32 lore raw

PATCH v5 24/32 common/mlx5/windows: add getter functions

In reply to Tal Shnaiderman

From: Ophir Munk <[email protected]>

Add file mlx5/windows/mlx5_common_os.h the equivalent of Linux file mlx5/linux/mlx5_common_os.h. It contains getters functions mlx5_os_get_dev_device_name, mlx5_os_get_ctx_device_name, mlx5_os_get_ctx_device_path, mlx5_os_get_umem_id, mlx5_os_get_devx_channel_fd.

---
 drivers/common/mlx5/windows/mlx5_common_os.h | 91 ++++++++++++++++++++++++++++
 1 file changed, 91 insertions(+)
drivers/common/mlx5/windows/mlx5_common_os.h +91 -0
index cce7c88c6a..2abdb2c3ae 100644
@@ -48,4 +48,95 @@ mlx5_os_free(void *addr)
 {
 	_aligned_free(addr);
 }
+
+/**
+ * Get fd. Given a pointer to DevX channel object of type
+ * 'struct mlx5dv_devx_event_channel*' - return its fd.
+ * Under Windows it is a stub.
+ *
+ * @param[in] channel
+ *    Pointer to channel object.
+ *
+ * @return
+ *    0
+ */
+static inline int
+mlx5_os_get_devx_channel_fd(void *channel)
+{
+	if (!channel)
+		return 0;
+	return 0;
+}
+
+/**
+ * Get device name. Given a device pointer - return a
+ * pointer to the corresponding device name.
+ *
+ * @param[in] dev
+ *   Pointer to device.
+ *
+ * @return
+ *   Pointer to device name if dev is valid, NULL otherwise.
+ */
+static inline const char *
+mlx5_os_get_dev_device_name(void *dev)
+{
+	if (!dev)
+		return NULL;
+	return ((struct devx_device *)dev)->name;
+}
+
+/**
+ * Get device name. Given a context pointer - return a
+ * pointer to the corresponding device name.
+ *
+ * @param[in] ctx
+ *   Pointer to context.
+ *
+ * @return
+ *   Pointer to device name if ctx is valid, NULL otherwise.
+ */
+static inline const char *
+mlx5_os_get_ctx_device_name(void *ctx)
+{
+	if (!ctx)
+		return NULL;
+	return ((mlx5_context_st *)ctx)->mlx5_dev.name;
+}
+
+/**
+ * Get a device path name. Given acontext pointer - return a
+ * pointer to the corresponding device path name.
+ *
+ * @param[in] ctx
+ *   Pointer to context.
+ *
+ * @return
+ *   Pointer to device path name if ctx is valid, NULL otherwise.
+ */
+
+static inline const char *
+mlx5_os_get_ctx_device_path(void *ctx)
+{
+	if (!ctx)
+		return NULL;
+	return ((mlx5_context_st *)ctx)->mlx5_dev.dev_pnp_id;
+}
+
+/**
+ * Get umem id. Given a pointer to umem object of type return its id.
+ *
+ * @param[in] umem
+ *    Pointer to umem object.
+ *
+ * @return
+ *    The umem id if umem is valid, 0 otherwise.
+ */
+static inline uint32_t
+mlx5_os_get_umem_id(void *umem)
+{
+	if (!umem)
+		return 0;
+	return ((struct mlx5_devx_umem *)umem)->umem_id;
+}
 #endif /* RTE_PMD_MLX5_COMMON_OS_H_ */
Signature · 1 line
2.16.1.windows.4
#33 lore raw

PATCH v5 25/32 common/mlx5/windows: add OS alloc/dealloc pd

In reply to Tal Shnaiderman

Implement Windows API mlx5_os_alloc_pd() and mlx5_os_dealloc_pd(). They are equivalent to the Linux implementation in [1].

[1]
("net/mlx5: wrap glue alloc/dealloc PD with OS calls")

---
 drivers/common/mlx5/rte_common_mlx5_exports.def |  3 +-
 drivers/common/mlx5/windows/mlx5_common_os.c    | 48 +++++++++++++++++++++++++
 drivers/common/mlx5/windows/mlx5_common_os.h    |  3 ++
 drivers/common/mlx5/windows/mlx5_win_ext.h      |  6 ++++
 4 files changed, 59 insertions(+), 1 deletion(-)
drivers/common/mlx5/rte_common_mlx5_exports.def +2 -1
index 2f6aab133b..5db1eaa48c 100644
@@ -61,4 +61,5 @@ EXPORTS
 	mlx5_malloc
 	mlx5_realloc
 	mlx5_free
-
+	mlx5_os_alloc_pd
+	mlx5_os_dealloc_pd
drivers/common/mlx5/windows/mlx5_common_os.c +48 -0

51 lines not on this page · raw message

drivers/common/mlx5/windows/mlx5_common_os.h +3 -0
index 2abdb2c3ae..f47351ec41 100644
@@ -139,4 +139,7 @@ mlx5_os_get_umem_id(void *umem)
 		return 0;
 	return ((struct mlx5_devx_umem *)umem)->umem_id;
 }
+
+void *mlx5_os_alloc_pd(void *ctx);
+int mlx5_os_dealloc_pd(void *pd);
 #endif /* RTE_PMD_MLX5_COMMON_OS_H_ */
drivers/common/mlx5/windows/mlx5_win_ext.h +6 -0
index 0e74910e9d..8e697b30c1 100644
@@ -28,6 +28,12 @@ struct mlx5_devx_umem {
 	uint32_t                umem_id;
 };
 
+struct mlx5_pd {
+	void                   *obj;
+	uint32_t                pdn;
+	devx_device_ctx        *devx_ctx;
+};
+
 #define GET_DEVX_CTX(ctx) (((mlx5_context_st *)ctx)->devx_ctx)
 #define GET_OBJ_CTX(obj)  (((mlx5_devx_obj_st *)obj)->devx_ctx)
 
Signature · 1 line
2.16.1.windows.4
#34 lore raw

PATCH v5 26/32 common/mlx5/windows: add OS umem reg/dereg API

In reply to Tal Shnaiderman

Implement Windows API mlx5_os_umem_reg() and mlx5_os_umem_dereg(). They are equivalent to the Linux implementation.

---
 drivers/common/mlx5/rte_common_mlx5_exports.def |  2 +
 drivers/common/mlx5/windows/mlx5_common_os.c    | 60 +++++++++++++++++++++++++
 drivers/common/mlx5/windows/mlx5_common_os.h    |  2 +
 3 files changed, 64 insertions(+)
drivers/common/mlx5/rte_common_mlx5_exports.def +2 -0
index 5db1eaa48c..1eabe29a58 100644
@@ -63,3 +63,5 @@ EXPORTS
 	mlx5_free
 	mlx5_os_alloc_pd
 	mlx5_os_dealloc_pd
+	mlx5_os_umem_reg
+	mlx5_os_umem_dereg
drivers/common/mlx5/windows/mlx5_common_os.c +60 -0

63 lines not on this page · raw message

drivers/common/mlx5/windows/mlx5_common_os.h +2 -0
index f47351ec41..decb5acd45 100644
@@ -142,4 +142,6 @@ mlx5_os_get_umem_id(void *umem)
 
 void *mlx5_os_alloc_pd(void *ctx);
 int mlx5_os_dealloc_pd(void *pd);
+void *mlx5_os_umem_reg(void *ctx, void *addr, size_t size, uint32_t access);
+int mlx5_os_umem_dereg(void *pumem);
 #endif /* RTE_PMD_MLX5_COMMON_OS_H_ */
Signature · 1 line
2.16.1.windows.4
#35 lore raw

PATCH v5 27/32 net/mlx5: update MR prototypes for DevX

In reply to Tal Shnaiderman

From: Ophir Munk <[email protected]>

Currently MR operations are Verbs based. This commit updates MR operations prototypes such that DevX MR operations callbacks can be used as well. Rename 'struct mlx5_verbs_ops' as 'struct mlx5_mr_ops' and move it to shared file mlx5.h.

---
 drivers/net/mlx5/linux/mlx5_os.c    | 4 ++--
 drivers/net/mlx5/linux/mlx5_verbs.c | 2 +-
 drivers/net/mlx5/linux/mlx5_verbs.h | 8 +-------
 drivers/net/mlx5/mlx5.h             | 6 ++++++
 4 files changed, 10 insertions(+), 10 deletions(-)
drivers/net/mlx5/linux/mlx5_os.c +2 -2
index a6c1eba640..4f68c74267 100644
@@ -2478,8 +2478,8 @@ void
 mlx5_os_set_reg_mr_cb(mlx5_reg_mr_t *reg_mr_cb,
 		      mlx5_dereg_mr_t *dereg_mr_cb)
 {
-	*reg_mr_cb = mlx5_verbs_ops.reg_mr;
-	*dereg_mr_cb = mlx5_verbs_ops.dereg_mr;
+	*reg_mr_cb = mlx5_mr_verbs_ops.reg_mr;
+	*dereg_mr_cb = mlx5_mr_verbs_ops.dereg_mr;
 }
 
 /**
drivers/net/mlx5/linux/mlx5_verbs.c +1 -1
index 9161fa3b7d..b52ae2e6c1 100644
@@ -62,7 +62,7 @@ mlx5_dereg_mr(struct mlx5_pmd_mr *pmd_mr)
 }
 
 /* verbs operations. */
-const struct mlx5_verbs_ops mlx5_verbs_ops = {
+const struct mlx5_mr_ops mlx5_mr_verbs_ops = {
 	.reg_mr = mlx5_reg_mr,
 	.dereg_mr = mlx5_dereg_mr,
 };
drivers/net/mlx5/linux/mlx5_verbs.h +1 -7
index 0670f6c47e..76a79bf4f4 100644
@@ -7,16 +7,10 @@
 
 #include "mlx5.h"
 
-struct mlx5_verbs_ops {
-	mlx5_reg_mr_t reg_mr;
-	mlx5_dereg_mr_t dereg_mr;
-};
-
 int mlx5_txq_ibv_obj_new(struct rte_eth_dev *dev, uint16_t idx);
 void mlx5_txq_ibv_obj_release(struct mlx5_txq_obj *txq_obj);
 
 /* Verbs ops struct */
-extern const struct mlx5_verbs_ops mlx5_verbs_ops;
+extern const struct mlx5_mr_ops mlx5_mr_verbs_ops;
 extern struct mlx5_obj_ops ibv_obj_ops;
-
 #endif /* RTE_PMD_MLX5_VERBS_H_ */
drivers/net/mlx5/mlx5.h +6 -0
index 2186677810..a9db597f2b 100644
@@ -917,6 +917,12 @@ struct mlx5_obj_ops {
 
 #define MLX5_RSS_HASH_FIELDS_LEN RTE_DIM(mlx5_rss_hash_fields)
 
+/* MR operations structure. */
+struct mlx5_mr_ops {
+	mlx5_reg_mr_t reg_mr;
+	mlx5_dereg_mr_t dereg_mr;
+};
+
 struct mlx5_priv {
 	struct rte_eth_dev_data *dev_data;  /* Pointer to device data. */
 	struct mlx5_dev_ctx_shared *sh; /* Shared device context. */
Signature · 1 line
2.16.1.windows.4
#36 lore raw

PATCH v5 28/32 common/mlx5/windows: add OS reg/dereg MR

In reply to Tal Shnaiderman

From: Ophir Munk <[email protected]>

This commits implements Windows API for MR registration and deregistration. It is based on DevX. Is support the relaxed ordering flow in Windows by checking the capabilities and machine type.

---
 drivers/common/mlx5/mlx5_common_mr.h            |  1 +
 drivers/common/mlx5/rte_common_mlx5_exports.def |  2 +
 drivers/common/mlx5/windows/mlx5_common_os.c    | 78 +++++++++++++++++++++++++
 drivers/common/mlx5/windows/mlx5_common_os.h    |  7 +++
 4 files changed, 88 insertions(+)
drivers/common/mlx5/mlx5_common_mr.h +1 -0
index da0a0f0c79..5cc3f097c2 100644
@@ -28,6 +28,7 @@ struct mlx5_pmd_mr {
 	void		     *addr;
 	size_t		     len;
 	void		     *obj;  /* verbs mr object or devx umem object. */
+	struct mlx5_devx_obj *mkey; /* devx mkey object. */
 };
 
 /**
drivers/common/mlx5/rte_common_mlx5_exports.def +2 -0
index 1eabe29a58..65ae47ae6a 100644
@@ -63,5 +63,7 @@ EXPORTS
 	mlx5_free
 	mlx5_os_alloc_pd
 	mlx5_os_dealloc_pd
+	mlx5_os_dereg_mr
+	mlx5_os_reg_mr
 	mlx5_os_umem_reg
 	mlx5_os_umem_dereg
drivers/common/mlx5/windows/mlx5_common_os.c +78 -0

87 lines not on this page · raw message

drivers/common/mlx5/windows/mlx5_common_os.h +7 -0
index decb5acd45..ba166412cc 100644
@@ -7,9 +7,13 @@
 
 #include <stdio.h>
 
+#include <rte_errno.h>
+
 #include "mlx5_autoconf.h"
 #include "mlx5_glue.h"
 #include "mlx5_malloc.h"
+#include "mlx5_common_mr.h"
+#include "mlx5_win_ext.h"
 
 /**
  * This API allocates aligned or non-aligned memory.  The free can be on either
@@ -144,4 +148,7 @@ void *mlx5_os_alloc_pd(void *ctx);
 int mlx5_os_dealloc_pd(void *pd);
 void *mlx5_os_umem_reg(void *ctx, void *addr, size_t size, uint32_t access);
 int mlx5_os_umem_dereg(void *pumem);
+int mlx5_os_reg_mr(void *pd,
+		   void *addr, size_t length, struct mlx5_pmd_mr *pmd_mr);
+void mlx5_os_dereg_mr(struct mlx5_pmd_mr *pmd_mr);
 #endif /* RTE_PMD_MLX5_COMMON_OS_H_ */
Signature · 1 line
2.16.1.windows.4
#37 lore raw

PATCH v5 29/32 net/mlx5/windows: implement device attribute getter

In reply to Tal Shnaiderman

From: Ophir Munk <[email protected]>

This commit is the Windows implementation of mlx5_os_get_dev_attr() API. It follows the commit in [1]. A new file named mlx5_os.c is added under windows directory as its Linux counterpart file: linux/mlx5_os.c.

[1].
commit e85f623e13ea ("net/mlx5: remove attributes dependency on Verbs")

---
 drivers/common/mlx5/mlx5_prm.h       | 43 +++++++++++++++++++++
 drivers/net/mlx5/windows/meson.build |  8 ++++
 drivers/net/mlx5/windows/mlx5_os.c   | 75 ++++++++++++++++++++++++++++++++++++
 3 files changed, 126 insertions(+)
 create mode 100644 drivers/net/mlx5/windows/meson.build
 create mode 100644 drivers/net/mlx5/windows/mlx5_os.c
drivers/common/mlx5/mlx5_prm.h +43 -0
index 27a4e4f0f1..d62d2558eb 100644
@@ -2217,6 +2217,49 @@ struct mlx5_ifc_cqc_bits {
 	u8 dbr_addr[0x40];
 };
 
+struct mlx5_ifc_health_buffer_bits {
+	u8         reserved_0[0x100];
+	u8         assert_existptr[0x20];
+	u8         assert_callra[0x20];
+	u8         reserved_1[0x40];
+	u8         fw_version[0x20];
+	u8         hw_id[0x20];
+	u8         reserved_2[0x20];
+	u8         irisc_index[0x8];
+	u8         synd[0x8];
+	u8         ext_synd[0x10];
+};
+
+struct mlx5_ifc_initial_seg_bits {
+	u8         fw_rev_minor[0x10];
+	u8         fw_rev_major[0x10];
+	u8         cmd_interface_rev[0x10];
+	u8         fw_rev_subminor[0x10];
+	u8         reserved_0[0x40];
+	u8         cmdq_phy_addr_63_32[0x20];
+	u8         cmdq_phy_addr_31_12[0x14];
+	u8         reserved_1[0x2];
+	u8         nic_interface[0x2];
+	u8         log_cmdq_size[0x4];
+	u8         log_cmdq_stride[0x4];
+	u8         command_doorbell_vector[0x20];
+	u8         reserved_2[0xf00];
+	u8         initializing[0x1];
+	u8         nic_interface_supported[0x7];
+	u8         reserved_4[0x18];
+	struct mlx5_ifc_health_buffer_bits health_buffer;
+	u8         no_dram_nic_offset[0x20];
+	u8         reserved_5[0x6de0];
+	u8         internal_timer_h[0x20];
+	u8         internal_timer_l[0x20];
+	u8         reserved_6[0x20];
+	u8         reserved_7[0x1f];
+	u8         clear_int[0x1];
+	u8         health_syndrome[0x8];
+	u8         health_counter[0x18];
+	u8         reserved_8[0x17fc0];
+};
+
 struct mlx5_ifc_create_cq_out_bits {
 	u8 status[0x8];
 	u8 reserved_at_8[0x18];
drivers/net/mlx5/windows/meson.build new file +8 -0
new file mode 100644
index 0000000000..2ea0792a40
@@ -0,0 +1,8 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright 2020 Mellanox Technologies, Ltd
+
+includes += include_directories('.')
+sources += files(
+	'mlx5_os.c',
+)
+
drivers/net/mlx5/windows/mlx5_os.c new file +75 -0

75 lines not on this page · raw message

Signature · 1 line
2.16.1.windows.4
#38 lore raw

PATCH v5 30/32 net/mlx5/windows: add mlx5_os.c stubs

In reply to Tal Shnaiderman

From: Ophir Munk <[email protected]>

mlx5_os_set_nonblock_channel_fd
mlx5_os_dev_shared_handler_install
mlx5_os_dev_shared_handler_uninstall
mlx5_os_read_dev_stat
mlx5_os_mac_addr_flush
mlx5_os_mac_addr_remove
mlx5_os_vf_mac_addr_modify
mlx5_os_set_promisc
mlx5_os_set_allmulti

Set struct mlx5_flow_driver_ops mlx5_flow_verbs_drv_ops with NULL pointers.

---
 drivers/net/mlx5/windows/mlx5_os.c | 187 +++++++++++++++++++++++++++++++++++++
 1 file changed, 187 insertions(+)
drivers/net/mlx5/windows/mlx5_os.c +187 -0
index e0646670a3..a8bef70fa2 100644
@@ -13,10 +13,18 @@
 #include <mlx5_glue.h>
 #include <mlx5_devx_cmds.h>
 #include <mlx5_common.h>
+#include <mlx5_common_mp.h>
+#include <mlx5_common_mr.h>
+#include <mlx5_malloc.h>
 
 #include "mlx5_defs.h"
 #include "mlx5.h"
+#include "mlx5_common_os.h"
+#include "mlx5_utils.h"
+#include "mlx5_rxtx.h"
 #include "mlx5_autoconf.h"
+#include "mlx5_mr.h"
+#include "mlx5_flow.h"
 
 /**
  * Get mlx5 device attributes.
@@ -73,3 +81,182 @@ mlx5_os_get_dev_attr(void *ctx, struct mlx5_dev_attr *device_attr)
 	}
 	return err;
 }
+
+/**
+ * Set the completion channel file descriptor interrupt as non-blocking.
+ * Currently it has no support under Windows.
+ *
+ * @param[in] rxq_obj
+ *   Pointer to RQ channel object, which includes the channel fd
+ *
+ * @param[out] fd
+ *   The file descriptor (representing the intetrrupt) used in this channel.
+ *
+ * @return
+ *   0 on successfully setting the fd to non-blocking, non-zero otherwise.
+ */
+int
+mlx5_os_set_nonblock_channel_fd(int fd)
+{
+	(void)fd;
+	DRV_LOG(WARNING, "%s: is not supported", __func__);
+	return -ENOTSUP;
+}
+
+/**
+ * This function should share events between multiple ports of single IB
+ * device.  Currently it has no support under Windows.
+ *
+ * @param sh
+ *   Pointer to mlx5_dev_ctx_shared object.
+ */
+void
+mlx5_os_dev_shared_handler_install(struct mlx5_dev_ctx_shared *sh)
+{
+	(void)sh;
+	DRV_LOG(WARNING, "%s: is not supported", __func__);
+}
+
+/**
+ * This function should share events between multiple ports of single IB
+ * device.  Currently it has no support under Windows.
+ *
+ * @param dev
+ *   Pointer to mlx5_dev_ctx_shared object.
+ */
+void
+mlx5_os_dev_shared_handler_uninstall(struct mlx5_dev_ctx_shared *sh)
+{
+	(void)sh;
+	DRV_LOG(WARNING, "%s: is not supported", __func__);
+}
+
+/**
+ * Read statistics by a named counter.
+ *
+ * @param[in] priv
+ *   Pointer to the private device data structure.
+ * @param[in] ctr_name
+ *   Pointer to the name of the statistic counter to read
+ * @param[out] stat
+ *   Pointer to read statistic value.
+ * @return
+ *   0 on success and stat is valud, 1 if failed to read the value
+ *   rte_errno is set.
+ *
+ */
+int
+mlx5_os_read_dev_stat(struct mlx5_priv *priv, const char *ctr_name,
+		      uint64_t *stat)
+{
+	RTE_SET_USED(priv);
+	RTE_SET_USED(ctr_name);
+	RTE_SET_USED(stat);
+	DRV_LOG(WARNING, "%s: is not supported", __func__);
+	return -ENOTSUP;
+}
+
+/**
+ * Flush device MAC addresses
+ * Currently it has no support under Windows.
+ *
+ * @param dev
+ *   Pointer to Ethernet device structure.
+ *
+ */
+void
+mlx5_os_mac_addr_flush(struct rte_eth_dev *dev)
+{
+	(void)dev;
+	DRV_LOG(WARNING, "%s: is not supported", __func__);
+}
+
+/**
+ * Remove a MAC address from device
+ * Currently it has no support under Windows.
+ *
+ * @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)
+{
+	(void)dev;
+	(void)(index);
+	DRV_LOG(WARNING, "%s: is not supported", __func__);
+}
+
+/**
+ * Modify a VF MAC address
+ * Currently it has no support under Windows.
+ *
+ * @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)
+{
+	(void)priv;
+	(void)iface_idx;
+	(void)mac_addr;
+	(void)vf_index;
+	DRV_LOG(WARNING, "%s: is not supported", __func__);
+	return -ENOTSUP;
+}
+
+/**
+ * Set device promiscuous mode
+ * Currently it has no support under Windows.
+ *
+ * @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)
+{
+	(void)dev;
+	(void)enable;
+	DRV_LOG(WARNING, "%s: is not supported", __func__);
+	return -ENOTSUP;
+}
+
+/**
+ * Set device allmulti 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)
+{
+	(void)dev;
+	(void)enable;
+	DRV_LOG(WARNING, "%s: is not supported", __func__);
+	return -ENOTSUP;
+}
+
+const struct mlx5_flow_driver_ops mlx5_flow_verbs_drv_ops = {0};
Signature · 1 line
2.16.1.windows.4
#39 lore raw

PATCH v5 31/32 net/mlx5/windows: implement mlx5 mac addr add

In reply to Tal Shnaiderman

Get the list of MAC addresses and verify if the input mac parameter already exists. If not - return -ENOTSUP (as Windows does not support adding new MAC addresses). If the MAC address exists (EEXIST) return 0 (the equivalent of Linux implementation of this API).

---
 drivers/net/mlx5/windows/mlx5_os.c | 36 ++++++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)
drivers/net/mlx5/windows/mlx5_os.c +36 -0
index a8bef70fa2..0e5433e05b 100644
@@ -188,6 +188,42 @@ mlx5_os_mac_addr_remove(struct rte_eth_dev *dev, uint32_t index)
 	DRV_LOG(WARNING, "%s: is not supported", __func__);
 }
 
+/**
+ * Adds a MAC address to the device
+ * Currently it has no support under Windows.
+ *
+ * @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)
+{
+	(void)index;
+	struct rte_ether_addr lmac;
+
+	if (mlx5_get_mac(dev, &lmac.addr_bytes)) {
+		DRV_LOG(ERR,
+			"port %u cannot get MAC address, is mlx5_en"
+			" loaded? (errno: %s)",
+			dev->data->port_id, strerror(rte_errno));
+		return rte_errno;
+	}
+	if (!rte_is_same_ether_addr(&lmac, mac)) {
+		DRV_LOG(ERR,
+			"adding new mac address to device is unsupported");
+		return -ENOTSUP;
+	}
+	return 0;
+}
+
 /**
  * Modify a VF MAC address
  * Currently it has no support under Windows.
Signature · 1 line
2.16.1.windows.4
#40 lore raw

PATCH v5 32/32 net/mlx5: refactor eth dev ops for Windows

In reply to Tal Shnaiderman

From: Ophir Munk <[email protected]>

There are two types of eth_dev_ops used under Windows: primary and isolate mode. Their function calls initialization is added to the OS specific file mlx5_os.c. Secondary process eth_dev_ops is nullified.

---
 drivers/net/mlx5/windows/mlx5_os.c | 108 +++++++++++++++++++++++++++++++++++++
 1 file changed, 108 insertions(+)
drivers/net/mlx5/windows/mlx5_os.c +108 -0
index 0e5433e05b..7bcce9dae0 100644
@@ -296,3 +296,111 @@ mlx5_os_set_allmulti(struct rte_eth_dev *dev, int enable)
 }
 
 const struct mlx5_flow_driver_ops mlx5_flow_verbs_drv_ops = {0};
+
+const struct eth_dev_ops mlx5_os_dev_ops = {
+	.dev_configure = mlx5_dev_configure,
+	.dev_start = mlx5_dev_start,
+	.dev_stop = mlx5_dev_stop,
+	.dev_close = mlx5_dev_close,
+	.mtu_set = mlx5_dev_set_mtu,
+	.link_update = mlx5_link_update,
+	.stats_get = mlx5_stats_get,
+	.stats_reset = mlx5_stats_reset,
+	.dev_infos_get = mlx5_dev_infos_get,
+	.dev_supported_ptypes_get = mlx5_dev_supported_ptypes_get,
+	.promiscuous_enable = mlx5_promiscuous_enable,
+	.promiscuous_disable = mlx5_promiscuous_disable,
+	.allmulticast_enable = mlx5_allmulticast_enable,
+	.allmulticast_disable = mlx5_allmulticast_disable,
+	.xstats_get = mlx5_xstats_get,
+	.xstats_reset = mlx5_xstats_reset,
+	.xstats_get_names = mlx5_xstats_get_names,
+	.fw_version_get = mlx5_fw_version_get,
+	.read_clock = mlx5_read_clock,
+	.vlan_filter_set = mlx5_vlan_filter_set,
+	.rx_queue_setup = mlx5_rx_queue_setup,
+	.rx_hairpin_queue_setup = mlx5_rx_hairpin_queue_setup,
+	.tx_queue_setup = mlx5_tx_queue_setup,
+	.tx_hairpin_queue_setup = mlx5_tx_hairpin_queue_setup,
+	.rx_queue_release = mlx5_rx_queue_release,
+	.tx_queue_release = mlx5_tx_queue_release,
+	.flow_ctrl_get = mlx5_dev_get_flow_ctrl,
+	.flow_ctrl_set = mlx5_dev_set_flow_ctrl,
+	.mac_addr_remove = mlx5_mac_addr_remove,
+	.mac_addr_add = mlx5_mac_addr_add,
+	.mac_addr_set = mlx5_mac_addr_set,
+	.set_mc_addr_list = mlx5_set_mc_addr_list,
+	.vlan_strip_queue_set = mlx5_vlan_strip_queue_set,
+	.vlan_offload_set = mlx5_vlan_offload_set,
+	.reta_update = mlx5_dev_rss_reta_update,
+	.reta_query = mlx5_dev_rss_reta_query,
+	.rss_hash_update = mlx5_rss_hash_update,
+	.rss_hash_conf_get = mlx5_rss_hash_conf_get,
+	.filter_ctrl = mlx5_dev_filter_ctrl,
+	.rxq_info_get = mlx5_rxq_info_get,
+	.txq_info_get = mlx5_txq_info_get,
+	.rx_burst_mode_get = mlx5_rx_burst_mode_get,
+	.tx_burst_mode_get = mlx5_tx_burst_mode_get,
+	.rx_queue_intr_enable = mlx5_rx_intr_enable,
+	.rx_queue_intr_disable = mlx5_rx_intr_disable,
+	.is_removed = mlx5_is_removed,
+	.udp_tunnel_port_add  = mlx5_udp_tunnel_port_add,
+	.get_module_info = mlx5_get_module_info,
+	.get_module_eeprom = mlx5_get_module_eeprom,
+	.hairpin_cap_get = mlx5_hairpin_cap_get,
+	.mtr_ops_get = mlx5_flow_meter_ops_get,
+};
+
+/* Available operations from secondary process. */
+const struct eth_dev_ops mlx5_os_dev_sec_ops = {0};
+
+/* Available operations in flow isolated mode. */
+const struct eth_dev_ops mlx5_os_dev_ops_isolate = {
+	.dev_configure = mlx5_dev_configure,
+	.dev_start = mlx5_dev_start,
+	.dev_stop = mlx5_dev_stop,
+	.dev_close = mlx5_dev_close,
+	.mtu_set = mlx5_dev_set_mtu,
+	.link_update = mlx5_link_update,
+	.stats_get = mlx5_stats_get,
+	.stats_reset = mlx5_stats_reset,
+	.dev_infos_get = mlx5_dev_infos_get,
+	.dev_set_link_down = mlx5_set_link_down,
+	.dev_set_link_up = mlx5_set_link_up,
+	.promiscuous_enable = mlx5_promiscuous_enable,
+	.promiscuous_disable = mlx5_promiscuous_disable,
+	.allmulticast_enable = mlx5_allmulticast_enable,
+	.allmulticast_disable = mlx5_allmulticast_disable,
+	.xstats_get = mlx5_xstats_get,
+	.xstats_reset = mlx5_xstats_reset,
+	.xstats_get_names = mlx5_xstats_get_names,
+	.fw_version_get = mlx5_fw_version_get,
+	.dev_supported_ptypes_get = mlx5_dev_supported_ptypes_get,
+	.vlan_filter_set = mlx5_vlan_filter_set,
+	.rx_queue_setup = mlx5_rx_queue_setup,
+	.rx_hairpin_queue_setup = mlx5_rx_hairpin_queue_setup,
+	.tx_queue_setup = mlx5_tx_queue_setup,
+	.tx_hairpin_queue_setup = mlx5_tx_hairpin_queue_setup,
+	.rx_queue_release = mlx5_rx_queue_release,
+	.tx_queue_release = mlx5_tx_queue_release,
+	.flow_ctrl_get = mlx5_dev_get_flow_ctrl,
+	.flow_ctrl_set = mlx5_dev_set_flow_ctrl,
+	.mac_addr_remove = mlx5_mac_addr_remove,
+	.mac_addr_add = mlx5_mac_addr_add,
+	.mac_addr_set = mlx5_mac_addr_set,
+	.set_mc_addr_list = mlx5_set_mc_addr_list,
+	.vlan_strip_queue_set = mlx5_vlan_strip_queue_set,
+	.vlan_offload_set = mlx5_vlan_offload_set,
+	.filter_ctrl = mlx5_dev_filter_ctrl,
+	.rxq_info_get = mlx5_rxq_info_get,
+	.txq_info_get = mlx5_txq_info_get,
+	.rx_burst_mode_get = mlx5_rx_burst_mode_get,
+	.tx_burst_mode_get = mlx5_tx_burst_mode_get,
+	.rx_queue_intr_enable = mlx5_rx_intr_enable,
+	.rx_queue_intr_disable = mlx5_rx_intr_disable,
+	.is_removed = mlx5_is_removed,
+	.get_module_info = mlx5_get_module_info,
+	.get_module_eeprom = mlx5_get_module_eeprom,
+	.hairpin_cap_get = mlx5_hairpin_cap_get,
+	.mtr_ops_get = mlx5_flow_meter_ops_get,
+};
Signature · 1 line
2.16.1.windows.4
#41 lore raw
In reply to Tal Shnaiderman

Hi,

Quoted 106 lines

-----Original Message-----
From: Tal Shnaiderman <[email protected]>
Sent: Monday, December 28, 2020 11:54 AM
To: [email protected]
Cc: NBU-Contact-Thomas Monjalon <[email protected]>; Matan Azrad <[email protected]>; Raslan Darawsheh <[email protected]>; Ophir Munk <[email protected]>
Subject: [PATCH v5 00/32] mlx5 Windows support - part #5

This patch series is part of preparing mlx5 PMD to compile and run under Windows OS. Part #5

v1: initial version
v2: Fixes after CR and rebase, also patchset was split and part of the commits sent in v1 will be sent later on.
v3: Remove common compilation as it depends on upcoming patches [DmitryK].
v4: Fix syntax error in warning message.
v5: Fix style issues.

Ophir Munk (20):
net/mlx5/linux: extend device attributes getter net/mlx5: remove Linux files from Windows compilation net/mlx5: fix freeing packet pacing
net/mlx5: replace Linux sleep with rte sleep net/mlx5: define mprq functions as static inline net/mlx5: do not define static_assert in Windows net/mlx5: move static_assert calls to global scope net/mlx5: wrap glue alloc/dealloc PD with OS calls net/mlx5: fix adding destroy flow action wrapper common/mlx5: add definition HAVE_INFINIBAND_VERBS_H common/mlx5/linux: handle memory allocations with alignment common/mlx5/windows: handle memory allocations with alignment mlx5/windows: add initialization routine for external lib mlx5/windows: generate file mlx5_autoconf.h common/mlx5/windows: add getter functions
net/mlx5: update MR prototypes for DevX common/mlx5/windows: add OS reg/dereg MR net/mlx5/windows: implement device attribute getter net/mlx5/windows: add mlx5_os.c stubs
net/mlx5: refactor eth dev ops for Windows

Tal Shnaiderman (12):
net/mlx5: fix folding constant array error net/mlx5: wrap glue reg/dereg UMEM with OS calls common/mlx5/linux: wrap event channel APIs with OS calls common/mlx5: add Windows exports file common/mlx5: extend DevX query hca attributes command common/mlx5: add DevX alloc PD command common/mlx5/windows: add glue functions APIs mlx5/windows: add mlx5 meson file common/mlx5/windows: extend PRM match_param_bits struct common/mlx5/windows: add OS alloc/dealloc pd common/mlx5/windows: add OS umem reg/dereg API net/mlx5/windows: implement mlx5 mac addr add

 drivers/common/mlx5/linux/meson.build           |   6 +-
 drivers/common/mlx5/linux/mlx5_common_os.h      |  83 +++++
 drivers/common/mlx5/mlx5_common.c               |   4 +-
 drivers/common/mlx5/mlx5_common_mr.h            |   1 +
 drivers/common/mlx5/mlx5_devx_cmds.c            |  46 +++
 drivers/common/mlx5/mlx5_devx_cmds.h            |  12 +-
 drivers/common/mlx5/mlx5_malloc.c               |  14 +-
 drivers/common/mlx5/mlx5_prm.h                  |  87 +++++
 drivers/common/mlx5/rte_common_mlx5_exports.def |  69 ++++
 drivers/common/mlx5/version.map                 |   1 +
 drivers/common/mlx5/windows/meson.build         |  45 +++
 drivers/common/mlx5/windows/mlx5_common_os.c    | 210
++++++++++++
 drivers/common/mlx5/windows/mlx5_common_os.h    | 154 +++++++++
 drivers/common/mlx5/windows/mlx5_glue.c         | 307
++++++++++++++++++
 drivers/common/mlx5/windows/mlx5_glue.h         |  58 ++++
 drivers/common/mlx5/windows/mlx5_win_defs.h     |  25 ++
 drivers/common/mlx5/windows/mlx5_win_ext.h      |  40 +++
 drivers/net/mlx5/linux/mlx5_os.c                |   9 +-
 drivers/net/mlx5/linux/mlx5_verbs.c             |   2 +-
 drivers/net/mlx5/linux/mlx5_verbs.h             |   8 +-
 drivers/net/mlx5/meson.build                    |  16 +-
 drivers/net/mlx5/mlx5.c                         |  20 +-
 drivers/net/mlx5/mlx5.h                         |  11 +
 drivers/net/mlx5/mlx5_defs.h                    |   7 +-
 drivers/net/mlx5/mlx5_devx.c                    |  24 +-
 drivers/net/mlx5/mlx5_flow.c                    |  17 +-
 drivers/net/mlx5/mlx5_flow_dv.c                 |   6 +-
 drivers/net/mlx5/mlx5_rxq.c                     |  71 -----
 drivers/net/mlx5/mlx5_rxtx.c                    |  98 +++---
 drivers/net/mlx5/mlx5_rxtx.h                    |  73 ++++-
 drivers/net/mlx5/mlx5_trigger.c                 |   3 +-
 drivers/net/mlx5/mlx5_txpp.c                    |  34 +-
 drivers/net/mlx5/windows/meson.build            |   8 +
 drivers/net/mlx5/windows/mlx5_os.c              | 406
++++++++++++++++++++++++
 drivers/vdpa/mlx5/mlx5_vdpa_event.c             |   7 +-
 35 files changed, 1778 insertions(+), 204 deletions(-)
 create mode 100644 drivers/common/mlx5/rte_common_mlx5_exports.def
 create mode 100644 drivers/common/mlx5/windows/meson.build
 create mode 100644 drivers/common/mlx5/windows/mlx5_common_os.c
 create mode 100644 drivers/common/mlx5/windows/mlx5_common_os.h
 create mode 100644 drivers/common/mlx5/windows/mlx5_glue.c
 create mode 100644 drivers/common/mlx5/windows/mlx5_glue.h
 create mode 100644 drivers/common/mlx5/windows/mlx5_win_defs.h
 create mode 100644 drivers/common/mlx5/windows/mlx5_win_ext.h
 create mode 100644 drivers/net/mlx5/windows/meson.build
 create mode 100644 drivers/net/mlx5/windows/mlx5_os.c
Quoted 2 lines

--
2.16.1.windows.4

Series applied to next-net-mlx,

Kindest regards,
Raslan Darawsheh

#42 lore raw

PATCH v4 2/32 net/mlx5/linux: extend device attributes getter

In reply to Tal Shnaiderman

From: Ophir Munk <[email protected]>

This commit adds device attributes parameters to be reported by mlx5_os_get_dev_attr(): max_cqe, max_mr, max_pd, max_srq, max_srq_wr

---
 drivers/net/mlx5/linux/mlx5_os.c | 5 +++++
 drivers/net/mlx5/mlx5.h          | 5 +++++
 2 files changed, 10 insertions(+)
drivers/net/mlx5/linux/mlx5_os.c +5 -0
index 917d6be7b8..a6c1eba640 100644
@@ -116,7 +116,12 @@ mlx5_os_get_dev_attr(void *ctx, struct mlx5_dev_attr *device_attr)
 	device_attr->max_qp_wr = attr_ex.orig_attr.max_qp_wr;
 	device_attr->max_sge = attr_ex.orig_attr.max_sge;
 	device_attr->max_cq = attr_ex.orig_attr.max_cq;
+	device_attr->max_cqe = attr_ex.orig_attr.max_cqe;
+	device_attr->max_mr = attr_ex.orig_attr.max_mr;
+	device_attr->max_pd = attr_ex.orig_attr.max_pd;
 	device_attr->max_qp = attr_ex.orig_attr.max_qp;
+	device_attr->max_srq = attr_ex.orig_attr.max_srq;
+	device_attr->max_srq_wr = attr_ex.orig_attr.max_srq_wr;
 	device_attr->raw_packet_caps = attr_ex.raw_packet_caps;
 	device_attr->max_rwq_indirection_table_size =
 		attr_ex.rss_caps.max_rwq_indirection_table_size;
drivers/net/mlx5/mlx5.h +5 -0
index 121d726405..2186677810 100644
@@ -83,6 +83,11 @@ struct mlx5_dev_attr {
 	int		max_sge;
 	int		max_cq;
 	int		max_qp;
+	int		max_cqe;
+	uint32_t	max_pd;
+	uint32_t	max_mr;
+	uint32_t	max_srq;
+	uint32_t	max_srq_wr;
 	uint32_t	raw_packet_caps;
 	uint32_t	max_rwq_indirection_table_size;
 	uint32_t	max_tso;
Signature · 1 line
2.16.1.windows.4
#43 lore raw

PATCH v4 3/32 net/mlx5: remove Linux files from Windows compilation

In reply to Tal Shnaiderman

From: Ophir Munk <[email protected]>

This commit removes Linux files flow_verbs.c and mlx5_rxtx_vec.c from Windows compilation.

---
 drivers/net/mlx5/meson.build | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)
drivers/net/mlx5/meson.build +11 -5
index e7495a764a..f2fafbdd05 100644
@@ -15,7 +15,6 @@ sources = files(
 	'mlx5_flow.c',
 	'mlx5_flow_meter.c',
 	'mlx5_flow_dv.c',
-	'mlx5_flow_verbs.c',
         'mlx5_flow_age.c',
 	'mlx5_mac.c',
 	'mlx5_mr.c',
@@ -31,11 +30,18 @@ sources = files(
 	'mlx5_utils.c',
 	'mlx5_devx.c',
 )
-if (dpdk_conf.has('RTE_ARCH_X86_64')
-	or dpdk_conf.has('RTE_ARCH_ARM64')
-	or dpdk_conf.has('RTE_ARCH_PPC_64'))
-	sources += files('mlx5_rxtx_vec.c')
+
+if is_linux
+	sources += files(
+		'mlx5_flow_verbs.c',
+	)
+	if (dpdk_conf.has('RTE_ARCH_X86_64')
+		or dpdk_conf.has('RTE_ARCH_ARM64')
+		or dpdk_conf.has('RTE_ARCH_PPC_64'))
+		sources += files('mlx5_rxtx_vec.c')
+	endif
 endif
+
 cflags_options = [
 	'-std=c11',
 	'-Wno-strict-prototypes',
Signature · 1 line
2.16.1.windows.4
#44 lore raw

PATCH v4 4/32 net/mlx5: fix freeing packet pacing

In reply to Tal Shnaiderman

From: Ophir Munk <[email protected]>

Packet pacing is allocated under condition #ifdef HAVE_MLX5DV_PP_ALLOC. In a similar way - free packet pacing index under the same condition. This update is required to successfully compile under operating systems which do not support packet pacing.

Fixes aef1e20ebeb2 ("net/mlx5: allocate packet pacing context")
---
 drivers/net/mlx5/mlx5_txpp.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/net/mlx5/mlx5_txpp.c +5 -0
index 2438bf1f1d..21675ab17a 100644
@@ -57,11 +57,16 @@ mlx5_txpp_create_event_channel(struct mlx5_dev_ctx_shared *sh)
 static void
 mlx5_txpp_free_pp_index(struct mlx5_dev_ctx_shared *sh)
 {
+#ifdef HAVE_MLX5DV_PP_ALLOC
 	if (sh->txpp.pp) {
 		mlx5_glue->dv_free_pp(sh->txpp.pp);
 		sh->txpp.pp = NULL;
 		sh->txpp.pp_id = 0;
 	}
+#else
+	RTE_SET_USED(sh);
+	DRV_LOG(ERR, "Freeing pacing index is not supported.");
+#endif
 }
 
 /* Allocate Packet Pacing index from kernel via mlx5dv call. */
Signature · 1 line
2.16.1.windows.4
#45 lore raw

PATCH v4 5/32 net/mlx5: replace Linux sleep with rte sleep

In reply to Tal Shnaiderman

From: Ophir Munk <[email protected]>

Replace Linux API usleep() and nanosleep() with rte_delay_us_sleep(). The replacement occurs in shared files compiled under different operating systems.

---
 drivers/net/mlx5/mlx5.c         | 5 +++--
 drivers/net/mlx5/mlx5_trigger.c | 3 ++-
 drivers/net/mlx5/mlx5_txpp.c    | 6 +-----
 3 files changed, 6 insertions(+), 8 deletions(-)
drivers/net/mlx5/mlx5.c +3 -2
index 52a8a252d4..8e9df6abcf 100644
@@ -21,6 +21,7 @@
 #include <rte_spinlock.h>
 #include <rte_string_fns.h>
 #include <rte_alarm.h>
+#include <rte_cycles.h>
 
 #include <mlx5_glue.h>
 #include <mlx5_devx_cmds.h>
@@ -1330,7 +1331,7 @@ mlx5_dev_close(struct rte_eth_dev *dev)
 	mlx5_flex_parser_ecpri_release(dev);
 	if (priv->rxqs != NULL) {
 		/* XXX race condition if mlx5_rx_burst() is still running. */
-		usleep(1000);
+		rte_delay_us_sleep(1000);
 		for (i = 0; (i != priv->rxqs_n); ++i)
 			mlx5_rxq_release(dev, i);
 		priv->rxqs_n = 0;
@@ -1338,7 +1339,7 @@ mlx5_dev_close(struct rte_eth_dev *dev)
 	}
 	if (priv->txqs != NULL) {
 		/* XXX race condition if mlx5_tx_burst() is still running. */
-		usleep(1000);
+		rte_delay_us_sleep(1000);
 		for (i = 0; (i != priv->txqs_n); ++i)
 			mlx5_txq_release(dev, i);
 		priv->txqs_n = 0;
drivers/net/mlx5/mlx5_trigger.c +2 -1
index bd029154f8..646f29b923 100644
@@ -9,6 +9,7 @@
 #include <rte_ethdev_driver.h>
 #include <rte_interrupts.h>
 #include <rte_alarm.h>
+#include <rte_cycles.h>
 
 #include <mlx5_malloc.h>
 
@@ -1171,7 +1172,7 @@ mlx5_dev_stop(struct rte_eth_dev *dev)
 	rte_wmb();
 	/* Disable datapath on secondary process. */
 	mlx5_mp_os_req_stop_rxtx(dev);
-	usleep(1000 * priv->rxqs_n);
+	rte_delay_us_sleep(1000 * priv->rxqs_n);
 	DRV_LOG(DEBUG, "port %u stopping device", dev->data->port_id);
 	mlx5_flow_stop_default(dev);
 	/* Control flows for default traffic can be removed firstly. */
drivers/net/mlx5/mlx5_txpp.c +1 -5
index 21675ab17a..a1ec294942 100644
@@ -769,15 +769,11 @@ mlx5_txpp_init_timestamp(struct mlx5_dev_ctx_shared *sh)
 	sh->txpp.ts_p = 0;
 	sh->txpp.ts_n = 0;
 	for (wait = 0; wait < MLX5_TXPP_WAIT_INIT_TS; wait++) {
-		struct timespec onems;
-
 		mlx5_txpp_update_timestamp(sh);
 		if (wq->sq_ci)
 			return;
 		/* Wait one millisecond and try again. */
-		onems.tv_sec = 0;
-		onems.tv_nsec = NS_PER_S / MS_PER_S;
-		nanosleep(&onems, 0);
+		rte_delay_us_sleep(US_PER_S / MS_PER_S);
 	}
 	DRV_LOG(ERR, "Unable to initialize timestamp.");
 	sh->txpp.sync_lost = 1;
Signature · 1 line
2.16.1.windows.4
#46 lore raw

PATCH v4 6/32 net/mlx5: define mprq functions as static inline

In reply to Tal Shnaiderman

From: Ophir Munk <[email protected]>

Functions mlx5_check_mprq_support(), mlx5_rxq_mprq_enabled(), mlx5_mprq_enabled() are moved from source file mlx5_rxq.c to header file mlx5_rxtx.h and their type is updated to 'static __rte_always_inline'. Previously the functions were declared as 'inline' in the source file which was reported as 'unresolved external symbol' error by some Windows linkers.

---
 drivers/net/mlx5/mlx5_rxq.c  | 71 ------------------------------------------
 drivers/net/mlx5/mlx5_rxtx.h | 73 ++++++++++++++++++++++++++++++++++++++++++--
 2 files changed, 70 insertions(+), 74 deletions(-)
drivers/net/mlx5/mlx5_rxq.c +0 -71
index da7a8b3cd7..c89e55b1c0 100644
@@ -48,77 +48,6 @@ static_assert(MLX5_RSS_HASH_KEY_LEN ==
 	      (unsigned int)sizeof(rss_hash_default_key),
 	      "wrong RSS default key size.");
 
-/**
- * Check whether Multi-Packet RQ can be enabled for the device.
- *
- * @param dev
- *   Pointer to Ethernet device.
- *
- * @return
- *   1 if supported, negative errno value if not.
- */
-inline int
-mlx5_check_mprq_support(struct rte_eth_dev *dev)
-{
-	struct mlx5_priv *priv = dev->data->dev_private;
-
-	if (priv->config.mprq.enabled &&
-	    priv->rxqs_n >= priv->config.mprq.min_rxqs_num)
-		return 1;
-	return -ENOTSUP;
-}
-
-/**
- * Check whether Multi-Packet RQ is enabled for the Rx queue.
- *
- *  @param rxq
- *     Pointer to receive queue structure.
- *
- * @return
- *   0 if disabled, otherwise enabled.
- */
-inline int
-mlx5_rxq_mprq_enabled(struct mlx5_rxq_data *rxq)
-{
-	return rxq->strd_num_n > 0;
-}
-
-/**
- * Check whether Multi-Packet RQ is enabled for the device.
- *
- * @param dev
- *   Pointer to Ethernet device.
- *
- * @return
- *   0 if disabled, otherwise enabled.
- */
-inline int
-mlx5_mprq_enabled(struct rte_eth_dev *dev)
-{
-	struct mlx5_priv *priv = dev->data->dev_private;
-	uint32_t i;
-	uint16_t n = 0;
-	uint16_t n_ibv = 0;
-
-	if (mlx5_check_mprq_support(dev) < 0)
-		return 0;
-	/* All the configured queues should be enabled. */
-	for (i = 0; i < priv->rxqs_n; ++i) {
-		struct mlx5_rxq_data *rxq = (*priv->rxqs)[i];
-		struct mlx5_rxq_ctrl *rxq_ctrl = container_of
-			(rxq, struct mlx5_rxq_ctrl, rxq);
-
-		if (rxq == NULL || rxq_ctrl->type != MLX5_RXQ_TYPE_STANDARD)
-			continue;
-		n_ibv++;
-		if (mlx5_rxq_mprq_enabled(rxq))
-			++n;
-	}
-	/* Multi-Packet RQ can't be partially configured. */
-	MLX5_ASSERT(n == 0 || n == n_ibv);
-	return n == n_ibv;
-}
-
 /**
  * Calculate the number of CQEs in CQ for the Rx queue.
  *
drivers/net/mlx5/mlx5_rxtx.h +70 -3

83 lines not on this page · raw message

Signature · 1 line
2.16.1.windows.4
#47 lore raw

PATCH v4 7/32 net/mlx5: do not define static_assert in Windows

In reply to Tal Shnaiderman

From: Ophir Munk <[email protected]>

In Linux 'static_assert' is defined in file mlx5_defs.h:

 #ifndef HAVE_STATIC_ASSERT
    #define static_assert _Static_assert

#endif

The same definition can originate from Linux file /usr/include/assert.h.

In Windows static_assert is used while _Static_assert is unknown. Therefore update the definition condition to be:

 #if !defined(HAVE_STATIC_ASSERT) && !defined(RTE_EXEC_ENV_WINDOWS)
    #define static_assert _Static_assert

#endif

---
 drivers/net/mlx5/mlx5_defs.h | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/net/mlx5/mlx5_defs.h +5 -2
index aa55db3750..85a0979653 100644
@@ -199,8 +199,11 @@
 /* Maximum number of shared actions supported by rte_flow */
 #define MLX5_MAX_SHARED_ACTIONS 2
 
-/* Definition of static_assert found in /usr/include/assert.h */
-#ifndef HAVE_STATIC_ASSERT
+/*
+ * Linux definition of static_assert is found in /usr/include/assert.h.
+ * Windows does not require a redefinition.
+ */
+#if !defined(HAVE_STATIC_ASSERT) && !defined(RTE_EXEC_ENV_WINDOWS)
 #define static_assert _Static_assert
 #endif
 
Signature · 1 line
2.16.1.windows.4
#48 lore raw

PATCH v4 8/32 net/mlx5: move static_assert calls to global scope

In reply to Tal Shnaiderman

From: Ophir Munk <[email protected]>

Some Windows compilers consider static_assert() as calls to another function rather than a compiler directive which allows checking type information at compile time. This only occurs if the static_assert call appears inside another function scope. To solve it move the static_assert calls to global scope in the files where they are used.

---
 drivers/net/mlx5/mlx5_rxtx.c | 98 ++++++++++++++++++++++----------------------
 drivers/net/mlx5/mlx5_txpp.c |  5 ++-
 2 files changed, 53 insertions(+), 50 deletions(-)
drivers/net/mlx5/mlx5_rxtx.c +50 -48
index d12d746c2f..65a1f997e9 100644
@@ -79,6 +79,56 @@ static uint16_t mlx5_tx_burst_##func(void *txq, \
 
 #define MLX5_TXOFF_INFO(func, olx) {mlx5_tx_burst_##func, olx},
 
+/* static asserts */
+static_assert(MLX5_CQE_STATUS_HW_OWN < 0, "Must be negative value");
+static_assert(MLX5_CQE_STATUS_SW_OWN < 0, "Must be negative value");
+static_assert(MLX5_ESEG_MIN_INLINE_SIZE ==
+		(sizeof(uint16_t) +
+		 sizeof(rte_v128u32_t)),
+		"invalid Ethernet Segment data size");
+static_assert(MLX5_ESEG_MIN_INLINE_SIZE ==
+		(sizeof(uint16_t) +
+		 sizeof(struct rte_vlan_hdr) +
+		 2 * RTE_ETHER_ADDR_LEN),
+		"invalid Ethernet Segment data size");
+static_assert(MLX5_ESEG_MIN_INLINE_SIZE ==
+		(sizeof(uint16_t) +
+		 sizeof(rte_v128u32_t)),
+		"invalid Ethernet Segment data size");
+static_assert(MLX5_ESEG_MIN_INLINE_SIZE ==
+		(sizeof(uint16_t) +
+		 sizeof(struct rte_vlan_hdr) +
+		 2 * RTE_ETHER_ADDR_LEN),
+		"invalid Ethernet Segment data size");
+static_assert(MLX5_ESEG_MIN_INLINE_SIZE ==
+		(sizeof(uint16_t) +
+		 sizeof(rte_v128u32_t)),
+		"invalid Ethernet Segment data size");
+static_assert(MLX5_ESEG_MIN_INLINE_SIZE ==
+		(sizeof(uint16_t) +
+		 sizeof(struct rte_vlan_hdr) +
+		 2 * RTE_ETHER_ADDR_LEN),
+		"invalid Ethernet Segment data size");
+static_assert(MLX5_DSEG_MIN_INLINE_SIZE ==
+		(2 * RTE_ETHER_ADDR_LEN),
+		"invalid Data Segment data size");
+static_assert(MLX5_EMPW_MIN_PACKETS >= 2, "invalid min size");
+static_assert(MLX5_EMPW_MIN_PACKETS >= 2, "invalid min size");
+static_assert((sizeof(struct rte_vlan_hdr) +
+			sizeof(struct rte_ether_hdr)) ==
+		MLX5_ESEG_MIN_INLINE_SIZE,
+		"invalid min inline data size");
+static_assert(MLX5_WQE_SIZE_MAX / MLX5_WSEG_SIZE <=
+		MLX5_DSEG_MAX, "invalid WQE max size");
+static_assert(MLX5_WQE_CSEG_SIZE == MLX5_WSEG_SIZE,
+		"invalid WQE Control Segment size");
+static_assert(MLX5_WQE_ESEG_SIZE == MLX5_WSEG_SIZE,
+		"invalid WQE Ethernet Segment size");
+static_assert(MLX5_WQE_DSEG_SIZE == MLX5_WSEG_SIZE,
+		"invalid WQE Data Segment size");
+static_assert(MLX5_WQE_SIZE == 4 * MLX5_WSEG_SIZE,
+		"invalid WQE size");
+
 static __rte_always_inline uint32_t
 rxq_cq_to_pkt_type(struct mlx5_rxq_data *rxq, volatile struct mlx5_cqe *cqe,
 				   volatile struct mlx5_mini_cqe8 *mcqe);
@@ -2070,8 +2120,6 @@ mlx5_tx_handle_completion(struct mlx5_txq_data *__rte_restrict txq,
 	bool ring_doorbell = false;
 	int ret;
 
-	static_assert(MLX5_CQE_STATUS_HW_OWN < 0, "Must be negative value");
-	static_assert(MLX5_CQE_STATUS_SW_OWN < 0, "Must be negative value");
 	do {
 		volatile struct mlx5_cqe *cqe;
 
@@ -2381,15 +2429,6 @@ mlx5_tx_eseg_dmin(struct mlx5_txq_data *__rte_restrict txq __rte_unused,
 	es->metadata = MLX5_TXOFF_CONFIG(METADATA) ?
 		       loc->mbuf->ol_flags & PKT_TX_DYNF_METADATA ?
 		       *RTE_FLOW_DYNF_METADATA(loc->mbuf) : 0 : 0;
-	static_assert(MLX5_ESEG_MIN_INLINE_SIZE ==
-				(sizeof(uint16_t) +
-				 sizeof(rte_v128u32_t)),
-		      "invalid Ethernet Segment data size");
-	static_assert(MLX5_ESEG_MIN_INLINE_SIZE ==
-				(sizeof(uint16_t) +
-				 sizeof(struct rte_vlan_hdr) +
-				 2 * RTE_ETHER_ADDR_LEN),
-		      "invalid Ethernet Segment data size");
 	psrc = rte_pktmbuf_mtod(loc->mbuf, uint8_t *);
 	es->inline_hdr_sz = RTE_BE16(MLX5_ESEG_MIN_INLINE_SIZE);
 	es->inline_data = *(unaligned_uint16_t *)psrc;
@@ -2474,15 +2513,6 @@ mlx5_tx_eseg_data(struct mlx5_txq_data *__rte_restrict txq,
 	es->metadata = MLX5_TXOFF_CONFIG(METADATA) ?
 		       loc->mbuf->ol_flags & PKT_TX_DYNF_METADATA ?
 		       *RTE_FLOW_DYNF_METADATA(loc->mbuf) : 0 : 0;
-	static_assert(MLX5_ESEG_MIN_INLINE_SIZE ==
-				(sizeof(uint16_t) +
-				 sizeof(rte_v128u32_t)),
-		      "invalid Ethernet Segment data size");
-	static_assert(MLX5_ESEG_MIN_INLINE_SIZE ==
-				(sizeof(uint16_t) +
-				 sizeof(struct rte_vlan_hdr) +
-				 2 * RTE_ETHER_ADDR_LEN),
-		      "invalid Ethernet Segment data size");
 	psrc = rte_pktmbuf_mtod(loc->mbuf, uint8_t *);
 	es->inline_hdr_sz = rte_cpu_to_be_16(inlen);
 	es->inline_data = *(unaligned_uint16_t *)psrc;
@@ -2697,15 +2727,6 @@ mlx5_tx_eseg_mdat(struct mlx5_txq_data *__rte_restrict txq,
 	es->metadata = MLX5_TXOFF_CONFIG(METADATA) ?
 		       loc->mbuf->ol_flags & PKT_TX_DYNF_METADATA ?
 		       *RTE_FLOW_DYNF_METADATA(loc->mbuf) : 0 : 0;
-	static_assert(MLX5_ESEG_MIN_INLINE_SIZE ==
-				(sizeof(uint16_t) +
-				 sizeof(rte_v128u32_t)),
-		      "invalid Ethernet Segment data size");
-	static_assert(MLX5_ESEG_MIN_INLINE_SIZE ==
-				(sizeof(uint16_t) +
-				 sizeof(struct rte_vlan_hdr) +
-				 2 * RTE_ETHER_ADDR_LEN),
-		      "invalid Ethernet Segment data size");
 	MLX5_ASSERT(inlen >= MLX5_ESEG_MIN_INLINE_SIZE);
 	pdst = (uint8_t *)&es->inline_data;
 	if (MLX5_TXOFF_CONFIG(VLAN) && vlan) {
@@ -2952,9 +2973,6 @@ mlx5_tx_dseg_vlan(struct mlx5_txq_data *__rte_restrict txq,
 	uint8_t *pdst;
 
 	MLX5_ASSERT(len > MLX5_ESEG_MIN_INLINE_SIZE);
-	static_assert(MLX5_DSEG_MIN_INLINE_SIZE ==
-				 (2 * RTE_ETHER_ADDR_LEN),
-		      "invalid Data Segment data size");
 	if (!MLX5_TXOFF_CONFIG(MPW)) {
 		/* Store the descriptor byte counter for eMPW sessions. */
 		dseg->bcount = rte_cpu_to_be_32
@@ -4070,7 +4088,6 @@ mlx5_tx_burst_empw_simple(struct mlx5_txq_data *__rte_restrict txq,
 	MLX5_ASSERT(MLX5_TXOFF_CONFIG(EMPW));
 	MLX5_ASSERT(loc->elts_free && loc->wqe_free);
 	MLX5_ASSERT(pkts_n > loc->pkts_sent);
-	static_assert(MLX5_EMPW_MIN_PACKETS >= 2, "invalid min size");
 	pkts += loc->pkts_sent + 1;
 	pkts_n -= loc->pkts_sent;
 	for (;;) {
@@ -4247,7 +4264,6 @@ mlx5_tx_burst_empw_inline(struct mlx5_txq_data *__rte_restrict txq,
 	MLX5_ASSERT(MLX5_TXOFF_CONFIG(EMPW));
 	MLX5_ASSERT(loc->elts_free && loc->wqe_free);
 	MLX5_ASSERT(pkts_n > loc->pkts_sent);
-	static_assert(MLX5_EMPW_MIN_PACKETS >= 2, "invalid min size");
 	pkts += loc->pkts_sent + 1;
 	pkts_n -= loc->pkts_sent;
 	for (;;) {
@@ -4561,10 +4577,6 @@ mlx5_tx_burst_single_send(struct mlx5_txq_data *__rte_restrict txq,
 			    loc->mbuf->ol_flags & PKT_TX_VLAN_PKT) {
 				vlan = sizeof(struct rte_vlan_hdr);
 				inlen += vlan;
-				static_assert((sizeof(struct rte_vlan_hdr) +
-					       sizeof(struct rte_ether_hdr)) ==
-					       MLX5_ESEG_MIN_INLINE_SIZE,
-					       "invalid min inline data size");
 			}
 			/*
 			 * If inlining is enabled at configuration time
@@ -5567,16 +5579,6 @@ mlx5_select_tx_function(struct rte_eth_dev *dev)
 	uint64_t tx_offloads = dev->data->dev_conf.txmode.offloads;
 	unsigned int diff = 0, olx = 0, i, m;
 
-	static_assert(MLX5_WQE_SIZE_MAX / MLX5_WSEG_SIZE <=
-		      MLX5_DSEG_MAX, "invalid WQE max size");
-	static_assert(MLX5_WQE_CSEG_SIZE == MLX5_WSEG_SIZE,
-		      "invalid WQE Control Segment size");
-	static_assert(MLX5_WQE_ESEG_SIZE == MLX5_WSEG_SIZE,
-		      "invalid WQE Ethernet Segment size");
-	static_assert(MLX5_WQE_DSEG_SIZE == MLX5_WSEG_SIZE,
-		      "invalid WQE Data Segment size");
-	static_assert(MLX5_WQE_SIZE == 4 * MLX5_WSEG_SIZE,
-		      "invalid WQE size");
 	MLX5_ASSERT(priv);
 	if (tx_offloads & DEV_TX_OFFLOAD_MULTI_SEGS) {
 		/* We should support Multi-Segment Packets. */
drivers/net/mlx5/mlx5_txpp.c +3 -2
index a1ec294942..d61e43e55d 100644
@@ -18,6 +18,9 @@
 #include "mlx5_rxtx.h"
 #include "mlx5_common_os.h"
 
+static_assert(sizeof(struct mlx5_cqe_ts) == sizeof(rte_int128_t),
+		"Wrong timestamp CQE part size");
+
 static const char * const mlx5_txpp_stat_names[] = {
 	"tx_pp_missed_interrupt_errors", /* Missed service interrupt. */
 	"tx_pp_rearm_queue_errors", /* Rearm Queue errors. */
@@ -741,8 +744,6 @@ mlx5_txpp_update_timestamp(struct mlx5_dev_ctx_shared *sh)
 	uint64_t ts;
 	uint16_t ci;
 
-	static_assert(sizeof(struct mlx5_cqe_ts) == sizeof(rte_int128_t),
-		      "Wrong timestamp CQE part size");
 	mlx5_atomic_read_cqe((rte_int128_t *)&cqe->timestamp, &to.u128);
 	if (to.cts.op_own >> 4) {
 		DRV_LOG(DEBUG, "Clock Queue error sync lost.");
Signature · 1 line
2.16.1.windows.4
#49 lore raw

PATCH v4 9/32 net/mlx5: wrap glue alloc/dealloc PD with OS calls

In reply to Tal Shnaiderman

From: Ophir Munk <[email protected]>

Wrap glue calls alloc_pd() and dealloc_pd() with generic OS calls. In Linux - protection domain allocations are implemented by Verbs glue API while in Windows it is by DevX API.

---
 drivers/common/mlx5/linux/mlx5_common_os.h | 11 +++++++++++
 drivers/net/mlx5/mlx5.c                    |  6 +++---
 2 files changed, 14 insertions(+), 3 deletions(-)
drivers/common/mlx5/linux/mlx5_common_os.h +11 -0
index 3420937859..c9f8d7cbc1 100644
@@ -201,4 +201,15 @@ mlx5_os_get_devx_uar_page_id(void *uar)
 #endif
 }
 
+static inline void *
+mlx5_os_alloc_pd(void *ctx)
+{
+	return mlx5_glue->alloc_pd(ctx);
+}
+
+static inline int
+mlx5_os_dealloc_pd(void *pd)
+{
+	return mlx5_glue->dealloc_pd(pd);
+}
 #endif /* RTE_PMD_MLX5_COMMON_OS_H_ */
drivers/net/mlx5/mlx5.c +3 -3
index 8e9df6abcf..7d1b4fbdc0 100644
@@ -932,7 +932,7 @@ mlx5_alloc_shared_dev_ctx(const struct mlx5_dev_spawn_data *spawn,
 		sh->port[i].ih_port_id = RTE_MAX_ETHPORTS;
 		sh->port[i].devx_ih_port_id = RTE_MAX_ETHPORTS;
 	}
-	sh->pd = mlx5_glue->alloc_pd(sh->ctx);
+	sh->pd = mlx5_os_alloc_pd(sh->ctx);
 	if (sh->pd == NULL) {
 		DRV_LOG(ERR, "PD allocation failure");
 		err = ENOMEM;
@@ -1032,7 +1032,7 @@ mlx5_alloc_shared_dev_ctx(const struct mlx5_dev_spawn_data *spawn,
 	if (sh->tx_uar)
 		mlx5_glue->devx_free_uar(sh->tx_uar);
 	if (sh->pd)
-		claim_zero(mlx5_glue->dealloc_pd(sh->pd));
+		claim_zero(mlx5_os_dealloc_pd(sh->pd));
 	if (sh->ctx)
 		claim_zero(mlx5_glue->close_device(sh->ctx));
 	mlx5_free(sh);
@@ -1100,7 +1100,7 @@ mlx5_free_shared_dev_ctx(struct mlx5_dev_ctx_shared *sh)
 		sh->tx_uar = NULL;
 	}
 	if (sh->pd)
-		claim_zero(mlx5_glue->dealloc_pd(sh->pd));
+		claim_zero(mlx5_os_dealloc_pd(sh->pd));
 	if (sh->tis)
 		claim_zero(mlx5_devx_cmd_destroy(sh->tis));
 	if (sh->td)
Signature · 1 line
2.16.1.windows.4
#50 lore raw

PATCH v4 10/32 net/mlx5: wrap glue reg/dereg UMEM with OS calls

In reply to Tal Shnaiderman

Wrap glue calls for UMEM registration and deregistration with generic OS calls since each OS (Linux or Windows) has a different glue API parameters.

---
 drivers/common/mlx5/linux/mlx5_common_os.h | 12 ++++++++++++
 drivers/common/mlx5/mlx5_common.c          |  4 ++--
 drivers/net/mlx5/mlx5.c                    |  2 +-
 drivers/net/mlx5/mlx5_devx.c               | 16 ++++++++--------
 drivers/net/mlx5/mlx5_flow.c               |  4 ++--
 drivers/net/mlx5/mlx5_txpp.c               | 12 ++++++------
 6 files changed, 31 insertions(+), 19 deletions(-)
drivers/common/mlx5/linux/mlx5_common_os.h +12 -0
index c9f8d7cbc1..f8b215cc29 100644
@@ -212,4 +212,16 @@ mlx5_os_dealloc_pd(void *pd)
 {
 	return mlx5_glue->dealloc_pd(pd);
 }
+
+static inline void *
+mlx5_os_umem_reg(void *ctx, void *addr, size_t size, uint32_t access)
+{
+	return mlx5_glue->devx_umem_reg(ctx, addr, size, access);
+}
+
+static inline int
+mlx5_os_umem_dereg(void *pumem)
+{
+	return mlx5_glue->devx_umem_dereg(pumem);
+}
 #endif /* RTE_PMD_MLX5_COMMON_OS_H_ */
drivers/common/mlx5/mlx5_common.c +2 -2
index 044513223c..a00ffcb833 100644
@@ -148,7 +148,7 @@ mlx5_alloc_dbr_page(void *ctx)
 		return NULL;
 	}
 	/* Register allocated memory. */
-	page->umem = mlx5_glue->devx_umem_reg(ctx, page->dbrs,
+	page->umem = mlx5_os_umem_reg(ctx, page->dbrs,
 					      MLX5_DBR_PAGE_SIZE, 0);
 	if (!page->umem) {
 		DRV_LOG(ERR, "cannot umem reg dbr page");
@@ -232,7 +232,7 @@ mlx5_release_dbr(struct mlx5_dbr_page_list *head, uint32_t umem_id,
 		/* Page not used, free it and remove from list. */
 		LIST_REMOVE(page, next);
 		if (page->umem)
-			ret = -mlx5_glue->devx_umem_dereg(page->umem);
+			ret = -mlx5_os_umem_dereg(page->umem);
 		mlx5_free(page);
 	} else {
 		/* Mark in bitmap that this door-bell is not in use. */
drivers/net/mlx5/mlx5.c +1 -1
index 7d1b4fbdc0..84123f8e3d 100644
@@ -482,7 +482,7 @@ mlx5_flow_destroy_counter_stat_mem_mng(struct mlx5_counter_stats_mem_mng *mng)
 
 	LIST_REMOVE(mng, next);
 	claim_zero(mlx5_devx_cmd_destroy(mng->dm));
-	claim_zero(mlx5_glue->devx_umem_dereg(mng->umem));
+	claim_zero(mlx5_os_umem_dereg(mng->umem));
 	mlx5_free(mem);
 }
 
drivers/net/mlx5/mlx5_devx.c +8 -8
index de9b204075..235fd5798d 100644
@@ -155,7 +155,7 @@ mlx5_rxq_release_devx_rq_resources(struct mlx5_rxq_ctrl *rxq_ctrl)
 	struct mlx5_devx_dbr_page *dbr_page = rxq_ctrl->rq_dbrec_page;
 
 	if (rxq_ctrl->wq_umem) {
-		mlx5_glue->devx_umem_dereg(rxq_ctrl->wq_umem);
+		mlx5_os_umem_dereg(rxq_ctrl->wq_umem);
 		rxq_ctrl->wq_umem = NULL;
 	}
 	if (rxq_ctrl->rxq.wqes) {
@@ -182,7 +182,7 @@ mlx5_rxq_release_devx_cq_resources(struct mlx5_rxq_ctrl *rxq_ctrl)
 	struct mlx5_devx_dbr_page *dbr_page = rxq_ctrl->cq_dbrec_page;
 
 	if (rxq_ctrl->cq_umem) {
-		mlx5_glue->devx_umem_dereg(rxq_ctrl->cq_umem);
+		mlx5_os_umem_dereg(rxq_ctrl->cq_umem);
 		rxq_ctrl->cq_umem = NULL;
 	}
 	if (rxq_ctrl->rxq.cqes) {
@@ -375,7 +375,7 @@ mlx5_rxq_create_devx_rq_resources(struct rte_eth_dev *dev, uint16_t idx)
 	if (!buf)
 		return NULL;
 	rxq_data->wqes = buf;
-	rxq_ctrl->wq_umem = mlx5_glue->devx_umem_reg(priv->sh->ctx,
+	rxq_ctrl->wq_umem = mlx5_os_umem_reg(priv->sh->ctx,
 						     buf, wq_size, 0);
 	if (!rxq_ctrl->wq_umem)
 		goto error;
@@ -497,7 +497,7 @@ mlx5_rxq_create_devx_cq_resources(struct rte_eth_dev *dev, uint16_t idx)
 		goto error;
 	}
 	rxq_data->cqes = (volatile struct mlx5_cqe (*)[])(uintptr_t)buf;
-	rxq_ctrl->cq_umem = mlx5_glue->devx_umem_reg(priv->sh->ctx, buf,
+	rxq_ctrl->cq_umem = mlx5_os_umem_reg(priv->sh->ctx, buf,
 						     cq_size,
 						     IBV_ACCESS_LOCAL_WRITE);
 	if (!rxq_ctrl->cq_umem) {
@@ -1127,7 +1127,7 @@ mlx5_txq_release_devx_sq_resources(struct mlx5_txq_obj *txq_obj)
 		txq_obj->sq_devx = NULL;
 	}
 	if (txq_obj->sq_umem) {
-		claim_zero(mlx5_glue->devx_umem_dereg(txq_obj->sq_umem));
+		claim_zero(mlx5_os_umem_dereg(txq_obj->sq_umem));
 		txq_obj->sq_umem = NULL;
 	}
 	if (txq_obj->sq_buf) {
@@ -1155,7 +1155,7 @@ mlx5_txq_release_devx_cq_resources(struct mlx5_txq_obj *txq_obj)
 	if (txq_obj->cq_devx)
 		claim_zero(mlx5_devx_cmd_destroy(txq_obj->cq_devx));
 	if (txq_obj->cq_umem)
-		claim_zero(mlx5_glue->devx_umem_dereg(txq_obj->cq_umem));
+		claim_zero(mlx5_os_umem_dereg(txq_obj->cq_umem));
 	if (txq_obj->cq_buf)
 		mlx5_free(txq_obj->cq_buf);
 	if (txq_obj->cq_dbrec_page)
@@ -1243,7 +1243,7 @@ mlx5_txq_create_devx_cq_resources(struct rte_eth_dev *dev, uint16_t idx)
 		return 0;
 	}
 	/* Register allocated buffer in user space with DevX. */
-	txq_obj->cq_umem = mlx5_glue->devx_umem_reg(priv->sh->ctx,
+	txq_obj->cq_umem = mlx5_os_umem_reg(priv->sh->ctx,
 						(void *)txq_obj->cq_buf,
 						cqe_n * sizeof(struct mlx5_cqe),
 						IBV_ACCESS_LOCAL_WRITE);
@@ -1342,7 +1342,7 @@ mlx5_txq_create_devx_sq_resources(struct rte_eth_dev *dev, uint16_t idx)
 		goto error;
 	}
 	/* Register allocated buffer in user space with DevX. */
-	txq_obj->sq_umem = mlx5_glue->devx_umem_reg
+	txq_obj->sq_umem = mlx5_os_umem_reg
 					(priv->sh->ctx,
 					 (void *)txq_obj->sq_buf,
 					 wqe_n * sizeof(struct mlx5_wqe),
drivers/net/mlx5/mlx5_flow.c +2 -2
index bf86aaaa39..66491bbf78 100644
@@ -6446,7 +6446,7 @@ mlx5_flow_create_counter_stat_mem_mng(struct mlx5_dev_ctx_shared *sh)
 	}
 	mem_mng = (struct mlx5_counter_stats_mem_mng *)(mem + size) - 1;
 	size = sizeof(*raw_data) * MLX5_COUNTERS_PER_POOL * raws_n;
-	mem_mng->umem = mlx5_glue->devx_umem_reg(sh->ctx, mem, size,
+	mem_mng->umem = mlx5_os_umem_reg(sh->ctx, mem, size,
 						 IBV_ACCESS_LOCAL_WRITE);
 	if (!mem_mng->umem) {
 		rte_errno = errno;
@@ -6465,7 +6465,7 @@ mlx5_flow_create_counter_stat_mem_mng(struct mlx5_dev_ctx_shared *sh)
 	mkey_attr.relaxed_ordering_read = sh->cmng.relaxed_ordering_read;
 	mem_mng->dm = mlx5_devx_cmd_mkey_create(sh->ctx, &mkey_attr);
 	if (!mem_mng->dm) {
-		mlx5_glue->devx_umem_dereg(mem_mng->umem);
+		mlx5_os_umem_dereg(mem_mng->umem);
 		rte_errno = errno;
 		mlx5_free(mem);
 		return -rte_errno;
drivers/net/mlx5/mlx5_txpp.c +6 -6
index d61e43e55d..749529c410 100644
@@ -131,13 +131,13 @@ mlx5_txpp_destroy_send_queue(struct mlx5_txpp_wq *wq)
 	if (wq->sq)
 		claim_zero(mlx5_devx_cmd_destroy(wq->sq));
 	if (wq->sq_umem)
-		claim_zero(mlx5_glue->devx_umem_dereg(wq->sq_umem));
+		claim_zero(mlx5_os_umem_dereg(wq->sq_umem));
 	if (wq->sq_buf)
 		mlx5_free((void *)(uintptr_t)wq->sq_buf);
 	if (wq->cq)
 		claim_zero(mlx5_devx_cmd_destroy(wq->cq));
 	if (wq->cq_umem)
-		claim_zero(mlx5_glue->devx_umem_dereg(wq->cq_umem));
+		claim_zero(mlx5_os_umem_dereg(wq->cq_umem));
 	if (wq->cq_buf)
 		mlx5_free((void *)(uintptr_t)wq->cq_buf);
 	memset(wq, 0, sizeof(*wq));
@@ -268,7 +268,7 @@ mlx5_txpp_create_rearm_queue(struct mlx5_dev_ctx_shared *sh)
 		return -ENOMEM;
 	}
 	/* Register allocated buffer in user space with DevX. */
-	wq->cq_umem = mlx5_glue->devx_umem_reg(sh->ctx,
+	wq->cq_umem = mlx5_os_umem_reg(sh->ctx,
 					       (void *)(uintptr_t)wq->cq_buf,
 					       umem_size,
 					       IBV_ACCESS_LOCAL_WRITE);
@@ -318,7 +318,7 @@ mlx5_txpp_create_rearm_queue(struct mlx5_dev_ctx_shared *sh)
 		goto error;
 	}
 	/* Register allocated buffer in user space with DevX. */
-	wq->sq_umem = mlx5_glue->devx_umem_reg(sh->ctx,
+	wq->sq_umem = mlx5_os_umem_reg(sh->ctx,
 					       (void *)(uintptr_t)wq->sq_buf,
 					       umem_size,
 					       IBV_ACCESS_LOCAL_WRITE);
@@ -506,7 +506,7 @@ mlx5_txpp_create_clock_queue(struct mlx5_dev_ctx_shared *sh)
 		return -ENOMEM;
 	}
 	/* Register allocated buffer in user space with DevX. */
-	wq->cq_umem = mlx5_glue->devx_umem_reg(sh->ctx,
+	wq->cq_umem = mlx5_os_umem_reg(sh->ctx,
 					       (void *)(uintptr_t)wq->cq_buf,
 					       umem_size,
 					       IBV_ACCESS_LOCAL_WRITE);
@@ -562,7 +562,7 @@ mlx5_txpp_create_clock_queue(struct mlx5_dev_ctx_shared *sh)
 		goto error;
 	}
 	/* Register allocated buffer in user space with DevX. */
-	wq->sq_umem = mlx5_glue->devx_umem_reg(sh->ctx,
+	wq->sq_umem = mlx5_os_umem_reg(sh->ctx,
 					       (void *)(uintptr_t)wq->sq_buf,
 					       umem_size,
 					       IBV_ACCESS_LOCAL_WRITE);
Signature · 1 line
2.16.1.windows.4
#51 lore raw

PATCH v4 11/32 net/mlx5: fix adding destroy flow action wrapper

In reply to Tal Shnaiderman

From: Ophir Munk <[email protected]>

Glue function destroy_flow_action() was wrapped by OS specific operation mlx5_flow_os_destroy_flow_action(). It was skipped in file mlx5.c.

Fixes b293fbf9672b ("net/mlx5: add OS specific flow actions operations")
---
 drivers/net/mlx5/mlx5.c         | 5 +++--
 drivers/net/mlx5/mlx5_flow_dv.c | 6 +++---
 2 files changed, 6 insertions(+), 5 deletions(-)
drivers/net/mlx5/mlx5.c +3 -2
index 84123f8e3d..ea5cf80ac1 100644
@@ -38,6 +38,7 @@
 #include "mlx5_autoconf.h"
 #include "mlx5_mr.h"
 #include "mlx5_flow.h"
+#include "mlx5_flow_os.h"
 #include "rte_pmd_mlx5.h"
 
 /* Device parameter to enable RX completion queue compression. */
@@ -415,7 +416,7 @@ mlx5_flow_aso_age_mng_close(struct mlx5_dev_ctx_shared *sh)
 			for (j = 0; j < MLX5_COUNTERS_PER_POOL; ++j)
 				if (pool->actions[j].dr_action)
 					claim_zero
-						(mlx5_glue->destroy_flow_action
+						(mlx5_flow_os_destroy_flow_action
 						  (pool->actions[j].dr_action));
 			mlx5_free(pool);
 		}
@@ -523,7 +524,7 @@ mlx5_flow_counters_mng_close(struct mlx5_dev_ctx_shared *sh)
 
 				if (cnt->action)
 					claim_zero
-					 (mlx5_glue->destroy_flow_action
+					 (mlx5_flow_os_destroy_flow_action
 					  (cnt->action));
 				if (fallback && MLX5_POOL_GET_CNT
 				    (pool, j)->dcs_when_free)
drivers/net/mlx5/mlx5_flow_dv.c +3 -3
index c31737652c..78b5a6b338 100644
@@ -11117,11 +11117,11 @@ flow_dv_sample_remove_cb(struct mlx5_cache_list *list __rte_unused,
 	struct mlx5_priv *priv = dev->data->dev_private;
 
 	if (cache_resource->verbs_action)
-		claim_zero(mlx5_glue->destroy_flow_action
+		claim_zero(mlx5_flow_os_destroy_flow_action
 				(cache_resource->verbs_action));
 	if (cache_resource->ft_type == MLX5DV_FLOW_TABLE_TYPE_FDB) {
 		if (cache_resource->default_miss)
-			claim_zero(mlx5_glue->destroy_flow_action
+			claim_zero(mlx5_flow_os_destroy_flow_action
 			  (cache_resource->default_miss));
 	}
 	if (cache_resource->normal_path_tbl)
@@ -11174,7 +11174,7 @@ flow_dv_dest_array_remove_cb(struct mlx5_cache_list *list __rte_unused,
 
 	MLX5_ASSERT(cache_resource->action);
 	if (cache_resource->action)
-		claim_zero(mlx5_glue->destroy_flow_action
+		claim_zero(mlx5_flow_os_destroy_flow_action
 					(cache_resource->action));
 	for (; i < cache_resource->num_of_dest; i++)
 		flow_dv_sample_sub_actions_release(dev,
Signature · 1 line
2.16.1.windows.4
#52 lore raw

PATCH v4 12/32 common/mlx5: add definition HAVE_INFINIBAND_VERBS_H

In reply to Tal Shnaiderman

From: Ophir Munk <[email protected]>

Add a Verbs file presence indication. Under Linux it is required that file infiniband/verbs.h is installed for building DPDK. Other operating systems (e.g. Windows) ignore Verbs completely. This commit adds definition HAVE_INFINIBAND_VERBS_H (file mlx5_autoconf.h) to indicate whether DPDK compiles with Verbs or not.

---
 drivers/common/mlx5/linux/meson.build | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/common/mlx5/linux/meson.build +4 -2
index 63b78e4bce..580419e6d9 100644
@@ -181,8 +181,10 @@ has_sym_args = [
 	[ 'HAVE_MLX5_DR_CREATE_ACTION_DEST_ARRAY', 'infiniband/mlx5dv.h',
 	'mlx5dv_dr_action_create_dest_array'],
 	[ 'HAVE_DEVLINK', 'linux/devlink.h', 'DEVLINK_GENL_NAME' ],
-        [ 'HAVE_MLX5_DR_CREATE_ACTION_ASO', 'infiniband/mlx5dv.h',
-        'mlx5dv_dr_action_create_aso' ],
+	[ 'HAVE_MLX5_DR_CREATE_ACTION_ASO', 'infiniband/mlx5dv.h',
+	'mlx5dv_dr_action_create_aso' ],
+	[ 'HAVE_INFINIBAND_VERBS_H', 'infiniband/verbs.h',
+	'INFINIBAND_VERBS_H' ],
 ]
 config = configuration_data()
 foreach arg:has_sym_args
Signature · 1 line
2.16.1.windows.4
#53 lore raw

PATCH v4 13/32 common/mlx5/linux: handle memory allocations with alignment

In reply to Tal Shnaiderman

From: Ophir Munk <[email protected]>

mlx5_malloc() API has an alignment parameter for system memory allocations. malloc() is called for non-aligned allocations and posix_memalign() is called for aligned allocations. When calling mlx5_free() there is no distinction whether the memory was originally allocated with or without alignment. Freeing a memory may be handled differently by operating systems. Therefore this commit wraps these APIs with OS specific calls: mlx5_os_malloc(), mlx5_os_free().

---
 drivers/common/mlx5/linux/mlx5_common_os.h | 38 ++++++++++++++++++++++++++++++
 drivers/common/mlx5/mlx5_malloc.c          | 14 +++++------
 2 files changed, 44 insertions(+), 8 deletions(-)
drivers/common/mlx5/linux/mlx5_common_os.h +38 -0
index f8b215cc29..bd44ecb7d6 100644
@@ -6,6 +6,7 @@
 #define RTE_PMD_MLX5_COMMON_OS_H_
 
 #include <stdio.h>
+#include <malloc.h>
 
 #include <rte_pci.h>
 #include <rte_debug.h>
@@ -16,6 +17,7 @@
 
 #include "mlx5_autoconf.h"
 #include "mlx5_glue.h"
+#include "mlx5_malloc.h"
 
 /**
  * Get device name. Given an ibv_device pointer - return a
@@ -224,4 +226,40 @@ mlx5_os_umem_dereg(void *pumem)
 {
 	return mlx5_glue->devx_umem_dereg(pumem);
 }
+
+/**
+ * Memory allocation optionally with alignment.
+ *
+ * @param[in] align
+ *    Alignment size (may be zero)
+ * @param[in] size
+ *    Size in bytes to allocate
+ *
+ * @return
+ *    Valid pointer to allocated memory, NULL in case of failure
+ */
+static inline void *
+mlx5_os_malloc(size_t align, size_t size)
+{
+	void *buf;
+
+	if (posix_memalign(&buf, align, size))
+		return NULL;
+	return buf;
+}
+
+/**
+ * This API de-allocates a memory that originally could have been
+ * allocated aligned or non-aligned. In Linux it is a wrapper
+ * around free().
+ *
+ * @param[in] addr
+ *    Pointer to address to free
+ *
+ */
+static inline void
+mlx5_os_free(void *addr)
+{
+	free(addr);
+}
 #endif /* RTE_PMD_MLX5_COMMON_OS_H_ */
drivers/common/mlx5/mlx5_malloc.c +6 -8
index 5a3267f730..9d30cedbaa 100644
@@ -9,6 +9,7 @@
 #include <string.h>
 
 #include "mlx5_common_utils.h"
+#include "mlx5_common_os.h"
 #include "mlx5_malloc.h"
 
 struct mlx5_sys_mem {
@@ -148,14 +149,11 @@ static void *
 mlx5_alloc_align(size_t size, unsigned int align, unsigned int zero)
 {
 	void *buf;
-	int ret;
-
-	ret = posix_memalign(&buf, align, size);
-	if (ret) {
-		DRV_LOG(ERR,
-			"Couldn't allocate buf size=%zu align=%u. Err=%d\n",
-			size, align, ret);
 
+	buf = mlx5_os_malloc(align, size);
+	if (!buf) {
+		DRV_LOG(ERR, "Couldn't allocate buf size=%zu align=%u.",
+			size, align);
 		return NULL;
 	}
 	if (zero)
@@ -264,7 +262,7 @@ mlx5_free(void *addr)
 		__atomic_add_fetch(&mlx5_sys_mem.free_sys, 1,
 				   __ATOMIC_RELAXED);
 #endif
-		free(addr);
+		mlx5_os_free(addr);
 	} else {
 #ifdef RTE_LIBRTE_MLX5_DEBUG
 		__atomic_add_fetch(&mlx5_sys_mem.free_rte, 1,
Signature · 1 line
2.16.1.windows.4
#54 lore raw

PATCH v4 14/32 common/mlx5/windows: handle memory allocations with alignment

In reply to Tal Shnaiderman

From: Ophir Munk <[email protected]>

This commit is the Windows equivalent of the Linux implementation. The APIs included in this commit: mlx5_os_malloc(), mlx5_os_free(). For memory allocations (with or without alignment) we always call _aligned_malloc(). Even if zero alignment was requested in the first place - we always select a minimal alignment value. In this way when the memory is free - it is always safe to call _aligned_free().

---
 drivers/common/mlx5/windows/mlx5_common_os.h | 51 ++++++++++++++++++++++++++++
 1 file changed, 51 insertions(+)
 create mode 100644 drivers/common/mlx5/windows/mlx5_common_os.h
drivers/common/mlx5/windows/mlx5_common_os.h new file +51 -0
new file mode 100644
index 0000000000..cce7c88c6a
@@ -0,0 +1,51 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright 2020 Mellanox Technologies, Ltd
+ */
+
+#ifndef RTE_PMD_MLX5_COMMON_OS_H_
+#define RTE_PMD_MLX5_COMMON_OS_H_
+
+#include <stdio.h>
+
+#include "mlx5_autoconf.h"
+#include "mlx5_glue.h"
+#include "mlx5_malloc.h"
+
+/**
+ * This API allocates aligned or non-aligned memory.  The free can be on either
+ * aligned or nonaligned memory.  To be protected - even though there may be no
+ * alignment - in Windows this API will unconditioanlly call _aligned_malloc()
+ * with at least a minimal alignment size.
+ *
+ * @param[in] align
+ *    The alignment value, which must be an integer power of 2 (or 0 for
+ *    non-alignment)
+ * @param[in] size
+ *    Size in bytes to allocate
+ *
+ * @return
+ *    Valid pointer to allocated memory, NULL in case of failure
+ */
+static inline void *
+mlx5_os_malloc(size_t align, size_t size)
+{
+	if (align < MLX5_MALLOC_ALIGNMENT)
+		align = MLX5_MALLOC_ALIGNMENT;
+	return _aligned_malloc(size, align);
+}
+
+/**
+ * This API de-allocates a memory that originally could have been allocated
+ * aligned or non-aligned. In Windows since the allocation was with
+ * _aligned_malloc() - it is safe to always call _aligned_free().
+ *
+ * @param[in] addr
+ *    Pointer to address to free
+ *
+ */
+static inline void
+mlx5_os_free(void *addr)
+{
+	_aligned_free(addr);
+}
+#endif /* RTE_PMD_MLX5_COMMON_OS_H_ */
Signature · 1 line
2.16.1.windows.4
#55 lore raw

PATCH v4 15/32 common/mlx5/linux: wrap event channel APIs with OS calls

In reply to Tal Shnaiderman

Wrap the API to create/destroy event channel and to subscribe an event with OS calls. In Linux those calls are implemented by glue functions while in Windows they are not supported.

---
 drivers/common/mlx5/linux/mlx5_common_os.h | 22 ++++++++++++++++++++++
 drivers/net/mlx5/mlx5_devx.c               |  8 ++++----
 drivers/net/mlx5/mlx5_txpp.c               |  6 +++---
 drivers/vdpa/mlx5/mlx5_vdpa_event.c        |  7 ++++---
 4 files changed, 33 insertions(+), 10 deletions(-)
drivers/common/mlx5/linux/mlx5_common_os.h +22 -0
index bd44ecb7d6..63f070d9c4 100644
@@ -227,6 +227,28 @@ mlx5_os_umem_dereg(void *pumem)
 	return mlx5_glue->devx_umem_dereg(pumem);
 }
 
+static inline void *
+mlx5_os_devx_create_event_channel(void *ctx, int flags)
+{
+	return mlx5_glue->devx_create_event_channel(ctx, flags);
+}
+
+static inline void
+mlx5_os_devx_destroy_event_channel(void *eventc)
+{
+	mlx5_glue->devx_destroy_event_channel(eventc);
+}
+
+static inline int
+mlx5_os_devx_subscribe_devx_event(void *eventc,
+				  void *obj,
+				  uint16_t events_sz, uint16_t events_num[],
+				  uint64_t cookie)
+{
+	return mlx5_glue->devx_subscribe_devx_event(eventc, obj, events_sz,
+						    events_num, cookie);
+}
+
 /**
  * Memory allocation optionally with alignment.
  *
drivers/net/mlx5/mlx5_devx.c +4 -4
index 235fd5798d..84a5c55ee0 100644
@@ -216,7 +216,7 @@ mlx5_rxq_devx_obj_release(struct mlx5_rxq_obj *rxq_obj)
 		claim_zero(mlx5_devx_cmd_destroy(rxq_obj->rq));
 		claim_zero(mlx5_devx_cmd_destroy(rxq_obj->devx_cq));
 		if (rxq_obj->devx_channel)
-			mlx5_glue->devx_destroy_event_channel
+			mlx5_os_devx_destroy_event_channel
 							(rxq_obj->devx_channel);
 		mlx5_rxq_release_devx_rq_resources(rxq_obj->rxq_ctrl);
 		mlx5_rxq_release_devx_cq_resources(rxq_obj->rxq_ctrl);
@@ -533,7 +533,7 @@ mlx5_rxq_create_devx_cq_resources(struct rte_eth_dev *dev, uint16_t idx)
 	rxq_data->cqe_n = log_cqe_n;
 	rxq_data->cqn = cq_obj->id;
 	if (rxq_ctrl->obj->devx_channel) {
-		ret = mlx5_glue->devx_subscribe_devx_event
+		ret = mlx5_os_devx_subscribe_devx_event
 						(rxq_ctrl->obj->devx_channel,
 						 cq_obj->obj,
 						 sizeof(event_nums),
@@ -644,7 +644,7 @@ mlx5_rxq_devx_obj_new(struct rte_eth_dev *dev, uint16_t idx)
 		int devx_ev_flag =
 			  MLX5DV_DEVX_CREATE_EVENT_CHANNEL_FLAGS_OMIT_EV_DATA;
 
-		tmpl->devx_channel = mlx5_glue->devx_create_event_channel
+		tmpl->devx_channel = mlx5_os_devx_create_event_channel
 								(priv->sh->ctx,
 								 devx_ev_flag);
 		if (!tmpl->devx_channel) {
@@ -686,7 +686,7 @@ mlx5_rxq_devx_obj_new(struct rte_eth_dev *dev, uint16_t idx)
 	if (tmpl->devx_cq)
 		claim_zero(mlx5_devx_cmd_destroy(tmpl->devx_cq));
 	if (tmpl->devx_channel)
-		mlx5_glue->devx_destroy_event_channel(tmpl->devx_channel);
+		mlx5_os_devx_destroy_event_channel(tmpl->devx_channel);
 	mlx5_rxq_release_devx_rq_resources(rxq_ctrl);
 	mlx5_rxq_release_devx_cq_resources(rxq_ctrl);
 	rte_errno = ret; /* Restore rte_errno. */
drivers/net/mlx5/mlx5_txpp.c +3 -3
index 749529c410..726bdc6ae1 100644
@@ -37,7 +37,7 @@ static void
 mlx5_txpp_destroy_event_channel(struct mlx5_dev_ctx_shared *sh)
 {
 	if (sh->txpp.echan) {
-		mlx5_glue->devx_destroy_event_channel(sh->txpp.echan);
+		mlx5_os_devx_destroy_event_channel(sh->txpp.echan);
 		sh->txpp.echan = NULL;
 	}
 }
@@ -47,7 +47,7 @@ static int
 mlx5_txpp_create_event_channel(struct mlx5_dev_ctx_shared *sh)
 {
 	MLX5_ASSERT(!sh->txpp.echan);
-	sh->txpp.echan = mlx5_glue->devx_create_event_channel(sh->ctx,
+	sh->txpp.echan = mlx5_os_devx_create_event_channel(sh->ctx,
 			MLX5DV_DEVX_CREATE_EVENT_CHANNEL_FLAGS_OMIT_EV_DATA);
 	if (!sh->txpp.echan) {
 		rte_errno = errno;
@@ -937,7 +937,7 @@ mlx5_txpp_start_service(struct mlx5_dev_ctx_shared *sh)
 		return -rte_errno;
 	}
 	/* Subscribe CQ event to the event channel controlled by the driver. */
-	ret = mlx5_glue->devx_subscribe_devx_event(sh->txpp.echan,
+	ret = mlx5_os_devx_subscribe_devx_event(sh->txpp.echan,
 						   sh->txpp.rearm_queue.cq->obj,
 						   sizeof(event_nums),
 						   event_nums, 0);
drivers/vdpa/mlx5/mlx5_vdpa_event.c +4 -3
index 3aeaeb893f..fd6150928b 100644
@@ -15,6 +15,7 @@
 #include <rte_alarm.h>
 
 #include <mlx5_common.h>
+#include <mlx5_common_os.h>
 #include <mlx5_glue.h>
 
 #include "mlx5_vdpa_utils.h"
@@ -43,7 +44,7 @@ mlx5_vdpa_event_qp_global_release(struct mlx5_vdpa_priv *priv)
 		       sizeof(out.buf)) >=
 		       (ssize_t)sizeof(out.event_resp.cookie))
 			;
-		mlx5_glue->devx_destroy_event_channel(priv->eventc);
+		mlx5_os_devx_destroy_event_channel(priv->eventc);
 		priv->eventc = NULL;
 	}
 #endif
@@ -63,7 +64,7 @@ mlx5_vdpa_event_qp_global_prepare(struct mlx5_vdpa_priv *priv)
 		DRV_LOG(ERR, "Failed to query EQ number %d.", rte_errno);
 		return -1;
 	}
-	priv->eventc = mlx5_glue->devx_create_event_channel(priv->ctx,
+	priv->eventc = mlx5_os_devx_create_event_channel(priv->ctx,
 			   MLX5DV_DEVX_CREATE_EVENT_CHANNEL_FLAGS_OMIT_EV_DATA);
 	if (!priv->eventc) {
 		rte_errno = errno;
@@ -176,7 +177,7 @@ mlx5_vdpa_cq_create(struct mlx5_vdpa_priv *priv, uint16_t log_desc_n,
 	cq->cq_ci = 0;
 	rte_spinlock_init(&cq->sl);
 	/* Subscribe CQ event to the event channel controlled by the driver. */
-	ret = mlx5_glue->devx_subscribe_devx_event(priv->eventc, cq->cq->obj,
+	ret = mlx5_os_devx_subscribe_devx_event(priv->eventc, cq->cq->obj,
 						   sizeof(event_nums),
 						   event_nums,
 						   (uint64_t)(uintptr_t)cq);
Signature · 1 line
2.16.1.windows.4
#56 lore raw

PATCH v4 16/32 common/mlx5: add Windows exports file

In reply to Tal Shnaiderman

File drivers/common/mlx5/rte_common_mlx5_exports.def contains mlx5 Windows exported symbols under common/mlx5 directory (DLL file name librte_common_mlx5*.dll). It is the equivalent of Linux map file rte_common_mlx5_version.map but the list of symbols may be different between the two operating systems.

---
 drivers/common/mlx5/rte_common_mlx5_exports.def | 62 +++++++++++++++++++++++++
 1 file changed, 62 insertions(+)
 create mode 100644 drivers/common/mlx5/rte_common_mlx5_exports.def
drivers/common/mlx5/rte_common_mlx5_exports.def new file +62 -0
new file mode 100644
index 0000000000..23984b7abd
@@ -0,0 +1,62 @@
+EXPORTS
+	haswell_broadwell_cpu
+
+	mlx5_common_init
+
+	mlx5_create_mr_ext
+
+	mlx5_devx_cmd_create_cq
+	mlx5_devx_cmd_create_flex_parser
+	mlx5_devx_cmd_create_qp
+	mlx5_devx_cmd_create_rq
+	mlx5_devx_cmd_create_rqt
+	mlx5_devx_cmd_create_sq
+	mlx5_devx_cmd_create_tir
+	mlx5_devx_cmd_create_td
+	mlx5_devx_cmd_create_tis
+	mlx5_devx_cmd_create_virtq
+	mlx5_devx_cmd_destroy
+	mlx5_devx_cmd_flow_counter_alloc
+	mlx5_devx_cmd_flow_counter_query
+	mlx5_devx_cmd_flow_dump
+	mlx5_devx_cmd_mkey_create
+	mlx5_devx_cmd_modify_qp_state
+	mlx5_devx_cmd_modify_rq
+	mlx5_devx_cmd_modify_rqt
+	mlx5_devx_cmd_modify_sq
+	mlx5_devx_cmd_modify_tir
+	mlx5_devx_cmd_modify_virtq
+	mlx5_devx_cmd_qp_query_tis_td
+	mlx5_devx_cmd_query_hca_attr
+	mlx5_devx_cmd_query_parse_samples
+	mlx5_devx_cmd_query_virtq
+	mlx5_devx_cmd_register_read
+	mlx5_devx_get_out_command_status
+	mlx5_devx_cmd_create_flow_hit_aso_obj
+
+	mlx5_get_dbr
+
+	mlx5_malloc_mem_select
+	mlx5_mr_btree_init
+	mlx5_mr_btree_free
+	mlx5_mr_btree_dump
+	mlx5_mr_addr2mr_bh
+	mlx5_mr_release_cache
+	mlx5_mr_dump_cache
+	mlx5_mr_rebuild_cache
+	mlx5_mr_insert_cache
+	mlx5_mr_lookup_cache
+	mlx5_mr_lookup_list
+	mlx5_mr_create_primary
+	mlx5_mr_flush_local_cache
+	mlx5_mp_req_queue_state_modify
+	mlx5_mr_free
+
+	mlx5_pci_driver_register
+
+	mlx5_release_dbr
+
+	mlx5_malloc
+	mlx5_realloc
+	mlx5_free
+
Signature · 1 line
2.16.1.windows.4
#57 lore raw

PATCH v4 17/32 common/mlx5: extend DevX query hca attributes command

In reply to Tal Shnaiderman

Extend DevX API mlx5_devx_cmd_query_hca_attr() to report on max number of available objects including: CQ, QP, PD, SRQ.

---
 drivers/common/mlx5/mlx5_devx_cmds.c | 11 +++++++++++
 drivers/common/mlx5/mlx5_devx_cmds.h | 10 +++++++++-
 drivers/common/mlx5/mlx5_prm.h       |  1 +
 3 files changed, 21 insertions(+), 1 deletion(-)
drivers/common/mlx5/mlx5_devx_cmds.c +11 -0
index 9c1d1883ea..36d3a421aa 100644
@@ -720,6 +720,14 @@ mlx5_devx_cmd_query_hca_attr(void *ctx,
 	attr->flow_hit_aso = !!(MLX5_GET64(cmd_hca_cap, hcattr,
 					   general_obj_types) &
 				MLX5_GENERAL_OBJ_TYPES_CAP_FLOW_HIT_ASO);
+	attr->log_max_cq = MLX5_GET(cmd_hca_cap, hcattr, log_max_cq);
+	attr->log_max_qp = MLX5_GET(cmd_hca_cap, hcattr, log_max_qp);
+	attr->log_max_cq_sz = MLX5_GET(cmd_hca_cap, hcattr, log_max_cq_sz);
+	attr->log_max_qp_sz = MLX5_GET(cmd_hca_cap, hcattr, log_max_qp_sz);
+	attr->log_max_mrw_sz = MLX5_GET(cmd_hca_cap, hcattr, log_max_mrw_sz);
+	attr->log_max_pd = MLX5_GET(cmd_hca_cap, hcattr, log_max_pd);
+	attr->log_max_srq = MLX5_GET(cmd_hca_cap, hcattr, log_max_srq);
+	attr->log_max_srq_sz = MLX5_GET(cmd_hca_cap, hcattr, log_max_srq_sz);
 	if (attr->qos.sup) {
 		MLX5_SET(query_hca_cap_in, in, op_mod,
 			 MLX5_GET_HCA_CAP_OP_MOD_QOS_CAP |
@@ -834,6 +842,9 @@ mlx5_devx_cmd_query_hca_attr(void *ctx,
 	attr->tunnel_stateless_gtp = MLX5_GET
 					(per_protocol_networking_offload_caps,
 					 hcattr, tunnel_stateless_gtp);
+	attr->rss_ind_tbl_cap = MLX5_GET
+					(per_protocol_networking_offload_caps,
+					 hcattr, rss_ind_tbl_cap);
 	if (attr->wqe_inline_mode != MLX5_CAP_INLINE_MODE_VPORT_CONTEXT)
 		return 0;
 	if (attr->eth_virt) {
drivers/common/mlx5/mlx5_devx_cmds.h +9 -1
index 726e9f5192..5056d86ed9 100644
@@ -117,6 +117,15 @@ struct mlx5_hca_attr {
 	uint32_t log_max_ft_sampler_num:8;
 	struct mlx5_hca_qos_attr qos;
 	struct mlx5_hca_vdpa_attr vdpa;
+	int log_max_qp_sz;
+	int log_max_cq_sz;
+	int log_max_qp;
+	int log_max_cq;
+	uint32_t log_max_pd;
+	uint32_t log_max_mrw_sz;
+	uint32_t log_max_srq;
+	uint32_t log_max_srq_sz;
+	uint32_t rss_ind_tbl_cap;
 };
 
 struct mlx5_devx_wq_attr {
@@ -495,7 +504,6 @@ struct mlx5_devx_obj *mlx5_devx_cmd_create_virtio_q_counters(void *ctx);
 __rte_internal
 int mlx5_devx_cmd_query_virtio_q_counters(struct mlx5_devx_obj *couners_obj,
 				  struct mlx5_devx_virtio_q_couners_attr *attr);
-
 __rte_internal
 struct mlx5_devx_obj *mlx5_devx_cmd_create_flow_hit_aso_obj(void *ctx,
 							    uint32_t pd);
drivers/common/mlx5/mlx5_prm.h +1 -0
index 58d180486e..585e9d1c05 100644
@@ -665,6 +665,7 @@ typedef uint8_t u8;
 #define MLX5_GET64(typ, p, fld) rte_be_to_cpu_64(*((rte_be64_t *)(p) + \
 						   __mlx5_64_off(typ, fld)))
 #define MLX5_FLD_SZ_BYTES(typ, fld) (__mlx5_bit_sz(typ, fld) / 8)
+#define MLX5_UN_SZ_BYTES(typ) (sizeof(union mlx5_ifc_##typ##_bits) / 8)
 
 struct mlx5_ifc_fte_match_set_misc_bits {
 	u8 gre_c_present[0x1];
Signature · 1 line
2.16.1.windows.4
#58 lore raw

PATCH v4 18/32 common/mlx5: add DevX alloc PD command

In reply to Tal Shnaiderman

Add a new DevX API mlx5_devx_cmd_alloc_pd() that creates a new protection domain (PD).

---
 drivers/common/mlx5/mlx5_devx_cmds.c            | 35 ++++++++++++++++++++++++
 drivers/common/mlx5/mlx5_devx_cmds.h            |  2 ++
 drivers/common/mlx5/mlx5_prm.h                  | 36 +++++++++++++++++++++++++
 drivers/common/mlx5/rte_common_mlx5_exports.def |  1 +
 drivers/common/mlx5/version.map                 |  1 +
 5 files changed, 75 insertions(+)
drivers/common/mlx5/mlx5_devx_cmds.c +35 -0
index 36d3a421aa..12f51a940c 100644
@@ -2055,3 +2055,38 @@ mlx5_devx_cmd_create_flow_hit_aso_obj(void *ctx, uint32_t pd)
 	flow_hit_aso_obj->id = MLX5_GET(general_obj_out_cmd_hdr, out, obj_id);
 	return flow_hit_aso_obj;
 }
+
+/*
+ * Create PD using DevX API.
+ *
+ * @param[in] ctx
+ *   Context returned from mlx5 open_device() glue function.
+ *
+ * @return
+ *   The DevX object created, NULL otherwise and rte_errno is set.
+ */
+struct mlx5_devx_obj *
+mlx5_devx_cmd_alloc_pd(void *ctx)
+{
+	struct mlx5_devx_obj *ppd =
+		mlx5_malloc(MLX5_MEM_ZERO, sizeof(*ppd), 0, SOCKET_ID_ANY);
+	u32 in[MLX5_ST_SZ_DW(alloc_pd_in)] = {0};
+	u32 out[MLX5_ST_SZ_DW(alloc_pd_out)] = {0};
+
+	if (!ppd) {
+		DRV_LOG(ERR, "Failed to allocate PD data.");
+		rte_errno = ENOMEM;
+		return NULL;
+	}
+	MLX5_SET(alloc_pd_in, in, opcode, MLX5_CMD_OP_ALLOC_PD);
+	ppd->obj = mlx5_glue->devx_obj_create(ctx, in, sizeof(in),
+				out, sizeof(out));
+	if (!ppd->obj) {
+		mlx5_free(ppd);
+		DRV_LOG(ERR, "Failed to allocate PD Obj using DevX.");
+		rte_errno = errno;
+		return NULL;
+	}
+	ppd->id = MLX5_GET(alloc_pd_out, out, pd);
+	return ppd;
+}
drivers/common/mlx5/mlx5_devx_cmds.h +2 -0
index 5056d86ed9..8277fdbc39 100644
@@ -508,4 +508,6 @@ __rte_internal
 struct mlx5_devx_obj *mlx5_devx_cmd_create_flow_hit_aso_obj(void *ctx,
 							    uint32_t pd);
 
+__rte_internal
+struct mlx5_devx_obj *mlx5_devx_cmd_alloc_pd(void *ctx);
 #endif /* RTE_PMD_MLX5_DEVX_CMDS_H_ */
drivers/common/mlx5/mlx5_prm.h +36 -0
index 585e9d1c05..4ddf865743 100644
@@ -844,6 +844,8 @@ enum {
 	MLX5_CMD_OP_SUSPEND_QP = 0x50F,
 	MLX5_CMD_OP_RESUME_QP = 0x510,
 	MLX5_CMD_OP_QUERY_NIC_VPORT_CONTEXT = 0x754,
+	MLX5_CMD_OP_ALLOC_PD = 0x800,
+	MLX5_CMD_OP_DEALLOC_PD = 0x801,
 	MLX5_CMD_OP_ACCESS_REGISTER = 0x805,
 	MLX5_CMD_OP_ALLOC_TRANSPORT_DOMAIN = 0x816,
 	MLX5_CMD_OP_CREATE_TIR = 0x900,
@@ -2772,6 +2774,40 @@ struct mlx5_ifc_init2init_qp_in_bits {
 	u8 reserved_at_800[0x80];
 };
 
+struct mlx5_ifc_dealloc_pd_out_bits {
+	u8 status[0x8];
+	u8 reserved_0[0x18];
+	u8 syndrome[0x20];
+	u8 reserved_1[0x40];
+};
+
+struct mlx5_ifc_dealloc_pd_in_bits {
+	u8 opcode[0x10];
+	u8 reserved_0[0x10];
+	u8 reserved_1[0x10];
+	u8 op_mod[0x10];
+	u8 reserved_2[0x8];
+	u8 pd[0x18];
+	u8 reserved_3[0x20];
+};
+
+struct mlx5_ifc_alloc_pd_out_bits {
+	u8 status[0x8];
+	u8 reserved_0[0x18];
+	u8 syndrome[0x20];
+	u8 reserved_1[0x8];
+	u8 pd[0x18];
+	u8 reserved_2[0x20];
+};
+
+struct mlx5_ifc_alloc_pd_in_bits {
+	u8 opcode[0x10];
+	u8 reserved_0[0x10];
+	u8 reserved_1[0x10];
+	u8 op_mod[0x10];
+	u8 reserved_2[0x40];
+};
+
 #ifdef PEDANTIC
 #pragma GCC diagnostic ignored "-Wpedantic"
 #endif
drivers/common/mlx5/rte_common_mlx5_exports.def +1 -0
index 23984b7abd..15aafc3809 100644
@@ -5,6 +5,7 @@ EXPORTS
 
 	mlx5_create_mr_ext
 
+	mlx5_devx_cmd_alloc_pd
 	mlx5_devx_cmd_create_cq
 	mlx5_devx_cmd_create_flex_parser
 	mlx5_devx_cmd_create_qp
drivers/common/mlx5/version.map +1 -0
index 17dd11f635..fb3952bbc6 100644
@@ -10,6 +10,7 @@ INTERNAL {
 
 	mlx5_dev_to_pci_addr;
 
+	mlx5_devx_cmd_alloc_pd;
 	mlx5_devx_cmd_create_cq;
 	mlx5_devx_cmd_create_flex_parser;
 	mlx5_devx_cmd_create_qp;
Signature · 1 line
2.16.1.windows.4
#59 lore raw

PATCH v4 19/32 common/mlx5/windows: add glue functions APIs

In reply to Tal Shnaiderman

Windows glue functions are added to file mlx5/windows/mlx5_glue.c. The following APIs are supported:
get_device_list, free_device_list, open_device, close_device, query_device, query_hca_iseg, devx_obj_create, devx_obj_destroy, devx_obj_query, devx_obj_modify, devx_general_cmd, devx_umem_reg, devx_umem_dereg, devx_alloc_uar, devx_free_uar, devx_fs_rule_add, devx_fs_rule_del, devx_query_eqn
New added files:
mlx5_win_defs.h - this file imports missing definitions from Linux rdma-core library and Linux OS.
mlx5_win_ext.h - this file contains structs that enable a unified Linux/Windows API. Each struct has an equivalent (but different) Linux struct. By calling with 'void *' pointers - the Linux/Windows API is identical.

---
 drivers/common/mlx5/rte_common_mlx5_exports.def |   1 +
 drivers/common/mlx5/windows/mlx5_glue.c         | 304 ++++++++++++++++++++++++
 drivers/common/mlx5/windows/mlx5_glue.h         |  58 +++++
 drivers/common/mlx5/windows/mlx5_win_defs.h     |  25 ++
 drivers/common/mlx5/windows/mlx5_win_ext.h      |  34 +++
 5 files changed, 422 insertions(+)
 create mode 100644 drivers/common/mlx5/windows/mlx5_glue.c
 create mode 100644 drivers/common/mlx5/windows/mlx5_glue.h
 create mode 100644 drivers/common/mlx5/windows/mlx5_win_defs.h
 create mode 100644 drivers/common/mlx5/windows/mlx5_win_ext.h
drivers/common/mlx5/rte_common_mlx5_exports.def +1 -0
index 15aafc3809..2f6aab133b 100644
@@ -36,6 +36,7 @@ EXPORTS
 	mlx5_devx_cmd_create_flow_hit_aso_obj
 
 	mlx5_get_dbr
+	mlx5_glue
 
 	mlx5_malloc_mem_select
 	mlx5_mr_btree_init
drivers/common/mlx5/windows/mlx5_glue.c new file +304 -0

304 lines not on this page · raw message

drivers/common/mlx5/windows/mlx5_glue.h new file +58 -0

58 lines not on this page · raw message

drivers/common/mlx5/windows/mlx5_win_defs.h new file +25 -0
new file mode 100644
index 0000000000..72a3131f5e
@@ -0,0 +1,25 @@
+/*
+ * Copyright (C) Mellanox Technologies, Ltd. 2001-2020.
+ *
+ */
+#ifndef __MLX5_WIN_DEFS_H__
+#define __MLX5_WIN_DEFS_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+enum {
+	MLX5_CQE_OWNER_MASK	= 1,
+	MLX5_CQE_REQ		= 0,
+	MLX5_CQE_RESP_WR_IMM	= 1,
+	MLX5_CQE_RESP_SEND	= 2,
+	MLX5_CQE_RESP_SEND_IMM	= 3,
+	MLX5_CQE_RESP_SEND_INV	= 4,
+	MLX5_CQE_RESIZE_CQ	= 5,
+	MLX5_CQE_NO_PACKET	= 6,
+	MLX5_CQE_REQ_ERR	= 13,
+	MLX5_CQE_RESP_ERR	= 14,
+	MLX5_CQE_INVALID	= 15,
+};
+#endif /* __MLX5_WIN_DEFS_H__ */
drivers/common/mlx5/windows/mlx5_win_ext.h new file +34 -0
new file mode 100644
index 0000000000..0e74910e9d
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) Mellanox Technologies, Ltd. 2001-2020.
+ *
+ */
+#ifndef __MLX5_WIN_ETX_H__
+#define __MLX5_WIN_ETX_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "mlx5devx.h"
+
+typedef struct mlx5_context {
+	devx_device_ctx        *devx_ctx;
+	struct devx_device mlx5_dev;
+
+} mlx5_context_st;
+
+typedef struct {
+	devx_device_ctx *devx_ctx;
+	struct devx_obj_handle *obj;
+} mlx5_devx_obj_st;
+
+struct mlx5_devx_umem {
+	void                   *addr;
+	struct devx_obj_handle *umem_hdl;
+	uint32_t                umem_id;
+};
+
+#define GET_DEVX_CTX(ctx) (((mlx5_context_st *)ctx)->devx_ctx)
+#define GET_OBJ_CTX(obj)  (((mlx5_devx_obj_st *)obj)->devx_ctx)
+
+#endif /* __MLX5_WIN_ETX_H__ */
Signature · 1 line
2.16.1.windows.4
#60 lore raw

PATCH v4 20/32 mlx5/windows: add mlx5 meson file

In reply to Tal Shnaiderman

File drivers/common/mlx5/windows/meson.build is added to enable mlx5 source files compilation under common windows directory.
A Devx SDK tool must be installed to export two external H files:
mlx5devx.h and mlx5_ifc_devx.h. The installation is based on environment variable DEVX_INC_PATH. In addition a DLL lib file is installed based on environment variable DEVX_LIB_PATH. The meson file is using the environment variables for compilation and linkage.

---
 drivers/common/mlx5/windows/meson.build | 42 +++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)
 create mode 100644 drivers/common/mlx5/windows/meson.build
drivers/common/mlx5/windows/meson.build new file +42 -0
new file mode 100644
index 0000000000..2b2aa3b097
@@ -0,0 +1,42 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright 2019 Mellanox Technologies, Ltd
+
+includes += include_directories('.')
+
+allow_experimental_apis = true
+sources += files(
+	'mlx5_glue.c',
+)
+
+res_lib = run_command(python3, '-c', 'import os; print(os.environ["DEVX_LIB_PATH"])')
+res_inc = run_command(python3, '-c', 'import os; print(os.environ["DEVX_INC_PATH"])')
+
+if (res_lib.returncode() != 0 or res_inc.returncode() != 0)
+	build = false
+	reason = 'DevX environment variables are not set, DEVX_LIB_PATH and DEVX_INC_PATH vars must be exported'
+	subdir_done()
+endif
+
+devx_lib_dir = res_lib.stdout().strip()
+devx_inc_dir = res_inc.stdout().strip()
+
+ext_deps += cc.find_library('mlx5devx', dirs: devx_lib_dir, required: true)
+includes += include_directories(devx_inc_dir)
+cflags_options = [
+	'-std=c11',
+	'-Wno-strict-prototypes',
+	'-D_BSD_SOURCE',
+	'-D_DEFAULT_SOURCE',
+	'-D_XOPEN_SOURCE=600'
+]
+foreach option:cflags_options
+	if cc.has_argument(option)
+		cflags += option
+	endif
+endforeach
+if get_option('buildtype').contains('debug')
+	cflags += [ '-pedantic', '-DPEDANTIC' ]
+else
+	cflags += [ '-UPEDANTIC' ]
+endif
+
Signature · 1 line
2.16.1.windows.4
#61 lore raw

PATCH v4 21/32 mlx5/windows: add initialization routine for external lib

In reply to Tal Shnaiderman

From: Ophir Munk <[email protected]>

Add function mlx5_glue_constructor() as an initialization routine for run-time dependency on external lib. Currently the routine has an empty body. It is used for compatibility with Linux.

---
 drivers/common/mlx5/windows/meson.build      |  1 +
 drivers/common/mlx5/windows/mlx5_common_os.c | 24 ++++++++++++++++++++++++
 2 files changed, 25 insertions(+)
 create mode 100644 drivers/common/mlx5/windows/mlx5_common_os.c
drivers/common/mlx5/windows/meson.build +1 -0
index 2b2aa3b097..9e74ebdea3 100644
@@ -6,6 +6,7 @@ includes += include_directories('.')
 allow_experimental_apis = true
 sources += files(
 	'mlx5_glue.c',
+	'mlx5_common_os.c',
 )
 
 res_lib = run_command(python3, '-c', 'import os; print(os.environ["DEVX_LIB_PATH"])')
drivers/common/mlx5/windows/mlx5_common_os.c new file +24 -0
new file mode 100644
index 0000000000..5707fb60c3
@@ -0,0 +1,24 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright 2020 Mellanox Technologies, Ltd
+ */
+
+#include <unistd.h>
+#include <string.h>
+#include <stdio.h>
+
+#include <rte_errno.h>
+#include <rte_mempool.h>
+#include <rte_malloc.h>
+#include <rte_errno.h>
+
+#include "mlx5_devx_cmds.h"
+#include "mlx5_common_utils.h"
+#include <mlx5_common.h>
+
+/**
+ * Initialization routine for run-time dependency on external lib
+ */
+void
+mlx5_glue_constructor(void)
+{
+}
Signature · 1 line
2.16.1.windows.4
#62 lore raw

PATCH v4 22/32 mlx5/windows: generate file mlx5_autoconf.h

In reply to Tal Shnaiderman

From: Ophir Munk <[email protected]>

File mlx5_autoconf.h is generated under Windows to maintain compatibility with the Linux build system. This file is included in Linux/Windows shared source files therefore it is required. Currently the file is created empty.

---
 drivers/common/mlx5/windows/meson.build | 3 +++
 1 file changed, 3 insertions(+)
drivers/common/mlx5/windows/meson.build +3 -0
index 9e74ebdea3..5ac5724b40 100644
@@ -41,3 +41,6 @@ else
 	cflags += [ '-UPEDANTIC' ]
 endif
 
+# Generate an empty mlx5_autoconf.h file for compatibility with Linux
+config = configuration_data()
+configure_file(output : 'mlx5_autoconf.h', configuration : config)
Signature · 1 line
2.16.1.windows.4
#63 lore raw

PATCH v4 23/32 common/mlx5/windows: extend PRM match_param_bits struct

In reply to Tal Shnaiderman

Add reserved size to PRM 'struct mlx5_ifc_fte_match_param_bits' for non Linux OS. Windows drivers require this extension since their expected size should match the actual struct size. Linux drivers do not require this extension and already use calculations based on the shorter size. Use a static assert to verify that the PRM fte_match_param struct size remains correct.

---
 drivers/common/mlx5/mlx5_prm.h          | 7 +++++++
 drivers/common/mlx5/windows/mlx5_glue.c | 3 +++
 2 files changed, 10 insertions(+)
drivers/common/mlx5/mlx5_prm.h +7 -0
index 4ddf865743..27a4e4f0f1 100644
@@ -815,6 +815,13 @@ struct mlx5_ifc_fte_match_param_bits {
 	struct mlx5_ifc_fte_match_set_misc2_bits misc_parameters_2;
 	struct mlx5_ifc_fte_match_set_misc3_bits misc_parameters_3;
 	struct mlx5_ifc_fte_match_set_misc4_bits misc_parameters_4;
+/*
+ * Add reserved bit to match the struct size with the size defined in PRM.
+ * This extension is not required in Linux.
+ */
+#ifndef HAVE_INFINIBAND_VERBS_H
+	u8 reserved_0[0x400];
+#endif
 };
 
 enum {
drivers/common/mlx5/windows/mlx5_glue.c +3 -0
index 7f8a00aaa7..3896cf0932 100644
@@ -256,6 +256,9 @@ mlx5_glue_devx_free_uar(void *uar)
 	devx_free_uar((devx_uar_handle *)uar);
 }
 
+static_assert(MLX5_ST_SZ_BYTES(fte_match_param) == 0x200,
+	"PRM size of fte_match_param is broken! cannot compile Windows!");
+
 static void*
 mlx5_glue_devx_fs_rule_add(void *ctx, void *in, uint32_t inlen)
 
Signature · 1 line
2.16.1.windows.4
#64 lore raw

PATCH v4 24/32 common/mlx5/windows: add getter functions

In reply to Tal Shnaiderman

From: Ophir Munk <[email protected]>

Add file mlx5/windows/mlx5_common_os.h the equivalent of Linux file mlx5/linux/mlx5_common_os.h. It contains getters functions mlx5_os_get_dev_device_name, mlx5_os_get_ctx_device_name, mlx5_os_get_ctx_device_path, mlx5_os_get_umem_id, mlx5_os_get_devx_channel_fd.

---
 drivers/common/mlx5/windows/mlx5_common_os.h | 91 ++++++++++++++++++++++++++++
 1 file changed, 91 insertions(+)
drivers/common/mlx5/windows/mlx5_common_os.h +91 -0
index cce7c88c6a..2abdb2c3ae 100644
@@ -48,4 +48,95 @@ mlx5_os_free(void *addr)
 {
 	_aligned_free(addr);
 }
+
+/**
+ * Get fd. Given a pointer to DevX channel object of type
+ * 'struct mlx5dv_devx_event_channel*' - return its fd.
+ * Under Windows it is a stub.
+ *
+ * @param[in] channel
+ *    Pointer to channel object.
+ *
+ * @return
+ *    0
+ */
+static inline int
+mlx5_os_get_devx_channel_fd(void *channel)
+{
+	if (!channel)
+		return 0;
+	return 0;
+}
+
+/**
+ * Get device name. Given a device pointer - return a
+ * pointer to the corresponding device name.
+ *
+ * @param[in] dev
+ *   Pointer to device.
+ *
+ * @return
+ *   Pointer to device name if dev is valid, NULL otherwise.
+ */
+static inline const char *
+mlx5_os_get_dev_device_name(void *dev)
+{
+	if (!dev)
+		return NULL;
+	return ((struct devx_device *)dev)->name;
+}
+
+/**
+ * Get device name. Given a context pointer - return a
+ * pointer to the corresponding device name.
+ *
+ * @param[in] ctx
+ *   Pointer to context.
+ *
+ * @return
+ *   Pointer to device name if ctx is valid, NULL otherwise.
+ */
+static inline const char *
+mlx5_os_get_ctx_device_name(void *ctx)
+{
+	if (!ctx)
+		return NULL;
+	return ((mlx5_context_st *)ctx)->mlx5_dev.name;
+}
+
+/**
+ * Get a device path name. Given acontext pointer - return a
+ * pointer to the corresponding device path name.
+ *
+ * @param[in] ctx
+ *   Pointer to context.
+ *
+ * @return
+ *   Pointer to device path name if ctx is valid, NULL otherwise.
+ */
+
+static inline const char *
+mlx5_os_get_ctx_device_path(void *ctx)
+{
+	if (!ctx)
+		return NULL;
+	return ((mlx5_context_st *)ctx)->mlx5_dev.dev_pnp_id;
+}
+
+/**
+ * Get umem id. Given a pointer to umem object of type return its id.
+ *
+ * @param[in] umem
+ *    Pointer to umem object.
+ *
+ * @return
+ *    The umem id if umem is valid, 0 otherwise.
+ */
+static inline uint32_t
+mlx5_os_get_umem_id(void *umem)
+{
+	if (!umem)
+		return 0;
+	return ((struct mlx5_devx_umem *)umem)->umem_id;
+}
 #endif /* RTE_PMD_MLX5_COMMON_OS_H_ */
Signature · 1 line
2.16.1.windows.4
#65 lore raw

PATCH v4 25/32 common/mlx5/windows: add OS alloc/dealloc pd

In reply to Tal Shnaiderman

Implement Windows API mlx5_os_alloc_pd() and mlx5_os_dealloc_pd(). They are equivalent to the Linux implementation in [1].

[1]
("net/mlx5: wrap glue alloc/dealloc PD with OS calls")

---
 drivers/common/mlx5/rte_common_mlx5_exports.def |  3 +-
 drivers/common/mlx5/windows/mlx5_common_os.c    | 48 +++++++++++++++++++++++++
 drivers/common/mlx5/windows/mlx5_common_os.h    |  3 ++
 drivers/common/mlx5/windows/mlx5_win_ext.h      |  6 ++++
 4 files changed, 59 insertions(+), 1 deletion(-)
drivers/common/mlx5/rte_common_mlx5_exports.def +2 -1
index 2f6aab133b..5db1eaa48c 100644
@@ -61,4 +61,5 @@ EXPORTS
 	mlx5_malloc
 	mlx5_realloc
 	mlx5_free
-
+	mlx5_os_alloc_pd
+	mlx5_os_dealloc_pd
drivers/common/mlx5/windows/mlx5_common_os.c +48 -0

51 lines not on this page · raw message

drivers/common/mlx5/windows/mlx5_common_os.h +3 -0
index 2abdb2c3ae..f47351ec41 100644
@@ -139,4 +139,7 @@ mlx5_os_get_umem_id(void *umem)
 		return 0;
 	return ((struct mlx5_devx_umem *)umem)->umem_id;
 }
+
+void *mlx5_os_alloc_pd(void *ctx);
+int mlx5_os_dealloc_pd(void *pd);
 #endif /* RTE_PMD_MLX5_COMMON_OS_H_ */
drivers/common/mlx5/windows/mlx5_win_ext.h +6 -0
index 0e74910e9d..8e697b30c1 100644
@@ -28,6 +28,12 @@ struct mlx5_devx_umem {
 	uint32_t                umem_id;
 };
 
+struct mlx5_pd {
+	void                   *obj;
+	uint32_t                pdn;
+	devx_device_ctx        *devx_ctx;
+};
+
 #define GET_DEVX_CTX(ctx) (((mlx5_context_st *)ctx)->devx_ctx)
 #define GET_OBJ_CTX(obj)  (((mlx5_devx_obj_st *)obj)->devx_ctx)
 
Signature · 1 line
2.16.1.windows.4
#66 lore raw

PATCH v4 26/32 common/mlx5/windows: add OS umem reg/dereg API

In reply to Tal Shnaiderman

Implement Windows API mlx5_os_umem_reg() and mlx5_os_umem_dereg(). They are equivalent to the Linux implementation.

---
 drivers/common/mlx5/rte_common_mlx5_exports.def |  2 +
 drivers/common/mlx5/windows/mlx5_common_os.c    | 60 +++++++++++++++++++++++++
 drivers/common/mlx5/windows/mlx5_common_os.h    |  2 +
 3 files changed, 64 insertions(+)
drivers/common/mlx5/rte_common_mlx5_exports.def +2 -0
index 5db1eaa48c..1eabe29a58 100644
@@ -63,3 +63,5 @@ EXPORTS
 	mlx5_free
 	mlx5_os_alloc_pd
 	mlx5_os_dealloc_pd
+	mlx5_os_umem_reg
+	mlx5_os_umem_dereg
drivers/common/mlx5/windows/mlx5_common_os.c +60 -0

63 lines not on this page · raw message

drivers/common/mlx5/windows/mlx5_common_os.h +2 -0
index f47351ec41..decb5acd45 100644
@@ -142,4 +142,6 @@ mlx5_os_get_umem_id(void *umem)
 
 void *mlx5_os_alloc_pd(void *ctx);
 int mlx5_os_dealloc_pd(void *pd);
+void *mlx5_os_umem_reg(void *ctx, void *addr, size_t size, uint32_t access);
+int mlx5_os_umem_dereg(void *pumem);
 #endif /* RTE_PMD_MLX5_COMMON_OS_H_ */
Signature · 1 line
2.16.1.windows.4
#67 lore raw

PATCH v4 27/32 net/mlx5: update MR prototypes for DevX

In reply to Tal Shnaiderman

From: Ophir Munk <[email protected]>

Currently MR operations are Verbs based. This commit updates MR operations prototypes such that DevX MR operations callbacks can be used as well. Rename 'struct mlx5_verbs_ops' as 'struct mlx5_mr_ops' and move it to shared file mlx5.h.

---
 drivers/net/mlx5/linux/mlx5_os.c    | 4 ++--
 drivers/net/mlx5/linux/mlx5_verbs.c | 2 +-
 drivers/net/mlx5/linux/mlx5_verbs.h | 8 +-------
 drivers/net/mlx5/mlx5.h             | 6 ++++++
 4 files changed, 10 insertions(+), 10 deletions(-)
drivers/net/mlx5/linux/mlx5_os.c +2 -2
index a6c1eba640..4f68c74267 100644
@@ -2478,8 +2478,8 @@ void
 mlx5_os_set_reg_mr_cb(mlx5_reg_mr_t *reg_mr_cb,
 		      mlx5_dereg_mr_t *dereg_mr_cb)
 {
-	*reg_mr_cb = mlx5_verbs_ops.reg_mr;
-	*dereg_mr_cb = mlx5_verbs_ops.dereg_mr;
+	*reg_mr_cb = mlx5_mr_verbs_ops.reg_mr;
+	*dereg_mr_cb = mlx5_mr_verbs_ops.dereg_mr;
 }
 
 /**
drivers/net/mlx5/linux/mlx5_verbs.c +1 -1
index 9161fa3b7d..b52ae2e6c1 100644
@@ -62,7 +62,7 @@ mlx5_dereg_mr(struct mlx5_pmd_mr *pmd_mr)
 }
 
 /* verbs operations. */
-const struct mlx5_verbs_ops mlx5_verbs_ops = {
+const struct mlx5_mr_ops mlx5_mr_verbs_ops = {
 	.reg_mr = mlx5_reg_mr,
 	.dereg_mr = mlx5_dereg_mr,
 };
drivers/net/mlx5/linux/mlx5_verbs.h +1 -7
index 0670f6c47e..76a79bf4f4 100644
@@ -7,16 +7,10 @@
 
 #include "mlx5.h"
 
-struct mlx5_verbs_ops {
-	mlx5_reg_mr_t reg_mr;
-	mlx5_dereg_mr_t dereg_mr;
-};
-
 int mlx5_txq_ibv_obj_new(struct rte_eth_dev *dev, uint16_t idx);
 void mlx5_txq_ibv_obj_release(struct mlx5_txq_obj *txq_obj);
 
 /* Verbs ops struct */
-extern const struct mlx5_verbs_ops mlx5_verbs_ops;
+extern const struct mlx5_mr_ops mlx5_mr_verbs_ops;
 extern struct mlx5_obj_ops ibv_obj_ops;
-
 #endif /* RTE_PMD_MLX5_VERBS_H_ */
drivers/net/mlx5/mlx5.h +6 -0
index 2186677810..a9db597f2b 100644
@@ -917,6 +917,12 @@ struct mlx5_obj_ops {
 
 #define MLX5_RSS_HASH_FIELDS_LEN RTE_DIM(mlx5_rss_hash_fields)
 
+/* MR operations structure. */
+struct mlx5_mr_ops {
+	mlx5_reg_mr_t reg_mr;
+	mlx5_dereg_mr_t dereg_mr;
+};
+
 struct mlx5_priv {
 	struct rte_eth_dev_data *dev_data;  /* Pointer to device data. */
 	struct mlx5_dev_ctx_shared *sh; /* Shared device context. */
Signature · 1 line
2.16.1.windows.4
#68 lore raw

PATCH v4 28/32 common/mlx5/windows: add OS reg/dereg MR

In reply to Tal Shnaiderman

From: Ophir Munk <[email protected]>

This commits implements Windows API for MR registration and deregistration. It is based on DevX. Is support the relaxed ordering flow in Windows by checking the capabilities and machine type.

---
 drivers/common/mlx5/mlx5_common_mr.h            |  1 +
 drivers/common/mlx5/rte_common_mlx5_exports.def |  2 +
 drivers/common/mlx5/windows/mlx5_common_os.c    | 78 +++++++++++++++++++++++++
 drivers/common/mlx5/windows/mlx5_common_os.h    |  7 +++
 4 files changed, 88 insertions(+)
drivers/common/mlx5/mlx5_common_mr.h +1 -0
index da0a0f0c79..5cc3f097c2 100644
@@ -28,6 +28,7 @@ struct mlx5_pmd_mr {
 	void		     *addr;
 	size_t		     len;
 	void		     *obj;  /* verbs mr object or devx umem object. */
+	struct mlx5_devx_obj *mkey; /* devx mkey object. */
 };
 
 /**
drivers/common/mlx5/rte_common_mlx5_exports.def +2 -0
index 1eabe29a58..65ae47ae6a 100644
@@ -63,5 +63,7 @@ EXPORTS
 	mlx5_free
 	mlx5_os_alloc_pd
 	mlx5_os_dealloc_pd
+	mlx5_os_dereg_mr
+	mlx5_os_reg_mr
 	mlx5_os_umem_reg
 	mlx5_os_umem_dereg
drivers/common/mlx5/windows/mlx5_common_os.c +78 -0

87 lines not on this page · raw message

drivers/common/mlx5/windows/mlx5_common_os.h +7 -0
index decb5acd45..ba166412cc 100644
@@ -7,9 +7,13 @@
 
 #include <stdio.h>
 
+#include <rte_errno.h>
+
 #include "mlx5_autoconf.h"
 #include "mlx5_glue.h"
 #include "mlx5_malloc.h"
+#include "mlx5_common_mr.h"
+#include "mlx5_win_ext.h"
 
 /**
  * This API allocates aligned or non-aligned memory.  The free can be on either
@@ -144,4 +148,7 @@ void *mlx5_os_alloc_pd(void *ctx);
 int mlx5_os_dealloc_pd(void *pd);
 void *mlx5_os_umem_reg(void *ctx, void *addr, size_t size, uint32_t access);
 int mlx5_os_umem_dereg(void *pumem);
+int mlx5_os_reg_mr(void *pd,
+		   void *addr, size_t length, struct mlx5_pmd_mr *pmd_mr);
+void mlx5_os_dereg_mr(struct mlx5_pmd_mr *pmd_mr);
 #endif /* RTE_PMD_MLX5_COMMON_OS_H_ */
Signature · 1 line
2.16.1.windows.4
#69 lore raw

PATCH v4 29/32 net/mlx5/windows: implement device attribute getter

In reply to Tal Shnaiderman

From: Ophir Munk <[email protected]>

This commit is the Windows implementation of mlx5_os_get_dev_attr() API. It follows the commit in [1]. A new file named mlx5_os.c is added under windows directory as its Linux counterpart file: linux/mlx5_os.c.

[1].
commit e85f623e13ea ("net/mlx5: remove attributes dependency on Verbs")

---
 drivers/common/mlx5/mlx5_prm.h       | 43 +++++++++++++++++++++
 drivers/net/mlx5/windows/meson.build |  8 ++++
 drivers/net/mlx5/windows/mlx5_os.c   | 75 ++++++++++++++++++++++++++++++++++++
 3 files changed, 126 insertions(+)
 create mode 100644 drivers/net/mlx5/windows/meson.build
 create mode 100644 drivers/net/mlx5/windows/mlx5_os.c
drivers/common/mlx5/mlx5_prm.h +43 -0
index 27a4e4f0f1..d62d2558eb 100644
@@ -2217,6 +2217,49 @@ struct mlx5_ifc_cqc_bits {
 	u8 dbr_addr[0x40];
 };
 
+struct mlx5_ifc_health_buffer_bits {
+	u8         reserved_0[0x100];
+	u8         assert_existptr[0x20];
+	u8         assert_callra[0x20];
+	u8         reserved_1[0x40];
+	u8         fw_version[0x20];
+	u8         hw_id[0x20];
+	u8         reserved_2[0x20];
+	u8         irisc_index[0x8];
+	u8         synd[0x8];
+	u8         ext_synd[0x10];
+};
+
+struct mlx5_ifc_initial_seg_bits {
+	u8         fw_rev_minor[0x10];
+	u8         fw_rev_major[0x10];
+	u8         cmd_interface_rev[0x10];
+	u8         fw_rev_subminor[0x10];
+	u8         reserved_0[0x40];
+	u8         cmdq_phy_addr_63_32[0x20];
+	u8         cmdq_phy_addr_31_12[0x14];
+	u8         reserved_1[0x2];
+	u8         nic_interface[0x2];
+	u8         log_cmdq_size[0x4];
+	u8         log_cmdq_stride[0x4];
+	u8         command_doorbell_vector[0x20];
+	u8         reserved_2[0xf00];
+	u8         initializing[0x1];
+	u8         nic_interface_supported[0x7];
+	u8         reserved_4[0x18];
+	struct mlx5_ifc_health_buffer_bits health_buffer;
+	u8         no_dram_nic_offset[0x20];
+	u8         reserved_5[0x6de0];
+	u8         internal_timer_h[0x20];
+	u8         internal_timer_l[0x20];
+	u8         reserved_6[0x20];
+	u8         reserved_7[0x1f];
+	u8         clear_int[0x1];
+	u8         health_syndrome[0x8];
+	u8         health_counter[0x18];
+	u8         reserved_8[0x17fc0];
+};
+
 struct mlx5_ifc_create_cq_out_bits {
 	u8 status[0x8];
 	u8 reserved_at_8[0x18];
drivers/net/mlx5/windows/meson.build new file +8 -0
new file mode 100644
index 0000000000..2ea0792a40
@@ -0,0 +1,8 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright 2020 Mellanox Technologies, Ltd
+
+includes += include_directories('.')
+sources += files(
+	'mlx5_os.c',
+)
+
drivers/net/mlx5/windows/mlx5_os.c new file +75 -0

75 lines not on this page · raw message

Signature · 1 line
2.16.1.windows.4
#70 lore raw

PATCH v4 30/32 net/mlx5/windows: add mlx5_os.c stubs

In reply to Tal Shnaiderman

From: Ophir Munk <[email protected]>

mlx5_os_set_nonblock_channel_fd
mlx5_os_dev_shared_handler_install
mlx5_os_dev_shared_handler_uninstall
mlx5_os_read_dev_stat
mlx5_os_mac_addr_flush
mlx5_os_mac_addr_remove
mlx5_os_vf_mac_addr_modify
mlx5_os_set_promisc
mlx5_os_set_allmulti

Set struct mlx5_flow_driver_ops mlx5_flow_verbs_drv_ops with NULL pointers.

---
 drivers/net/mlx5/windows/mlx5_os.c | 187 +++++++++++++++++++++++++++++++++++++
 1 file changed, 187 insertions(+)
drivers/net/mlx5/windows/mlx5_os.c +187 -0
index e0646670a3..4a7c745a71 100644
@@ -13,10 +13,18 @@
 #include <mlx5_glue.h>
 #include <mlx5_devx_cmds.h>
 #include <mlx5_common.h>
+#include <mlx5_common_mp.h>
+#include <mlx5_common_mr.h>
+#include <mlx5_malloc.h>
 
 #include "mlx5_defs.h"
 #include "mlx5.h"
+#include "mlx5_common_os.h"
+#include "mlx5_utils.h"
+#include "mlx5_rxtx.h"
 #include "mlx5_autoconf.h"
+#include "mlx5_mr.h"
+#include "mlx5_flow.h"
 
 /**
  * Get mlx5 device attributes.
@@ -73,3 +81,182 @@ mlx5_os_get_dev_attr(void *ctx, struct mlx5_dev_attr *device_attr)
 	}
 	return err;
 }
+
+/**
+ * Set the completion channel file descriptor interrupt as non-blocking.
+ * Currently it has no support under Windows.
+ *
+ * @param[in] rxq_obj
+ *   Pointer to RQ channel object, which includes the channel fd
+ *
+ * @param[out] fd
+ *   The file descriptor (representing the intetrrupt) used in this channel.
+ *
+ * @return
+ *   0 on successfully setting the fd to non-blocking, non-zero otherwise.
+ */
+int
+mlx5_os_set_nonblock_channel_fd(int fd)
+{
+	(void)fd;
+	DRV_LOG(WARNING, "mlx5_os_set_nonblock_channel_fd is not supported");
+	return -ENOTSUP;
+}
+
+/**
+ * This function should share events between multiple ports of single IB
+ * device.  Currently it has no support under Windows.
+ *
+ * @param sh
+ *   Pointer to mlx5_dev_ctx_shared object.
+ */
+void
+mlx5_os_dev_shared_handler_install(struct mlx5_dev_ctx_shared *sh)
+{
+	(void)sh;
+	DRV_LOG(WARNING, "mlx5_os_dev_shared_handler_install is not supported");
+}
+
+/**
+ * This function should share events between multiple ports of single IB
+ * device.  Currently it has no support under Windows.
+ *
+ * @param dev
+ *   Pointer to mlx5_dev_ctx_shared object.
+ */
+void
+mlx5_os_dev_shared_handler_uninstall(struct mlx5_dev_ctx_shared *sh)
+{
+	(void)sh;
+	DRV_LOG(WARNING, "mlx5_os_dev_shared_handler_uninstall is not supported");
+}
+
+/**
+ * Read statistics by a named counter.
+ *
+ * @param[in] priv
+ *   Pointer to the private device data structure.
+ * @param[in] ctr_name
+ *   Pointer to the name of the statistic counter to read
+ * @param[out] stat
+ *   Pointer to read statistic value.
+ * @return
+ *   0 on success and stat is valud, 1 if failed to read the value
+ *   rte_errno is set.
+ *
+ */
+int
+mlx5_os_read_dev_stat(struct mlx5_priv *priv, const char *ctr_name,
+		      uint64_t *stat)
+{
+	RTE_SET_USED(priv);
+	RTE_SET_USED(ctr_name);
+	RTE_SET_USED(stat);
+	DRV_LOG(WARNING, "mlx5_os_read_dev_stat is not supported");
+	return -ENOTSUP;
+}
+
+/**
+ * Flush device MAC addresses
+ * Currently it has no support under Windows.
+ *
+ * @param dev
+ *   Pointer to Ethernet device structure.
+ *
+ */
+void
+mlx5_os_mac_addr_flush(struct rte_eth_dev *dev)
+{
+	(void)dev;
+	DRV_LOG(WARNING, "mlx5_os_mac_addr_flush is not supported");
+}
+
+/**
+ * Remove a MAC address from device
+ * Currently it has no support under Windows.
+ *
+ * @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)
+{
+	(void)dev;
+	(void)(index);
+	DRV_LOG(WARNING, "mlx5_os_mac_addr_remove is not supported");
+}
+
+/**
+ * Modify a VF MAC address
+ * Currently it has no support under Windows.
+ *
+ * @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)
+{
+	(void)priv;
+	(void)iface_idx;
+	(void)mac_addr;
+	(void)vf_index;
+	DRV_LOG(WARNING, "mlx5_os_vf_mac_addr_modify is not supported");
+	return -ENOTSUP;
+}
+
+/**
+ * Set device promiscuous mode
+ * Currently it has no support under Windows.
+ *
+ * @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)
+{
+	(void)dev;
+	(void)enable;
+	DRV_LOG(WARNING, "mlx5_os_set_promisc is not supported");
+	return -ENOTSUP;
+}
+
+/**
+ * Set device allmulti 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)
+{
+	(void)dev;
+	(void)enable;
+	DRV_LOG(WARNING, "mlx5_os_set_allmulti is not supported");
+	return -ENOTSUP;
+}
+
+const struct mlx5_flow_driver_ops mlx5_flow_verbs_drv_ops = {0};
Signature · 1 line
2.16.1.windows.4
#71 lore raw

PATCH v4 31/32 net/mlx5/windows: implement mlx5 mac addr add

In reply to Tal Shnaiderman

Get the list of MAC addresses and verify if the input mac parameter already exists. If not - return -ENOTSUP (as Windows does not support adding new MAC addresses). If the MAC address exists (EEXIST) return 0 (the equivalent of Linux implementation of this API).

---
 drivers/net/mlx5/windows/mlx5_os.c | 36 ++++++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)
drivers/net/mlx5/windows/mlx5_os.c +36 -0
index 4a7c745a71..52ddd00399 100644
@@ -188,6 +188,42 @@ mlx5_os_mac_addr_remove(struct rte_eth_dev *dev, uint32_t index)
 	DRV_LOG(WARNING, "mlx5_os_mac_addr_remove is not supported");
 }
 
+/**
+ * Adds a MAC address to the device
+ * Currently it has no support under Windows.
+ *
+ * @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)
+{
+	(void)index;
+	struct rte_ether_addr lmac;
+
+	if (mlx5_get_mac(dev, &lmac.addr_bytes)) {
+		DRV_LOG(ERR,
+			"port %u cannot get MAC address, is mlx5_en"
+			" loaded? (errno: %s)",
+			dev->data->port_id, strerror(rte_errno));
+		return rte_errno;
+	}
+	if (!rte_is_same_ether_addr(&lmac, mac)) {
+		DRV_LOG(ERR,
+			"adding new mac address to device is unsupported");
+		return -ENOTSUP;
+	}
+	return 0;
+}
+
 /**
  * Modify a VF MAC address
  * Currently it has no support under Windows.
Signature · 1 line
2.16.1.windows.4
#72 lore raw

PATCH v4 32/32 net/mlx5: refactor eth dev ops for Windows

In reply to Tal Shnaiderman

From: Ophir Munk <[email protected]>

There are two types of eth_dev_ops used under Windows: primary and isolate mode. Their function calls initialization is added to the OS specific file mlx5_os.c. Secondary process eth_dev_ops is nullified.

---
 drivers/net/mlx5/windows/mlx5_os.c | 108 +++++++++++++++++++++++++++++++++++++
 1 file changed, 108 insertions(+)
drivers/net/mlx5/windows/mlx5_os.c +108 -0
index 52ddd00399..e207d186aa 100644
@@ -296,3 +296,111 @@ mlx5_os_set_allmulti(struct rte_eth_dev *dev, int enable)
 }
 
 const struct mlx5_flow_driver_ops mlx5_flow_verbs_drv_ops = {0};
+
+const struct eth_dev_ops mlx5_os_dev_ops = {
+	.dev_configure = mlx5_dev_configure,
+	.dev_start = mlx5_dev_start,
+	.dev_stop = mlx5_dev_stop,
+	.dev_close = mlx5_dev_close,
+	.mtu_set = mlx5_dev_set_mtu,
+	.link_update = mlx5_link_update,
+	.stats_get = mlx5_stats_get,
+	.stats_reset = mlx5_stats_reset,
+	.dev_infos_get = mlx5_dev_infos_get,
+	.dev_supported_ptypes_get = mlx5_dev_supported_ptypes_get,
+	.promiscuous_enable = mlx5_promiscuous_enable,
+	.promiscuous_disable = mlx5_promiscuous_disable,
+	.allmulticast_enable = mlx5_allmulticast_enable,
+	.allmulticast_disable = mlx5_allmulticast_disable,
+	.xstats_get = mlx5_xstats_get,
+	.xstats_reset = mlx5_xstats_reset,
+	.xstats_get_names = mlx5_xstats_get_names,
+	.fw_version_get = mlx5_fw_version_get,
+	.read_clock = mlx5_read_clock,
+	.vlan_filter_set = mlx5_vlan_filter_set,
+	.rx_queue_setup = mlx5_rx_queue_setup,
+	.rx_hairpin_queue_setup = mlx5_rx_hairpin_queue_setup,
+	.tx_queue_setup = mlx5_tx_queue_setup,
+	.tx_hairpin_queue_setup = mlx5_tx_hairpin_queue_setup,
+	.rx_queue_release = mlx5_rx_queue_release,
+	.tx_queue_release = mlx5_tx_queue_release,
+	.flow_ctrl_get = mlx5_dev_get_flow_ctrl,
+	.flow_ctrl_set = mlx5_dev_set_flow_ctrl,
+	.mac_addr_remove = mlx5_mac_addr_remove,
+	.mac_addr_add = mlx5_mac_addr_add,
+	.mac_addr_set = mlx5_mac_addr_set,
+	.set_mc_addr_list = mlx5_set_mc_addr_list,
+	.vlan_strip_queue_set = mlx5_vlan_strip_queue_set,
+	.vlan_offload_set = mlx5_vlan_offload_set,
+	.reta_update = mlx5_dev_rss_reta_update,
+	.reta_query = mlx5_dev_rss_reta_query,
+	.rss_hash_update = mlx5_rss_hash_update,
+	.rss_hash_conf_get = mlx5_rss_hash_conf_get,
+	.filter_ctrl = mlx5_dev_filter_ctrl,
+	.rxq_info_get = mlx5_rxq_info_get,
+	.txq_info_get = mlx5_txq_info_get,
+	.rx_burst_mode_get = mlx5_rx_burst_mode_get,
+	.tx_burst_mode_get = mlx5_tx_burst_mode_get,
+	.rx_queue_intr_enable = mlx5_rx_intr_enable,
+	.rx_queue_intr_disable = mlx5_rx_intr_disable,
+	.is_removed = mlx5_is_removed,
+	.udp_tunnel_port_add  = mlx5_udp_tunnel_port_add,
+	.get_module_info = mlx5_get_module_info,
+	.get_module_eeprom = mlx5_get_module_eeprom,
+	.hairpin_cap_get = mlx5_hairpin_cap_get,
+	.mtr_ops_get = mlx5_flow_meter_ops_get,
+};
+
+/* Available operations from secondary process. */
+const struct eth_dev_ops mlx5_os_dev_sec_ops = {0};
+
+/* Available operations in flow isolated mode. */
+const struct eth_dev_ops mlx5_os_dev_ops_isolate = {
+	.dev_configure = mlx5_dev_configure,
+	.dev_start = mlx5_dev_start,
+	.dev_stop = mlx5_dev_stop,
+	.dev_close = mlx5_dev_close,
+	.mtu_set = mlx5_dev_set_mtu,
+	.link_update = mlx5_link_update,
+	.stats_get = mlx5_stats_get,
+	.stats_reset = mlx5_stats_reset,
+	.dev_infos_get = mlx5_dev_infos_get,
+	.dev_set_link_down = mlx5_set_link_down,
+	.dev_set_link_up = mlx5_set_link_up,
+	.promiscuous_enable = mlx5_promiscuous_enable,
+	.promiscuous_disable = mlx5_promiscuous_disable,
+	.allmulticast_enable = mlx5_allmulticast_enable,
+	.allmulticast_disable = mlx5_allmulticast_disable,
+	.xstats_get = mlx5_xstats_get,
+	.xstats_reset = mlx5_xstats_reset,
+	.xstats_get_names = mlx5_xstats_get_names,
+	.fw_version_get = mlx5_fw_version_get,
+	.dev_supported_ptypes_get = mlx5_dev_supported_ptypes_get,
+	.vlan_filter_set = mlx5_vlan_filter_set,
+	.rx_queue_setup = mlx5_rx_queue_setup,
+	.rx_hairpin_queue_setup = mlx5_rx_hairpin_queue_setup,
+	.tx_queue_setup = mlx5_tx_queue_setup,
+	.tx_hairpin_queue_setup = mlx5_tx_hairpin_queue_setup,
+	.rx_queue_release = mlx5_rx_queue_release,
+	.tx_queue_release = mlx5_tx_queue_release,
+	.flow_ctrl_get = mlx5_dev_get_flow_ctrl,
+	.flow_ctrl_set = mlx5_dev_set_flow_ctrl,
+	.mac_addr_remove = mlx5_mac_addr_remove,
+	.mac_addr_add = mlx5_mac_addr_add,
+	.mac_addr_set = mlx5_mac_addr_set,
+	.set_mc_addr_list = mlx5_set_mc_addr_list,
+	.vlan_strip_queue_set = mlx5_vlan_strip_queue_set,
+	.vlan_offload_set = mlx5_vlan_offload_set,
+	.filter_ctrl = mlx5_dev_filter_ctrl,
+	.rxq_info_get = mlx5_rxq_info_get,
+	.txq_info_get = mlx5_txq_info_get,
+	.rx_burst_mode_get = mlx5_rx_burst_mode_get,
+	.tx_burst_mode_get = mlx5_tx_burst_mode_get,
+	.rx_queue_intr_enable = mlx5_rx_intr_enable,
+	.rx_queue_intr_disable = mlx5_rx_intr_disable,
+	.is_removed = mlx5_is_removed,
+	.get_module_info = mlx5_get_module_info,
+	.get_module_eeprom = mlx5_get_module_eeprom,
+	.hairpin_cap_get = mlx5_hairpin_cap_get,
+	.mtr_ops_get = mlx5_flow_meter_ops_get,
+};
Signature · 1 line
2.16.1.windows.4
#73 lore raw

PATCH v3 2/32 net/mlx5/linux: extend device attributes getter

In reply to Tal Shnaiderman

From: Ophir Munk <[email protected]>

This commit adds device attributes parameters to be reported by mlx5_os_get_dev_attr(): max_cqe, max_mr, max_pd, max_srq, max_srq_wr

---
 drivers/net/mlx5/linux/mlx5_os.c | 5 +++++
 drivers/net/mlx5/mlx5.h          | 5 +++++
 2 files changed, 10 insertions(+)
drivers/net/mlx5/linux/mlx5_os.c +5 -0
index 917d6be7b8..a6c1eba640 100644
@@ -116,7 +116,12 @@ mlx5_os_get_dev_attr(void *ctx, struct mlx5_dev_attr *device_attr)
 	device_attr->max_qp_wr = attr_ex.orig_attr.max_qp_wr;
 	device_attr->max_sge = attr_ex.orig_attr.max_sge;
 	device_attr->max_cq = attr_ex.orig_attr.max_cq;
+	device_attr->max_cqe = attr_ex.orig_attr.max_cqe;
+	device_attr->max_mr = attr_ex.orig_attr.max_mr;
+	device_attr->max_pd = attr_ex.orig_attr.max_pd;
 	device_attr->max_qp = attr_ex.orig_attr.max_qp;
+	device_attr->max_srq = attr_ex.orig_attr.max_srq;
+	device_attr->max_srq_wr = attr_ex.orig_attr.max_srq_wr;
 	device_attr->raw_packet_caps = attr_ex.raw_packet_caps;
 	device_attr->max_rwq_indirection_table_size =
 		attr_ex.rss_caps.max_rwq_indirection_table_size;
drivers/net/mlx5/mlx5.h +5 -0
index 121d726405..2186677810 100644
@@ -83,6 +83,11 @@ struct mlx5_dev_attr {
 	int		max_sge;
 	int		max_cq;
 	int		max_qp;
+	int		max_cqe;
+	uint32_t	max_pd;
+	uint32_t	max_mr;
+	uint32_t	max_srq;
+	uint32_t	max_srq_wr;
 	uint32_t	raw_packet_caps;
 	uint32_t	max_rwq_indirection_table_size;
 	uint32_t	max_tso;
Signature · 1 line
2.16.1.windows.4
#74 lore raw

PATCH v3 3/32 net/mlx5: remove Linux files from Windows compilation

In reply to Tal Shnaiderman

From: Ophir Munk <[email protected]>

This commit removes Linux files flow_verbs.c and mlx5_rxtx_vec.c from Windows compilation.

---
 drivers/net/mlx5/meson.build | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)
drivers/net/mlx5/meson.build +11 -5
index e7495a764a..f2fafbdd05 100644
@@ -15,7 +15,6 @@ sources = files(
 	'mlx5_flow.c',
 	'mlx5_flow_meter.c',
 	'mlx5_flow_dv.c',
-	'mlx5_flow_verbs.c',
         'mlx5_flow_age.c',
 	'mlx5_mac.c',
 	'mlx5_mr.c',
@@ -31,11 +30,18 @@ sources = files(
 	'mlx5_utils.c',
 	'mlx5_devx.c',
 )
-if (dpdk_conf.has('RTE_ARCH_X86_64')
-	or dpdk_conf.has('RTE_ARCH_ARM64')
-	or dpdk_conf.has('RTE_ARCH_PPC_64'))
-	sources += files('mlx5_rxtx_vec.c')
+
+if is_linux
+	sources += files(
+		'mlx5_flow_verbs.c',
+	)
+	if (dpdk_conf.has('RTE_ARCH_X86_64')
+		or dpdk_conf.has('RTE_ARCH_ARM64')
+		or dpdk_conf.has('RTE_ARCH_PPC_64'))
+		sources += files('mlx5_rxtx_vec.c')
+	endif
 endif
+
 cflags_options = [
 	'-std=c11',
 	'-Wno-strict-prototypes',
Signature · 1 line
2.16.1.windows.4
#75 lore raw

PATCH v3 4/32 net/mlx5: fix freeing packet pacing

In reply to Tal Shnaiderman

From: Ophir Munk <[email protected]>

Packet pacing is allocated under condition #ifdef HAVE_MLX5DV_PP_ALLOC. In a similar way - free packet pacing index under the same condition. This update is required to successfully compile under operating systems which do not support packet pacing.

Fixes aef1e20ebeb2 ("net/mlx5: allocate packet pacing context")
---
 drivers/net/mlx5/mlx5_txpp.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/net/mlx5/mlx5_txpp.c +5 -0
index 2438bf1f1d..21675ab17a 100644
@@ -57,11 +57,16 @@ mlx5_txpp_create_event_channel(struct mlx5_dev_ctx_shared *sh)
 static void
 mlx5_txpp_free_pp_index(struct mlx5_dev_ctx_shared *sh)
 {
+#ifdef HAVE_MLX5DV_PP_ALLOC
 	if (sh->txpp.pp) {
 		mlx5_glue->dv_free_pp(sh->txpp.pp);
 		sh->txpp.pp = NULL;
 		sh->txpp.pp_id = 0;
 	}
+#else
+	RTE_SET_USED(sh);
+	DRV_LOG(ERR, "Freeing pacing index is not supported.");
+#endif
 }
 
 /* Allocate Packet Pacing index from kernel via mlx5dv call. */
Signature · 1 line
2.16.1.windows.4
#76 lore raw

PATCH v3 5/32 net/mlx5: replace Linux sleep with rte sleep

In reply to Tal Shnaiderman

From: Ophir Munk <[email protected]>

Replace Linux API usleep() and nanosleep() with rte_delay_us_sleep(). The replacement occurs in shared files compiled under different operating systems.

---
 drivers/net/mlx5/mlx5.c         | 5 +++--
 drivers/net/mlx5/mlx5_trigger.c | 3 ++-
 drivers/net/mlx5/mlx5_txpp.c    | 6 +-----
 3 files changed, 6 insertions(+), 8 deletions(-)
drivers/net/mlx5/mlx5.c +3 -2
index 52a8a252d4..8e9df6abcf 100644
@@ -21,6 +21,7 @@
 #include <rte_spinlock.h>
 #include <rte_string_fns.h>
 #include <rte_alarm.h>
+#include <rte_cycles.h>
 
 #include <mlx5_glue.h>
 #include <mlx5_devx_cmds.h>
@@ -1330,7 +1331,7 @@ mlx5_dev_close(struct rte_eth_dev *dev)
 	mlx5_flex_parser_ecpri_release(dev);
 	if (priv->rxqs != NULL) {
 		/* XXX race condition if mlx5_rx_burst() is still running. */
-		usleep(1000);
+		rte_delay_us_sleep(1000);
 		for (i = 0; (i != priv->rxqs_n); ++i)
 			mlx5_rxq_release(dev, i);
 		priv->rxqs_n = 0;
@@ -1338,7 +1339,7 @@ mlx5_dev_close(struct rte_eth_dev *dev)
 	}
 	if (priv->txqs != NULL) {
 		/* XXX race condition if mlx5_tx_burst() is still running. */
-		usleep(1000);
+		rte_delay_us_sleep(1000);
 		for (i = 0; (i != priv->txqs_n); ++i)
 			mlx5_txq_release(dev, i);
 		priv->txqs_n = 0;
drivers/net/mlx5/mlx5_trigger.c +2 -1
index bd029154f8..646f29b923 100644
@@ -9,6 +9,7 @@
 #include <rte_ethdev_driver.h>
 #include <rte_interrupts.h>
 #include <rte_alarm.h>
+#include <rte_cycles.h>
 
 #include <mlx5_malloc.h>
 
@@ -1171,7 +1172,7 @@ mlx5_dev_stop(struct rte_eth_dev *dev)
 	rte_wmb();
 	/* Disable datapath on secondary process. */
 	mlx5_mp_os_req_stop_rxtx(dev);
-	usleep(1000 * priv->rxqs_n);
+	rte_delay_us_sleep(1000 * priv->rxqs_n);
 	DRV_LOG(DEBUG, "port %u stopping device", dev->data->port_id);
 	mlx5_flow_stop_default(dev);
 	/* Control flows for default traffic can be removed firstly. */
drivers/net/mlx5/mlx5_txpp.c +1 -5
index 21675ab17a..a1ec294942 100644
@@ -769,15 +769,11 @@ mlx5_txpp_init_timestamp(struct mlx5_dev_ctx_shared *sh)
 	sh->txpp.ts_p = 0;
 	sh->txpp.ts_n = 0;
 	for (wait = 0; wait < MLX5_TXPP_WAIT_INIT_TS; wait++) {
-		struct timespec onems;
-
 		mlx5_txpp_update_timestamp(sh);
 		if (wq->sq_ci)
 			return;
 		/* Wait one millisecond and try again. */
-		onems.tv_sec = 0;
-		onems.tv_nsec = NS_PER_S / MS_PER_S;
-		nanosleep(&onems, 0);
+		rte_delay_us_sleep(US_PER_S / MS_PER_S);
 	}
 	DRV_LOG(ERR, "Unable to initialize timestamp.");
 	sh->txpp.sync_lost = 1;
Signature · 1 line
2.16.1.windows.4
#77 lore raw

PATCH v3 6/32 net/mlx5: define mprq functions as static inline

In reply to Tal Shnaiderman

From: Ophir Munk <[email protected]>

Functions mlx5_check_mprq_support(), mlx5_rxq_mprq_enabled(), mlx5_mprq_enabled() are moved from source file mlx5_rxq.c to header file mlx5_rxtx.h and their type is updated to 'static __rte_always_inline'. Previously the functions were declared as 'inline' in the source file which was reported as 'unresolved external symbol' error by some Windows linkers.

---
 drivers/net/mlx5/mlx5_rxq.c  | 71 ------------------------------------------
 drivers/net/mlx5/mlx5_rxtx.h | 73 ++++++++++++++++++++++++++++++++++++++++++--
 2 files changed, 70 insertions(+), 74 deletions(-)
drivers/net/mlx5/mlx5_rxq.c +0 -71
index da7a8b3cd7..c89e55b1c0 100644
@@ -48,77 +48,6 @@ static_assert(MLX5_RSS_HASH_KEY_LEN ==
 	      (unsigned int)sizeof(rss_hash_default_key),
 	      "wrong RSS default key size.");
 
-/**
- * Check whether Multi-Packet RQ can be enabled for the device.
- *
- * @param dev
- *   Pointer to Ethernet device.
- *
- * @return
- *   1 if supported, negative errno value if not.
- */
-inline int
-mlx5_check_mprq_support(struct rte_eth_dev *dev)
-{
-	struct mlx5_priv *priv = dev->data->dev_private;
-
-	if (priv->config.mprq.enabled &&
-	    priv->rxqs_n >= priv->config.mprq.min_rxqs_num)
-		return 1;
-	return -ENOTSUP;
-}
-
-/**
- * Check whether Multi-Packet RQ is enabled for the Rx queue.
- *
- *  @param rxq
- *     Pointer to receive queue structure.
- *
- * @return
- *   0 if disabled, otherwise enabled.
- */
-inline int
-mlx5_rxq_mprq_enabled(struct mlx5_rxq_data *rxq)
-{
-	return rxq->strd_num_n > 0;
-}
-
-/**
- * Check whether Multi-Packet RQ is enabled for the device.
- *
- * @param dev
- *   Pointer to Ethernet device.
- *
- * @return
- *   0 if disabled, otherwise enabled.
- */
-inline int
-mlx5_mprq_enabled(struct rte_eth_dev *dev)
-{
-	struct mlx5_priv *priv = dev->data->dev_private;
-	uint32_t i;
-	uint16_t n = 0;
-	uint16_t n_ibv = 0;
-
-	if (mlx5_check_mprq_support(dev) < 0)
-		return 0;
-	/* All the configured queues should be enabled. */
-	for (i = 0; i < priv->rxqs_n; ++i) {
-		struct mlx5_rxq_data *rxq = (*priv->rxqs)[i];
-		struct mlx5_rxq_ctrl *rxq_ctrl = container_of
-			(rxq, struct mlx5_rxq_ctrl, rxq);
-
-		if (rxq == NULL || rxq_ctrl->type != MLX5_RXQ_TYPE_STANDARD)
-			continue;
-		n_ibv++;
-		if (mlx5_rxq_mprq_enabled(rxq))
-			++n;
-	}
-	/* Multi-Packet RQ can't be partially configured. */
-	MLX5_ASSERT(n == 0 || n == n_ibv);
-	return n == n_ibv;
-}
-
 /**
  * Calculate the number of CQEs in CQ for the Rx queue.
  *
drivers/net/mlx5/mlx5_rxtx.h +70 -3

83 lines not on this page · raw message

Signature · 1 line
2.16.1.windows.4
#78 lore raw

PATCH v3 7/32 net/mlx5: do not define static_assert in Windows

In reply to Tal Shnaiderman

From: Ophir Munk <[email protected]>

In Linux 'static_assert' is defined in file mlx5_defs.h:

 #ifndef HAVE_STATIC_ASSERT
    #define static_assert _Static_assert

#endif

The same definition can originate from Linux file /usr/include/assert.h.

In Windows static_assert is used while _Static_assert is unknown. Therefore update the definition condition to be:

 #if !defined(HAVE_STATIC_ASSERT) && !defined(RTE_EXEC_ENV_WINDOWS)
    #define static_assert _Static_assert

#endif

---
 drivers/net/mlx5/mlx5_defs.h | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/net/mlx5/mlx5_defs.h +5 -2
index aa55db3750..85a0979653 100644
@@ -199,8 +199,11 @@
 /* Maximum number of shared actions supported by rte_flow */
 #define MLX5_MAX_SHARED_ACTIONS 2
 
-/* Definition of static_assert found in /usr/include/assert.h */
-#ifndef HAVE_STATIC_ASSERT
+/*
+ * Linux definition of static_assert is found in /usr/include/assert.h.
+ * Windows does not require a redefinition.
+ */
+#if !defined(HAVE_STATIC_ASSERT) && !defined(RTE_EXEC_ENV_WINDOWS)
 #define static_assert _Static_assert
 #endif
 
Signature · 1 line
2.16.1.windows.4
#79 lore raw

PATCH v3 8/32 net/mlx5: move static_assert calls to global scope

In reply to Tal Shnaiderman

From: Ophir Munk <[email protected]>

Some Windows compilers consider static_assert() as calls to another function rather than a compiler directive which allows checking type information at compile time. This only occurs if the static_assert call appears inside another function scope. To solve it move the static_assert calls to global scope in the files where they are used.

---
 drivers/net/mlx5/mlx5_rxtx.c | 98 ++++++++++++++++++++++----------------------
 drivers/net/mlx5/mlx5_txpp.c |  5 ++-
 2 files changed, 53 insertions(+), 50 deletions(-)
drivers/net/mlx5/mlx5_rxtx.c +50 -48
index d12d746c2f..65a1f997e9 100644
@@ -79,6 +79,56 @@ static uint16_t mlx5_tx_burst_##func(void *txq, \
 
 #define MLX5_TXOFF_INFO(func, olx) {mlx5_tx_burst_##func, olx},
 
+/* static asserts */
+static_assert(MLX5_CQE_STATUS_HW_OWN < 0, "Must be negative value");
+static_assert(MLX5_CQE_STATUS_SW_OWN < 0, "Must be negative value");
+static_assert(MLX5_ESEG_MIN_INLINE_SIZE ==
+		(sizeof(uint16_t) +
+		 sizeof(rte_v128u32_t)),
+		"invalid Ethernet Segment data size");
+static_assert(MLX5_ESEG_MIN_INLINE_SIZE ==
+		(sizeof(uint16_t) +
+		 sizeof(struct rte_vlan_hdr) +
+		 2 * RTE_ETHER_ADDR_LEN),
+		"invalid Ethernet Segment data size");
+static_assert(MLX5_ESEG_MIN_INLINE_SIZE ==
+		(sizeof(uint16_t) +
+		 sizeof(rte_v128u32_t)),
+		"invalid Ethernet Segment data size");
+static_assert(MLX5_ESEG_MIN_INLINE_SIZE ==
+		(sizeof(uint16_t) +
+		 sizeof(struct rte_vlan_hdr) +
+		 2 * RTE_ETHER_ADDR_LEN),
+		"invalid Ethernet Segment data size");
+static_assert(MLX5_ESEG_MIN_INLINE_SIZE ==
+		(sizeof(uint16_t) +
+		 sizeof(rte_v128u32_t)),
+		"invalid Ethernet Segment data size");
+static_assert(MLX5_ESEG_MIN_INLINE_SIZE ==
+		(sizeof(uint16_t) +
+		 sizeof(struct rte_vlan_hdr) +
+		 2 * RTE_ETHER_ADDR_LEN),
+		"invalid Ethernet Segment data size");
+static_assert(MLX5_DSEG_MIN_INLINE_SIZE ==
+		(2 * RTE_ETHER_ADDR_LEN),
+		"invalid Data Segment data size");
+static_assert(MLX5_EMPW_MIN_PACKETS >= 2, "invalid min size");
+static_assert(MLX5_EMPW_MIN_PACKETS >= 2, "invalid min size");
+static_assert((sizeof(struct rte_vlan_hdr) +
+			sizeof(struct rte_ether_hdr)) ==
+		MLX5_ESEG_MIN_INLINE_SIZE,
+		"invalid min inline data size");
+static_assert(MLX5_WQE_SIZE_MAX / MLX5_WSEG_SIZE <=
+		MLX5_DSEG_MAX, "invalid WQE max size");
+static_assert(MLX5_WQE_CSEG_SIZE == MLX5_WSEG_SIZE,
+		"invalid WQE Control Segment size");
+static_assert(MLX5_WQE_ESEG_SIZE == MLX5_WSEG_SIZE,
+		"invalid WQE Ethernet Segment size");
+static_assert(MLX5_WQE_DSEG_SIZE == MLX5_WSEG_SIZE,
+		"invalid WQE Data Segment size");
+static_assert(MLX5_WQE_SIZE == 4 * MLX5_WSEG_SIZE,
+		"invalid WQE size");
+
 static __rte_always_inline uint32_t
 rxq_cq_to_pkt_type(struct mlx5_rxq_data *rxq, volatile struct mlx5_cqe *cqe,
 				   volatile struct mlx5_mini_cqe8 *mcqe);
@@ -2070,8 +2120,6 @@ mlx5_tx_handle_completion(struct mlx5_txq_data *__rte_restrict txq,
 	bool ring_doorbell = false;
 	int ret;
 
-	static_assert(MLX5_CQE_STATUS_HW_OWN < 0, "Must be negative value");
-	static_assert(MLX5_CQE_STATUS_SW_OWN < 0, "Must be negative value");
 	do {
 		volatile struct mlx5_cqe *cqe;
 
@@ -2381,15 +2429,6 @@ mlx5_tx_eseg_dmin(struct mlx5_txq_data *__rte_restrict txq __rte_unused,
 	es->metadata = MLX5_TXOFF_CONFIG(METADATA) ?
 		       loc->mbuf->ol_flags & PKT_TX_DYNF_METADATA ?
 		       *RTE_FLOW_DYNF_METADATA(loc->mbuf) : 0 : 0;
-	static_assert(MLX5_ESEG_MIN_INLINE_SIZE ==
-				(sizeof(uint16_t) +
-				 sizeof(rte_v128u32_t)),
-		      "invalid Ethernet Segment data size");
-	static_assert(MLX5_ESEG_MIN_INLINE_SIZE ==
-				(sizeof(uint16_t) +
-				 sizeof(struct rte_vlan_hdr) +
-				 2 * RTE_ETHER_ADDR_LEN),
-		      "invalid Ethernet Segment data size");
 	psrc = rte_pktmbuf_mtod(loc->mbuf, uint8_t *);
 	es->inline_hdr_sz = RTE_BE16(MLX5_ESEG_MIN_INLINE_SIZE);
 	es->inline_data = *(unaligned_uint16_t *)psrc;
@@ -2474,15 +2513,6 @@ mlx5_tx_eseg_data(struct mlx5_txq_data *__rte_restrict txq,
 	es->metadata = MLX5_TXOFF_CONFIG(METADATA) ?
 		       loc->mbuf->ol_flags & PKT_TX_DYNF_METADATA ?
 		       *RTE_FLOW_DYNF_METADATA(loc->mbuf) : 0 : 0;
-	static_assert(MLX5_ESEG_MIN_INLINE_SIZE ==
-				(sizeof(uint16_t) +
-				 sizeof(rte_v128u32_t)),
-		      "invalid Ethernet Segment data size");
-	static_assert(MLX5_ESEG_MIN_INLINE_SIZE ==
-				(sizeof(uint16_t) +
-				 sizeof(struct rte_vlan_hdr) +
-				 2 * RTE_ETHER_ADDR_LEN),
-		      "invalid Ethernet Segment data size");
 	psrc = rte_pktmbuf_mtod(loc->mbuf, uint8_t *);
 	es->inline_hdr_sz = rte_cpu_to_be_16(inlen);
 	es->inline_data = *(unaligned_uint16_t *)psrc;
@@ -2697,15 +2727,6 @@ mlx5_tx_eseg_mdat(struct mlx5_txq_data *__rte_restrict txq,
 	es->metadata = MLX5_TXOFF_CONFIG(METADATA) ?
 		       loc->mbuf->ol_flags & PKT_TX_DYNF_METADATA ?
 		       *RTE_FLOW_DYNF_METADATA(loc->mbuf) : 0 : 0;
-	static_assert(MLX5_ESEG_MIN_INLINE_SIZE ==
-				(sizeof(uint16_t) +
-				 sizeof(rte_v128u32_t)),
-		      "invalid Ethernet Segment data size");
-	static_assert(MLX5_ESEG_MIN_INLINE_SIZE ==
-				(sizeof(uint16_t) +
-				 sizeof(struct rte_vlan_hdr) +
-				 2 * RTE_ETHER_ADDR_LEN),
-		      "invalid Ethernet Segment data size");
 	MLX5_ASSERT(inlen >= MLX5_ESEG_MIN_INLINE_SIZE);
 	pdst = (uint8_t *)&es->inline_data;
 	if (MLX5_TXOFF_CONFIG(VLAN) && vlan) {
@@ -2952,9 +2973,6 @@ mlx5_tx_dseg_vlan(struct mlx5_txq_data *__rte_restrict txq,
 	uint8_t *pdst;
 
 	MLX5_ASSERT(len > MLX5_ESEG_MIN_INLINE_SIZE);
-	static_assert(MLX5_DSEG_MIN_INLINE_SIZE ==
-				 (2 * RTE_ETHER_ADDR_LEN),
-		      "invalid Data Segment data size");
 	if (!MLX5_TXOFF_CONFIG(MPW)) {
 		/* Store the descriptor byte counter for eMPW sessions. */
 		dseg->bcount = rte_cpu_to_be_32
@@ -4070,7 +4088,6 @@ mlx5_tx_burst_empw_simple(struct mlx5_txq_data *__rte_restrict txq,
 	MLX5_ASSERT(MLX5_TXOFF_CONFIG(EMPW));
 	MLX5_ASSERT(loc->elts_free && loc->wqe_free);
 	MLX5_ASSERT(pkts_n > loc->pkts_sent);
-	static_assert(MLX5_EMPW_MIN_PACKETS >= 2, "invalid min size");
 	pkts += loc->pkts_sent + 1;
 	pkts_n -= loc->pkts_sent;
 	for (;;) {
@@ -4247,7 +4264,6 @@ mlx5_tx_burst_empw_inline(struct mlx5_txq_data *__rte_restrict txq,
 	MLX5_ASSERT(MLX5_TXOFF_CONFIG(EMPW));
 	MLX5_ASSERT(loc->elts_free && loc->wqe_free);
 	MLX5_ASSERT(pkts_n > loc->pkts_sent);
-	static_assert(MLX5_EMPW_MIN_PACKETS >= 2, "invalid min size");
 	pkts += loc->pkts_sent + 1;
 	pkts_n -= loc->pkts_sent;
 	for (;;) {
@@ -4561,10 +4577,6 @@ mlx5_tx_burst_single_send(struct mlx5_txq_data *__rte_restrict txq,
 			    loc->mbuf->ol_flags & PKT_TX_VLAN_PKT) {
 				vlan = sizeof(struct rte_vlan_hdr);
 				inlen += vlan;
-				static_assert((sizeof(struct rte_vlan_hdr) +
-					       sizeof(struct rte_ether_hdr)) ==
-					       MLX5_ESEG_MIN_INLINE_SIZE,
-					       "invalid min inline data size");
 			}
 			/*
 			 * If inlining is enabled at configuration time
@@ -5567,16 +5579,6 @@ mlx5_select_tx_function(struct rte_eth_dev *dev)
 	uint64_t tx_offloads = dev->data->dev_conf.txmode.offloads;
 	unsigned int diff = 0, olx = 0, i, m;
 
-	static_assert(MLX5_WQE_SIZE_MAX / MLX5_WSEG_SIZE <=
-		      MLX5_DSEG_MAX, "invalid WQE max size");
-	static_assert(MLX5_WQE_CSEG_SIZE == MLX5_WSEG_SIZE,
-		      "invalid WQE Control Segment size");
-	static_assert(MLX5_WQE_ESEG_SIZE == MLX5_WSEG_SIZE,
-		      "invalid WQE Ethernet Segment size");
-	static_assert(MLX5_WQE_DSEG_SIZE == MLX5_WSEG_SIZE,
-		      "invalid WQE Data Segment size");
-	static_assert(MLX5_WQE_SIZE == 4 * MLX5_WSEG_SIZE,
-		      "invalid WQE size");
 	MLX5_ASSERT(priv);
 	if (tx_offloads & DEV_TX_OFFLOAD_MULTI_SEGS) {
 		/* We should support Multi-Segment Packets. */
drivers/net/mlx5/mlx5_txpp.c +3 -2
index a1ec294942..d61e43e55d 100644
@@ -18,6 +18,9 @@
 #include "mlx5_rxtx.h"
 #include "mlx5_common_os.h"
 
+static_assert(sizeof(struct mlx5_cqe_ts) == sizeof(rte_int128_t),
+		"Wrong timestamp CQE part size");
+
 static const char * const mlx5_txpp_stat_names[] = {
 	"tx_pp_missed_interrupt_errors", /* Missed service interrupt. */
 	"tx_pp_rearm_queue_errors", /* Rearm Queue errors. */
@@ -741,8 +744,6 @@ mlx5_txpp_update_timestamp(struct mlx5_dev_ctx_shared *sh)
 	uint64_t ts;
 	uint16_t ci;
 
-	static_assert(sizeof(struct mlx5_cqe_ts) == sizeof(rte_int128_t),
-		      "Wrong timestamp CQE part size");
 	mlx5_atomic_read_cqe((rte_int128_t *)&cqe->timestamp, &to.u128);
 	if (to.cts.op_own >> 4) {
 		DRV_LOG(DEBUG, "Clock Queue error sync lost.");
Signature · 1 line
2.16.1.windows.4
#80 lore raw

PATCH v3 9/32 net/mlx5: wrap glue alloc/dealloc PD with OS calls

In reply to Tal Shnaiderman

From: Ophir Munk <[email protected]>

Wrap glue calls alloc_pd() and dealloc_pd() with generic OS calls. In Linux - protection domain allocations are implemented by Verbs glue API while in Windows it is by DevX API.

---
 drivers/common/mlx5/linux/mlx5_common_os.h | 11 +++++++++++
 drivers/net/mlx5/mlx5.c                    |  6 +++---
 2 files changed, 14 insertions(+), 3 deletions(-)
drivers/common/mlx5/linux/mlx5_common_os.h +11 -0
index 3420937859..c9f8d7cbc1 100644
@@ -201,4 +201,15 @@ mlx5_os_get_devx_uar_page_id(void *uar)
 #endif
 }
 
+static inline void *
+mlx5_os_alloc_pd(void *ctx)
+{
+	return mlx5_glue->alloc_pd(ctx);
+}
+
+static inline int
+mlx5_os_dealloc_pd(void *pd)
+{
+	return mlx5_glue->dealloc_pd(pd);
+}
 #endif /* RTE_PMD_MLX5_COMMON_OS_H_ */
drivers/net/mlx5/mlx5.c +3 -3
index 8e9df6abcf..7d1b4fbdc0 100644
@@ -932,7 +932,7 @@ mlx5_alloc_shared_dev_ctx(const struct mlx5_dev_spawn_data *spawn,
 		sh->port[i].ih_port_id = RTE_MAX_ETHPORTS;
 		sh->port[i].devx_ih_port_id = RTE_MAX_ETHPORTS;
 	}
-	sh->pd = mlx5_glue->alloc_pd(sh->ctx);
+	sh->pd = mlx5_os_alloc_pd(sh->ctx);
 	if (sh->pd == NULL) {
 		DRV_LOG(ERR, "PD allocation failure");
 		err = ENOMEM;
@@ -1032,7 +1032,7 @@ mlx5_alloc_shared_dev_ctx(const struct mlx5_dev_spawn_data *spawn,
 	if (sh->tx_uar)
 		mlx5_glue->devx_free_uar(sh->tx_uar);
 	if (sh->pd)
-		claim_zero(mlx5_glue->dealloc_pd(sh->pd));
+		claim_zero(mlx5_os_dealloc_pd(sh->pd));
 	if (sh->ctx)
 		claim_zero(mlx5_glue->close_device(sh->ctx));
 	mlx5_free(sh);
@@ -1100,7 +1100,7 @@ mlx5_free_shared_dev_ctx(struct mlx5_dev_ctx_shared *sh)
 		sh->tx_uar = NULL;
 	}
 	if (sh->pd)
-		claim_zero(mlx5_glue->dealloc_pd(sh->pd));
+		claim_zero(mlx5_os_dealloc_pd(sh->pd));
 	if (sh->tis)
 		claim_zero(mlx5_devx_cmd_destroy(sh->tis));
 	if (sh->td)
Signature · 1 line
2.16.1.windows.4
#81 lore raw

PATCH v3 10/32 net/mlx5: wrap glue reg/dereg UMEM with OS calls

In reply to Tal Shnaiderman

Wrap glue calls for UMEM registration and deregistration with generic OS calls since each OS (Linux or Windows) has a different glue API parameters.

---
 drivers/common/mlx5/linux/mlx5_common_os.h | 12 ++++++++++++
 drivers/common/mlx5/mlx5_common.c          |  4 ++--
 drivers/net/mlx5/mlx5.c                    |  2 +-
 drivers/net/mlx5/mlx5_devx.c               | 16 ++++++++--------
 drivers/net/mlx5/mlx5_flow.c               |  4 ++--
 drivers/net/mlx5/mlx5_txpp.c               | 12 ++++++------
 6 files changed, 31 insertions(+), 19 deletions(-)
drivers/common/mlx5/linux/mlx5_common_os.h +12 -0
index c9f8d7cbc1..f8b215cc29 100644
@@ -212,4 +212,16 @@ mlx5_os_dealloc_pd(void *pd)
 {
 	return mlx5_glue->dealloc_pd(pd);
 }
+
+static inline void *
+mlx5_os_umem_reg(void *ctx, void *addr, size_t size, uint32_t access)
+{
+	return mlx5_glue->devx_umem_reg(ctx, addr, size, access);
+}
+
+static inline int
+mlx5_os_umem_dereg(void *pumem)
+{
+	return mlx5_glue->devx_umem_dereg(pumem);
+}
 #endif /* RTE_PMD_MLX5_COMMON_OS_H_ */
drivers/common/mlx5/mlx5_common.c +2 -2
index 044513223c..a00ffcb833 100644
@@ -148,7 +148,7 @@ mlx5_alloc_dbr_page(void *ctx)
 		return NULL;
 	}
 	/* Register allocated memory. */
-	page->umem = mlx5_glue->devx_umem_reg(ctx, page->dbrs,
+	page->umem = mlx5_os_umem_reg(ctx, page->dbrs,
 					      MLX5_DBR_PAGE_SIZE, 0);
 	if (!page->umem) {
 		DRV_LOG(ERR, "cannot umem reg dbr page");
@@ -232,7 +232,7 @@ mlx5_release_dbr(struct mlx5_dbr_page_list *head, uint32_t umem_id,
 		/* Page not used, free it and remove from list. */
 		LIST_REMOVE(page, next);
 		if (page->umem)
-			ret = -mlx5_glue->devx_umem_dereg(page->umem);
+			ret = -mlx5_os_umem_dereg(page->umem);
 		mlx5_free(page);
 	} else {
 		/* Mark in bitmap that this door-bell is not in use. */
drivers/net/mlx5/mlx5.c +1 -1
index 7d1b4fbdc0..84123f8e3d 100644
@@ -482,7 +482,7 @@ mlx5_flow_destroy_counter_stat_mem_mng(struct mlx5_counter_stats_mem_mng *mng)
 
 	LIST_REMOVE(mng, next);
 	claim_zero(mlx5_devx_cmd_destroy(mng->dm));
-	claim_zero(mlx5_glue->devx_umem_dereg(mng->umem));
+	claim_zero(mlx5_os_umem_dereg(mng->umem));
 	mlx5_free(mem);
 }
 
drivers/net/mlx5/mlx5_devx.c +8 -8
index de9b204075..235fd5798d 100644
@@ -155,7 +155,7 @@ mlx5_rxq_release_devx_rq_resources(struct mlx5_rxq_ctrl *rxq_ctrl)
 	struct mlx5_devx_dbr_page *dbr_page = rxq_ctrl->rq_dbrec_page;
 
 	if (rxq_ctrl->wq_umem) {
-		mlx5_glue->devx_umem_dereg(rxq_ctrl->wq_umem);
+		mlx5_os_umem_dereg(rxq_ctrl->wq_umem);
 		rxq_ctrl->wq_umem = NULL;
 	}
 	if (rxq_ctrl->rxq.wqes) {
@@ -182,7 +182,7 @@ mlx5_rxq_release_devx_cq_resources(struct mlx5_rxq_ctrl *rxq_ctrl)
 	struct mlx5_devx_dbr_page *dbr_page = rxq_ctrl->cq_dbrec_page;
 
 	if (rxq_ctrl->cq_umem) {
-		mlx5_glue->devx_umem_dereg(rxq_ctrl->cq_umem);
+		mlx5_os_umem_dereg(rxq_ctrl->cq_umem);
 		rxq_ctrl->cq_umem = NULL;
 	}
 	if (rxq_ctrl->rxq.cqes) {
@@ -375,7 +375,7 @@ mlx5_rxq_create_devx_rq_resources(struct rte_eth_dev *dev, uint16_t idx)
 	if (!buf)
 		return NULL;
 	rxq_data->wqes = buf;
-	rxq_ctrl->wq_umem = mlx5_glue->devx_umem_reg(priv->sh->ctx,
+	rxq_ctrl->wq_umem = mlx5_os_umem_reg(priv->sh->ctx,
 						     buf, wq_size, 0);
 	if (!rxq_ctrl->wq_umem)
 		goto error;
@@ -497,7 +497,7 @@ mlx5_rxq_create_devx_cq_resources(struct rte_eth_dev *dev, uint16_t idx)
 		goto error;
 	}
 	rxq_data->cqes = (volatile struct mlx5_cqe (*)[])(uintptr_t)buf;
-	rxq_ctrl->cq_umem = mlx5_glue->devx_umem_reg(priv->sh->ctx, buf,
+	rxq_ctrl->cq_umem = mlx5_os_umem_reg(priv->sh->ctx, buf,
 						     cq_size,
 						     IBV_ACCESS_LOCAL_WRITE);
 	if (!rxq_ctrl->cq_umem) {
@@ -1127,7 +1127,7 @@ mlx5_txq_release_devx_sq_resources(struct mlx5_txq_obj *txq_obj)
 		txq_obj->sq_devx = NULL;
 	}
 	if (txq_obj->sq_umem) {
-		claim_zero(mlx5_glue->devx_umem_dereg(txq_obj->sq_umem));
+		claim_zero(mlx5_os_umem_dereg(txq_obj->sq_umem));
 		txq_obj->sq_umem = NULL;
 	}
 	if (txq_obj->sq_buf) {
@@ -1155,7 +1155,7 @@ mlx5_txq_release_devx_cq_resources(struct mlx5_txq_obj *txq_obj)
 	if (txq_obj->cq_devx)
 		claim_zero(mlx5_devx_cmd_destroy(txq_obj->cq_devx));
 	if (txq_obj->cq_umem)
-		claim_zero(mlx5_glue->devx_umem_dereg(txq_obj->cq_umem));
+		claim_zero(mlx5_os_umem_dereg(txq_obj->cq_umem));
 	if (txq_obj->cq_buf)
 		mlx5_free(txq_obj->cq_buf);
 	if (txq_obj->cq_dbrec_page)
@@ -1243,7 +1243,7 @@ mlx5_txq_create_devx_cq_resources(struct rte_eth_dev *dev, uint16_t idx)
 		return 0;
 	}
 	/* Register allocated buffer in user space with DevX. */
-	txq_obj->cq_umem = mlx5_glue->devx_umem_reg(priv->sh->ctx,
+	txq_obj->cq_umem = mlx5_os_umem_reg(priv->sh->ctx,
 						(void *)txq_obj->cq_buf,
 						cqe_n * sizeof(struct mlx5_cqe),
 						IBV_ACCESS_LOCAL_WRITE);
@@ -1342,7 +1342,7 @@ mlx5_txq_create_devx_sq_resources(struct rte_eth_dev *dev, uint16_t idx)
 		goto error;
 	}
 	/* Register allocated buffer in user space with DevX. */
-	txq_obj->sq_umem = mlx5_glue->devx_umem_reg
+	txq_obj->sq_umem = mlx5_os_umem_reg
 					(priv->sh->ctx,
 					 (void *)txq_obj->sq_buf,
 					 wqe_n * sizeof(struct mlx5_wqe),
drivers/net/mlx5/mlx5_flow.c +2 -2
index bf86aaaa39..66491bbf78 100644
@@ -6446,7 +6446,7 @@ mlx5_flow_create_counter_stat_mem_mng(struct mlx5_dev_ctx_shared *sh)
 	}
 	mem_mng = (struct mlx5_counter_stats_mem_mng *)(mem + size) - 1;
 	size = sizeof(*raw_data) * MLX5_COUNTERS_PER_POOL * raws_n;
-	mem_mng->umem = mlx5_glue->devx_umem_reg(sh->ctx, mem, size,
+	mem_mng->umem = mlx5_os_umem_reg(sh->ctx, mem, size,
 						 IBV_ACCESS_LOCAL_WRITE);
 	if (!mem_mng->umem) {
 		rte_errno = errno;
@@ -6465,7 +6465,7 @@ mlx5_flow_create_counter_stat_mem_mng(struct mlx5_dev_ctx_shared *sh)
 	mkey_attr.relaxed_ordering_read = sh->cmng.relaxed_ordering_read;
 	mem_mng->dm = mlx5_devx_cmd_mkey_create(sh->ctx, &mkey_attr);
 	if (!mem_mng->dm) {
-		mlx5_glue->devx_umem_dereg(mem_mng->umem);
+		mlx5_os_umem_dereg(mem_mng->umem);
 		rte_errno = errno;
 		mlx5_free(mem);
 		return -rte_errno;
drivers/net/mlx5/mlx5_txpp.c +6 -6
index d61e43e55d..749529c410 100644
@@ -131,13 +131,13 @@ mlx5_txpp_destroy_send_queue(struct mlx5_txpp_wq *wq)
 	if (wq->sq)
 		claim_zero(mlx5_devx_cmd_destroy(wq->sq));
 	if (wq->sq_umem)
-		claim_zero(mlx5_glue->devx_umem_dereg(wq->sq_umem));
+		claim_zero(mlx5_os_umem_dereg(wq->sq_umem));
 	if (wq->sq_buf)
 		mlx5_free((void *)(uintptr_t)wq->sq_buf);
 	if (wq->cq)
 		claim_zero(mlx5_devx_cmd_destroy(wq->cq));
 	if (wq->cq_umem)
-		claim_zero(mlx5_glue->devx_umem_dereg(wq->cq_umem));
+		claim_zero(mlx5_os_umem_dereg(wq->cq_umem));
 	if (wq->cq_buf)
 		mlx5_free((void *)(uintptr_t)wq->cq_buf);
 	memset(wq, 0, sizeof(*wq));
@@ -268,7 +268,7 @@ mlx5_txpp_create_rearm_queue(struct mlx5_dev_ctx_shared *sh)
 		return -ENOMEM;
 	}
 	/* Register allocated buffer in user space with DevX. */
-	wq->cq_umem = mlx5_glue->devx_umem_reg(sh->ctx,
+	wq->cq_umem = mlx5_os_umem_reg(sh->ctx,
 					       (void *)(uintptr_t)wq->cq_buf,
 					       umem_size,
 					       IBV_ACCESS_LOCAL_WRITE);
@@ -318,7 +318,7 @@ mlx5_txpp_create_rearm_queue(struct mlx5_dev_ctx_shared *sh)
 		goto error;
 	}
 	/* Register allocated buffer in user space with DevX. */
-	wq->sq_umem = mlx5_glue->devx_umem_reg(sh->ctx,
+	wq->sq_umem = mlx5_os_umem_reg(sh->ctx,
 					       (void *)(uintptr_t)wq->sq_buf,
 					       umem_size,
 					       IBV_ACCESS_LOCAL_WRITE);
@@ -506,7 +506,7 @@ mlx5_txpp_create_clock_queue(struct mlx5_dev_ctx_shared *sh)
 		return -ENOMEM;
 	}
 	/* Register allocated buffer in user space with DevX. */
-	wq->cq_umem = mlx5_glue->devx_umem_reg(sh->ctx,
+	wq->cq_umem = mlx5_os_umem_reg(sh->ctx,
 					       (void *)(uintptr_t)wq->cq_buf,
 					       umem_size,
 					       IBV_ACCESS_LOCAL_WRITE);
@@ -562,7 +562,7 @@ mlx5_txpp_create_clock_queue(struct mlx5_dev_ctx_shared *sh)
 		goto error;
 	}
 	/* Register allocated buffer in user space with DevX. */
-	wq->sq_umem = mlx5_glue->devx_umem_reg(sh->ctx,
+	wq->sq_umem = mlx5_os_umem_reg(sh->ctx,
 					       (void *)(uintptr_t)wq->sq_buf,
 					       umem_size,
 					       IBV_ACCESS_LOCAL_WRITE);
Signature · 1 line
2.16.1.windows.4
#82 lore raw

PATCH v3 11/32 net/mlx5: fix adding destroy flow action wrapper

In reply to Tal Shnaiderman

From: Ophir Munk <[email protected]>

Glue function destroy_flow_action() was wrapped by OS specific operation mlx5_flow_os_destroy_flow_action(). It was skipped in file mlx5.c.

Fixes b293fbf9672b ("net/mlx5: add OS specific flow actions operations")
---
 drivers/net/mlx5/mlx5.c         | 5 +++--
 drivers/net/mlx5/mlx5_flow_dv.c | 6 +++---
 2 files changed, 6 insertions(+), 5 deletions(-)
drivers/net/mlx5/mlx5.c +3 -2
index 84123f8e3d..ea5cf80ac1 100644
@@ -38,6 +38,7 @@
 #include "mlx5_autoconf.h"
 #include "mlx5_mr.h"
 #include "mlx5_flow.h"
+#include "mlx5_flow_os.h"
 #include "rte_pmd_mlx5.h"
 
 /* Device parameter to enable RX completion queue compression. */
@@ -415,7 +416,7 @@ mlx5_flow_aso_age_mng_close(struct mlx5_dev_ctx_shared *sh)
 			for (j = 0; j < MLX5_COUNTERS_PER_POOL; ++j)
 				if (pool->actions[j].dr_action)
 					claim_zero
-						(mlx5_glue->destroy_flow_action
+						(mlx5_flow_os_destroy_flow_action
 						  (pool->actions[j].dr_action));
 			mlx5_free(pool);
 		}
@@ -523,7 +524,7 @@ mlx5_flow_counters_mng_close(struct mlx5_dev_ctx_shared *sh)
 
 				if (cnt->action)
 					claim_zero
-					 (mlx5_glue->destroy_flow_action
+					 (mlx5_flow_os_destroy_flow_action
 					  (cnt->action));
 				if (fallback && MLX5_POOL_GET_CNT
 				    (pool, j)->dcs_when_free)
drivers/net/mlx5/mlx5_flow_dv.c +3 -3
index c31737652c..78b5a6b338 100644
@@ -11117,11 +11117,11 @@ flow_dv_sample_remove_cb(struct mlx5_cache_list *list __rte_unused,
 	struct mlx5_priv *priv = dev->data->dev_private;
 
 	if (cache_resource->verbs_action)
-		claim_zero(mlx5_glue->destroy_flow_action
+		claim_zero(mlx5_flow_os_destroy_flow_action
 				(cache_resource->verbs_action));
 	if (cache_resource->ft_type == MLX5DV_FLOW_TABLE_TYPE_FDB) {
 		if (cache_resource->default_miss)
-			claim_zero(mlx5_glue->destroy_flow_action
+			claim_zero(mlx5_flow_os_destroy_flow_action
 			  (cache_resource->default_miss));
 	}
 	if (cache_resource->normal_path_tbl)
@@ -11174,7 +11174,7 @@ flow_dv_dest_array_remove_cb(struct mlx5_cache_list *list __rte_unused,
 
 	MLX5_ASSERT(cache_resource->action);
 	if (cache_resource->action)
-		claim_zero(mlx5_glue->destroy_flow_action
+		claim_zero(mlx5_flow_os_destroy_flow_action
 					(cache_resource->action));
 	for (; i < cache_resource->num_of_dest; i++)
 		flow_dv_sample_sub_actions_release(dev,
Signature · 1 line
2.16.1.windows.4
#83 lore raw

PATCH v3 12/32 common/mlx5: add definition HAVE_INFINIBAND_VERBS_H

In reply to Tal Shnaiderman

From: Ophir Munk <[email protected]>

Add a Verbs file presence indication. Under Linux it is required that file infiniband/verbs.h is installed for building DPDK. Other operating systems (e.g. Windows) ignore Verbs completely. This commit adds definition HAVE_INFINIBAND_VERBS_H (file mlx5_autoconf.h) to indicate whether DPDK compiles with Verbs or not.

---
 drivers/common/mlx5/linux/meson.build | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/common/mlx5/linux/meson.build +4 -2
index 63b78e4bce..580419e6d9 100644
@@ -181,8 +181,10 @@ has_sym_args = [
 	[ 'HAVE_MLX5_DR_CREATE_ACTION_DEST_ARRAY', 'infiniband/mlx5dv.h',
 	'mlx5dv_dr_action_create_dest_array'],
 	[ 'HAVE_DEVLINK', 'linux/devlink.h', 'DEVLINK_GENL_NAME' ],
-        [ 'HAVE_MLX5_DR_CREATE_ACTION_ASO', 'infiniband/mlx5dv.h',
-        'mlx5dv_dr_action_create_aso' ],
+	[ 'HAVE_MLX5_DR_CREATE_ACTION_ASO', 'infiniband/mlx5dv.h',
+	'mlx5dv_dr_action_create_aso' ],
+	[ 'HAVE_INFINIBAND_VERBS_H', 'infiniband/verbs.h',
+	'INFINIBAND_VERBS_H' ],
 ]
 config = configuration_data()
 foreach arg:has_sym_args
Signature · 1 line
2.16.1.windows.4
#84 lore raw

PATCH v3 13/32 common/mlx5/linux: handle memory allocations with alignment

In reply to Tal Shnaiderman

From: Ophir Munk <[email protected]>

mlx5_malloc() API has an alignment parameter for system memory allocations. malloc() is called for non-aligned allocations and posix_memalign() is called for aligned allocations. When calling mlx5_free() there is no distinction whether the memory was originally allocated with or without alignment. Freeing a memory may be handled differently by operating systems. Therefore this commit wraps these APIs with OS specific calls: mlx5_os_malloc(), mlx5_os_free().

---
 drivers/common/mlx5/linux/mlx5_common_os.h | 38 ++++++++++++++++++++++++++++++
 drivers/common/mlx5/mlx5_malloc.c          | 14 +++++------
 2 files changed, 44 insertions(+), 8 deletions(-)
drivers/common/mlx5/linux/mlx5_common_os.h +38 -0
index f8b215cc29..bd44ecb7d6 100644
@@ -6,6 +6,7 @@
 #define RTE_PMD_MLX5_COMMON_OS_H_
 
 #include <stdio.h>
+#include <malloc.h>
 
 #include <rte_pci.h>
 #include <rte_debug.h>
@@ -16,6 +17,7 @@
 
 #include "mlx5_autoconf.h"
 #include "mlx5_glue.h"
+#include "mlx5_malloc.h"
 
 /**
  * Get device name. Given an ibv_device pointer - return a
@@ -224,4 +226,40 @@ mlx5_os_umem_dereg(void *pumem)
 {
 	return mlx5_glue->devx_umem_dereg(pumem);
 }
+
+/**
+ * Memory allocation optionally with alignment.
+ *
+ * @param[in] align
+ *    Alignment size (may be zero)
+ * @param[in] size
+ *    Size in bytes to allocate
+ *
+ * @return
+ *    Valid pointer to allocated memory, NULL in case of failure
+ */
+static inline void *
+mlx5_os_malloc(size_t align, size_t size)
+{
+	void *buf;
+
+	if (posix_memalign(&buf, align, size))
+		return NULL;
+	return buf;
+}
+
+/**
+ * This API de-allocates a memory that originally could have been
+ * allocated aligned or non-aligned. In Linux it is a wrapper
+ * around free().
+ *
+ * @param[in] addr
+ *    Pointer to address to free
+ *
+ */
+static inline void
+mlx5_os_free(void *addr)
+{
+	free(addr);
+}
 #endif /* RTE_PMD_MLX5_COMMON_OS_H_ */
drivers/common/mlx5/mlx5_malloc.c +6 -8
index 5a3267f730..9d30cedbaa 100644
@@ -9,6 +9,7 @@
 #include <string.h>
 
 #include "mlx5_common_utils.h"
+#include "mlx5_common_os.h"
 #include "mlx5_malloc.h"
 
 struct mlx5_sys_mem {
@@ -148,14 +149,11 @@ static void *
 mlx5_alloc_align(size_t size, unsigned int align, unsigned int zero)
 {
 	void *buf;
-	int ret;
-
-	ret = posix_memalign(&buf, align, size);
-	if (ret) {
-		DRV_LOG(ERR,
-			"Couldn't allocate buf size=%zu align=%u. Err=%d\n",
-			size, align, ret);
 
+	buf = mlx5_os_malloc(align, size);
+	if (!buf) {
+		DRV_LOG(ERR, "Couldn't allocate buf size=%zu align=%u.",
+			size, align);
 		return NULL;
 	}
 	if (zero)
@@ -264,7 +262,7 @@ mlx5_free(void *addr)
 		__atomic_add_fetch(&mlx5_sys_mem.free_sys, 1,
 				   __ATOMIC_RELAXED);
 #endif
-		free(addr);
+		mlx5_os_free(addr);
 	} else {
 #ifdef RTE_LIBRTE_MLX5_DEBUG
 		__atomic_add_fetch(&mlx5_sys_mem.free_rte, 1,
Signature · 1 line
2.16.1.windows.4
#85 lore raw

PATCH v3 14/32 common/mlx5/windows: handle memory allocations with alignment

In reply to Tal Shnaiderman

From: Ophir Munk <[email protected]>

This commit is the Windows equivalent of the Linux implementation. The APIs included in this commit: mlx5_os_malloc(), mlx5_os_free(). For memory allocations (with or without alignment) we always call _aligned_malloc(). Even if zero alignment was requested in the first place - we always select a minimal alignment value. In this way when the memory is free - it is always safe to call _aligned_free().

---
 drivers/common/mlx5/windows/mlx5_common_os.h | 51 ++++++++++++++++++++++++++++
 1 file changed, 51 insertions(+)
 create mode 100644 drivers/common/mlx5/windows/mlx5_common_os.h
drivers/common/mlx5/windows/mlx5_common_os.h new file +51 -0
new file mode 100644
index 0000000000..cce7c88c6a
@@ -0,0 +1,51 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright 2020 Mellanox Technologies, Ltd
+ */
+
+#ifndef RTE_PMD_MLX5_COMMON_OS_H_
+#define RTE_PMD_MLX5_COMMON_OS_H_
+
+#include <stdio.h>
+
+#include "mlx5_autoconf.h"
+#include "mlx5_glue.h"
+#include "mlx5_malloc.h"
+
+/**
+ * This API allocates aligned or non-aligned memory.  The free can be on either
+ * aligned or nonaligned memory.  To be protected - even though there may be no
+ * alignment - in Windows this API will unconditioanlly call _aligned_malloc()
+ * with at least a minimal alignment size.
+ *
+ * @param[in] align
+ *    The alignment value, which must be an integer power of 2 (or 0 for
+ *    non-alignment)
+ * @param[in] size
+ *    Size in bytes to allocate
+ *
+ * @return
+ *    Valid pointer to allocated memory, NULL in case of failure
+ */
+static inline void *
+mlx5_os_malloc(size_t align, size_t size)
+{
+	if (align < MLX5_MALLOC_ALIGNMENT)
+		align = MLX5_MALLOC_ALIGNMENT;
+	return _aligned_malloc(size, align);
+}
+
+/**
+ * This API de-allocates a memory that originally could have been allocated
+ * aligned or non-aligned. In Windows since the allocation was with
+ * _aligned_malloc() - it is safe to always call _aligned_free().
+ *
+ * @param[in] addr
+ *    Pointer to address to free
+ *
+ */
+static inline void
+mlx5_os_free(void *addr)
+{
+	_aligned_free(addr);
+}
+#endif /* RTE_PMD_MLX5_COMMON_OS_H_ */
Signature · 1 line
2.16.1.windows.4
#86 lore raw

PATCH v3 15/32 common/mlx5/linux: wrap event channel APIs with OS calls

In reply to Tal Shnaiderman

Wrap the API to create/destroy event channel and to subscribe an event with OS calls. In Linux those calls are implemented by glue functions while in Windows they are not supported.

---
 drivers/common/mlx5/linux/mlx5_common_os.h | 22 ++++++++++++++++++++++
 drivers/net/mlx5/mlx5_devx.c               |  8 ++++----
 drivers/net/mlx5/mlx5_txpp.c               |  6 +++---
 drivers/vdpa/mlx5/mlx5_vdpa_event.c        |  7 ++++---
 4 files changed, 33 insertions(+), 10 deletions(-)
drivers/common/mlx5/linux/mlx5_common_os.h +22 -0
index bd44ecb7d6..63f070d9c4 100644
@@ -227,6 +227,28 @@ mlx5_os_umem_dereg(void *pumem)
 	return mlx5_glue->devx_umem_dereg(pumem);
 }
 
+static inline void *
+mlx5_os_devx_create_event_channel(void *ctx, int flags)
+{
+	return mlx5_glue->devx_create_event_channel(ctx, flags);
+}
+
+static inline void
+mlx5_os_devx_destroy_event_channel(void *eventc)
+{
+	mlx5_glue->devx_destroy_event_channel(eventc);
+}
+
+static inline int
+mlx5_os_devx_subscribe_devx_event(void *eventc,
+				  void *obj,
+				  uint16_t events_sz, uint16_t events_num[],
+				  uint64_t cookie)
+{
+	return mlx5_glue->devx_subscribe_devx_event(eventc, obj, events_sz,
+						    events_num, cookie);
+}
+
 /**
  * Memory allocation optionally with alignment.
  *
drivers/net/mlx5/mlx5_devx.c +4 -4
index 235fd5798d..84a5c55ee0 100644
@@ -216,7 +216,7 @@ mlx5_rxq_devx_obj_release(struct mlx5_rxq_obj *rxq_obj)
 		claim_zero(mlx5_devx_cmd_destroy(rxq_obj->rq));
 		claim_zero(mlx5_devx_cmd_destroy(rxq_obj->devx_cq));
 		if (rxq_obj->devx_channel)
-			mlx5_glue->devx_destroy_event_channel
+			mlx5_os_devx_destroy_event_channel
 							(rxq_obj->devx_channel);
 		mlx5_rxq_release_devx_rq_resources(rxq_obj->rxq_ctrl);
 		mlx5_rxq_release_devx_cq_resources(rxq_obj->rxq_ctrl);
@@ -533,7 +533,7 @@ mlx5_rxq_create_devx_cq_resources(struct rte_eth_dev *dev, uint16_t idx)
 	rxq_data->cqe_n = log_cqe_n;
 	rxq_data->cqn = cq_obj->id;
 	if (rxq_ctrl->obj->devx_channel) {
-		ret = mlx5_glue->devx_subscribe_devx_event
+		ret = mlx5_os_devx_subscribe_devx_event
 						(rxq_ctrl->obj->devx_channel,
 						 cq_obj->obj,
 						 sizeof(event_nums),
@@ -644,7 +644,7 @@ mlx5_rxq_devx_obj_new(struct rte_eth_dev *dev, uint16_t idx)
 		int devx_ev_flag =
 			  MLX5DV_DEVX_CREATE_EVENT_CHANNEL_FLAGS_OMIT_EV_DATA;
 
-		tmpl->devx_channel = mlx5_glue->devx_create_event_channel
+		tmpl->devx_channel = mlx5_os_devx_create_event_channel
 								(priv->sh->ctx,
 								 devx_ev_flag);
 		if (!tmpl->devx_channel) {
@@ -686,7 +686,7 @@ mlx5_rxq_devx_obj_new(struct rte_eth_dev *dev, uint16_t idx)
 	if (tmpl->devx_cq)
 		claim_zero(mlx5_devx_cmd_destroy(tmpl->devx_cq));
 	if (tmpl->devx_channel)
-		mlx5_glue->devx_destroy_event_channel(tmpl->devx_channel);
+		mlx5_os_devx_destroy_event_channel(tmpl->devx_channel);
 	mlx5_rxq_release_devx_rq_resources(rxq_ctrl);
 	mlx5_rxq_release_devx_cq_resources(rxq_ctrl);
 	rte_errno = ret; /* Restore rte_errno. */
drivers/net/mlx5/mlx5_txpp.c +3 -3
index 749529c410..726bdc6ae1 100644
@@ -37,7 +37,7 @@ static void
 mlx5_txpp_destroy_event_channel(struct mlx5_dev_ctx_shared *sh)
 {
 	if (sh->txpp.echan) {
-		mlx5_glue->devx_destroy_event_channel(sh->txpp.echan);
+		mlx5_os_devx_destroy_event_channel(sh->txpp.echan);
 		sh->txpp.echan = NULL;
 	}
 }
@@ -47,7 +47,7 @@ static int
 mlx5_txpp_create_event_channel(struct mlx5_dev_ctx_shared *sh)
 {
 	MLX5_ASSERT(!sh->txpp.echan);
-	sh->txpp.echan = mlx5_glue->devx_create_event_channel(sh->ctx,
+	sh->txpp.echan = mlx5_os_devx_create_event_channel(sh->ctx,
 			MLX5DV_DEVX_CREATE_EVENT_CHANNEL_FLAGS_OMIT_EV_DATA);
 	if (!sh->txpp.echan) {
 		rte_errno = errno;
@@ -937,7 +937,7 @@ mlx5_txpp_start_service(struct mlx5_dev_ctx_shared *sh)
 		return -rte_errno;
 	}
 	/* Subscribe CQ event to the event channel controlled by the driver. */
-	ret = mlx5_glue->devx_subscribe_devx_event(sh->txpp.echan,
+	ret = mlx5_os_devx_subscribe_devx_event(sh->txpp.echan,
 						   sh->txpp.rearm_queue.cq->obj,
 						   sizeof(event_nums),
 						   event_nums, 0);
drivers/vdpa/mlx5/mlx5_vdpa_event.c +4 -3
index 3aeaeb893f..fd6150928b 100644
@@ -15,6 +15,7 @@
 #include <rte_alarm.h>
 
 #include <mlx5_common.h>
+#include <mlx5_common_os.h>
 #include <mlx5_glue.h>
 
 #include "mlx5_vdpa_utils.h"
@@ -43,7 +44,7 @@ mlx5_vdpa_event_qp_global_release(struct mlx5_vdpa_priv *priv)
 		       sizeof(out.buf)) >=
 		       (ssize_t)sizeof(out.event_resp.cookie))
 			;
-		mlx5_glue->devx_destroy_event_channel(priv->eventc);
+		mlx5_os_devx_destroy_event_channel(priv->eventc);
 		priv->eventc = NULL;
 	}
 #endif
@@ -63,7 +64,7 @@ mlx5_vdpa_event_qp_global_prepare(struct mlx5_vdpa_priv *priv)
 		DRV_LOG(ERR, "Failed to query EQ number %d.", rte_errno);
 		return -1;
 	}
-	priv->eventc = mlx5_glue->devx_create_event_channel(priv->ctx,
+	priv->eventc = mlx5_os_devx_create_event_channel(priv->ctx,
 			   MLX5DV_DEVX_CREATE_EVENT_CHANNEL_FLAGS_OMIT_EV_DATA);
 	if (!priv->eventc) {
 		rte_errno = errno;
@@ -176,7 +177,7 @@ mlx5_vdpa_cq_create(struct mlx5_vdpa_priv *priv, uint16_t log_desc_n,
 	cq->cq_ci = 0;
 	rte_spinlock_init(&cq->sl);
 	/* Subscribe CQ event to the event channel controlled by the driver. */
-	ret = mlx5_glue->devx_subscribe_devx_event(priv->eventc, cq->cq->obj,
+	ret = mlx5_os_devx_subscribe_devx_event(priv->eventc, cq->cq->obj,
 						   sizeof(event_nums),
 						   event_nums,
 						   (uint64_t)(uintptr_t)cq);
Signature · 1 line
2.16.1.windows.4
#87 lore raw

PATCH v3 16/32 common/mlx5: add Windows exports file

In reply to Tal Shnaiderman

File drivers/common/mlx5/rte_common_mlx5_exports.def contains mlx5 Windows exported symbols under common/mlx5 directory (DLL file name librte_common_mlx5*.dll). It is the equivalent of Linux map file rte_common_mlx5_version.map but the list of symbols may be different between the two operating systems.

---
 drivers/common/mlx5/rte_common_mlx5_exports.def | 62 +++++++++++++++++++++++++
 1 file changed, 62 insertions(+)
 create mode 100644 drivers/common/mlx5/rte_common_mlx5_exports.def
drivers/common/mlx5/rte_common_mlx5_exports.def new file +62 -0
new file mode 100644
index 0000000000..23984b7abd
@@ -0,0 +1,62 @@
+EXPORTS
+	haswell_broadwell_cpu
+
+	mlx5_common_init
+
+	mlx5_create_mr_ext
+
+	mlx5_devx_cmd_create_cq
+	mlx5_devx_cmd_create_flex_parser
+	mlx5_devx_cmd_create_qp
+	mlx5_devx_cmd_create_rq
+	mlx5_devx_cmd_create_rqt
+	mlx5_devx_cmd_create_sq
+	mlx5_devx_cmd_create_tir
+	mlx5_devx_cmd_create_td
+	mlx5_devx_cmd_create_tis
+	mlx5_devx_cmd_create_virtq
+	mlx5_devx_cmd_destroy
+	mlx5_devx_cmd_flow_counter_alloc
+	mlx5_devx_cmd_flow_counter_query
+	mlx5_devx_cmd_flow_dump
+	mlx5_devx_cmd_mkey_create
+	mlx5_devx_cmd_modify_qp_state
+	mlx5_devx_cmd_modify_rq
+	mlx5_devx_cmd_modify_rqt
+	mlx5_devx_cmd_modify_sq
+	mlx5_devx_cmd_modify_tir
+	mlx5_devx_cmd_modify_virtq
+	mlx5_devx_cmd_qp_query_tis_td
+	mlx5_devx_cmd_query_hca_attr
+	mlx5_devx_cmd_query_parse_samples
+	mlx5_devx_cmd_query_virtq
+	mlx5_devx_cmd_register_read
+	mlx5_devx_get_out_command_status
+	mlx5_devx_cmd_create_flow_hit_aso_obj
+
+	mlx5_get_dbr
+
+	mlx5_malloc_mem_select
+	mlx5_mr_btree_init
+	mlx5_mr_btree_free
+	mlx5_mr_btree_dump
+	mlx5_mr_addr2mr_bh
+	mlx5_mr_release_cache
+	mlx5_mr_dump_cache
+	mlx5_mr_rebuild_cache
+	mlx5_mr_insert_cache
+	mlx5_mr_lookup_cache
+	mlx5_mr_lookup_list
+	mlx5_mr_create_primary
+	mlx5_mr_flush_local_cache
+	mlx5_mp_req_queue_state_modify
+	mlx5_mr_free
+
+	mlx5_pci_driver_register
+
+	mlx5_release_dbr
+
+	mlx5_malloc
+	mlx5_realloc
+	mlx5_free
+
Signature · 1 line
2.16.1.windows.4
#88 lore raw

PATCH v3 17/32 common/mlx5: extend DevX query hca attributes command

In reply to Tal Shnaiderman

Extend DevX API mlx5_devx_cmd_query_hca_attr() to report on max number of available objects including: CQ, QP, PD, SRQ.

---
 drivers/common/mlx5/mlx5_devx_cmds.c | 11 +++++++++++
 drivers/common/mlx5/mlx5_devx_cmds.h | 10 +++++++++-
 drivers/common/mlx5/mlx5_prm.h       |  1 +
 3 files changed, 21 insertions(+), 1 deletion(-)
drivers/common/mlx5/mlx5_devx_cmds.c +11 -0
index 9c1d1883ea..36d3a421aa 100644
@@ -720,6 +720,14 @@ mlx5_devx_cmd_query_hca_attr(void *ctx,
 	attr->flow_hit_aso = !!(MLX5_GET64(cmd_hca_cap, hcattr,
 					   general_obj_types) &
 				MLX5_GENERAL_OBJ_TYPES_CAP_FLOW_HIT_ASO);
+	attr->log_max_cq = MLX5_GET(cmd_hca_cap, hcattr, log_max_cq);
+	attr->log_max_qp = MLX5_GET(cmd_hca_cap, hcattr, log_max_qp);
+	attr->log_max_cq_sz = MLX5_GET(cmd_hca_cap, hcattr, log_max_cq_sz);
+	attr->log_max_qp_sz = MLX5_GET(cmd_hca_cap, hcattr, log_max_qp_sz);
+	attr->log_max_mrw_sz = MLX5_GET(cmd_hca_cap, hcattr, log_max_mrw_sz);
+	attr->log_max_pd = MLX5_GET(cmd_hca_cap, hcattr, log_max_pd);
+	attr->log_max_srq = MLX5_GET(cmd_hca_cap, hcattr, log_max_srq);
+	attr->log_max_srq_sz = MLX5_GET(cmd_hca_cap, hcattr, log_max_srq_sz);
 	if (attr->qos.sup) {
 		MLX5_SET(query_hca_cap_in, in, op_mod,
 			 MLX5_GET_HCA_CAP_OP_MOD_QOS_CAP |
@@ -834,6 +842,9 @@ mlx5_devx_cmd_query_hca_attr(void *ctx,
 	attr->tunnel_stateless_gtp = MLX5_GET
 					(per_protocol_networking_offload_caps,
 					 hcattr, tunnel_stateless_gtp);
+	attr->rss_ind_tbl_cap = MLX5_GET
+					(per_protocol_networking_offload_caps,
+					 hcattr, rss_ind_tbl_cap);
 	if (attr->wqe_inline_mode != MLX5_CAP_INLINE_MODE_VPORT_CONTEXT)
 		return 0;
 	if (attr->eth_virt) {
drivers/common/mlx5/mlx5_devx_cmds.h +9 -1
index 726e9f5192..5056d86ed9 100644
@@ -117,6 +117,15 @@ struct mlx5_hca_attr {
 	uint32_t log_max_ft_sampler_num:8;
 	struct mlx5_hca_qos_attr qos;
 	struct mlx5_hca_vdpa_attr vdpa;
+	int log_max_qp_sz;
+	int log_max_cq_sz;
+	int log_max_qp;
+	int log_max_cq;
+	uint32_t log_max_pd;
+	uint32_t log_max_mrw_sz;
+	uint32_t log_max_srq;
+	uint32_t log_max_srq_sz;
+	uint32_t rss_ind_tbl_cap;
 };
 
 struct mlx5_devx_wq_attr {
@@ -495,7 +504,6 @@ struct mlx5_devx_obj *mlx5_devx_cmd_create_virtio_q_counters(void *ctx);
 __rte_internal
 int mlx5_devx_cmd_query_virtio_q_counters(struct mlx5_devx_obj *couners_obj,
 				  struct mlx5_devx_virtio_q_couners_attr *attr);
-
 __rte_internal
 struct mlx5_devx_obj *mlx5_devx_cmd_create_flow_hit_aso_obj(void *ctx,
 							    uint32_t pd);
drivers/common/mlx5/mlx5_prm.h +1 -0
index 58d180486e..585e9d1c05 100644
@@ -665,6 +665,7 @@ typedef uint8_t u8;
 #define MLX5_GET64(typ, p, fld) rte_be_to_cpu_64(*((rte_be64_t *)(p) + \
 						   __mlx5_64_off(typ, fld)))
 #define MLX5_FLD_SZ_BYTES(typ, fld) (__mlx5_bit_sz(typ, fld) / 8)
+#define MLX5_UN_SZ_BYTES(typ) (sizeof(union mlx5_ifc_##typ##_bits) / 8)
 
 struct mlx5_ifc_fte_match_set_misc_bits {
 	u8 gre_c_present[0x1];
Signature · 1 line
2.16.1.windows.4
#89 lore raw

PATCH v3 18/32 common/mlx5: add DevX alloc PD command

In reply to Tal Shnaiderman

Add a new DevX API mlx5_devx_cmd_alloc_pd() that creates a new protection domain (PD).

---
 drivers/common/mlx5/mlx5_devx_cmds.c            | 35 ++++++++++++++++++++++++
 drivers/common/mlx5/mlx5_devx_cmds.h            |  2 ++
 drivers/common/mlx5/mlx5_prm.h                  | 36 +++++++++++++++++++++++++
 drivers/common/mlx5/rte_common_mlx5_exports.def |  1 +
 drivers/common/mlx5/version.map                 |  1 +
 5 files changed, 75 insertions(+)
drivers/common/mlx5/mlx5_devx_cmds.c +35 -0
index 36d3a421aa..12f51a940c 100644
@@ -2055,3 +2055,38 @@ mlx5_devx_cmd_create_flow_hit_aso_obj(void *ctx, uint32_t pd)
 	flow_hit_aso_obj->id = MLX5_GET(general_obj_out_cmd_hdr, out, obj_id);
 	return flow_hit_aso_obj;
 }
+
+/*
+ * Create PD using DevX API.
+ *
+ * @param[in] ctx
+ *   Context returned from mlx5 open_device() glue function.
+ *
+ * @return
+ *   The DevX object created, NULL otherwise and rte_errno is set.
+ */
+struct mlx5_devx_obj *
+mlx5_devx_cmd_alloc_pd(void *ctx)
+{
+	struct mlx5_devx_obj *ppd =
+		mlx5_malloc(MLX5_MEM_ZERO, sizeof(*ppd), 0, SOCKET_ID_ANY);
+	u32 in[MLX5_ST_SZ_DW(alloc_pd_in)] = {0};
+	u32 out[MLX5_ST_SZ_DW(alloc_pd_out)] = {0};
+
+	if (!ppd) {
+		DRV_LOG(ERR, "Failed to allocate PD data.");
+		rte_errno = ENOMEM;
+		return NULL;
+	}
+	MLX5_SET(alloc_pd_in, in, opcode, MLX5_CMD_OP_ALLOC_PD);
+	ppd->obj = mlx5_glue->devx_obj_create(ctx, in, sizeof(in),
+				out, sizeof(out));
+	if (!ppd->obj) {
+		mlx5_free(ppd);
+		DRV_LOG(ERR, "Failed to allocate PD Obj using DevX.");
+		rte_errno = errno;
+		return NULL;
+	}
+	ppd->id = MLX5_GET(alloc_pd_out, out, pd);
+	return ppd;
+}
drivers/common/mlx5/mlx5_devx_cmds.h +2 -0
index 5056d86ed9..8277fdbc39 100644
@@ -508,4 +508,6 @@ __rte_internal
 struct mlx5_devx_obj *mlx5_devx_cmd_create_flow_hit_aso_obj(void *ctx,
 							    uint32_t pd);
 
+__rte_internal
+struct mlx5_devx_obj *mlx5_devx_cmd_alloc_pd(void *ctx);
 #endif /* RTE_PMD_MLX5_DEVX_CMDS_H_ */
drivers/common/mlx5/mlx5_prm.h +36 -0
index 585e9d1c05..4ddf865743 100644
@@ -844,6 +844,8 @@ enum {
 	MLX5_CMD_OP_SUSPEND_QP = 0x50F,
 	MLX5_CMD_OP_RESUME_QP = 0x510,
 	MLX5_CMD_OP_QUERY_NIC_VPORT_CONTEXT = 0x754,
+	MLX5_CMD_OP_ALLOC_PD = 0x800,
+	MLX5_CMD_OP_DEALLOC_PD = 0x801,
 	MLX5_CMD_OP_ACCESS_REGISTER = 0x805,
 	MLX5_CMD_OP_ALLOC_TRANSPORT_DOMAIN = 0x816,
 	MLX5_CMD_OP_CREATE_TIR = 0x900,
@@ -2772,6 +2774,40 @@ struct mlx5_ifc_init2init_qp_in_bits {
 	u8 reserved_at_800[0x80];
 };
 
+struct mlx5_ifc_dealloc_pd_out_bits {
+	u8 status[0x8];
+	u8 reserved_0[0x18];
+	u8 syndrome[0x20];
+	u8 reserved_1[0x40];
+};
+
+struct mlx5_ifc_dealloc_pd_in_bits {
+	u8 opcode[0x10];
+	u8 reserved_0[0x10];
+	u8 reserved_1[0x10];
+	u8 op_mod[0x10];
+	u8 reserved_2[0x8];
+	u8 pd[0x18];
+	u8 reserved_3[0x20];
+};
+
+struct mlx5_ifc_alloc_pd_out_bits {
+	u8 status[0x8];
+	u8 reserved_0[0x18];
+	u8 syndrome[0x20];
+	u8 reserved_1[0x8];
+	u8 pd[0x18];
+	u8 reserved_2[0x20];
+};
+
+struct mlx5_ifc_alloc_pd_in_bits {
+	u8 opcode[0x10];
+	u8 reserved_0[0x10];
+	u8 reserved_1[0x10];
+	u8 op_mod[0x10];
+	u8 reserved_2[0x40];
+};
+
 #ifdef PEDANTIC
 #pragma GCC diagnostic ignored "-Wpedantic"
 #endif
drivers/common/mlx5/rte_common_mlx5_exports.def +1 -0
index 23984b7abd..15aafc3809 100644
@@ -5,6 +5,7 @@ EXPORTS
 
 	mlx5_create_mr_ext
 
+	mlx5_devx_cmd_alloc_pd
 	mlx5_devx_cmd_create_cq
 	mlx5_devx_cmd_create_flex_parser
 	mlx5_devx_cmd_create_qp
drivers/common/mlx5/version.map +1 -0
index 17dd11f635..fb3952bbc6 100644
@@ -10,6 +10,7 @@ INTERNAL {
 
 	mlx5_dev_to_pci_addr;
 
+	mlx5_devx_cmd_alloc_pd;
 	mlx5_devx_cmd_create_cq;
 	mlx5_devx_cmd_create_flex_parser;
 	mlx5_devx_cmd_create_qp;
Signature · 1 line
2.16.1.windows.4
#90 lore raw

PATCH v3 19/32 common/mlx5/windows: add glue functions APIs

In reply to Tal Shnaiderman

Windows glue functions are added to file mlx5/windows/mlx5_glue.c. The following APIs are supported:
get_device_list, free_device_list, open_device, close_device, query_device, query_hca_iseg, devx_obj_create, devx_obj_destroy, devx_obj_query, devx_obj_modify, devx_general_cmd, devx_umem_reg, devx_umem_dereg, devx_alloc_uar, devx_free_uar, devx_fs_rule_add, devx_fs_rule_del, devx_query_eqn
New added files:
mlx5_win_defs.h - this file imports missing definitions from Linux rdma-core library and Linux OS.
mlx5_win_ext.h - this file contains structs that enable a unified Linux/Windows API. Each struct has an equivalent (but different) Linux struct. By calling with 'void *' pointers - the Linux/Windows API is identical.

---
 drivers/common/mlx5/rte_common_mlx5_exports.def |   1 +
 drivers/common/mlx5/windows/mlx5_glue.c         | 304 ++++++++++++++++++++++++
 drivers/common/mlx5/windows/mlx5_glue.h         |  58 +++++
 drivers/common/mlx5/windows/mlx5_win_defs.h     |  25 ++
 drivers/common/mlx5/windows/mlx5_win_ext.h      |  34 +++
 5 files changed, 422 insertions(+)
 create mode 100644 drivers/common/mlx5/windows/mlx5_glue.c
 create mode 100644 drivers/common/mlx5/windows/mlx5_glue.h
 create mode 100644 drivers/common/mlx5/windows/mlx5_win_defs.h
 create mode 100644 drivers/common/mlx5/windows/mlx5_win_ext.h
drivers/common/mlx5/rte_common_mlx5_exports.def +1 -0
index 15aafc3809..2f6aab133b 100644
@@ -36,6 +36,7 @@ EXPORTS
 	mlx5_devx_cmd_create_flow_hit_aso_obj
 
 	mlx5_get_dbr
+	mlx5_glue
 
 	mlx5_malloc_mem_select
 	mlx5_mr_btree_init
drivers/common/mlx5/windows/mlx5_glue.c new file +304 -0

304 lines not on this page · raw message

drivers/common/mlx5/windows/mlx5_glue.h new file +58 -0

58 lines not on this page · raw message

drivers/common/mlx5/windows/mlx5_win_defs.h new file +25 -0
new file mode 100644
index 0000000000..72a3131f5e
@@ -0,0 +1,25 @@
+/*
+ * Copyright (C) Mellanox Technologies, Ltd. 2001-2020.
+ *
+ */
+#ifndef __MLX5_WIN_DEFS_H__
+#define __MLX5_WIN_DEFS_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+enum {
+	MLX5_CQE_OWNER_MASK	= 1,
+	MLX5_CQE_REQ		= 0,
+	MLX5_CQE_RESP_WR_IMM	= 1,
+	MLX5_CQE_RESP_SEND	= 2,
+	MLX5_CQE_RESP_SEND_IMM	= 3,
+	MLX5_CQE_RESP_SEND_INV	= 4,
+	MLX5_CQE_RESIZE_CQ	= 5,
+	MLX5_CQE_NO_PACKET	= 6,
+	MLX5_CQE_REQ_ERR	= 13,
+	MLX5_CQE_RESP_ERR	= 14,
+	MLX5_CQE_INVALID	= 15,
+};
+#endif /* __MLX5_WIN_DEFS_H__ */
drivers/common/mlx5/windows/mlx5_win_ext.h new file +34 -0
new file mode 100644
index 0000000000..0e74910e9d
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) Mellanox Technologies, Ltd. 2001-2020.
+ *
+ */
+#ifndef __MLX5_WIN_ETX_H__
+#define __MLX5_WIN_ETX_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "mlx5devx.h"
+
+typedef struct mlx5_context {
+	devx_device_ctx        *devx_ctx;
+	struct devx_device mlx5_dev;
+
+} mlx5_context_st;
+
+typedef struct {
+	devx_device_ctx *devx_ctx;
+	struct devx_obj_handle *obj;
+} mlx5_devx_obj_st;
+
+struct mlx5_devx_umem {
+	void                   *addr;
+	struct devx_obj_handle *umem_hdl;
+	uint32_t                umem_id;
+};
+
+#define GET_DEVX_CTX(ctx) (((mlx5_context_st *)ctx)->devx_ctx)
+#define GET_OBJ_CTX(obj)  (((mlx5_devx_obj_st *)obj)->devx_ctx)
+
+#endif /* __MLX5_WIN_ETX_H__ */
Signature · 1 line
2.16.1.windows.4
#91 lore raw

PATCH v3 20/32 mlx5/windows: add mlx5 meson file

In reply to Tal Shnaiderman

File drivers/common/mlx5/windows/meson.build is added to enable mlx5 source files compilation under common windows directory.
A Devx SDK tool must be installed to export two external H files:
mlx5devx.h and mlx5_ifc_devx.h. The installation is based on environment variable DEVX_INC_PATH. In addition a DLL lib file is installed based on environment variable DEVX_LIB_PATH. The meson file is using the environment variables for compilation and linkage.

---
 drivers/common/mlx5/windows/meson.build | 42 +++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)
 create mode 100644 drivers/common/mlx5/windows/meson.build
drivers/common/mlx5/windows/meson.build new file +42 -0
new file mode 100644
index 0000000000..2b2aa3b097
@@ -0,0 +1,42 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright 2019 Mellanox Technologies, Ltd
+
+includes += include_directories('.')
+
+allow_experimental_apis = true
+sources += files(
+	'mlx5_glue.c',
+)
+
+res_lib = run_command(python3, '-c', 'import os; print(os.environ["DEVX_LIB_PATH"])')
+res_inc = run_command(python3, '-c', 'import os; print(os.environ["DEVX_INC_PATH"])')
+
+if (res_lib.returncode() != 0 or res_inc.returncode() != 0)
+	build = false
+	reason = 'DevX environment variables are not set, DEVX_LIB_PATH and DEVX_INC_PATH vars must be exported'
+	subdir_done()
+endif
+
+devx_lib_dir = res_lib.stdout().strip()
+devx_inc_dir = res_inc.stdout().strip()
+
+ext_deps += cc.find_library('mlx5devx', dirs: devx_lib_dir, required: true)
+includes += include_directories(devx_inc_dir)
+cflags_options = [
+	'-std=c11',
+	'-Wno-strict-prototypes',
+	'-D_BSD_SOURCE',
+	'-D_DEFAULT_SOURCE',
+	'-D_XOPEN_SOURCE=600'
+]
+foreach option:cflags_options
+	if cc.has_argument(option)
+		cflags += option
+	endif
+endforeach
+if get_option('buildtype').contains('debug')
+	cflags += [ '-pedantic', '-DPEDANTIC' ]
+else
+	cflags += [ '-UPEDANTIC' ]
+endif
+
Signature · 1 line
2.16.1.windows.4
#92 lore raw

PATCH v3 21/32 mlx5/windows: add initialization routine for external lib

In reply to Tal Shnaiderman

From: Ophir Munk <[email protected]>

Add function mlx5_glue_constructor() as an initialization routine for run-time dependency on external lib. Currently the routine has an empty body. It is used for compatibility with Linux.

---
 drivers/common/mlx5/windows/meson.build      |  1 +
 drivers/common/mlx5/windows/mlx5_common_os.c | 24 ++++++++++++++++++++++++
 2 files changed, 25 insertions(+)
 create mode 100644 drivers/common/mlx5/windows/mlx5_common_os.c
drivers/common/mlx5/windows/meson.build +1 -0
index 2b2aa3b097..9e74ebdea3 100644
@@ -6,6 +6,7 @@ includes += include_directories('.')
 allow_experimental_apis = true
 sources += files(
 	'mlx5_glue.c',
+	'mlx5_common_os.c',
 )
 
 res_lib = run_command(python3, '-c', 'import os; print(os.environ["DEVX_LIB_PATH"])')
drivers/common/mlx5/windows/mlx5_common_os.c new file +24 -0
new file mode 100644
index 0000000000..5707fb60c3
@@ -0,0 +1,24 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright 2020 Mellanox Technologies, Ltd
+ */
+
+#include <unistd.h>
+#include <string.h>
+#include <stdio.h>
+
+#include <rte_errno.h>
+#include <rte_mempool.h>
+#include <rte_malloc.h>
+#include <rte_errno.h>
+
+#include "mlx5_devx_cmds.h"
+#include "mlx5_common_utils.h"
+#include <mlx5_common.h>
+
+/**
+ * Initialization routine for run-time dependency on external lib
+ */
+void
+mlx5_glue_constructor(void)
+{
+}
Signature · 1 line
2.16.1.windows.4
#93 lore raw

PATCH v3 22/32 mlx5/windows: generate file mlx5_autoconf.h

In reply to Tal Shnaiderman

From: Ophir Munk <[email protected]>

File mlx5_autoconf.h is generated under Windows to maintain compatibility with the Linux build system. This file is included in Linux/Windows shared source files therefore it is required. Currently the file is created empty.

---
 drivers/common/mlx5/windows/meson.build | 3 +++
 1 file changed, 3 insertions(+)
drivers/common/mlx5/windows/meson.build +3 -0
index 9e74ebdea3..5ac5724b40 100644
@@ -41,3 +41,6 @@ else
 	cflags += [ '-UPEDANTIC' ]
 endif
 
+# Generate an empty mlx5_autoconf.h file for compatibility with Linux
+config = configuration_data()
+configure_file(output : 'mlx5_autoconf.h', configuration : config)
Signature · 1 line
2.16.1.windows.4
#94 lore raw

PATCH v3 23/32 common/mlx5/windows: extend PRM match_param_bits struct

In reply to Tal Shnaiderman

Add reserved size to PRM 'struct mlx5_ifc_fte_match_param_bits' for non Linux OS. Windows drivers require this extension since their expected size should match the actual struct size. Linux drivers do not require this extension and already use calculations based on the shorter size. Use a static assert to verify that the PRM fte_match_param struct size remains correct.

---
 drivers/common/mlx5/mlx5_prm.h          | 7 +++++++
 drivers/common/mlx5/windows/mlx5_glue.c | 3 +++
 2 files changed, 10 insertions(+)
drivers/common/mlx5/mlx5_prm.h +7 -0
index 4ddf865743..27a4e4f0f1 100644
@@ -815,6 +815,13 @@ struct mlx5_ifc_fte_match_param_bits {
 	struct mlx5_ifc_fte_match_set_misc2_bits misc_parameters_2;
 	struct mlx5_ifc_fte_match_set_misc3_bits misc_parameters_3;
 	struct mlx5_ifc_fte_match_set_misc4_bits misc_parameters_4;
+/*
+ * Add reserved bit to match the struct size with the size defined in PRM.
+ * This extension is not required in Linux.
+ */
+#ifndef HAVE_INFINIBAND_VERBS_H
+	u8 reserved_0[0x400];
+#endif
 };
 
 enum {
drivers/common/mlx5/windows/mlx5_glue.c +3 -0
index 7f8a00aaa7..3896cf0932 100644
@@ -256,6 +256,9 @@ mlx5_glue_devx_free_uar(void *uar)
 	devx_free_uar((devx_uar_handle *)uar);
 }
 
+static_assert(MLX5_ST_SZ_BYTES(fte_match_param) == 0x200,
+	"PRM size of fte_match_param is broken! cannot compile Windows!");
+
 static void*
 mlx5_glue_devx_fs_rule_add(void *ctx, void *in, uint32_t inlen)
 
Signature · 1 line
2.16.1.windows.4
#95 lore raw

PATCH v3 24/32 common/mlx5/windows: add getter functions

In reply to Tal Shnaiderman

From: Ophir Munk <[email protected]>

Add file mlx5/windows/mlx5_common_os.h the equivalent of Linux file mlx5/linux/mlx5_common_os.h. It contains getters functions mlx5_os_get_dev_device_name, mlx5_os_get_ctx_device_name, mlx5_os_get_ctx_device_path, mlx5_os_get_umem_id, mlx5_os_get_devx_channel_fd.

---
 drivers/common/mlx5/windows/mlx5_common_os.h | 91 ++++++++++++++++++++++++++++
 1 file changed, 91 insertions(+)
drivers/common/mlx5/windows/mlx5_common_os.h +91 -0
index cce7c88c6a..2abdb2c3ae 100644
@@ -48,4 +48,95 @@ mlx5_os_free(void *addr)
 {
 	_aligned_free(addr);
 }
+
+/**
+ * Get fd. Given a pointer to DevX channel object of type
+ * 'struct mlx5dv_devx_event_channel*' - return its fd.
+ * Under Windows it is a stub.
+ *
+ * @param[in] channel
+ *    Pointer to channel object.
+ *
+ * @return
+ *    0
+ */
+static inline int
+mlx5_os_get_devx_channel_fd(void *channel)
+{
+	if (!channel)
+		return 0;
+	return 0;
+}
+
+/**
+ * Get device name. Given a device pointer - return a
+ * pointer to the corresponding device name.
+ *
+ * @param[in] dev
+ *   Pointer to device.
+ *
+ * @return
+ *   Pointer to device name if dev is valid, NULL otherwise.
+ */
+static inline const char *
+mlx5_os_get_dev_device_name(void *dev)
+{
+	if (!dev)
+		return NULL;
+	return ((struct devx_device *)dev)->name;
+}
+
+/**
+ * Get device name. Given a context pointer - return a
+ * pointer to the corresponding device name.
+ *
+ * @param[in] ctx
+ *   Pointer to context.
+ *
+ * @return
+ *   Pointer to device name if ctx is valid, NULL otherwise.
+ */
+static inline const char *
+mlx5_os_get_ctx_device_name(void *ctx)
+{
+	if (!ctx)
+		return NULL;
+	return ((mlx5_context_st *)ctx)->mlx5_dev.name;
+}
+
+/**
+ * Get a device path name. Given acontext pointer - return a
+ * pointer to the corresponding device path name.
+ *
+ * @param[in] ctx
+ *   Pointer to context.
+ *
+ * @return
+ *   Pointer to device path name if ctx is valid, NULL otherwise.
+ */
+
+static inline const char *
+mlx5_os_get_ctx_device_path(void *ctx)
+{
+	if (!ctx)
+		return NULL;
+	return ((mlx5_context_st *)ctx)->mlx5_dev.dev_pnp_id;
+}
+
+/**
+ * Get umem id. Given a pointer to umem object of type return its id.
+ *
+ * @param[in] umem
+ *    Pointer to umem object.
+ *
+ * @return
+ *    The umem id if umem is valid, 0 otherwise.
+ */
+static inline uint32_t
+mlx5_os_get_umem_id(void *umem)
+{
+	if (!umem)
+		return 0;
+	return ((struct mlx5_devx_umem *)umem)->umem_id;
+}
 #endif /* RTE_PMD_MLX5_COMMON_OS_H_ */
Signature · 1 line
2.16.1.windows.4
#96 lore raw

PATCH v3 25/32 common/mlx5/windows: add OS alloc/dealloc pd

In reply to Tal Shnaiderman

Implement Windows API mlx5_os_alloc_pd() and mlx5_os_dealloc_pd(). They are equivalent to the Linux implementation in (1).

(1)
("net/mlx5: wrap glue alloc/dealloc PD with OS calls")

---
 drivers/common/mlx5/rte_common_mlx5_exports.def |  3 +-
 drivers/common/mlx5/windows/mlx5_common_os.c    | 48 +++++++++++++++++++++++++
 drivers/common/mlx5/windows/mlx5_common_os.h    |  3 ++
 drivers/common/mlx5/windows/mlx5_win_ext.h      |  6 ++++
 4 files changed, 59 insertions(+), 1 deletion(-)
drivers/common/mlx5/rte_common_mlx5_exports.def +2 -1
index 2f6aab133b..5db1eaa48c 100644
@@ -61,4 +61,5 @@ EXPORTS
 	mlx5_malloc
 	mlx5_realloc
 	mlx5_free
-
+	mlx5_os_alloc_pd
+	mlx5_os_dealloc_pd
drivers/common/mlx5/windows/mlx5_common_os.c +48 -0

51 lines not on this page · raw message

drivers/common/mlx5/windows/mlx5_common_os.h +3 -0
index 2abdb2c3ae..f47351ec41 100644
@@ -139,4 +139,7 @@ mlx5_os_get_umem_id(void *umem)
 		return 0;
 	return ((struct mlx5_devx_umem *)umem)->umem_id;
 }
+
+void *mlx5_os_alloc_pd(void *ctx);
+int mlx5_os_dealloc_pd(void *pd);
 #endif /* RTE_PMD_MLX5_COMMON_OS_H_ */
drivers/common/mlx5/windows/mlx5_win_ext.h +6 -0
index 0e74910e9d..8e697b30c1 100644
@@ -28,6 +28,12 @@ struct mlx5_devx_umem {
 	uint32_t                umem_id;
 };
 
+struct mlx5_pd {
+	void                   *obj;
+	uint32_t                pdn;
+	devx_device_ctx        *devx_ctx;
+};
+
 #define GET_DEVX_CTX(ctx) (((mlx5_context_st *)ctx)->devx_ctx)
 #define GET_OBJ_CTX(obj)  (((mlx5_devx_obj_st *)obj)->devx_ctx)
 
Signature · 1 line
2.16.1.windows.4
#97 lore raw

PATCH v3 26/32 common/mlx5/windows: add OS umem reg/dereg API

In reply to Tal Shnaiderman

Implement Windows API mlx5_os_umem_reg() and mlx5_os_umem_dereg(). They are equivalent to the Linux implementation.

---
 drivers/common/mlx5/rte_common_mlx5_exports.def |  2 +
 drivers/common/mlx5/windows/mlx5_common_os.c    | 60 +++++++++++++++++++++++++
 drivers/common/mlx5/windows/mlx5_common_os.h    |  2 +
 3 files changed, 64 insertions(+)
drivers/common/mlx5/rte_common_mlx5_exports.def +2 -0
index 5db1eaa48c..1eabe29a58 100644
@@ -63,3 +63,5 @@ EXPORTS
 	mlx5_free
 	mlx5_os_alloc_pd
 	mlx5_os_dealloc_pd
+	mlx5_os_umem_reg
+	mlx5_os_umem_dereg
drivers/common/mlx5/windows/mlx5_common_os.c +60 -0

63 lines not on this page · raw message

drivers/common/mlx5/windows/mlx5_common_os.h +2 -0
index f47351ec41..decb5acd45 100644
@@ -142,4 +142,6 @@ mlx5_os_get_umem_id(void *umem)
 
 void *mlx5_os_alloc_pd(void *ctx);
 int mlx5_os_dealloc_pd(void *pd);
+void *mlx5_os_umem_reg(void *ctx, void *addr, size_t size, uint32_t access);
+int mlx5_os_umem_dereg(void *pumem);
 #endif /* RTE_PMD_MLX5_COMMON_OS_H_ */
Signature · 1 line
2.16.1.windows.4
#98 lore raw

PATCH v3 27/32 net/mlx5: update MR prototypes for DevX

In reply to Tal Shnaiderman

From: Ophir Munk <[email protected]>

Currently MR operations are Verbs based. This commit updates MR operations prototypes such that DevX MR operations callbacks can be used as well. Rename 'struct mlx5_verbs_ops' as 'struct mlx5_mr_ops' and move it to shared file mlx5.h.

---
 drivers/net/mlx5/linux/mlx5_os.c    | 4 ++--
 drivers/net/mlx5/linux/mlx5_verbs.c | 2 +-
 drivers/net/mlx5/linux/mlx5_verbs.h | 8 +-------
 drivers/net/mlx5/mlx5.h             | 6 ++++++
 4 files changed, 10 insertions(+), 10 deletions(-)
drivers/net/mlx5/linux/mlx5_os.c +2 -2
index a6c1eba640..4f68c74267 100644
@@ -2478,8 +2478,8 @@ void
 mlx5_os_set_reg_mr_cb(mlx5_reg_mr_t *reg_mr_cb,
 		      mlx5_dereg_mr_t *dereg_mr_cb)
 {
-	*reg_mr_cb = mlx5_verbs_ops.reg_mr;
-	*dereg_mr_cb = mlx5_verbs_ops.dereg_mr;
+	*reg_mr_cb = mlx5_mr_verbs_ops.reg_mr;
+	*dereg_mr_cb = mlx5_mr_verbs_ops.dereg_mr;
 }
 
 /**
drivers/net/mlx5/linux/mlx5_verbs.c +1 -1
index 9161fa3b7d..b52ae2e6c1 100644
@@ -62,7 +62,7 @@ mlx5_dereg_mr(struct mlx5_pmd_mr *pmd_mr)
 }
 
 /* verbs operations. */
-const struct mlx5_verbs_ops mlx5_verbs_ops = {
+const struct mlx5_mr_ops mlx5_mr_verbs_ops = {
 	.reg_mr = mlx5_reg_mr,
 	.dereg_mr = mlx5_dereg_mr,
 };
drivers/net/mlx5/linux/mlx5_verbs.h +1 -7
index 0670f6c47e..76a79bf4f4 100644
@@ -7,16 +7,10 @@
 
 #include "mlx5.h"
 
-struct mlx5_verbs_ops {
-	mlx5_reg_mr_t reg_mr;
-	mlx5_dereg_mr_t dereg_mr;
-};
-
 int mlx5_txq_ibv_obj_new(struct rte_eth_dev *dev, uint16_t idx);
 void mlx5_txq_ibv_obj_release(struct mlx5_txq_obj *txq_obj);
 
 /* Verbs ops struct */
-extern const struct mlx5_verbs_ops mlx5_verbs_ops;
+extern const struct mlx5_mr_ops mlx5_mr_verbs_ops;
 extern struct mlx5_obj_ops ibv_obj_ops;
-
 #endif /* RTE_PMD_MLX5_VERBS_H_ */
drivers/net/mlx5/mlx5.h +6 -0
index 2186677810..a9db597f2b 100644
@@ -917,6 +917,12 @@ struct mlx5_obj_ops {
 
 #define MLX5_RSS_HASH_FIELDS_LEN RTE_DIM(mlx5_rss_hash_fields)
 
+/* MR operations structure. */
+struct mlx5_mr_ops {
+	mlx5_reg_mr_t reg_mr;
+	mlx5_dereg_mr_t dereg_mr;
+};
+
 struct mlx5_priv {
 	struct rte_eth_dev_data *dev_data;  /* Pointer to device data. */
 	struct mlx5_dev_ctx_shared *sh; /* Shared device context. */
Signature · 1 line
2.16.1.windows.4
#99 lore raw

PATCH v3 28/32 common/mlx5/windows: add OS reg/dereg MR

In reply to Tal Shnaiderman

From: Ophir Munk <[email protected]>

This commits implements Windows API for MR registration and deregistration. It is based on DevX. Is support the relaxed ordering flow in Windows by checking the capabilities and machine type.

---
 drivers/common/mlx5/mlx5_common_mr.h            |  1 +
 drivers/common/mlx5/rte_common_mlx5_exports.def |  2 +
 drivers/common/mlx5/windows/mlx5_common_os.c    | 78 +++++++++++++++++++++++++
 drivers/common/mlx5/windows/mlx5_common_os.h    |  7 +++
 4 files changed, 88 insertions(+)
drivers/common/mlx5/mlx5_common_mr.h +1 -0
index da0a0f0c79..5cc3f097c2 100644
@@ -28,6 +28,7 @@ struct mlx5_pmd_mr {
 	void		     *addr;
 	size_t		     len;
 	void		     *obj;  /* verbs mr object or devx umem object. */
+	struct mlx5_devx_obj *mkey; /* devx mkey object. */
 };
 
 /**
drivers/common/mlx5/rte_common_mlx5_exports.def +2 -0
index 1eabe29a58..65ae47ae6a 100644
@@ -63,5 +63,7 @@ EXPORTS
 	mlx5_free
 	mlx5_os_alloc_pd
 	mlx5_os_dealloc_pd
+	mlx5_os_dereg_mr
+	mlx5_os_reg_mr
 	mlx5_os_umem_reg
 	mlx5_os_umem_dereg
drivers/common/mlx5/windows/mlx5_common_os.c +78 -0

87 lines not on this page · raw message

drivers/common/mlx5/windows/mlx5_common_os.h +7 -0
index decb5acd45..ba166412cc 100644
@@ -7,9 +7,13 @@
 
 #include <stdio.h>
 
+#include <rte_errno.h>
+
 #include "mlx5_autoconf.h"
 #include "mlx5_glue.h"
 #include "mlx5_malloc.h"
+#include "mlx5_common_mr.h"
+#include "mlx5_win_ext.h"
 
 /**
  * This API allocates aligned or non-aligned memory.  The free can be on either
@@ -144,4 +148,7 @@ void *mlx5_os_alloc_pd(void *ctx);
 int mlx5_os_dealloc_pd(void *pd);
 void *mlx5_os_umem_reg(void *ctx, void *addr, size_t size, uint32_t access);
 int mlx5_os_umem_dereg(void *pumem);
+int mlx5_os_reg_mr(void *pd,
+		   void *addr, size_t length, struct mlx5_pmd_mr *pmd_mr);
+void mlx5_os_dereg_mr(struct mlx5_pmd_mr *pmd_mr);
 #endif /* RTE_PMD_MLX5_COMMON_OS_H_ */
Signature · 1 line
2.16.1.windows.4
#100 lore raw

PATCH v3 29/32 net/mlx5/windows: implement device attribute getter

In reply to Tal Shnaiderman

From: Ophir Munk <[email protected]>

This commit is the Windows implementation of mlx5_os_get_dev_attr() API. It follows the commit in [1]. A new file named mlx5_os.c is added under windows directory as its Linux counterpart file: linux/mlx5_os.c.

[1].
commit e85f623e13ea ("net/mlx5: remove attributes dependency on Verbs")

---
 drivers/common/mlx5/mlx5_prm.h       | 43 +++++++++++++++++++++
 drivers/net/mlx5/windows/meson.build |  8 ++++
 drivers/net/mlx5/windows/mlx5_os.c   | 75 ++++++++++++++++++++++++++++++++++++
 3 files changed, 126 insertions(+)
 create mode 100644 drivers/net/mlx5/windows/meson.build
 create mode 100644 drivers/net/mlx5/windows/mlx5_os.c
drivers/common/mlx5/mlx5_prm.h +43 -0
index 27a4e4f0f1..d62d2558eb 100644
@@ -2217,6 +2217,49 @@ struct mlx5_ifc_cqc_bits {
 	u8 dbr_addr[0x40];
 };
 
+struct mlx5_ifc_health_buffer_bits {
+	u8         reserved_0[0x100];
+	u8         assert_existptr[0x20];
+	u8         assert_callra[0x20];
+	u8         reserved_1[0x40];
+	u8         fw_version[0x20];
+	u8         hw_id[0x20];
+	u8         reserved_2[0x20];
+	u8         irisc_index[0x8];
+	u8         synd[0x8];
+	u8         ext_synd[0x10];
+};
+
+struct mlx5_ifc_initial_seg_bits {
+	u8         fw_rev_minor[0x10];
+	u8         fw_rev_major[0x10];
+	u8         cmd_interface_rev[0x10];
+	u8         fw_rev_subminor[0x10];
+	u8         reserved_0[0x40];
+	u8         cmdq_phy_addr_63_32[0x20];
+	u8         cmdq_phy_addr_31_12[0x14];
+	u8         reserved_1[0x2];
+	u8         nic_interface[0x2];
+	u8         log_cmdq_size[0x4];
+	u8         log_cmdq_stride[0x4];
+	u8         command_doorbell_vector[0x20];
+	u8         reserved_2[0xf00];
+	u8         initializing[0x1];
+	u8         nic_interface_supported[0x7];
+	u8         reserved_4[0x18];
+	struct mlx5_ifc_health_buffer_bits health_buffer;
+	u8         no_dram_nic_offset[0x20];
+	u8         reserved_5[0x6de0];
+	u8         internal_timer_h[0x20];
+	u8         internal_timer_l[0x20];
+	u8         reserved_6[0x20];
+	u8         reserved_7[0x1f];
+	u8         clear_int[0x1];
+	u8         health_syndrome[0x8];
+	u8         health_counter[0x18];
+	u8         reserved_8[0x17fc0];
+};
+
 struct mlx5_ifc_create_cq_out_bits {
 	u8 status[0x8];
 	u8 reserved_at_8[0x18];
drivers/net/mlx5/windows/meson.build new file +8 -0
new file mode 100644
index 0000000000..2ea0792a40
@@ -0,0 +1,8 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright 2020 Mellanox Technologies, Ltd
+
+includes += include_directories('.')
+sources += files(
+	'mlx5_os.c',
+)
+
drivers/net/mlx5/windows/mlx5_os.c new file +75 -0

75 lines not on this page · raw message

Signature · 1 line
2.16.1.windows.4
#101 lore raw

PATCH v3 30/32 net/mlx5/windows: add mlx5_os.c stubs

In reply to Tal Shnaiderman

From: Ophir Munk <[email protected]>

mlx5_os_set_nonblock_channel_fd
mlx5_os_dev_shared_handler_install
mlx5_os_dev_shared_handler_uninstall
mlx5_os_read_dev_stat
mlx5_os_mac_addr_flush
mlx5_os_mac_addr_remove
mlx5_os_vf_mac_addr_modify
mlx5_os_set_promisc
mlx5_os_set_allmulti

Set struct mlx5_flow_driver_ops mlx5_flow_verbs_drv_ops with NULL pointers.

---
 drivers/net/mlx5/windows/mlx5_os.c | 187 +++++++++++++++++++++++++++++++++++++
 1 file changed, 187 insertions(+)
drivers/net/mlx5/windows/mlx5_os.c +187 -0
index e0646670a3..bef10aba30 100644
@@ -13,10 +13,18 @@
 #include <mlx5_glue.h>
 #include <mlx5_devx_cmds.h>
 #include <mlx5_common.h>
+#include <mlx5_common_mp.h>
+#include <mlx5_common_mr.h>
+#include <mlx5_malloc.h>
 
 #include "mlx5_defs.h"
 #include "mlx5.h"
+#include "mlx5_common_os.h"
+#include "mlx5_utils.h"
+#include "mlx5_rxtx.h"
 #include "mlx5_autoconf.h"
+#include "mlx5_mr.h"
+#include "mlx5_flow.h"
 
 /**
  * Get mlx5 device attributes.
@@ -73,3 +81,182 @@ mlx5_os_get_dev_attr(void *ctx, struct mlx5_dev_attr *device_attr)
 	}
 	return err;
 }
+
+/**
+ * Set the completion channel file descriptor interrupt as non-blocking.
+ * Currently it has no support under Windows.
+ *
+ * @param[in] rxq_obj
+ *   Pointer to RQ channel object, which includes the channel fd
+ *
+ * @param[out] fd
+ *   The file descriptor (representing the intetrrupt) used in this channel.
+ *
+ * @return
+ *   0 on successfully setting the fd to non-blocking, non-zero otherwise.
+ */
+int
+mlx5_os_set_nonblock_channel_fd(int fd)
+{
+	(void)fd;
+	DRV_LOG(WARNING, "mlx5_os_set_nonblock_channel_fd is not support");
+	return -ENOTSUP;
+}
+
+/**
+ * This function should share events between multiple ports of single IB
+ * device.  Currently it has no support under Windows.
+ *
+ * @param sh
+ *   Pointer to mlx5_dev_ctx_shared object.
+ */
+void
+mlx5_os_dev_shared_handler_install(struct mlx5_dev_ctx_shared *sh)
+{
+	(void)sh;
+	DRV_LOG(WARNING, "mlx5_os_dev_shared_handler_install is not support");
+}
+
+/**
+ * This function should share events between multiple ports of single IB
+ * device.  Currently it has no support under Windows.
+ *
+ * @param dev
+ *   Pointer to mlx5_dev_ctx_shared object.
+ */
+void
+mlx5_os_dev_shared_handler_uninstall(struct mlx5_dev_ctx_shared *sh)
+{
+	(void)sh;
+	DRV_LOG(WARNING, "mlx5_os_dev_shared_handler_uninstall is not support");
+}
+
+/**
+ * Read statistics by a named counter.
+ *
+ * @param[in] priv
+ *   Pointer to the private device data structure.
+ * @param[in] ctr_name
+ *   Pointer to the name of the statistic counter to read
+ * @param[out] stat
+ *   Pointer to read statistic value.
+ * @return
+ *   0 on success and stat is valud, 1 if failed to read the value
+ *   rte_errno is set.
+ *
+ */
+int
+mlx5_os_read_dev_stat(struct mlx5_priv *priv, const char *ctr_name,
+		      uint64_t *stat)
+{
+	RTE_SET_USED(priv);
+	RTE_SET_USED(ctr_name);
+	RTE_SET_USED(stat);
+	DRV_LOG(WARNING, "mlx5_os_read_dev_stat is not support");
+	return -ENOTSUP;
+}
+
+/**
+ * Flush device MAC addresses
+ * Currently it has no support under Windows.
+ *
+ * @param dev
+ *   Pointer to Ethernet device structure.
+ *
+ */
+void
+mlx5_os_mac_addr_flush(struct rte_eth_dev *dev)
+{
+	(void)dev;
+	DRV_LOG(WARNING, "mlx5_os_mac_addr_flush is not support");
+}
+
+/**
+ * Remove a MAC address from device
+ * Currently it has no support under Windows.
+ *
+ * @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)
+{
+	(void)dev;
+	(void)(index);
+	DRV_LOG(WARNING, "mlx5_os_mac_addr_remove is not support");
+}
+
+/**
+ * Modify a VF MAC address
+ * Currently it has no support under Windows.
+ *
+ * @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)
+{
+	(void)priv;
+	(void)iface_idx;
+	(void)mac_addr;
+	(void)vf_index;
+	DRV_LOG(WARNING, "mlx5_os_vf_mac_addr_modify is not support");
+	return -ENOTSUP;
+}
+
+/**
+ * Set device promiscuous mode
+ * Currently it has no support under Windows.
+ *
+ * @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)
+{
+	(void)dev;
+	(void)enable;
+	DRV_LOG(WARNING, "mlx5_os_set_promisc is not support");
+	return -ENOTSUP;
+}
+
+/**
+ * Set device allmulti 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)
+{
+	(void)dev;
+	(void)enable;
+	DRV_LOG(WARNING, "mlx5_os_set_allmulti is not support");
+	return -ENOTSUP;
+}
+
+const struct mlx5_flow_driver_ops mlx5_flow_verbs_drv_ops = {0};
Signature · 1 line
2.16.1.windows.4
#102 lore raw

PATCH v3 31/32 net/mlx5/windows: implement mlx5 mac addr add

In reply to Tal Shnaiderman

Get the list of MAC addresses and verify if the input mac parameter already exists. If not - return -ENOTSUP (as Windows does not support adding new MAC addresses). If the MAC address exists (EEXIST) return 0 (the equivalent of Linux implementation of this API).

---
 drivers/net/mlx5/windows/mlx5_os.c | 36 ++++++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)
drivers/net/mlx5/windows/mlx5_os.c +36 -0
index bef10aba30..ccf0bc3be9 100644
@@ -188,6 +188,42 @@ mlx5_os_mac_addr_remove(struct rte_eth_dev *dev, uint32_t index)
 	DRV_LOG(WARNING, "mlx5_os_mac_addr_remove is not support");
 }
 
+/**
+ * Adds a MAC address to the device
+ * Currently it has no support under Windows.
+ *
+ * @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)
+{
+	(void)index;
+	struct rte_ether_addr lmac;
+
+	if (mlx5_get_mac(dev, &lmac.addr_bytes)) {
+		DRV_LOG(ERR,
+			"port %u cannot get MAC address, is mlx5_en"
+			" loaded? (errno: %s)",
+			dev->data->port_id, strerror(rte_errno));
+		return rte_errno;
+	}
+	if (!rte_is_same_ether_addr(&lmac, mac)) {
+		DRV_LOG(ERR,
+			"adding new mac address to device is unsupported");
+		return -ENOTSUP;
+	}
+	return 0;
+}
+
 /**
  * Modify a VF MAC address
  * Currently it has no support under Windows.
Signature · 1 line
2.16.1.windows.4
#103 lore raw

PATCH v3 32/32 net/mlx5: refactor eth dev ops for Windows

In reply to Tal Shnaiderman

From: Ophir Munk <[email protected]>

There are two types of eth_dev_ops used under Windows: primary and isolate mode. Their function calls initialization is added to the OS specific file mlx5_os.c. Secondary process eth_dev_ops is nullified.

---
 drivers/net/mlx5/windows/mlx5_os.c | 108 +++++++++++++++++++++++++++++++++++++
 1 file changed, 108 insertions(+)
drivers/net/mlx5/windows/mlx5_os.c +108 -0
index ccf0bc3be9..43665bff7f 100644
@@ -296,3 +296,111 @@ mlx5_os_set_allmulti(struct rte_eth_dev *dev, int enable)
 }
 
 const struct mlx5_flow_driver_ops mlx5_flow_verbs_drv_ops = {0};
+
+const struct eth_dev_ops mlx5_os_dev_ops = {
+	.dev_configure = mlx5_dev_configure,
+	.dev_start = mlx5_dev_start,
+	.dev_stop = mlx5_dev_stop,
+	.dev_close = mlx5_dev_close,
+	.mtu_set = mlx5_dev_set_mtu,
+	.link_update = mlx5_link_update,
+	.stats_get = mlx5_stats_get,
+	.stats_reset = mlx5_stats_reset,
+	.dev_infos_get = mlx5_dev_infos_get,
+	.dev_supported_ptypes_get = mlx5_dev_supported_ptypes_get,
+	.promiscuous_enable = mlx5_promiscuous_enable,
+	.promiscuous_disable = mlx5_promiscuous_disable,
+	.allmulticast_enable = mlx5_allmulticast_enable,
+	.allmulticast_disable = mlx5_allmulticast_disable,
+	.xstats_get = mlx5_xstats_get,
+	.xstats_reset = mlx5_xstats_reset,
+	.xstats_get_names = mlx5_xstats_get_names,
+	.fw_version_get = mlx5_fw_version_get,
+	.read_clock = mlx5_read_clock,
+	.vlan_filter_set = mlx5_vlan_filter_set,
+	.rx_queue_setup = mlx5_rx_queue_setup,
+	.rx_hairpin_queue_setup = mlx5_rx_hairpin_queue_setup,
+	.tx_queue_setup = mlx5_tx_queue_setup,
+	.tx_hairpin_queue_setup = mlx5_tx_hairpin_queue_setup,
+	.rx_queue_release = mlx5_rx_queue_release,
+	.tx_queue_release = mlx5_tx_queue_release,
+	.flow_ctrl_get = mlx5_dev_get_flow_ctrl,
+	.flow_ctrl_set = mlx5_dev_set_flow_ctrl,
+	.mac_addr_remove = mlx5_mac_addr_remove,
+	.mac_addr_add = mlx5_mac_addr_add,
+	.mac_addr_set = mlx5_mac_addr_set,
+	.set_mc_addr_list = mlx5_set_mc_addr_list,
+	.vlan_strip_queue_set = mlx5_vlan_strip_queue_set,
+	.vlan_offload_set = mlx5_vlan_offload_set,
+	.reta_update = mlx5_dev_rss_reta_update,
+	.reta_query = mlx5_dev_rss_reta_query,
+	.rss_hash_update = mlx5_rss_hash_update,
+	.rss_hash_conf_get = mlx5_rss_hash_conf_get,
+	.filter_ctrl = mlx5_dev_filter_ctrl,
+	.rxq_info_get = mlx5_rxq_info_get,
+	.txq_info_get = mlx5_txq_info_get,
+	.rx_burst_mode_get = mlx5_rx_burst_mode_get,
+	.tx_burst_mode_get = mlx5_tx_burst_mode_get,
+	.rx_queue_intr_enable = mlx5_rx_intr_enable,
+	.rx_queue_intr_disable = mlx5_rx_intr_disable,
+	.is_removed = mlx5_is_removed,
+	.udp_tunnel_port_add  = mlx5_udp_tunnel_port_add,
+	.get_module_info = mlx5_get_module_info,
+	.get_module_eeprom = mlx5_get_module_eeprom,
+	.hairpin_cap_get = mlx5_hairpin_cap_get,
+	.mtr_ops_get = mlx5_flow_meter_ops_get,
+};
+
+/* Available operations from secondary process. */
+const struct eth_dev_ops mlx5_os_dev_sec_ops = {0};
+
+/* Available operations in flow isolated mode. */
+const struct eth_dev_ops mlx5_os_dev_ops_isolate = {
+	.dev_configure = mlx5_dev_configure,
+	.dev_start = mlx5_dev_start,
+	.dev_stop = mlx5_dev_stop,
+	.dev_close = mlx5_dev_close,
+	.mtu_set = mlx5_dev_set_mtu,
+	.link_update = mlx5_link_update,
+	.stats_get = mlx5_stats_get,
+	.stats_reset = mlx5_stats_reset,
+	.dev_infos_get = mlx5_dev_infos_get,
+	.dev_set_link_down = mlx5_set_link_down,
+	.dev_set_link_up = mlx5_set_link_up,
+	.promiscuous_enable = mlx5_promiscuous_enable,
+	.promiscuous_disable = mlx5_promiscuous_disable,
+	.allmulticast_enable = mlx5_allmulticast_enable,
+	.allmulticast_disable = mlx5_allmulticast_disable,
+	.xstats_get = mlx5_xstats_get,
+	.xstats_reset = mlx5_xstats_reset,
+	.xstats_get_names = mlx5_xstats_get_names,
+	.fw_version_get = mlx5_fw_version_get,
+	.dev_supported_ptypes_get = mlx5_dev_supported_ptypes_get,
+	.vlan_filter_set = mlx5_vlan_filter_set,
+	.rx_queue_setup = mlx5_rx_queue_setup,
+	.rx_hairpin_queue_setup = mlx5_rx_hairpin_queue_setup,
+	.tx_queue_setup = mlx5_tx_queue_setup,
+	.tx_hairpin_queue_setup = mlx5_tx_hairpin_queue_setup,
+	.rx_queue_release = mlx5_rx_queue_release,
+	.tx_queue_release = mlx5_tx_queue_release,
+	.flow_ctrl_get = mlx5_dev_get_flow_ctrl,
+	.flow_ctrl_set = mlx5_dev_set_flow_ctrl,
+	.mac_addr_remove = mlx5_mac_addr_remove,
+	.mac_addr_add = mlx5_mac_addr_add,
+	.mac_addr_set = mlx5_mac_addr_set,
+	.set_mc_addr_list = mlx5_set_mc_addr_list,
+	.vlan_strip_queue_set = mlx5_vlan_strip_queue_set,
+	.vlan_offload_set = mlx5_vlan_offload_set,
+	.filter_ctrl = mlx5_dev_filter_ctrl,
+	.rxq_info_get = mlx5_rxq_info_get,
+	.txq_info_get = mlx5_txq_info_get,
+	.rx_burst_mode_get = mlx5_rx_burst_mode_get,
+	.tx_burst_mode_get = mlx5_tx_burst_mode_get,
+	.rx_queue_intr_enable = mlx5_rx_intr_enable,
+	.rx_queue_intr_disable = mlx5_rx_intr_disable,
+	.is_removed = mlx5_is_removed,
+	.get_module_info = mlx5_get_module_info,
+	.get_module_eeprom = mlx5_get_module_eeprom,
+	.hairpin_cap_get = mlx5_hairpin_cap_get,
+	.mtr_ops_get = mlx5_flow_meter_ops_get,
+};
Signature · 1 line
2.16.1.windows.4
#104 lore raw

PATCH v2 2/33 net/mlx5/linux: extend device attributes getter

In reply to Tal Shnaiderman

From: Ophir Munk <[email protected]>

This commit adds device attributes parameters to be reported by mlx5_os_get_dev_attr(): max_cqe, max_mr, max_pd, max_srq, max_srq_wr

---
 drivers/net/mlx5/linux/mlx5_os.c | 5 +++++
 drivers/net/mlx5/mlx5.h          | 5 +++++
 2 files changed, 10 insertions(+)
drivers/net/mlx5/linux/mlx5_os.c +5 -0
index 917d6be7b8..a6c1eba640 100644
@@ -116,7 +116,12 @@ mlx5_os_get_dev_attr(void *ctx, struct mlx5_dev_attr *device_attr)
 	device_attr->max_qp_wr = attr_ex.orig_attr.max_qp_wr;
 	device_attr->max_sge = attr_ex.orig_attr.max_sge;
 	device_attr->max_cq = attr_ex.orig_attr.max_cq;
+	device_attr->max_cqe = attr_ex.orig_attr.max_cqe;
+	device_attr->max_mr = attr_ex.orig_attr.max_mr;
+	device_attr->max_pd = attr_ex.orig_attr.max_pd;
 	device_attr->max_qp = attr_ex.orig_attr.max_qp;
+	device_attr->max_srq = attr_ex.orig_attr.max_srq;
+	device_attr->max_srq_wr = attr_ex.orig_attr.max_srq_wr;
 	device_attr->raw_packet_caps = attr_ex.raw_packet_caps;
 	device_attr->max_rwq_indirection_table_size =
 		attr_ex.rss_caps.max_rwq_indirection_table_size;
drivers/net/mlx5/mlx5.h +5 -0
index 121d726405..2186677810 100644
@@ -83,6 +83,11 @@ struct mlx5_dev_attr {
 	int		max_sge;
 	int		max_cq;
 	int		max_qp;
+	int		max_cqe;
+	uint32_t	max_pd;
+	uint32_t	max_mr;
+	uint32_t	max_srq;
+	uint32_t	max_srq_wr;
 	uint32_t	raw_packet_caps;
 	uint32_t	max_rwq_indirection_table_size;
 	uint32_t	max_tso;
Signature · 1 line
2.16.1.windows.4
#105 lore raw

PATCH v2 3/33 net/mlx5: remove Linux files from Windows compilation

In reply to Tal Shnaiderman

From: Ophir Munk <[email protected]>

This commit removes Linux files flow_verbs.c and mlx5_rxtx_vec.c from Windows compilation.

---
 drivers/net/mlx5/meson.build | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)
drivers/net/mlx5/meson.build +11 -5
index e7495a764a..f2fafbdd05 100644
@@ -15,7 +15,6 @@ sources = files(
 	'mlx5_flow.c',
 	'mlx5_flow_meter.c',
 	'mlx5_flow_dv.c',
-	'mlx5_flow_verbs.c',
         'mlx5_flow_age.c',
 	'mlx5_mac.c',
 	'mlx5_mr.c',
@@ -31,11 +30,18 @@ sources = files(
 	'mlx5_utils.c',
 	'mlx5_devx.c',
 )
-if (dpdk_conf.has('RTE_ARCH_X86_64')
-	or dpdk_conf.has('RTE_ARCH_ARM64')
-	or dpdk_conf.has('RTE_ARCH_PPC_64'))
-	sources += files('mlx5_rxtx_vec.c')
+
+if is_linux
+	sources += files(
+		'mlx5_flow_verbs.c',
+	)
+	if (dpdk_conf.has('RTE_ARCH_X86_64')
+		or dpdk_conf.has('RTE_ARCH_ARM64')
+		or dpdk_conf.has('RTE_ARCH_PPC_64'))
+		sources += files('mlx5_rxtx_vec.c')
+	endif
 endif
+
 cflags_options = [
 	'-std=c11',
 	'-Wno-strict-prototypes',
Signature · 1 line
2.16.1.windows.4
#106 lore raw

PATCH v2 4/33 net/mlx5: fix freeing packet pacing

In reply to Tal Shnaiderman

From: Ophir Munk <[email protected]>

Packet pacing is allocated under condition #ifdef HAVE_MLX5DV_PP_ALLOC. In a similar way - free packet pacing index under the same condition. This update is required to successfully compile under operating systems which do not support packet pacing.

Fixes aef1e20ebeb2 ("net/mlx5: allocate packet pacing context")
---
 drivers/net/mlx5/mlx5_txpp.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/net/mlx5/mlx5_txpp.c +5 -0
index 2438bf1f1d..21675ab17a 100644
@@ -57,11 +57,16 @@ mlx5_txpp_create_event_channel(struct mlx5_dev_ctx_shared *sh)
 static void
 mlx5_txpp_free_pp_index(struct mlx5_dev_ctx_shared *sh)
 {
+#ifdef HAVE_MLX5DV_PP_ALLOC
 	if (sh->txpp.pp) {
 		mlx5_glue->dv_free_pp(sh->txpp.pp);
 		sh->txpp.pp = NULL;
 		sh->txpp.pp_id = 0;
 	}
+#else
+	RTE_SET_USED(sh);
+	DRV_LOG(ERR, "Freeing pacing index is not supported.");
+#endif
 }
 
 /* Allocate Packet Pacing index from kernel via mlx5dv call. */
Signature · 1 line
2.16.1.windows.4
#107 lore raw

PATCH v2 5/33 net/mlx5: replace Linux sleep with rte sleep

In reply to Tal Shnaiderman

From: Ophir Munk <[email protected]>

Replace Linux API usleep() and nanosleep() with rte_delay_us_sleep(). The replacement occurs in shared files compiled under different operating systems.

---
 drivers/net/mlx5/mlx5.c         | 5 +++--
 drivers/net/mlx5/mlx5_trigger.c | 3 ++-
 drivers/net/mlx5/mlx5_txpp.c    | 6 +-----
 3 files changed, 6 insertions(+), 8 deletions(-)
drivers/net/mlx5/mlx5.c +3 -2
index 52a8a252d4..8e9df6abcf 100644
@@ -21,6 +21,7 @@
 #include <rte_spinlock.h>
 #include <rte_string_fns.h>
 #include <rte_alarm.h>
+#include <rte_cycles.h>
 
 #include <mlx5_glue.h>
 #include <mlx5_devx_cmds.h>
@@ -1330,7 +1331,7 @@ mlx5_dev_close(struct rte_eth_dev *dev)
 	mlx5_flex_parser_ecpri_release(dev);
 	if (priv->rxqs != NULL) {
 		/* XXX race condition if mlx5_rx_burst() is still running. */
-		usleep(1000);
+		rte_delay_us_sleep(1000);
 		for (i = 0; (i != priv->rxqs_n); ++i)
 			mlx5_rxq_release(dev, i);
 		priv->rxqs_n = 0;
@@ -1338,7 +1339,7 @@ mlx5_dev_close(struct rte_eth_dev *dev)
 	}
 	if (priv->txqs != NULL) {
 		/* XXX race condition if mlx5_tx_burst() is still running. */
-		usleep(1000);
+		rte_delay_us_sleep(1000);
 		for (i = 0; (i != priv->txqs_n); ++i)
 			mlx5_txq_release(dev, i);
 		priv->txqs_n = 0;
drivers/net/mlx5/mlx5_trigger.c +2 -1
index bd029154f8..646f29b923 100644
@@ -9,6 +9,7 @@
 #include <rte_ethdev_driver.h>
 #include <rte_interrupts.h>
 #include <rte_alarm.h>
+#include <rte_cycles.h>
 
 #include <mlx5_malloc.h>
 
@@ -1171,7 +1172,7 @@ mlx5_dev_stop(struct rte_eth_dev *dev)
 	rte_wmb();
 	/* Disable datapath on secondary process. */
 	mlx5_mp_os_req_stop_rxtx(dev);
-	usleep(1000 * priv->rxqs_n);
+	rte_delay_us_sleep(1000 * priv->rxqs_n);
 	DRV_LOG(DEBUG, "port %u stopping device", dev->data->port_id);
 	mlx5_flow_stop_default(dev);
 	/* Control flows for default traffic can be removed firstly. */
drivers/net/mlx5/mlx5_txpp.c +1 -5
index 21675ab17a..a1ec294942 100644
@@ -769,15 +769,11 @@ mlx5_txpp_init_timestamp(struct mlx5_dev_ctx_shared *sh)
 	sh->txpp.ts_p = 0;
 	sh->txpp.ts_n = 0;
 	for (wait = 0; wait < MLX5_TXPP_WAIT_INIT_TS; wait++) {
-		struct timespec onems;
-
 		mlx5_txpp_update_timestamp(sh);
 		if (wq->sq_ci)
 			return;
 		/* Wait one millisecond and try again. */
-		onems.tv_sec = 0;
-		onems.tv_nsec = NS_PER_S / MS_PER_S;
-		nanosleep(&onems, 0);
+		rte_delay_us_sleep(US_PER_S / MS_PER_S);
 	}
 	DRV_LOG(ERR, "Unable to initialize timestamp.");
 	sh->txpp.sync_lost = 1;
Signature · 1 line
2.16.1.windows.4
#108 lore raw

PATCH v2 6/33 net/mlx5: define mprq functions as static inline

In reply to Tal Shnaiderman

From: Ophir Munk <[email protected]>

Functions mlx5_check_mprq_support(), mlx5_rxq_mprq_enabled(), mlx5_mprq_enabled() are moved from source file mlx5_rxq.c to header file mlx5_rxtx.h and their type is updated to 'static __rte_always_inline'. Previously the functions were declared as 'inline' in the source file which was reported as 'unresolved external symbol' error by some Windows linkers.

---
 drivers/net/mlx5/mlx5_rxq.c  | 71 ------------------------------------------
 drivers/net/mlx5/mlx5_rxtx.h | 73 ++++++++++++++++++++++++++++++++++++++++++--
 2 files changed, 70 insertions(+), 74 deletions(-)
drivers/net/mlx5/mlx5_rxq.c +0 -71
index da7a8b3cd7..c89e55b1c0 100644
@@ -48,77 +48,6 @@ static_assert(MLX5_RSS_HASH_KEY_LEN ==
 	      (unsigned int)sizeof(rss_hash_default_key),
 	      "wrong RSS default key size.");
 
-/**
- * Check whether Multi-Packet RQ can be enabled for the device.
- *
- * @param dev
- *   Pointer to Ethernet device.
- *
- * @return
- *   1 if supported, negative errno value if not.
- */
-inline int
-mlx5_check_mprq_support(struct rte_eth_dev *dev)
-{
-	struct mlx5_priv *priv = dev->data->dev_private;
-
-	if (priv->config.mprq.enabled &&
-	    priv->rxqs_n >= priv->config.mprq.min_rxqs_num)
-		return 1;
-	return -ENOTSUP;
-}
-
-/**
- * Check whether Multi-Packet RQ is enabled for the Rx queue.
- *
- *  @param rxq
- *     Pointer to receive queue structure.
- *
- * @return
- *   0 if disabled, otherwise enabled.
- */
-inline int
-mlx5_rxq_mprq_enabled(struct mlx5_rxq_data *rxq)
-{
-	return rxq->strd_num_n > 0;
-}
-
-/**
- * Check whether Multi-Packet RQ is enabled for the device.
- *
- * @param dev
- *   Pointer to Ethernet device.
- *
- * @return
- *   0 if disabled, otherwise enabled.
- */
-inline int
-mlx5_mprq_enabled(struct rte_eth_dev *dev)
-{
-	struct mlx5_priv *priv = dev->data->dev_private;
-	uint32_t i;
-	uint16_t n = 0;
-	uint16_t n_ibv = 0;
-
-	if (mlx5_check_mprq_support(dev) < 0)
-		return 0;
-	/* All the configured queues should be enabled. */
-	for (i = 0; i < priv->rxqs_n; ++i) {
-		struct mlx5_rxq_data *rxq = (*priv->rxqs)[i];
-		struct mlx5_rxq_ctrl *rxq_ctrl = container_of
-			(rxq, struct mlx5_rxq_ctrl, rxq);
-
-		if (rxq == NULL || rxq_ctrl->type != MLX5_RXQ_TYPE_STANDARD)
-			continue;
-		n_ibv++;
-		if (mlx5_rxq_mprq_enabled(rxq))
-			++n;
-	}
-	/* Multi-Packet RQ can't be partially configured. */
-	MLX5_ASSERT(n == 0 || n == n_ibv);
-	return n == n_ibv;
-}
-
 /**
  * Calculate the number of CQEs in CQ for the Rx queue.
  *
drivers/net/mlx5/mlx5_rxtx.h +70 -3

83 lines not on this page · raw message

Signature · 1 line
2.16.1.windows.4
#109 lore raw

PATCH v2 7/33 net/mlx5: do not define static_assert in Windows

In reply to Tal Shnaiderman

From: Ophir Munk <[email protected]>

In Linux 'static_assert' is defined in file mlx5_defs.h:

 #ifndef HAVE_STATIC_ASSERT
    #define static_assert _Static_assert

#endif

The same definition can originate from Linux file /usr/include/assert.h.

In Windows static_assert is used while _Static_assert is unknown. Therefore update the definition condition to be:

 #if !defined(HAVE_STATIC_ASSERT) && !defined(RTE_EXEC_ENV_WINDOWS)
    #define static_assert _Static_assert

#endif

---
 drivers/net/mlx5/mlx5_defs.h | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/net/mlx5/mlx5_defs.h +5 -2
index aa55db3750..85a0979653 100644
@@ -199,8 +199,11 @@
 /* Maximum number of shared actions supported by rte_flow */
 #define MLX5_MAX_SHARED_ACTIONS 2
 
-/* Definition of static_assert found in /usr/include/assert.h */
-#ifndef HAVE_STATIC_ASSERT
+/*
+ * Linux definition of static_assert is found in /usr/include/assert.h.
+ * Windows does not require a redefinition.
+ */
+#if !defined(HAVE_STATIC_ASSERT) && !defined(RTE_EXEC_ENV_WINDOWS)
 #define static_assert _Static_assert
 #endif
 
Signature · 1 line
2.16.1.windows.4
#110 lore raw

PATCH v2 8/33 net/mlx5: move static_assert calls to global scope

In reply to Tal Shnaiderman

From: Ophir Munk <[email protected]>

Some Windows compilers consider static_assert() as calls to another function rather than a compiler directive which allows checking type information at compile time. This only occurs if the static_assert call appears inside another function scope. To solve it move the static_assert calls to global scope in the files where they are used.

---
 drivers/net/mlx5/mlx5_rxtx.c | 98 ++++++++++++++++++++++----------------------
 drivers/net/mlx5/mlx5_txpp.c |  5 ++-
 2 files changed, 53 insertions(+), 50 deletions(-)
drivers/net/mlx5/mlx5_rxtx.c +50 -48
index d12d746c2f..65a1f997e9 100644
@@ -79,6 +79,56 @@ static uint16_t mlx5_tx_burst_##func(void *txq, \
 
 #define MLX5_TXOFF_INFO(func, olx) {mlx5_tx_burst_##func, olx},
 
+/* static asserts */
+static_assert(MLX5_CQE_STATUS_HW_OWN < 0, "Must be negative value");
+static_assert(MLX5_CQE_STATUS_SW_OWN < 0, "Must be negative value");
+static_assert(MLX5_ESEG_MIN_INLINE_SIZE ==
+		(sizeof(uint16_t) +
+		 sizeof(rte_v128u32_t)),
+		"invalid Ethernet Segment data size");
+static_assert(MLX5_ESEG_MIN_INLINE_SIZE ==
+		(sizeof(uint16_t) +
+		 sizeof(struct rte_vlan_hdr) +
+		 2 * RTE_ETHER_ADDR_LEN),
+		"invalid Ethernet Segment data size");
+static_assert(MLX5_ESEG_MIN_INLINE_SIZE ==
+		(sizeof(uint16_t) +
+		 sizeof(rte_v128u32_t)),
+		"invalid Ethernet Segment data size");
+static_assert(MLX5_ESEG_MIN_INLINE_SIZE ==
+		(sizeof(uint16_t) +
+		 sizeof(struct rte_vlan_hdr) +
+		 2 * RTE_ETHER_ADDR_LEN),
+		"invalid Ethernet Segment data size");
+static_assert(MLX5_ESEG_MIN_INLINE_SIZE ==
+		(sizeof(uint16_t) +
+		 sizeof(rte_v128u32_t)),
+		"invalid Ethernet Segment data size");
+static_assert(MLX5_ESEG_MIN_INLINE_SIZE ==
+		(sizeof(uint16_t) +
+		 sizeof(struct rte_vlan_hdr) +
+		 2 * RTE_ETHER_ADDR_LEN),
+		"invalid Ethernet Segment data size");
+static_assert(MLX5_DSEG_MIN_INLINE_SIZE ==
+		(2 * RTE_ETHER_ADDR_LEN),
+		"invalid Data Segment data size");
+static_assert(MLX5_EMPW_MIN_PACKETS >= 2, "invalid min size");
+static_assert(MLX5_EMPW_MIN_PACKETS >= 2, "invalid min size");
+static_assert((sizeof(struct rte_vlan_hdr) +
+			sizeof(struct rte_ether_hdr)) ==
+		MLX5_ESEG_MIN_INLINE_SIZE,
+		"invalid min inline data size");
+static_assert(MLX5_WQE_SIZE_MAX / MLX5_WSEG_SIZE <=
+		MLX5_DSEG_MAX, "invalid WQE max size");
+static_assert(MLX5_WQE_CSEG_SIZE == MLX5_WSEG_SIZE,
+		"invalid WQE Control Segment size");
+static_assert(MLX5_WQE_ESEG_SIZE == MLX5_WSEG_SIZE,
+		"invalid WQE Ethernet Segment size");
+static_assert(MLX5_WQE_DSEG_SIZE == MLX5_WSEG_SIZE,
+		"invalid WQE Data Segment size");
+static_assert(MLX5_WQE_SIZE == 4 * MLX5_WSEG_SIZE,
+		"invalid WQE size");
+
 static __rte_always_inline uint32_t
 rxq_cq_to_pkt_type(struct mlx5_rxq_data *rxq, volatile struct mlx5_cqe *cqe,
 				   volatile struct mlx5_mini_cqe8 *mcqe);
@@ -2070,8 +2120,6 @@ mlx5_tx_handle_completion(struct mlx5_txq_data *__rte_restrict txq,
 	bool ring_doorbell = false;
 	int ret;
 
-	static_assert(MLX5_CQE_STATUS_HW_OWN < 0, "Must be negative value");
-	static_assert(MLX5_CQE_STATUS_SW_OWN < 0, "Must be negative value");
 	do {
 		volatile struct mlx5_cqe *cqe;
 
@@ -2381,15 +2429,6 @@ mlx5_tx_eseg_dmin(struct mlx5_txq_data *__rte_restrict txq __rte_unused,
 	es->metadata = MLX5_TXOFF_CONFIG(METADATA) ?
 		       loc->mbuf->ol_flags & PKT_TX_DYNF_METADATA ?
 		       *RTE_FLOW_DYNF_METADATA(loc->mbuf) : 0 : 0;
-	static_assert(MLX5_ESEG_MIN_INLINE_SIZE ==
-				(sizeof(uint16_t) +
-				 sizeof(rte_v128u32_t)),
-		      "invalid Ethernet Segment data size");
-	static_assert(MLX5_ESEG_MIN_INLINE_SIZE ==
-				(sizeof(uint16_t) +
-				 sizeof(struct rte_vlan_hdr) +
-				 2 * RTE_ETHER_ADDR_LEN),
-		      "invalid Ethernet Segment data size");
 	psrc = rte_pktmbuf_mtod(loc->mbuf, uint8_t *);
 	es->inline_hdr_sz = RTE_BE16(MLX5_ESEG_MIN_INLINE_SIZE);
 	es->inline_data = *(unaligned_uint16_t *)psrc;
@@ -2474,15 +2513,6 @@ mlx5_tx_eseg_data(struct mlx5_txq_data *__rte_restrict txq,
 	es->metadata = MLX5_TXOFF_CONFIG(METADATA) ?
 		       loc->mbuf->ol_flags & PKT_TX_DYNF_METADATA ?
 		       *RTE_FLOW_DYNF_METADATA(loc->mbuf) : 0 : 0;
-	static_assert(MLX5_ESEG_MIN_INLINE_SIZE ==
-				(sizeof(uint16_t) +
-				 sizeof(rte_v128u32_t)),
-		      "invalid Ethernet Segment data size");
-	static_assert(MLX5_ESEG_MIN_INLINE_SIZE ==
-				(sizeof(uint16_t) +
-				 sizeof(struct rte_vlan_hdr) +
-				 2 * RTE_ETHER_ADDR_LEN),
-		      "invalid Ethernet Segment data size");
 	psrc = rte_pktmbuf_mtod(loc->mbuf, uint8_t *);
 	es->inline_hdr_sz = rte_cpu_to_be_16(inlen);
 	es->inline_data = *(unaligned_uint16_t *)psrc;
@@ -2697,15 +2727,6 @@ mlx5_tx_eseg_mdat(struct mlx5_txq_data *__rte_restrict txq,
 	es->metadata = MLX5_TXOFF_CONFIG(METADATA) ?
 		       loc->mbuf->ol_flags & PKT_TX_DYNF_METADATA ?
 		       *RTE_FLOW_DYNF_METADATA(loc->mbuf) : 0 : 0;
-	static_assert(MLX5_ESEG_MIN_INLINE_SIZE ==
-				(sizeof(uint16_t) +
-				 sizeof(rte_v128u32_t)),
-		      "invalid Ethernet Segment data size");
-	static_assert(MLX5_ESEG_MIN_INLINE_SIZE ==
-				(sizeof(uint16_t) +
-				 sizeof(struct rte_vlan_hdr) +
-				 2 * RTE_ETHER_ADDR_LEN),
-		      "invalid Ethernet Segment data size");
 	MLX5_ASSERT(inlen >= MLX5_ESEG_MIN_INLINE_SIZE);
 	pdst = (uint8_t *)&es->inline_data;
 	if (MLX5_TXOFF_CONFIG(VLAN) && vlan) {
@@ -2952,9 +2973,6 @@ mlx5_tx_dseg_vlan(struct mlx5_txq_data *__rte_restrict txq,
 	uint8_t *pdst;
 
 	MLX5_ASSERT(len > MLX5_ESEG_MIN_INLINE_SIZE);
-	static_assert(MLX5_DSEG_MIN_INLINE_SIZE ==
-				 (2 * RTE_ETHER_ADDR_LEN),
-		      "invalid Data Segment data size");
 	if (!MLX5_TXOFF_CONFIG(MPW)) {
 		/* Store the descriptor byte counter for eMPW sessions. */
 		dseg->bcount = rte_cpu_to_be_32
@@ -4070,7 +4088,6 @@ mlx5_tx_burst_empw_simple(struct mlx5_txq_data *__rte_restrict txq,
 	MLX5_ASSERT(MLX5_TXOFF_CONFIG(EMPW));
 	MLX5_ASSERT(loc->elts_free && loc->wqe_free);
 	MLX5_ASSERT(pkts_n > loc->pkts_sent);
-	static_assert(MLX5_EMPW_MIN_PACKETS >= 2, "invalid min size");
 	pkts += loc->pkts_sent + 1;
 	pkts_n -= loc->pkts_sent;
 	for (;;) {
@@ -4247,7 +4264,6 @@ mlx5_tx_burst_empw_inline(struct mlx5_txq_data *__rte_restrict txq,
 	MLX5_ASSERT(MLX5_TXOFF_CONFIG(EMPW));
 	MLX5_ASSERT(loc->elts_free && loc->wqe_free);
 	MLX5_ASSERT(pkts_n > loc->pkts_sent);
-	static_assert(MLX5_EMPW_MIN_PACKETS >= 2, "invalid min size");
 	pkts += loc->pkts_sent + 1;
 	pkts_n -= loc->pkts_sent;
 	for (;;) {
@@ -4561,10 +4577,6 @@ mlx5_tx_burst_single_send(struct mlx5_txq_data *__rte_restrict txq,
 			    loc->mbuf->ol_flags & PKT_TX_VLAN_PKT) {
 				vlan = sizeof(struct rte_vlan_hdr);
 				inlen += vlan;
-				static_assert((sizeof(struct rte_vlan_hdr) +
-					       sizeof(struct rte_ether_hdr)) ==
-					       MLX5_ESEG_MIN_INLINE_SIZE,
-					       "invalid min inline data size");
 			}
 			/*
 			 * If inlining is enabled at configuration time
@@ -5567,16 +5579,6 @@ mlx5_select_tx_function(struct rte_eth_dev *dev)
 	uint64_t tx_offloads = dev->data->dev_conf.txmode.offloads;
 	unsigned int diff = 0, olx = 0, i, m;
 
-	static_assert(MLX5_WQE_SIZE_MAX / MLX5_WSEG_SIZE <=
-		      MLX5_DSEG_MAX, "invalid WQE max size");
-	static_assert(MLX5_WQE_CSEG_SIZE == MLX5_WSEG_SIZE,
-		      "invalid WQE Control Segment size");
-	static_assert(MLX5_WQE_ESEG_SIZE == MLX5_WSEG_SIZE,
-		      "invalid WQE Ethernet Segment size");
-	static_assert(MLX5_WQE_DSEG_SIZE == MLX5_WSEG_SIZE,
-		      "invalid WQE Data Segment size");
-	static_assert(MLX5_WQE_SIZE == 4 * MLX5_WSEG_SIZE,
-		      "invalid WQE size");
 	MLX5_ASSERT(priv);
 	if (tx_offloads & DEV_TX_OFFLOAD_MULTI_SEGS) {
 		/* We should support Multi-Segment Packets. */
drivers/net/mlx5/mlx5_txpp.c +3 -2
index a1ec294942..d61e43e55d 100644
@@ -18,6 +18,9 @@
 #include "mlx5_rxtx.h"
 #include "mlx5_common_os.h"
 
+static_assert(sizeof(struct mlx5_cqe_ts) == sizeof(rte_int128_t),
+		"Wrong timestamp CQE part size");
+
 static const char * const mlx5_txpp_stat_names[] = {
 	"tx_pp_missed_interrupt_errors", /* Missed service interrupt. */
 	"tx_pp_rearm_queue_errors", /* Rearm Queue errors. */
@@ -741,8 +744,6 @@ mlx5_txpp_update_timestamp(struct mlx5_dev_ctx_shared *sh)
 	uint64_t ts;
 	uint16_t ci;
 
-	static_assert(sizeof(struct mlx5_cqe_ts) == sizeof(rte_int128_t),
-		      "Wrong timestamp CQE part size");
 	mlx5_atomic_read_cqe((rte_int128_t *)&cqe->timestamp, &to.u128);
 	if (to.cts.op_own >> 4) {
 		DRV_LOG(DEBUG, "Clock Queue error sync lost.");
Signature · 1 line
2.16.1.windows.4
#111 lore raw

PATCH v2 9/33 net/mlx5: wrap glue alloc/dealloc PD with OS calls

In reply to Tal Shnaiderman

From: Ophir Munk <[email protected]>

Wrap glue calls alloc_pd() and dealloc_pd() with generic OS calls. In Linux - protection domain allocations are implemented by Verbs glue API while in Windows it is by DevX API.

---
 drivers/common/mlx5/linux/mlx5_common_os.h | 11 +++++++++++
 drivers/net/mlx5/mlx5.c                    |  6 +++---
 2 files changed, 14 insertions(+), 3 deletions(-)
drivers/common/mlx5/linux/mlx5_common_os.h +11 -0
index 3420937859..c9f8d7cbc1 100644
@@ -201,4 +201,15 @@ mlx5_os_get_devx_uar_page_id(void *uar)
 #endif
 }
 
+static inline void *
+mlx5_os_alloc_pd(void *ctx)
+{
+	return mlx5_glue->alloc_pd(ctx);
+}
+
+static inline int
+mlx5_os_dealloc_pd(void *pd)
+{
+	return mlx5_glue->dealloc_pd(pd);
+}
 #endif /* RTE_PMD_MLX5_COMMON_OS_H_ */
drivers/net/mlx5/mlx5.c +3 -3
index 8e9df6abcf..7d1b4fbdc0 100644
@@ -932,7 +932,7 @@ mlx5_alloc_shared_dev_ctx(const struct mlx5_dev_spawn_data *spawn,
 		sh->port[i].ih_port_id = RTE_MAX_ETHPORTS;
 		sh->port[i].devx_ih_port_id = RTE_MAX_ETHPORTS;
 	}
-	sh->pd = mlx5_glue->alloc_pd(sh->ctx);
+	sh->pd = mlx5_os_alloc_pd(sh->ctx);
 	if (sh->pd == NULL) {
 		DRV_LOG(ERR, "PD allocation failure");
 		err = ENOMEM;
@@ -1032,7 +1032,7 @@ mlx5_alloc_shared_dev_ctx(const struct mlx5_dev_spawn_data *spawn,
 	if (sh->tx_uar)
 		mlx5_glue->devx_free_uar(sh->tx_uar);
 	if (sh->pd)
-		claim_zero(mlx5_glue->dealloc_pd(sh->pd));
+		claim_zero(mlx5_os_dealloc_pd(sh->pd));
 	if (sh->ctx)
 		claim_zero(mlx5_glue->close_device(sh->ctx));
 	mlx5_free(sh);
@@ -1100,7 +1100,7 @@ mlx5_free_shared_dev_ctx(struct mlx5_dev_ctx_shared *sh)
 		sh->tx_uar = NULL;
 	}
 	if (sh->pd)
-		claim_zero(mlx5_glue->dealloc_pd(sh->pd));
+		claim_zero(mlx5_os_dealloc_pd(sh->pd));
 	if (sh->tis)
 		claim_zero(mlx5_devx_cmd_destroy(sh->tis));
 	if (sh->td)
Signature · 1 line
2.16.1.windows.4
#112 lore raw

PATCH v2 10/33 net/mlx5: wrap glue reg/dereg UMEM with OS calls

In reply to Tal Shnaiderman

Wrap glue calls for UMEM registration and deregistration with generic OS calls since each OS (Linux or Windows) has a different glue API parameters.

---
 drivers/common/mlx5/linux/mlx5_common_os.h | 12 ++++++++++++
 drivers/common/mlx5/mlx5_common.c          |  4 ++--
 drivers/net/mlx5/mlx5.c                    |  2 +-
 drivers/net/mlx5/mlx5_devx.c               | 16 ++++++++--------
 drivers/net/mlx5/mlx5_flow.c               |  4 ++--
 drivers/net/mlx5/mlx5_txpp.c               | 12 ++++++------
 6 files changed, 31 insertions(+), 19 deletions(-)
drivers/common/mlx5/linux/mlx5_common_os.h +12 -0
index c9f8d7cbc1..f8b215cc29 100644
@@ -212,4 +212,16 @@ mlx5_os_dealloc_pd(void *pd)
 {
 	return mlx5_glue->dealloc_pd(pd);
 }
+
+static inline void *
+mlx5_os_umem_reg(void *ctx, void *addr, size_t size, uint32_t access)
+{
+	return mlx5_glue->devx_umem_reg(ctx, addr, size, access);
+}
+
+static inline int
+mlx5_os_umem_dereg(void *pumem)
+{
+	return mlx5_glue->devx_umem_dereg(pumem);
+}
 #endif /* RTE_PMD_MLX5_COMMON_OS_H_ */
drivers/common/mlx5/mlx5_common.c +2 -2
index 044513223c..a00ffcb833 100644
@@ -148,7 +148,7 @@ mlx5_alloc_dbr_page(void *ctx)
 		return NULL;
 	}
 	/* Register allocated memory. */
-	page->umem = mlx5_glue->devx_umem_reg(ctx, page->dbrs,
+	page->umem = mlx5_os_umem_reg(ctx, page->dbrs,
 					      MLX5_DBR_PAGE_SIZE, 0);
 	if (!page->umem) {
 		DRV_LOG(ERR, "cannot umem reg dbr page");
@@ -232,7 +232,7 @@ mlx5_release_dbr(struct mlx5_dbr_page_list *head, uint32_t umem_id,
 		/* Page not used, free it and remove from list. */
 		LIST_REMOVE(page, next);
 		if (page->umem)
-			ret = -mlx5_glue->devx_umem_dereg(page->umem);
+			ret = -mlx5_os_umem_dereg(page->umem);
 		mlx5_free(page);
 	} else {
 		/* Mark in bitmap that this door-bell is not in use. */
drivers/net/mlx5/mlx5.c +1 -1
index 7d1b4fbdc0..84123f8e3d 100644
@@ -482,7 +482,7 @@ mlx5_flow_destroy_counter_stat_mem_mng(struct mlx5_counter_stats_mem_mng *mng)
 
 	LIST_REMOVE(mng, next);
 	claim_zero(mlx5_devx_cmd_destroy(mng->dm));
-	claim_zero(mlx5_glue->devx_umem_dereg(mng->umem));
+	claim_zero(mlx5_os_umem_dereg(mng->umem));
 	mlx5_free(mem);
 }
 
drivers/net/mlx5/mlx5_devx.c +8 -8
index de9b204075..235fd5798d 100644
@@ -155,7 +155,7 @@ mlx5_rxq_release_devx_rq_resources(struct mlx5_rxq_ctrl *rxq_ctrl)
 	struct mlx5_devx_dbr_page *dbr_page = rxq_ctrl->rq_dbrec_page;
 
 	if (rxq_ctrl->wq_umem) {
-		mlx5_glue->devx_umem_dereg(rxq_ctrl->wq_umem);
+		mlx5_os_umem_dereg(rxq_ctrl->wq_umem);
 		rxq_ctrl->wq_umem = NULL;
 	}
 	if (rxq_ctrl->rxq.wqes) {
@@ -182,7 +182,7 @@ mlx5_rxq_release_devx_cq_resources(struct mlx5_rxq_ctrl *rxq_ctrl)
 	struct mlx5_devx_dbr_page *dbr_page = rxq_ctrl->cq_dbrec_page;
 
 	if (rxq_ctrl->cq_umem) {
-		mlx5_glue->devx_umem_dereg(rxq_ctrl->cq_umem);
+		mlx5_os_umem_dereg(rxq_ctrl->cq_umem);
 		rxq_ctrl->cq_umem = NULL;
 	}
 	if (rxq_ctrl->rxq.cqes) {
@@ -375,7 +375,7 @@ mlx5_rxq_create_devx_rq_resources(struct rte_eth_dev *dev, uint16_t idx)
 	if (!buf)
 		return NULL;
 	rxq_data->wqes = buf;
-	rxq_ctrl->wq_umem = mlx5_glue->devx_umem_reg(priv->sh->ctx,
+	rxq_ctrl->wq_umem = mlx5_os_umem_reg(priv->sh->ctx,
 						     buf, wq_size, 0);
 	if (!rxq_ctrl->wq_umem)
 		goto error;
@@ -497,7 +497,7 @@ mlx5_rxq_create_devx_cq_resources(struct rte_eth_dev *dev, uint16_t idx)
 		goto error;
 	}
 	rxq_data->cqes = (volatile struct mlx5_cqe (*)[])(uintptr_t)buf;
-	rxq_ctrl->cq_umem = mlx5_glue->devx_umem_reg(priv->sh->ctx, buf,
+	rxq_ctrl->cq_umem = mlx5_os_umem_reg(priv->sh->ctx, buf,
 						     cq_size,
 						     IBV_ACCESS_LOCAL_WRITE);
 	if (!rxq_ctrl->cq_umem) {
@@ -1127,7 +1127,7 @@ mlx5_txq_release_devx_sq_resources(struct mlx5_txq_obj *txq_obj)
 		txq_obj->sq_devx = NULL;
 	}
 	if (txq_obj->sq_umem) {
-		claim_zero(mlx5_glue->devx_umem_dereg(txq_obj->sq_umem));
+		claim_zero(mlx5_os_umem_dereg(txq_obj->sq_umem));
 		txq_obj->sq_umem = NULL;
 	}
 	if (txq_obj->sq_buf) {
@@ -1155,7 +1155,7 @@ mlx5_txq_release_devx_cq_resources(struct mlx5_txq_obj *txq_obj)
 	if (txq_obj->cq_devx)
 		claim_zero(mlx5_devx_cmd_destroy(txq_obj->cq_devx));
 	if (txq_obj->cq_umem)
-		claim_zero(mlx5_glue->devx_umem_dereg(txq_obj->cq_umem));
+		claim_zero(mlx5_os_umem_dereg(txq_obj->cq_umem));
 	if (txq_obj->cq_buf)
 		mlx5_free(txq_obj->cq_buf);
 	if (txq_obj->cq_dbrec_page)
@@ -1243,7 +1243,7 @@ mlx5_txq_create_devx_cq_resources(struct rte_eth_dev *dev, uint16_t idx)
 		return 0;
 	}
 	/* Register allocated buffer in user space with DevX. */
-	txq_obj->cq_umem = mlx5_glue->devx_umem_reg(priv->sh->ctx,
+	txq_obj->cq_umem = mlx5_os_umem_reg(priv->sh->ctx,
 						(void *)txq_obj->cq_buf,
 						cqe_n * sizeof(struct mlx5_cqe),
 						IBV_ACCESS_LOCAL_WRITE);
@@ -1342,7 +1342,7 @@ mlx5_txq_create_devx_sq_resources(struct rte_eth_dev *dev, uint16_t idx)
 		goto error;
 	}
 	/* Register allocated buffer in user space with DevX. */
-	txq_obj->sq_umem = mlx5_glue->devx_umem_reg
+	txq_obj->sq_umem = mlx5_os_umem_reg
 					(priv->sh->ctx,
 					 (void *)txq_obj->sq_buf,
 					 wqe_n * sizeof(struct mlx5_wqe),
drivers/net/mlx5/mlx5_flow.c +2 -2
index bf86aaaa39..66491bbf78 100644
@@ -6446,7 +6446,7 @@ mlx5_flow_create_counter_stat_mem_mng(struct mlx5_dev_ctx_shared *sh)
 	}
 	mem_mng = (struct mlx5_counter_stats_mem_mng *)(mem + size) - 1;
 	size = sizeof(*raw_data) * MLX5_COUNTERS_PER_POOL * raws_n;
-	mem_mng->umem = mlx5_glue->devx_umem_reg(sh->ctx, mem, size,
+	mem_mng->umem = mlx5_os_umem_reg(sh->ctx, mem, size,
 						 IBV_ACCESS_LOCAL_WRITE);
 	if (!mem_mng->umem) {
 		rte_errno = errno;
@@ -6465,7 +6465,7 @@ mlx5_flow_create_counter_stat_mem_mng(struct mlx5_dev_ctx_shared *sh)
 	mkey_attr.relaxed_ordering_read = sh->cmng.relaxed_ordering_read;
 	mem_mng->dm = mlx5_devx_cmd_mkey_create(sh->ctx, &mkey_attr);
 	if (!mem_mng->dm) {
-		mlx5_glue->devx_umem_dereg(mem_mng->umem);
+		mlx5_os_umem_dereg(mem_mng->umem);
 		rte_errno = errno;
 		mlx5_free(mem);
 		return -rte_errno;
drivers/net/mlx5/mlx5_txpp.c +6 -6
index d61e43e55d..749529c410 100644
@@ -131,13 +131,13 @@ mlx5_txpp_destroy_send_queue(struct mlx5_txpp_wq *wq)
 	if (wq->sq)
 		claim_zero(mlx5_devx_cmd_destroy(wq->sq));
 	if (wq->sq_umem)
-		claim_zero(mlx5_glue->devx_umem_dereg(wq->sq_umem));
+		claim_zero(mlx5_os_umem_dereg(wq->sq_umem));
 	if (wq->sq_buf)
 		mlx5_free((void *)(uintptr_t)wq->sq_buf);
 	if (wq->cq)
 		claim_zero(mlx5_devx_cmd_destroy(wq->cq));
 	if (wq->cq_umem)
-		claim_zero(mlx5_glue->devx_umem_dereg(wq->cq_umem));
+		claim_zero(mlx5_os_umem_dereg(wq->cq_umem));
 	if (wq->cq_buf)
 		mlx5_free((void *)(uintptr_t)wq->cq_buf);
 	memset(wq, 0, sizeof(*wq));
@@ -268,7 +268,7 @@ mlx5_txpp_create_rearm_queue(struct mlx5_dev_ctx_shared *sh)
 		return -ENOMEM;
 	}
 	/* Register allocated buffer in user space with DevX. */
-	wq->cq_umem = mlx5_glue->devx_umem_reg(sh->ctx,
+	wq->cq_umem = mlx5_os_umem_reg(sh->ctx,
 					       (void *)(uintptr_t)wq->cq_buf,
 					       umem_size,
 					       IBV_ACCESS_LOCAL_WRITE);
@@ -318,7 +318,7 @@ mlx5_txpp_create_rearm_queue(struct mlx5_dev_ctx_shared *sh)
 		goto error;
 	}
 	/* Register allocated buffer in user space with DevX. */
-	wq->sq_umem = mlx5_glue->devx_umem_reg(sh->ctx,
+	wq->sq_umem = mlx5_os_umem_reg(sh->ctx,
 					       (void *)(uintptr_t)wq->sq_buf,
 					       umem_size,
 					       IBV_ACCESS_LOCAL_WRITE);
@@ -506,7 +506,7 @@ mlx5_txpp_create_clock_queue(struct mlx5_dev_ctx_shared *sh)
 		return -ENOMEM;
 	}
 	/* Register allocated buffer in user space with DevX. */
-	wq->cq_umem = mlx5_glue->devx_umem_reg(sh->ctx,
+	wq->cq_umem = mlx5_os_umem_reg(sh->ctx,
 					       (void *)(uintptr_t)wq->cq_buf,
 					       umem_size,
 					       IBV_ACCESS_LOCAL_WRITE);
@@ -562,7 +562,7 @@ mlx5_txpp_create_clock_queue(struct mlx5_dev_ctx_shared *sh)
 		goto error;
 	}
 	/* Register allocated buffer in user space with DevX. */
-	wq->sq_umem = mlx5_glue->devx_umem_reg(sh->ctx,
+	wq->sq_umem = mlx5_os_umem_reg(sh->ctx,
 					       (void *)(uintptr_t)wq->sq_buf,
 					       umem_size,
 					       IBV_ACCESS_LOCAL_WRITE);
Signature · 1 line
2.16.1.windows.4
#113 lore raw

PATCH v2 11/33 net/mlx5: fix adding destroy flow action wrapper

In reply to Tal Shnaiderman

From: Ophir Munk <[email protected]>

Glue function destroy_flow_action() was wrapped by OS specific operation mlx5_flow_os_destroy_flow_action(). It was skipped in file mlx5.c.

Fixes b293fbf9672b ("net/mlx5: add OS specific flow actions operations")
---
 drivers/net/mlx5/mlx5.c         | 5 +++--
 drivers/net/mlx5/mlx5_flow_dv.c | 6 +++---
 2 files changed, 6 insertions(+), 5 deletions(-)
drivers/net/mlx5/mlx5.c +3 -2
index 84123f8e3d..ea5cf80ac1 100644
@@ -38,6 +38,7 @@
 #include "mlx5_autoconf.h"
 #include "mlx5_mr.h"
 #include "mlx5_flow.h"
+#include "mlx5_flow_os.h"
 #include "rte_pmd_mlx5.h"
 
 /* Device parameter to enable RX completion queue compression. */
@@ -415,7 +416,7 @@ mlx5_flow_aso_age_mng_close(struct mlx5_dev_ctx_shared *sh)
 			for (j = 0; j < MLX5_COUNTERS_PER_POOL; ++j)
 				if (pool->actions[j].dr_action)
 					claim_zero
-						(mlx5_glue->destroy_flow_action
+						(mlx5_flow_os_destroy_flow_action
 						  (pool->actions[j].dr_action));
 			mlx5_free(pool);
 		}
@@ -523,7 +524,7 @@ mlx5_flow_counters_mng_close(struct mlx5_dev_ctx_shared *sh)
 
 				if (cnt->action)
 					claim_zero
-					 (mlx5_glue->destroy_flow_action
+					 (mlx5_flow_os_destroy_flow_action
 					  (cnt->action));
 				if (fallback && MLX5_POOL_GET_CNT
 				    (pool, j)->dcs_when_free)
drivers/net/mlx5/mlx5_flow_dv.c +3 -3
index c31737652c..78b5a6b338 100644
@@ -11117,11 +11117,11 @@ flow_dv_sample_remove_cb(struct mlx5_cache_list *list __rte_unused,
 	struct mlx5_priv *priv = dev->data->dev_private;
 
 	if (cache_resource->verbs_action)
-		claim_zero(mlx5_glue->destroy_flow_action
+		claim_zero(mlx5_flow_os_destroy_flow_action
 				(cache_resource->verbs_action));
 	if (cache_resource->ft_type == MLX5DV_FLOW_TABLE_TYPE_FDB) {
 		if (cache_resource->default_miss)
-			claim_zero(mlx5_glue->destroy_flow_action
+			claim_zero(mlx5_flow_os_destroy_flow_action
 			  (cache_resource->default_miss));
 	}
 	if (cache_resource->normal_path_tbl)
@@ -11174,7 +11174,7 @@ flow_dv_dest_array_remove_cb(struct mlx5_cache_list *list __rte_unused,
 
 	MLX5_ASSERT(cache_resource->action);
 	if (cache_resource->action)
-		claim_zero(mlx5_glue->destroy_flow_action
+		claim_zero(mlx5_flow_os_destroy_flow_action
 					(cache_resource->action));
 	for (; i < cache_resource->num_of_dest; i++)
 		flow_dv_sample_sub_actions_release(dev,
Signature · 1 line
2.16.1.windows.4
#114 lore raw

PATCH v2 12/33 common/mlx5: add definition HAVE_INFINIBAND_VERBS_H

In reply to Tal Shnaiderman

From: Ophir Munk <[email protected]>

Add a Verbs file presence indication. Under Linux it is required that file infiniband/verbs.h is installed for building DPDK. Other operating systems (e.g. Windows) ignore Verbs completely. This commit adds definition HAVE_INFINIBAND_VERBS_H (file mlx5_autoconf.h) to indicate whether DPDK compiles with Verbs or not.

---
 drivers/common/mlx5/linux/meson.build | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/common/mlx5/linux/meson.build +4 -2
index 63b78e4bce..580419e6d9 100644
@@ -181,8 +181,10 @@ has_sym_args = [
 	[ 'HAVE_MLX5_DR_CREATE_ACTION_DEST_ARRAY', 'infiniband/mlx5dv.h',
 	'mlx5dv_dr_action_create_dest_array'],
 	[ 'HAVE_DEVLINK', 'linux/devlink.h', 'DEVLINK_GENL_NAME' ],
-        [ 'HAVE_MLX5_DR_CREATE_ACTION_ASO', 'infiniband/mlx5dv.h',
-        'mlx5dv_dr_action_create_aso' ],
+	[ 'HAVE_MLX5_DR_CREATE_ACTION_ASO', 'infiniband/mlx5dv.h',
+	'mlx5dv_dr_action_create_aso' ],
+	[ 'HAVE_INFINIBAND_VERBS_H', 'infiniband/verbs.h',
+	'INFINIBAND_VERBS_H' ],
 ]
 config = configuration_data()
 foreach arg:has_sym_args
Signature · 1 line
2.16.1.windows.4
#115 lore raw

PATCH v2 13/33 common/mlx5/linux: handle memory allocations with alignment

In reply to Tal Shnaiderman

From: Ophir Munk <[email protected]>

mlx5_malloc() API has an alignment parameter for system memory allocations. malloc() is called for non-aligned allocations and posix_memalign() is called for aligned allocations. When calling mlx5_free() there is no distinction whether the memory was originally allocated with or without alignment. Freeing a memory may be handled differently by operating systems. Therefore this commit wraps these APIs with OS specific calls: mlx5_os_malloc(), mlx5_os_free().

---
 drivers/common/mlx5/linux/mlx5_common_os.h | 38 ++++++++++++++++++++++++++++++
 drivers/common/mlx5/mlx5_malloc.c          | 14 +++++------
 2 files changed, 44 insertions(+), 8 deletions(-)
drivers/common/mlx5/linux/mlx5_common_os.h +38 -0
index f8b215cc29..bd44ecb7d6 100644
@@ -6,6 +6,7 @@
 #define RTE_PMD_MLX5_COMMON_OS_H_
 
 #include <stdio.h>
+#include <malloc.h>
 
 #include <rte_pci.h>
 #include <rte_debug.h>
@@ -16,6 +17,7 @@
 
 #include "mlx5_autoconf.h"
 #include "mlx5_glue.h"
+#include "mlx5_malloc.h"
 
 /**
  * Get device name. Given an ibv_device pointer - return a
@@ -224,4 +226,40 @@ mlx5_os_umem_dereg(void *pumem)
 {
 	return mlx5_glue->devx_umem_dereg(pumem);
 }
+
+/**
+ * Memory allocation optionally with alignment.
+ *
+ * @param[in] align
+ *    Alignment size (may be zero)
+ * @param[in] size
+ *    Size in bytes to allocate
+ *
+ * @return
+ *    Valid pointer to allocated memory, NULL in case of failure
+ */
+static inline void *
+mlx5_os_malloc(size_t align, size_t size)
+{
+	void *buf;
+
+	if (posix_memalign(&buf, align, size))
+		return NULL;
+	return buf;
+}
+
+/**
+ * This API de-allocates a memory that originally could have been
+ * allocated aligned or non-aligned. In Linux it is a wrapper
+ * around free().
+ *
+ * @param[in] addr
+ *    Pointer to address to free
+ *
+ */
+static inline void
+mlx5_os_free(void *addr)
+{
+	free(addr);
+}
 #endif /* RTE_PMD_MLX5_COMMON_OS_H_ */
drivers/common/mlx5/mlx5_malloc.c +6 -8
index 5a3267f730..9d30cedbaa 100644
@@ -9,6 +9,7 @@
 #include <string.h>
 
 #include "mlx5_common_utils.h"
+#include "mlx5_common_os.h"
 #include "mlx5_malloc.h"
 
 struct mlx5_sys_mem {
@@ -148,14 +149,11 @@ static void *
 mlx5_alloc_align(size_t size, unsigned int align, unsigned int zero)
 {
 	void *buf;
-	int ret;
-
-	ret = posix_memalign(&buf, align, size);
-	if (ret) {
-		DRV_LOG(ERR,
-			"Couldn't allocate buf size=%zu align=%u. Err=%d\n",
-			size, align, ret);
 
+	buf = mlx5_os_malloc(align, size);
+	if (!buf) {
+		DRV_LOG(ERR, "Couldn't allocate buf size=%zu align=%u.",
+			size, align);
 		return NULL;
 	}
 	if (zero)
@@ -264,7 +262,7 @@ mlx5_free(void *addr)
 		__atomic_add_fetch(&mlx5_sys_mem.free_sys, 1,
 				   __ATOMIC_RELAXED);
 #endif
-		free(addr);
+		mlx5_os_free(addr);
 	} else {
 #ifdef RTE_LIBRTE_MLX5_DEBUG
 		__atomic_add_fetch(&mlx5_sys_mem.free_rte, 1,
Signature · 1 line
2.16.1.windows.4
#116 lore raw

PATCH v2 14/33 common/mlx5/windows: handle memory allocations with alignment

In reply to Tal Shnaiderman

From: Ophir Munk <[email protected]>

This commit is the Windows equivalent of the Linux implementation. The APIs included in this commit: mlx5_os_malloc(), mlx5_os_free(). For memory allocations (with or without alignment) we always call _aligned_malloc(). Even if zero alignment was requested in the first place - we always select a minimal alignment value. In this way when the memory is free - it is always safe to call _aligned_free().

---
 drivers/common/mlx5/windows/mlx5_common_os.h | 51 ++++++++++++++++++++++++++++
 1 file changed, 51 insertions(+)
 create mode 100644 drivers/common/mlx5/windows/mlx5_common_os.h
drivers/common/mlx5/windows/mlx5_common_os.h new file +51 -0
new file mode 100644
index 0000000000..cce7c88c6a
@@ -0,0 +1,51 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright 2020 Mellanox Technologies, Ltd
+ */
+
+#ifndef RTE_PMD_MLX5_COMMON_OS_H_
+#define RTE_PMD_MLX5_COMMON_OS_H_
+
+#include <stdio.h>
+
+#include "mlx5_autoconf.h"
+#include "mlx5_glue.h"
+#include "mlx5_malloc.h"
+
+/**
+ * This API allocates aligned or non-aligned memory.  The free can be on either
+ * aligned or nonaligned memory.  To be protected - even though there may be no
+ * alignment - in Windows this API will unconditioanlly call _aligned_malloc()
+ * with at least a minimal alignment size.
+ *
+ * @param[in] align
+ *    The alignment value, which must be an integer power of 2 (or 0 for
+ *    non-alignment)
+ * @param[in] size
+ *    Size in bytes to allocate
+ *
+ * @return
+ *    Valid pointer to allocated memory, NULL in case of failure
+ */
+static inline void *
+mlx5_os_malloc(size_t align, size_t size)
+{
+	if (align < MLX5_MALLOC_ALIGNMENT)
+		align = MLX5_MALLOC_ALIGNMENT;
+	return _aligned_malloc(size, align);
+}
+
+/**
+ * This API de-allocates a memory that originally could have been allocated
+ * aligned or non-aligned. In Windows since the allocation was with
+ * _aligned_malloc() - it is safe to always call _aligned_free().
+ *
+ * @param[in] addr
+ *    Pointer to address to free
+ *
+ */
+static inline void
+mlx5_os_free(void *addr)
+{
+	_aligned_free(addr);
+}
+#endif /* RTE_PMD_MLX5_COMMON_OS_H_ */
Signature · 1 line
2.16.1.windows.4
#117 lore raw

PATCH v2 15/33 common/mlx5/linux: wrap event channel APIs with OS calls

In reply to Tal Shnaiderman

Wrap the API to create/destroy event channel and to subscribe an event with OS calls. In Linux those calls are implemented by glue functions while in Windows they are not supported.

---
 drivers/common/mlx5/linux/mlx5_common_os.h | 22 ++++++++++++++++++++++
 drivers/net/mlx5/mlx5_devx.c               |  8 ++++----
 drivers/net/mlx5/mlx5_txpp.c               |  6 +++---
 drivers/vdpa/mlx5/mlx5_vdpa_event.c        |  7 ++++---
 4 files changed, 33 insertions(+), 10 deletions(-)
drivers/common/mlx5/linux/mlx5_common_os.h +22 -0
index bd44ecb7d6..63f070d9c4 100644
@@ -227,6 +227,28 @@ mlx5_os_umem_dereg(void *pumem)
 	return mlx5_glue->devx_umem_dereg(pumem);
 }
 
+static inline void *
+mlx5_os_devx_create_event_channel(void *ctx, int flags)
+{
+	return mlx5_glue->devx_create_event_channel(ctx, flags);
+}
+
+static inline void
+mlx5_os_devx_destroy_event_channel(void *eventc)
+{
+	mlx5_glue->devx_destroy_event_channel(eventc);
+}
+
+static inline int
+mlx5_os_devx_subscribe_devx_event(void *eventc,
+				  void *obj,
+				  uint16_t events_sz, uint16_t events_num[],
+				  uint64_t cookie)
+{
+	return mlx5_glue->devx_subscribe_devx_event(eventc, obj, events_sz,
+						    events_num, cookie);
+}
+
 /**
  * Memory allocation optionally with alignment.
  *
drivers/net/mlx5/mlx5_devx.c +4 -4
index 235fd5798d..84a5c55ee0 100644
@@ -216,7 +216,7 @@ mlx5_rxq_devx_obj_release(struct mlx5_rxq_obj *rxq_obj)
 		claim_zero(mlx5_devx_cmd_destroy(rxq_obj->rq));
 		claim_zero(mlx5_devx_cmd_destroy(rxq_obj->devx_cq));
 		if (rxq_obj->devx_channel)
-			mlx5_glue->devx_destroy_event_channel
+			mlx5_os_devx_destroy_event_channel
 							(rxq_obj->devx_channel);
 		mlx5_rxq_release_devx_rq_resources(rxq_obj->rxq_ctrl);
 		mlx5_rxq_release_devx_cq_resources(rxq_obj->rxq_ctrl);
@@ -533,7 +533,7 @@ mlx5_rxq_create_devx_cq_resources(struct rte_eth_dev *dev, uint16_t idx)
 	rxq_data->cqe_n = log_cqe_n;
 	rxq_data->cqn = cq_obj->id;
 	if (rxq_ctrl->obj->devx_channel) {
-		ret = mlx5_glue->devx_subscribe_devx_event
+		ret = mlx5_os_devx_subscribe_devx_event
 						(rxq_ctrl->obj->devx_channel,
 						 cq_obj->obj,
 						 sizeof(event_nums),
@@ -644,7 +644,7 @@ mlx5_rxq_devx_obj_new(struct rte_eth_dev *dev, uint16_t idx)
 		int devx_ev_flag =
 			  MLX5DV_DEVX_CREATE_EVENT_CHANNEL_FLAGS_OMIT_EV_DATA;
 
-		tmpl->devx_channel = mlx5_glue->devx_create_event_channel
+		tmpl->devx_channel = mlx5_os_devx_create_event_channel
 								(priv->sh->ctx,
 								 devx_ev_flag);
 		if (!tmpl->devx_channel) {
@@ -686,7 +686,7 @@ mlx5_rxq_devx_obj_new(struct rte_eth_dev *dev, uint16_t idx)
 	if (tmpl->devx_cq)
 		claim_zero(mlx5_devx_cmd_destroy(tmpl->devx_cq));
 	if (tmpl->devx_channel)
-		mlx5_glue->devx_destroy_event_channel(tmpl->devx_channel);
+		mlx5_os_devx_destroy_event_channel(tmpl->devx_channel);
 	mlx5_rxq_release_devx_rq_resources(rxq_ctrl);
 	mlx5_rxq_release_devx_cq_resources(rxq_ctrl);
 	rte_errno = ret; /* Restore rte_errno. */
drivers/net/mlx5/mlx5_txpp.c +3 -3
index 749529c410..726bdc6ae1 100644
@@ -37,7 +37,7 @@ static void
 mlx5_txpp_destroy_event_channel(struct mlx5_dev_ctx_shared *sh)
 {
 	if (sh->txpp.echan) {
-		mlx5_glue->devx_destroy_event_channel(sh->txpp.echan);
+		mlx5_os_devx_destroy_event_channel(sh->txpp.echan);
 		sh->txpp.echan = NULL;
 	}
 }
@@ -47,7 +47,7 @@ static int
 mlx5_txpp_create_event_channel(struct mlx5_dev_ctx_shared *sh)
 {
 	MLX5_ASSERT(!sh->txpp.echan);
-	sh->txpp.echan = mlx5_glue->devx_create_event_channel(sh->ctx,
+	sh->txpp.echan = mlx5_os_devx_create_event_channel(sh->ctx,
 			MLX5DV_DEVX_CREATE_EVENT_CHANNEL_FLAGS_OMIT_EV_DATA);
 	if (!sh->txpp.echan) {
 		rte_errno = errno;
@@ -937,7 +937,7 @@ mlx5_txpp_start_service(struct mlx5_dev_ctx_shared *sh)
 		return -rte_errno;
 	}
 	/* Subscribe CQ event to the event channel controlled by the driver. */
-	ret = mlx5_glue->devx_subscribe_devx_event(sh->txpp.echan,
+	ret = mlx5_os_devx_subscribe_devx_event(sh->txpp.echan,
 						   sh->txpp.rearm_queue.cq->obj,
 						   sizeof(event_nums),
 						   event_nums, 0);
drivers/vdpa/mlx5/mlx5_vdpa_event.c +4 -3
index 3aeaeb893f..fd6150928b 100644
@@ -15,6 +15,7 @@
 #include <rte_alarm.h>
 
 #include <mlx5_common.h>
+#include <mlx5_common_os.h>
 #include <mlx5_glue.h>
 
 #include "mlx5_vdpa_utils.h"
@@ -43,7 +44,7 @@ mlx5_vdpa_event_qp_global_release(struct mlx5_vdpa_priv *priv)
 		       sizeof(out.buf)) >=
 		       (ssize_t)sizeof(out.event_resp.cookie))
 			;
-		mlx5_glue->devx_destroy_event_channel(priv->eventc);
+		mlx5_os_devx_destroy_event_channel(priv->eventc);
 		priv->eventc = NULL;
 	}
 #endif
@@ -63,7 +64,7 @@ mlx5_vdpa_event_qp_global_prepare(struct mlx5_vdpa_priv *priv)
 		DRV_LOG(ERR, "Failed to query EQ number %d.", rte_errno);
 		return -1;
 	}
-	priv->eventc = mlx5_glue->devx_create_event_channel(priv->ctx,
+	priv->eventc = mlx5_os_devx_create_event_channel(priv->ctx,
 			   MLX5DV_DEVX_CREATE_EVENT_CHANNEL_FLAGS_OMIT_EV_DATA);
 	if (!priv->eventc) {
 		rte_errno = errno;
@@ -176,7 +177,7 @@ mlx5_vdpa_cq_create(struct mlx5_vdpa_priv *priv, uint16_t log_desc_n,
 	cq->cq_ci = 0;
 	rte_spinlock_init(&cq->sl);
 	/* Subscribe CQ event to the event channel controlled by the driver. */
-	ret = mlx5_glue->devx_subscribe_devx_event(priv->eventc, cq->cq->obj,
+	ret = mlx5_os_devx_subscribe_devx_event(priv->eventc, cq->cq->obj,
 						   sizeof(event_nums),
 						   event_nums,
 						   (uint64_t)(uintptr_t)cq);
Signature · 1 line
2.16.1.windows.4
#118 lore raw

PATCH v2 16/33 common/mlx5: add Windows exports file

In reply to Tal Shnaiderman

File drivers/common/mlx5/rte_common_mlx5_exports.def contains mlx5 Windows exported symbols under common/mlx5 directory (DLL file name librte_common_mlx5*.dll). It is the equivalent of Linux map file rte_common_mlx5_version.map but the list of symbols may be different between the two operating systems.

---
 drivers/common/mlx5/rte_common_mlx5_exports.def | 62 +++++++++++++++++++++++++
 1 file changed, 62 insertions(+)
 create mode 100644 drivers/common/mlx5/rte_common_mlx5_exports.def
drivers/common/mlx5/rte_common_mlx5_exports.def new file +62 -0
new file mode 100644
index 0000000000..23984b7abd
@@ -0,0 +1,62 @@
+EXPORTS
+	haswell_broadwell_cpu
+
+	mlx5_common_init
+
+	mlx5_create_mr_ext
+
+	mlx5_devx_cmd_create_cq
+	mlx5_devx_cmd_create_flex_parser
+	mlx5_devx_cmd_create_qp
+	mlx5_devx_cmd_create_rq
+	mlx5_devx_cmd_create_rqt
+	mlx5_devx_cmd_create_sq
+	mlx5_devx_cmd_create_tir
+	mlx5_devx_cmd_create_td
+	mlx5_devx_cmd_create_tis
+	mlx5_devx_cmd_create_virtq
+	mlx5_devx_cmd_destroy
+	mlx5_devx_cmd_flow_counter_alloc
+	mlx5_devx_cmd_flow_counter_query
+	mlx5_devx_cmd_flow_dump
+	mlx5_devx_cmd_mkey_create
+	mlx5_devx_cmd_modify_qp_state
+	mlx5_devx_cmd_modify_rq
+	mlx5_devx_cmd_modify_rqt
+	mlx5_devx_cmd_modify_sq
+	mlx5_devx_cmd_modify_tir
+	mlx5_devx_cmd_modify_virtq
+	mlx5_devx_cmd_qp_query_tis_td
+	mlx5_devx_cmd_query_hca_attr
+	mlx5_devx_cmd_query_parse_samples
+	mlx5_devx_cmd_query_virtq
+	mlx5_devx_cmd_register_read
+	mlx5_devx_get_out_command_status
+	mlx5_devx_cmd_create_flow_hit_aso_obj
+
+	mlx5_get_dbr
+
+	mlx5_malloc_mem_select
+	mlx5_mr_btree_init
+	mlx5_mr_btree_free
+	mlx5_mr_btree_dump
+	mlx5_mr_addr2mr_bh
+	mlx5_mr_release_cache
+	mlx5_mr_dump_cache
+	mlx5_mr_rebuild_cache
+	mlx5_mr_insert_cache
+	mlx5_mr_lookup_cache
+	mlx5_mr_lookup_list
+	mlx5_mr_create_primary
+	mlx5_mr_flush_local_cache
+	mlx5_mp_req_queue_state_modify
+	mlx5_mr_free
+
+	mlx5_pci_driver_register
+
+	mlx5_release_dbr
+
+	mlx5_malloc
+	mlx5_realloc
+	mlx5_free
+
Signature · 1 line
2.16.1.windows.4
#119 lore raw

PATCH v2 17/33 common/mlx5: extend DevX query hca attributes command

In reply to Tal Shnaiderman

Extend DevX API mlx5_devx_cmd_query_hca_attr() to report on max number of available objects including: CQ, QP, PD, SRQ.

---
 drivers/common/mlx5/mlx5_devx_cmds.c | 11 +++++++++++
 drivers/common/mlx5/mlx5_devx_cmds.h | 10 +++++++++-
 drivers/common/mlx5/mlx5_prm.h       |  1 +
 3 files changed, 21 insertions(+), 1 deletion(-)
drivers/common/mlx5/mlx5_devx_cmds.c +11 -0
index 9c1d1883ea..36d3a421aa 100644
@@ -720,6 +720,14 @@ mlx5_devx_cmd_query_hca_attr(void *ctx,
 	attr->flow_hit_aso = !!(MLX5_GET64(cmd_hca_cap, hcattr,
 					   general_obj_types) &
 				MLX5_GENERAL_OBJ_TYPES_CAP_FLOW_HIT_ASO);
+	attr->log_max_cq = MLX5_GET(cmd_hca_cap, hcattr, log_max_cq);
+	attr->log_max_qp = MLX5_GET(cmd_hca_cap, hcattr, log_max_qp);
+	attr->log_max_cq_sz = MLX5_GET(cmd_hca_cap, hcattr, log_max_cq_sz);
+	attr->log_max_qp_sz = MLX5_GET(cmd_hca_cap, hcattr, log_max_qp_sz);
+	attr->log_max_mrw_sz = MLX5_GET(cmd_hca_cap, hcattr, log_max_mrw_sz);
+	attr->log_max_pd = MLX5_GET(cmd_hca_cap, hcattr, log_max_pd);
+	attr->log_max_srq = MLX5_GET(cmd_hca_cap, hcattr, log_max_srq);
+	attr->log_max_srq_sz = MLX5_GET(cmd_hca_cap, hcattr, log_max_srq_sz);
 	if (attr->qos.sup) {
 		MLX5_SET(query_hca_cap_in, in, op_mod,
 			 MLX5_GET_HCA_CAP_OP_MOD_QOS_CAP |
@@ -834,6 +842,9 @@ mlx5_devx_cmd_query_hca_attr(void *ctx,
 	attr->tunnel_stateless_gtp = MLX5_GET
 					(per_protocol_networking_offload_caps,
 					 hcattr, tunnel_stateless_gtp);
+	attr->rss_ind_tbl_cap = MLX5_GET
+					(per_protocol_networking_offload_caps,
+					 hcattr, rss_ind_tbl_cap);
 	if (attr->wqe_inline_mode != MLX5_CAP_INLINE_MODE_VPORT_CONTEXT)
 		return 0;
 	if (attr->eth_virt) {
drivers/common/mlx5/mlx5_devx_cmds.h +9 -1
index 726e9f5192..5056d86ed9 100644
@@ -117,6 +117,15 @@ struct mlx5_hca_attr {
 	uint32_t log_max_ft_sampler_num:8;
 	struct mlx5_hca_qos_attr qos;
 	struct mlx5_hca_vdpa_attr vdpa;
+	int log_max_qp_sz;
+	int log_max_cq_sz;
+	int log_max_qp;
+	int log_max_cq;
+	uint32_t log_max_pd;
+	uint32_t log_max_mrw_sz;
+	uint32_t log_max_srq;
+	uint32_t log_max_srq_sz;
+	uint32_t rss_ind_tbl_cap;
 };
 
 struct mlx5_devx_wq_attr {
@@ -495,7 +504,6 @@ struct mlx5_devx_obj *mlx5_devx_cmd_create_virtio_q_counters(void *ctx);
 __rte_internal
 int mlx5_devx_cmd_query_virtio_q_counters(struct mlx5_devx_obj *couners_obj,
 				  struct mlx5_devx_virtio_q_couners_attr *attr);
-
 __rte_internal
 struct mlx5_devx_obj *mlx5_devx_cmd_create_flow_hit_aso_obj(void *ctx,
 							    uint32_t pd);
drivers/common/mlx5/mlx5_prm.h +1 -0
index 58d180486e..585e9d1c05 100644
@@ -665,6 +665,7 @@ typedef uint8_t u8;
 #define MLX5_GET64(typ, p, fld) rte_be_to_cpu_64(*((rte_be64_t *)(p) + \
 						   __mlx5_64_off(typ, fld)))
 #define MLX5_FLD_SZ_BYTES(typ, fld) (__mlx5_bit_sz(typ, fld) / 8)
+#define MLX5_UN_SZ_BYTES(typ) (sizeof(union mlx5_ifc_##typ##_bits) / 8)
 
 struct mlx5_ifc_fte_match_set_misc_bits {
 	u8 gre_c_present[0x1];
Signature · 1 line
2.16.1.windows.4
#120 lore raw

PATCH v2 18/33 common/mlx5: add DevX alloc PD command

In reply to Tal Shnaiderman

Add a new DevX API mlx5_devx_cmd_alloc_pd() that creates a new protection domain (PD).

---
 drivers/common/mlx5/mlx5_devx_cmds.c            | 35 ++++++++++++++++++++++++
 drivers/common/mlx5/mlx5_devx_cmds.h            |  2 ++
 drivers/common/mlx5/mlx5_prm.h                  | 36 +++++++++++++++++++++++++
 drivers/common/mlx5/rte_common_mlx5_exports.def |  1 +
 drivers/common/mlx5/version.map                 |  1 +
 5 files changed, 75 insertions(+)
drivers/common/mlx5/mlx5_devx_cmds.c +35 -0
index 36d3a421aa..12f51a940c 100644
@@ -2055,3 +2055,38 @@ mlx5_devx_cmd_create_flow_hit_aso_obj(void *ctx, uint32_t pd)
 	flow_hit_aso_obj->id = MLX5_GET(general_obj_out_cmd_hdr, out, obj_id);
 	return flow_hit_aso_obj;
 }
+
+/*
+ * Create PD using DevX API.
+ *
+ * @param[in] ctx
+ *   Context returned from mlx5 open_device() glue function.
+ *
+ * @return
+ *   The DevX object created, NULL otherwise and rte_errno is set.
+ */
+struct mlx5_devx_obj *
+mlx5_devx_cmd_alloc_pd(void *ctx)
+{
+	struct mlx5_devx_obj *ppd =
+		mlx5_malloc(MLX5_MEM_ZERO, sizeof(*ppd), 0, SOCKET_ID_ANY);
+	u32 in[MLX5_ST_SZ_DW(alloc_pd_in)] = {0};
+	u32 out[MLX5_ST_SZ_DW(alloc_pd_out)] = {0};
+
+	if (!ppd) {
+		DRV_LOG(ERR, "Failed to allocate PD data.");
+		rte_errno = ENOMEM;
+		return NULL;
+	}
+	MLX5_SET(alloc_pd_in, in, opcode, MLX5_CMD_OP_ALLOC_PD);
+	ppd->obj = mlx5_glue->devx_obj_create(ctx, in, sizeof(in),
+				out, sizeof(out));
+	if (!ppd->obj) {
+		mlx5_free(ppd);
+		DRV_LOG(ERR, "Failed to allocate PD Obj using DevX.");
+		rte_errno = errno;
+		return NULL;
+	}
+	ppd->id = MLX5_GET(alloc_pd_out, out, pd);
+	return ppd;
+}
drivers/common/mlx5/mlx5_devx_cmds.h +2 -0
index 5056d86ed9..8277fdbc39 100644
@@ -508,4 +508,6 @@ __rte_internal
 struct mlx5_devx_obj *mlx5_devx_cmd_create_flow_hit_aso_obj(void *ctx,
 							    uint32_t pd);
 
+__rte_internal
+struct mlx5_devx_obj *mlx5_devx_cmd_alloc_pd(void *ctx);
 #endif /* RTE_PMD_MLX5_DEVX_CMDS_H_ */
drivers/common/mlx5/mlx5_prm.h +36 -0
index 585e9d1c05..4ddf865743 100644
@@ -844,6 +844,8 @@ enum {
 	MLX5_CMD_OP_SUSPEND_QP = 0x50F,
 	MLX5_CMD_OP_RESUME_QP = 0x510,
 	MLX5_CMD_OP_QUERY_NIC_VPORT_CONTEXT = 0x754,
+	MLX5_CMD_OP_ALLOC_PD = 0x800,
+	MLX5_CMD_OP_DEALLOC_PD = 0x801,
 	MLX5_CMD_OP_ACCESS_REGISTER = 0x805,
 	MLX5_CMD_OP_ALLOC_TRANSPORT_DOMAIN = 0x816,
 	MLX5_CMD_OP_CREATE_TIR = 0x900,
@@ -2772,6 +2774,40 @@ struct mlx5_ifc_init2init_qp_in_bits {
 	u8 reserved_at_800[0x80];
 };
 
+struct mlx5_ifc_dealloc_pd_out_bits {
+	u8 status[0x8];
+	u8 reserved_0[0x18];
+	u8 syndrome[0x20];
+	u8 reserved_1[0x40];
+};
+
+struct mlx5_ifc_dealloc_pd_in_bits {
+	u8 opcode[0x10];
+	u8 reserved_0[0x10];
+	u8 reserved_1[0x10];
+	u8 op_mod[0x10];
+	u8 reserved_2[0x8];
+	u8 pd[0x18];
+	u8 reserved_3[0x20];
+};
+
+struct mlx5_ifc_alloc_pd_out_bits {
+	u8 status[0x8];
+	u8 reserved_0[0x18];
+	u8 syndrome[0x20];
+	u8 reserved_1[0x8];
+	u8 pd[0x18];
+	u8 reserved_2[0x20];
+};
+
+struct mlx5_ifc_alloc_pd_in_bits {
+	u8 opcode[0x10];
+	u8 reserved_0[0x10];
+	u8 reserved_1[0x10];
+	u8 op_mod[0x10];
+	u8 reserved_2[0x40];
+};
+
 #ifdef PEDANTIC
 #pragma GCC diagnostic ignored "-Wpedantic"
 #endif
drivers/common/mlx5/rte_common_mlx5_exports.def +1 -0
index 23984b7abd..15aafc3809 100644
@@ -5,6 +5,7 @@ EXPORTS
 
 	mlx5_create_mr_ext
 
+	mlx5_devx_cmd_alloc_pd
 	mlx5_devx_cmd_create_cq
 	mlx5_devx_cmd_create_flex_parser
 	mlx5_devx_cmd_create_qp
drivers/common/mlx5/version.map +1 -0
index 17dd11f635..fb3952bbc6 100644
@@ -10,6 +10,7 @@ INTERNAL {
 
 	mlx5_dev_to_pci_addr;
 
+	mlx5_devx_cmd_alloc_pd;
 	mlx5_devx_cmd_create_cq;
 	mlx5_devx_cmd_create_flex_parser;
 	mlx5_devx_cmd_create_qp;
Signature · 1 line
2.16.1.windows.4
#121 lore raw

PATCH v2 19/33 common/mlx5/windows: add glue functions APIs

In reply to Tal Shnaiderman

Windows glue functions are added to file mlx5/windows/mlx5_glue.c. The following APIs are supported:
get_device_list, free_device_list, open_device, close_device, query_device, query_hca_iseg, devx_obj_create, devx_obj_destroy, devx_obj_query, devx_obj_modify, devx_general_cmd, devx_umem_reg, devx_umem_dereg, devx_alloc_uar, devx_free_uar, devx_fs_rule_add, devx_fs_rule_del, devx_query_eqn
New added files:
mlx5_win_defs.h - this file imports missing definitions from Linux rdma-core library and Linux OS.
mlx5_win_ext.h - this file contains structs that enable a unified Linux/Windows API. Each struct has an equivalent (but different) Linux struct. By calling with 'void *' pointers - the Linux/Windows API is identical.

---
 drivers/common/mlx5/rte_common_mlx5_exports.def |   1 +
 drivers/common/mlx5/windows/mlx5_glue.c         | 304 ++++++++++++++++++++++++
 drivers/common/mlx5/windows/mlx5_glue.h         |  58 +++++
 drivers/common/mlx5/windows/mlx5_win_defs.h     |  25 ++
 drivers/common/mlx5/windows/mlx5_win_ext.h      |  34 +++
 5 files changed, 422 insertions(+)
 create mode 100644 drivers/common/mlx5/windows/mlx5_glue.c
 create mode 100644 drivers/common/mlx5/windows/mlx5_glue.h
 create mode 100644 drivers/common/mlx5/windows/mlx5_win_defs.h
 create mode 100644 drivers/common/mlx5/windows/mlx5_win_ext.h
drivers/common/mlx5/rte_common_mlx5_exports.def +1 -0
index 15aafc3809..2f6aab133b 100644
@@ -36,6 +36,7 @@ EXPORTS
 	mlx5_devx_cmd_create_flow_hit_aso_obj
 
 	mlx5_get_dbr
+	mlx5_glue
 
 	mlx5_malloc_mem_select
 	mlx5_mr_btree_init
drivers/common/mlx5/windows/mlx5_glue.c new file +304 -0

304 lines not on this page · raw message

drivers/common/mlx5/windows/mlx5_glue.h new file +58 -0

58 lines not on this page · raw message

drivers/common/mlx5/windows/mlx5_win_defs.h new file +25 -0
new file mode 100644
index 0000000000..72a3131f5e
@@ -0,0 +1,25 @@
+/*
+ * Copyright (C) Mellanox Technologies, Ltd. 2001-2020.
+ *
+ */
+#ifndef __MLX5_WIN_DEFS_H__
+#define __MLX5_WIN_DEFS_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+enum {
+	MLX5_CQE_OWNER_MASK	= 1,
+	MLX5_CQE_REQ		= 0,
+	MLX5_CQE_RESP_WR_IMM	= 1,
+	MLX5_CQE_RESP_SEND	= 2,
+	MLX5_CQE_RESP_SEND_IMM	= 3,
+	MLX5_CQE_RESP_SEND_INV	= 4,
+	MLX5_CQE_RESIZE_CQ	= 5,
+	MLX5_CQE_NO_PACKET	= 6,
+	MLX5_CQE_REQ_ERR	= 13,
+	MLX5_CQE_RESP_ERR	= 14,
+	MLX5_CQE_INVALID	= 15,
+};
+#endif /* __MLX5_WIN_DEFS_H__ */
drivers/common/mlx5/windows/mlx5_win_ext.h new file +34 -0
new file mode 100644
index 0000000000..0e74910e9d
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) Mellanox Technologies, Ltd. 2001-2020.
+ *
+ */
+#ifndef __MLX5_WIN_ETX_H__
+#define __MLX5_WIN_ETX_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "mlx5devx.h"
+
+typedef struct mlx5_context {
+	devx_device_ctx        *devx_ctx;
+	struct devx_device mlx5_dev;
+
+} mlx5_context_st;
+
+typedef struct {
+	devx_device_ctx *devx_ctx;
+	struct devx_obj_handle *obj;
+} mlx5_devx_obj_st;
+
+struct mlx5_devx_umem {
+	void                   *addr;
+	struct devx_obj_handle *umem_hdl;
+	uint32_t                umem_id;
+};
+
+#define GET_DEVX_CTX(ctx) (((mlx5_context_st *)ctx)->devx_ctx)
+#define GET_OBJ_CTX(obj)  (((mlx5_devx_obj_st *)obj)->devx_ctx)
+
+#endif /* __MLX5_WIN_ETX_H__ */
Signature · 1 line
2.16.1.windows.4
#122 lore raw

PATCH v2 20/33 mlx5/windows: add mlx5 meson file

In reply to Tal Shnaiderman

File drivers/common/mlx5/windows/meson.build is added to enable mlx5 source files compilation under common windows directory.
A Devx SDK tool must be installed to export two external H files:
mlx5devx.h and mlx5_ifc_devx.h. The installation is based on environment variable DEVX_INC_PATH. In addition a DLL lib file is installed based on environment variable DEVX_LIB_PATH. The meson file is using the environment variables for compilation and linkage.

---
 drivers/common/mlx5/meson.build         |  4 ++--
 drivers/common/mlx5/windows/meson.build | 42 +++++++++++++++++++++++++++++++++
 2 files changed, 44 insertions(+), 2 deletions(-)
 create mode 100644 drivers/common/mlx5/windows/meson.build
drivers/common/mlx5/meson.build +2 -2
index 3dacc6f683..3047b455cf 100644
@@ -1,9 +1,9 @@
 # SPDX-License-Identifier: BSD-3-Clause
 # Copyright 2019 Mellanox Technologies, Ltd
 
-if not is_linux
+if not (is_linux or (is_windows and is_ms_linker))
 	build = false
-	reason = 'only supported on Linux'
+	reason = 'only supported on Linux and Windows build with clang'
 	subdir_done()
 endif
 
drivers/common/mlx5/windows/meson.build new file +42 -0

42 lines not on this page · raw message

Signature · 1 line
2.16.1.windows.4
#123 lore raw

Re: [dpdk-dev] [PATCH v2 20/33] mlx5/windows: add mlx5 meson file

Quoted 7 lines · Tal Shnaiderman

File drivers/common/mlx5/windows/meson.build is added to enable mlx5 source files compilation under common windows directory.
A Devx SDK tool must be installed to export two external H files:
mlx5devx.h and mlx5_ifc_devx.h. The installation is based on environment variable DEVX_INC_PATH. In addition a DLL lib file is installed based on environment variable DEVX_LIB_PATH. The meson file is using the environment variables for compilation and linkage.

I installed WinOF-2 for Windows Server 2019 from this page:

https://www.mellanox.com/products/adapter-software/ethernet/windows/winof-2

Then I installed DevX SDK from C:\Program Files\Mellanox\DevX SDK and set environment variables:

$env:DEVX_INC_PATH = "C:\Program Files\Mellanox\MLNX_WinOF2_DevX_SDK\inc" $env:DEVX_LIB_PATH = "C:\Program Files\Mellanox\MLNX_WinOF2_DevX_SDK\lib"

Meson complained no more, but the build failed, log is below. What am I missing? Note: I'm building the whole series.

Another question, why there's a clang restriction?

[149/203] Compiling C object drivers/a715181@@rte_common_mlx5@sta/common_mlx5_mlx5_common.c.obj.
FAILED: drivers/a715181@@rte_common_mlx5@sta/common_mlx5_mlx5_common.c.obj
clang @drivers/a715181@@rte_common_mlx5@sta/common_mlx5_mlx5_common.c.obj.rsp
In file included from ../../drivers/common/mlx5/mlx5_common.c:13:
In file included from ..\..\drivers\common/mlx5/mlx5_common.h:18:
..\..\drivers\common/mlx5/mlx5_prm.h:363:31: error: field has incomplete type 'struct mlx5_wqe_srq_next_seg'

        struct mlx5_wqe_srq_next_seg next_seg;
                                     ^
..\..\drivers\common/mlx5/mlx5_prm.h:363:9: note: forward declaration of 'struct mlx5_wqe_srq_next_seg'
        struct mlx5_wqe_srq_next_seg next_seg;
               ^
..\..\drivers\common/mlx5/mlx5_prm.h:364:27: error: field has incomplete type 'struct mlx5_wqe_data_seg'
        struct mlx5_wqe_data_seg dseg;
                                 ^
..\..\drivers\common/mlx5/mlx5_prm.h:364:9: note: forward declaration of 'struct mlx5_wqe_data_seg'
        struct mlx5_wqe_data_seg dseg;
               ^

In file included from ../../drivers/common/mlx5/mlx5_common.c:14:
In file included from ..\..\drivers\common/mlx5\windows\mlx5_common_os.h:15:
In file included from ..\..\drivers\common/mlx5\mlx5_common_mr.h:19:
..\..\drivers\common/mlx5/mlx5_common_mp.h:29:7: warning: forward references to 'enum' types are a Microsoft extension [-Wmicrosoft-enum-forward-reference]
enum ibv_wq_state state; /* WQ requested state. */
^
In file included from ../../drivers/common/mlx5/mlx5_common.c:14:
In file included from ..\..\drivers\common/mlx5\windows\mlx5_common_os.h:16:
In file included from ..\..\drivers\common/mlx5\windows/mlx5_win_ext.h:12:
In file included from C:\Program Files\Mellanox\MLNX_WinOF2_DevX_SDK\inc\mlx5devx.h:26:
C:\Program Files\Mellanox\MLNX_WinOF2_DevX_SDK\inc/mlx5_ifc_devx.h:95:45: error: field has incomplete type 'struct mlx5_ifc_dest_format_struct_bits'

    struct mlx5_ifc_dest_format_struct_bits dest;
                                            ^
C:\Program Files\Mellanox\MLNX_WinOF2_DevX_SDK\inc/mlx5_ifc_devx.h:95:12: note: forward declaration of 'struct mlx5_ifc_dest_format_struct_bits'
    struct mlx5_ifc_dest_format_struct_bits dest;
           ^
../../drivers/common/mlx5/mlx5_common.c:323:15: warning: implicit declaration of function 'mlx5_os_get_devx_uar_base_addr' is invalid in C99 [-Wimplicit-function-declaration]
                base_addr = mlx5_os_get_devx_uar_base_addr(uar);
                            ^
../../drivers/common/mlx5/mlx5_common.c:323:13: warning: incompatible integer to pointer conversion assigning to 'void *' from 'int' [-Wint-conversion]
                base_addr = mlx5_os_get_devx_uar_base_addr(uar);
                          ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

3 warnings and 3 errors generated.
[151/203] Compiling C object drivers/a715181@@rte_common_mlx5@sta/common_mlx5_mlx5_malloc.c.obj.
FAILED: drivers/a715181@@rte_common_mlx5@sta/common_mlx5_mlx5_malloc.c.obj
clang @drivers/a715181@@rte_common_mlx5@sta/common_mlx5_mlx5_malloc.c.obj.rsp
In file included from ../../drivers/common/mlx5/mlx5_malloc.c:11:
In file included from ..\..\drivers\common/mlx5/mlx5_common_utils.h:8:
In file included from ..\..\drivers\common/mlx5/mlx5_common.h:18:
..\..\drivers\common/mlx5/mlx5_prm.h:363:31: error: field has incomplete type 'struct mlx5_wqe_srq_next_seg'

        struct mlx5_wqe_srq_next_seg next_seg;
                                     ^
..\..\drivers\common/mlx5/mlx5_prm.h:363:9: note: forward declaration of 'struct mlx5_wqe_srq_next_seg'
        struct mlx5_wqe_srq_next_seg next_seg;
               ^
..\..\drivers\common/mlx5/mlx5_prm.h:364:27: error: field has incomplete type 'struct mlx5_wqe_data_seg'
        struct mlx5_wqe_data_seg dseg;
                                 ^
..\..\drivers\common/mlx5/mlx5_prm.h:364:9: note: forward declaration of 'struct mlx5_wqe_data_seg'
        struct mlx5_wqe_data_seg dseg;
               ^

In file included from ../../drivers/common/mlx5/mlx5_malloc.c:12:
In file included from ..\..\drivers\common/mlx5\windows\mlx5_common_os.h:15:
In file included from ..\..\drivers\common/mlx5\mlx5_common_mr.h:19:
..\..\drivers\common/mlx5/mlx5_common_mp.h:29:7: warning: forward references to 'enum' types are a Microsoft extension [-Wmicrosoft-enum-forward-reference]
enum ibv_wq_state state; /* WQ requested state. */
^
In file included from ../../drivers/common/mlx5/mlx5_malloc.c:12:
In file included from ..\..\drivers\common/mlx5\windows\mlx5_common_os.h:16:
In file included from ..\..\drivers\common/mlx5\windows/mlx5_win_ext.h:12:
In file included from C:\Program Files\Mellanox\MLNX_WinOF2_DevX_SDK\inc\mlx5devx.h:26:
C:\Program Files\Mellanox\MLNX_WinOF2_DevX_SDK\inc/mlx5_ifc_devx.h:95:45: error: field has incomplete type 'struct mlx5_ifc_dest_format_struct_bits'

    struct mlx5_ifc_dest_format_struct_bits dest;
                                            ^
C:\Program Files\Mellanox\MLNX_WinOF2_DevX_SDK\inc/mlx5_ifc_devx.h:95:12: note: forward declaration of 'struct mlx5_ifc_dest_format_struct_bits'
    struct mlx5_ifc_dest_format_struct_bits dest;
           ^

1 warning and 3 errors generated.
[154/203] Compiling C object lib/76b5a35@@rte_hash@sta/librte_hash_rte_cuckoo_hash.c.obj.
ninja: build stopped: subcommand failed.

#124 lore raw

Re: [dpdk-dev] [PATCH v2 20/33] mlx5/windows: add mlx5 meson file

Quoted 23 lines

Subject: Re: [dpdk-dev] [PATCH v2 20/33] mlx5/windows: add mlx5 meson file

External email: Use caution opening links or attachments

Quoted 7 lines · Tal Shnaiderman

File drivers/common/mlx5/windows/meson.build is added to enable mlx5 source files compilation under common windows directory.
A Devx SDK tool must be installed to export two external H files:
mlx5devx.h and mlx5_ifc_devx.h. The installation is based on environment variable DEVX_INC_PATH. In addition a DLL lib file is installed based on environment variable DEVX_LIB_PATH. The meson file is using the environment variables for compilation and linkage.

I installed WinOF-2 for Windows Server 2019 from this page:

https://www.mellanox.com/products/adapter-
software/ethernet/windows/winof-2

Then I installed DevX SDK from C:\Program Files\Mellanox\DevX SDK and set environment variables:

Quoted 7 lines

$env:DEVX_INC_PATH = "C:\Program
Files\Mellanox\MLNX_WinOF2_DevX_SDK\inc"
$env:DEVX_LIB_PATH = "C:\Program
Files\Mellanox\MLNX_WinOF2_DevX_SDK\lib"

Meson complained no more, but the build failed, log is below. What am I missing? Note: I'm building the whole series.

Thanks for testing Dmitry, this is an patches order issue on my side, the common build patch should come in the next series.

I'll fix in v3.

Quoted 3 lines

Another question, why there's a clang restriction?

On the current release we've ported and tested the PMD and SDK for clang, once we'll do the same for MinGW64 we'll remove this restriction.

Quoted 120 lines

[149/203] Compiling C object drivers/a715181@@rte_common_mlx5@sta/common_mlx5_mlx5_common .c.obj.
FAILED:
drivers/a715181@@rte_common_mlx5@sta/common_mlx5_mlx5_common .c.obj
clang @drivers/a715181@@rte_common_mlx5@sta/common_mlx5_mlx5_comm on.c.obj.rsp
In file included from ../../drivers/common/mlx5/mlx5_common.c:13:
In file included from ..\..\drivers\common/mlx5/mlx5_common.h:18:
..\..\drivers\common/mlx5/mlx5_prm.h:363:31: error: field has incomplete type 'struct mlx5_wqe_srq_next_seg'

        struct mlx5_wqe_srq_next_seg next_seg;
                                     ^
..\..\drivers\common/mlx5/mlx5_prm.h:363:9: note: forward declaration of
'struct mlx5_wqe_srq_next_seg'
        struct mlx5_wqe_srq_next_seg next_seg;
               ^
..\..\drivers\common/mlx5/mlx5_prm.h:364:27: error: field has incomplete
type 'struct mlx5_wqe_data_seg'
        struct mlx5_wqe_data_seg dseg;
                                 ^
..\..\drivers\common/mlx5/mlx5_prm.h:364:9: note: forward declaration of
'struct mlx5_wqe_data_seg'
        struct mlx5_wqe_data_seg dseg;
               ^

In file included from ../../drivers/common/mlx5/mlx5_common.c:14:
In file included from ..\..\drivers\common/mlx5\windows\mlx5_common_os.h:15:
In file included from ..\..\drivers\common/mlx5\mlx5_common_mr.h:19:
..\..\drivers\common/mlx5/mlx5_common_mp.h:29:7: warning: forward references to 'enum' types are a Microsoft extension [-Wmicrosoft-enum- forward-reference]
enum ibv_wq_state state; /* WQ requested state. */
^
In file included from ../../drivers/common/mlx5/mlx5_common.c:14:
In file included from ..\..\drivers\common/mlx5\windows\mlx5_common_os.h:16:
In file included from ..\..\drivers\common/mlx5\windows/mlx5_win_ext.h:12:
In file included from C:\Program Files\Mellanox\MLNX_WinOF2_DevX_SDK\inc\mlx5devx.h:26:
C:\Program Files\Mellanox\MLNX_WinOF2_DevX_SDK\inc/mlx5_ifc_devx.h:95:45: error:
field has incomplete type 'struct mlx5_ifc_dest_format_struct_bits'

    struct mlx5_ifc_dest_format_struct_bits dest;
                                            ^ C:\Program
Files\Mellanox\MLNX_WinOF2_DevX_SDK\inc/mlx5_ifc_devx.h:95:12: note:
forward declaration of 'struct mlx5_ifc_dest_format_struct_bits'
    struct mlx5_ifc_dest_format_struct_bits dest;
           ^
../../drivers/common/mlx5/mlx5_common.c:323:15: warning: implicit
declaration of function 'mlx5_os_get_devx_uar_base_addr' is invalid in C99
[-Wimplicit-function-declaration]
                base_addr = mlx5_os_get_devx_uar_base_addr(uar);
                            ^
../../drivers/common/mlx5/mlx5_common.c:323:13: warning: incompatible
integer to pointer conversion assigning to 'void *' from 'int' [-Wint-
conversion]
                base_addr = mlx5_os_get_devx_uar_base_addr(uar);
                          ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

3 warnings and 3 errors generated.
[151/203] Compiling C object drivers/a715181@@rte_common_mlx5@sta/common_mlx5_mlx5_malloc.c. obj.
FAILED:
drivers/a715181@@rte_common_mlx5@sta/common_mlx5_mlx5_malloc.c. obj
clang @drivers/a715181@@rte_common_mlx5@sta/common_mlx5_mlx5_malloc. c.obj.rsp
In file included from ../../drivers/common/mlx5/mlx5_malloc.c:11:
In file included from ..\..\drivers\common/mlx5/mlx5_common_utils.h:8:
In file included from ..\..\drivers\common/mlx5/mlx5_common.h:18:
..\..\drivers\common/mlx5/mlx5_prm.h:363:31: error: field has incomplete type 'struct mlx5_wqe_srq_next_seg'

        struct mlx5_wqe_srq_next_seg next_seg;
                                     ^
..\..\drivers\common/mlx5/mlx5_prm.h:363:9: note: forward declaration of
'struct mlx5_wqe_srq_next_seg'
        struct mlx5_wqe_srq_next_seg next_seg;
               ^
..\..\drivers\common/mlx5/mlx5_prm.h:364:27: error: field has incomplete
type 'struct mlx5_wqe_data_seg'
        struct mlx5_wqe_data_seg dseg;
                                 ^
..\..\drivers\common/mlx5/mlx5_prm.h:364:9: note: forward declaration of
'struct mlx5_wqe_data_seg'
        struct mlx5_wqe_data_seg dseg;
               ^

In file included from ../../drivers/common/mlx5/mlx5_malloc.c:12:
In file included from ..\..\drivers\common/mlx5\windows\mlx5_common_os.h:15:
In file included from ..\..\drivers\common/mlx5\mlx5_common_mr.h:19:
..\..\drivers\common/mlx5/mlx5_common_mp.h:29:7: warning: forward references to 'enum' types are a Microsoft extension [-Wmicrosoft-enum- forward-reference]
enum ibv_wq_state state; /* WQ requested state. */
^
In file included from ../../drivers/common/mlx5/mlx5_malloc.c:12:
In file included from ..\..\drivers\common/mlx5\windows\mlx5_common_os.h:16:
In file included from ..\..\drivers\common/mlx5\windows/mlx5_win_ext.h:12:
In file included from C:\Program Files\Mellanox\MLNX_WinOF2_DevX_SDK\inc\mlx5devx.h:26:
C:\Program Files\Mellanox\MLNX_WinOF2_DevX_SDK\inc/mlx5_ifc_devx.h:95:45: error:
field has incomplete type 'struct mlx5_ifc_dest_format_struct_bits'

    struct mlx5_ifc_dest_format_struct_bits dest;
                                            ^ C:\Program
Files\Mellanox\MLNX_WinOF2_DevX_SDK\inc/mlx5_ifc_devx.h:95:12: note:
forward declaration of 'struct mlx5_ifc_dest_format_struct_bits'
    struct mlx5_ifc_dest_format_struct_bits dest;
           ^

1 warning and 3 errors generated.
[154/203] Compiling C object lib/76b5a35@@rte_hash@sta/librte_hash_rte_cuckoo_hash.c.obj.
ninja: build stopped: subcommand failed.

#125 lore raw

PATCH v2 21/33 mlx5/windows: add initialization routine for external lib

In reply to Tal Shnaiderman

From: Ophir Munk <[email protected]>

Add function mlx5_glue_constructor() as an initialization routine for run-time dependency on external lib. Currently the routine has an empty body. It is used for compatibility with Linux.

---
 drivers/common/mlx5/windows/meson.build      |  1 +
 drivers/common/mlx5/windows/mlx5_common_os.c | 24 ++++++++++++++++++++++++
 2 files changed, 25 insertions(+)
 create mode 100644 drivers/common/mlx5/windows/mlx5_common_os.c
drivers/common/mlx5/windows/meson.build +1 -0
index 2b2aa3b097..9e74ebdea3 100644
@@ -6,6 +6,7 @@ includes += include_directories('.')
 allow_experimental_apis = true
 sources += files(
 	'mlx5_glue.c',
+	'mlx5_common_os.c',
 )
 
 res_lib = run_command(python3, '-c', 'import os; print(os.environ["DEVX_LIB_PATH"])')
drivers/common/mlx5/windows/mlx5_common_os.c new file +24 -0
new file mode 100644
index 0000000000..5707fb60c3
@@ -0,0 +1,24 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright 2020 Mellanox Technologies, Ltd
+ */
+
+#include <unistd.h>
+#include <string.h>
+#include <stdio.h>
+
+#include <rte_errno.h>
+#include <rte_mempool.h>
+#include <rte_malloc.h>
+#include <rte_errno.h>
+
+#include "mlx5_devx_cmds.h"
+#include "mlx5_common_utils.h"
+#include <mlx5_common.h>
+
+/**
+ * Initialization routine for run-time dependency on external lib
+ */
+void
+mlx5_glue_constructor(void)
+{
+}
Signature · 1 line
2.16.1.windows.4
#126 lore raw

PATCH v2 22/33 mlx5/windows: generate file mlx5_autoconf.h

In reply to Tal Shnaiderman

From: Ophir Munk <[email protected]>

File mlx5_autoconf.h is generated under Windows to maintain compatibility with the Linux build system. This file is included in Linux/Windows shared source files therefore it is required. Currently the file is created empty.

---
 drivers/common/mlx5/windows/meson.build | 3 +++
 1 file changed, 3 insertions(+)
drivers/common/mlx5/windows/meson.build +3 -0
index 9e74ebdea3..5ac5724b40 100644
@@ -41,3 +41,6 @@ else
 	cflags += [ '-UPEDANTIC' ]
 endif
 
+# Generate an empty mlx5_autoconf.h file for compatibility with Linux
+config = configuration_data()
+configure_file(output : 'mlx5_autoconf.h', configuration : config)
Signature · 1 line
2.16.1.windows.4
#127 lore raw

PATCH v2 23/33 common/mlx5/windows: extend PRM match_param_bits struct

In reply to Tal Shnaiderman

Add reserved size to PRM 'struct mlx5_ifc_fte_match_param_bits' for non Linux OS. Windows drivers require this extension since their expected size should match the actual struct size. Linux drivers do not require this extension and already use calculations based on the shorter size. Use a static assert to verify that the PRM fte_match_param struct size remains correct.

---
 drivers/common/mlx5/mlx5_prm.h          | 7 +++++++
 drivers/common/mlx5/windows/mlx5_glue.c | 3 +++
 2 files changed, 10 insertions(+)
drivers/common/mlx5/mlx5_prm.h +7 -0
index 4ddf865743..27a4e4f0f1 100644
@@ -815,6 +815,13 @@ struct mlx5_ifc_fte_match_param_bits {
 	struct mlx5_ifc_fte_match_set_misc2_bits misc_parameters_2;
 	struct mlx5_ifc_fte_match_set_misc3_bits misc_parameters_3;
 	struct mlx5_ifc_fte_match_set_misc4_bits misc_parameters_4;
+/*
+ * Add reserved bit to match the struct size with the size defined in PRM.
+ * This extension is not required in Linux.
+ */
+#ifndef HAVE_INFINIBAND_VERBS_H
+	u8 reserved_0[0x400];
+#endif
 };
 
 enum {
drivers/common/mlx5/windows/mlx5_glue.c +3 -0
index 7f8a00aaa7..3896cf0932 100644
@@ -256,6 +256,9 @@ mlx5_glue_devx_free_uar(void *uar)
 	devx_free_uar((devx_uar_handle *)uar);
 }
 
+static_assert(MLX5_ST_SZ_BYTES(fte_match_param) == 0x200,
+	"PRM size of fte_match_param is broken! cannot compile Windows!");
+
 static void*
 mlx5_glue_devx_fs_rule_add(void *ctx, void *in, uint32_t inlen)
 
Signature · 1 line
2.16.1.windows.4
#128 lore raw

PATCH v2 24/33 common/mlx5/windows: add getter functions

In reply to Tal Shnaiderman

From: Ophir Munk <[email protected]>

Add file mlx5/windows/mlx5_common_os.h the equivalent of Linux file mlx5/linux/mlx5_common_os.h. It contains getters functions mlx5_os_get_dev_device_name, mlx5_os_get_ctx_device_name, mlx5_os_get_ctx_device_path, mlx5_os_get_umem_id, mlx5_os_get_devx_channel_fd.

---
 drivers/common/mlx5/windows/mlx5_common_os.h | 91 ++++++++++++++++++++++++++++
 1 file changed, 91 insertions(+)
drivers/common/mlx5/windows/mlx5_common_os.h +91 -0
index cce7c88c6a..2abdb2c3ae 100644
@@ -48,4 +48,95 @@ mlx5_os_free(void *addr)
 {
 	_aligned_free(addr);
 }
+
+/**
+ * Get fd. Given a pointer to DevX channel object of type
+ * 'struct mlx5dv_devx_event_channel*' - return its fd.
+ * Under Windows it is a stub.
+ *
+ * @param[in] channel
+ *    Pointer to channel object.
+ *
+ * @return
+ *    0
+ */
+static inline int
+mlx5_os_get_devx_channel_fd(void *channel)
+{
+	if (!channel)
+		return 0;
+	return 0;
+}
+
+/**
+ * Get device name. Given a device pointer - return a
+ * pointer to the corresponding device name.
+ *
+ * @param[in] dev
+ *   Pointer to device.
+ *
+ * @return
+ *   Pointer to device name if dev is valid, NULL otherwise.
+ */
+static inline const char *
+mlx5_os_get_dev_device_name(void *dev)
+{
+	if (!dev)
+		return NULL;
+	return ((struct devx_device *)dev)->name;
+}
+
+/**
+ * Get device name. Given a context pointer - return a
+ * pointer to the corresponding device name.
+ *
+ * @param[in] ctx
+ *   Pointer to context.
+ *
+ * @return
+ *   Pointer to device name if ctx is valid, NULL otherwise.
+ */
+static inline const char *
+mlx5_os_get_ctx_device_name(void *ctx)
+{
+	if (!ctx)
+		return NULL;
+	return ((mlx5_context_st *)ctx)->mlx5_dev.name;
+}
+
+/**
+ * Get a device path name. Given acontext pointer - return a
+ * pointer to the corresponding device path name.
+ *
+ * @param[in] ctx
+ *   Pointer to context.
+ *
+ * @return
+ *   Pointer to device path name if ctx is valid, NULL otherwise.
+ */
+
+static inline const char *
+mlx5_os_get_ctx_device_path(void *ctx)
+{
+	if (!ctx)
+		return NULL;
+	return ((mlx5_context_st *)ctx)->mlx5_dev.dev_pnp_id;
+}
+
+/**
+ * Get umem id. Given a pointer to umem object of type return its id.
+ *
+ * @param[in] umem
+ *    Pointer to umem object.
+ *
+ * @return
+ *    The umem id if umem is valid, 0 otherwise.
+ */
+static inline uint32_t
+mlx5_os_get_umem_id(void *umem)
+{
+	if (!umem)
+		return 0;
+	return ((struct mlx5_devx_umem *)umem)->umem_id;
+}
 #endif /* RTE_PMD_MLX5_COMMON_OS_H_ */
Signature · 1 line
2.16.1.windows.4
#129 lore raw

PATCH v2 25/33 common/mlx5/windows: add OS alloc/dealloc pd

In reply to Tal Shnaiderman

Implement Windows API mlx5_os_alloc_pd() and mlx5_os_dealloc_pd(). They are equivalent to the Linux implementation in [1].

[1]
("net/mlx5: wrap glue alloc/dealloc PD with OS calls")

---
 drivers/common/mlx5/rte_common_mlx5_exports.def |  3 +-
 drivers/common/mlx5/windows/mlx5_common_os.c    | 48 +++++++++++++++++++++++++
 drivers/common/mlx5/windows/mlx5_common_os.h    |  3 ++
 drivers/common/mlx5/windows/mlx5_win_ext.h      |  6 ++++
 4 files changed, 59 insertions(+), 1 deletion(-)
drivers/common/mlx5/rte_common_mlx5_exports.def +2 -1
index 2f6aab133b..5db1eaa48c 100644
@@ -61,4 +61,5 @@ EXPORTS
 	mlx5_malloc
 	mlx5_realloc
 	mlx5_free
-
+	mlx5_os_alloc_pd
+	mlx5_os_dealloc_pd
drivers/common/mlx5/windows/mlx5_common_os.c +48 -0

51 lines not on this page · raw message

drivers/common/mlx5/windows/mlx5_common_os.h +3 -0
index 2abdb2c3ae..f47351ec41 100644
@@ -139,4 +139,7 @@ mlx5_os_get_umem_id(void *umem)
 		return 0;
 	return ((struct mlx5_devx_umem *)umem)->umem_id;
 }
+
+void *mlx5_os_alloc_pd(void *ctx);
+int mlx5_os_dealloc_pd(void *pd);
 #endif /* RTE_PMD_MLX5_COMMON_OS_H_ */
drivers/common/mlx5/windows/mlx5_win_ext.h +6 -0
index 0e74910e9d..8e697b30c1 100644
@@ -28,6 +28,12 @@ struct mlx5_devx_umem {
 	uint32_t                umem_id;
 };
 
+struct mlx5_pd {
+	void                   *obj;
+	uint32_t                pdn;
+	devx_device_ctx        *devx_ctx;
+};
+
 #define GET_DEVX_CTX(ctx) (((mlx5_context_st *)ctx)->devx_ctx)
 #define GET_OBJ_CTX(obj)  (((mlx5_devx_obj_st *)obj)->devx_ctx)
 
Signature · 1 line
2.16.1.windows.4
#130 lore raw

PATCH v2 26/33 common/mlx5/windows: add OS umem reg/dereg API

In reply to Tal Shnaiderman

Implement Windows API mlx5_os_umem_reg() and mlx5_os_umem_dereg(). They are equivalent to the Linux implementation.

---
 drivers/common/mlx5/rte_common_mlx5_exports.def |  2 +
 drivers/common/mlx5/windows/mlx5_common_os.c    | 60 +++++++++++++++++++++++++
 drivers/common/mlx5/windows/mlx5_common_os.h    |  2 +
 3 files changed, 64 insertions(+)
drivers/common/mlx5/rte_common_mlx5_exports.def +2 -0
index 5db1eaa48c..1eabe29a58 100644
@@ -63,3 +63,5 @@ EXPORTS
 	mlx5_free
 	mlx5_os_alloc_pd
 	mlx5_os_dealloc_pd
+	mlx5_os_umem_reg
+	mlx5_os_umem_dereg
drivers/common/mlx5/windows/mlx5_common_os.c +60 -0

63 lines not on this page · raw message

drivers/common/mlx5/windows/mlx5_common_os.h +2 -0
index f47351ec41..decb5acd45 100644
@@ -142,4 +142,6 @@ mlx5_os_get_umem_id(void *umem)
 
 void *mlx5_os_alloc_pd(void *ctx);
 int mlx5_os_dealloc_pd(void *pd);
+void *mlx5_os_umem_reg(void *ctx, void *addr, size_t size, uint32_t access);
+int mlx5_os_umem_dereg(void *pumem);
 #endif /* RTE_PMD_MLX5_COMMON_OS_H_ */
Signature · 1 line
2.16.1.windows.4
#131 lore raw

PATCH v2 27/33 net/mlx5: update MR prototypes for DevX

In reply to Tal Shnaiderman

From: Ophir Munk <[email protected]>

Currently MR operations are Verbs based. This commit updates MR operations prototypes such that DevX MR operations callbacks can be used as well. Rename 'struct mlx5_verbs_ops' as 'struct mlx5_mr_ops' and move it to shared file mlx5.h.

---
 drivers/net/mlx5/linux/mlx5_os.c    | 4 ++--
 drivers/net/mlx5/linux/mlx5_verbs.c | 2 +-
 drivers/net/mlx5/linux/mlx5_verbs.h | 8 +-------
 drivers/net/mlx5/mlx5.h             | 6 ++++++
 4 files changed, 10 insertions(+), 10 deletions(-)
drivers/net/mlx5/linux/mlx5_os.c +2 -2
index a6c1eba640..4f68c74267 100644
@@ -2478,8 +2478,8 @@ void
 mlx5_os_set_reg_mr_cb(mlx5_reg_mr_t *reg_mr_cb,
 		      mlx5_dereg_mr_t *dereg_mr_cb)
 {
-	*reg_mr_cb = mlx5_verbs_ops.reg_mr;
-	*dereg_mr_cb = mlx5_verbs_ops.dereg_mr;
+	*reg_mr_cb = mlx5_mr_verbs_ops.reg_mr;
+	*dereg_mr_cb = mlx5_mr_verbs_ops.dereg_mr;
 }
 
 /**
drivers/net/mlx5/linux/mlx5_verbs.c +1 -1
index 9161fa3b7d..b52ae2e6c1 100644
@@ -62,7 +62,7 @@ mlx5_dereg_mr(struct mlx5_pmd_mr *pmd_mr)
 }
 
 /* verbs operations. */
-const struct mlx5_verbs_ops mlx5_verbs_ops = {
+const struct mlx5_mr_ops mlx5_mr_verbs_ops = {
 	.reg_mr = mlx5_reg_mr,
 	.dereg_mr = mlx5_dereg_mr,
 };
drivers/net/mlx5/linux/mlx5_verbs.h +1 -7
index 0670f6c47e..76a79bf4f4 100644
@@ -7,16 +7,10 @@
 
 #include "mlx5.h"
 
-struct mlx5_verbs_ops {
-	mlx5_reg_mr_t reg_mr;
-	mlx5_dereg_mr_t dereg_mr;
-};
-
 int mlx5_txq_ibv_obj_new(struct rte_eth_dev *dev, uint16_t idx);
 void mlx5_txq_ibv_obj_release(struct mlx5_txq_obj *txq_obj);
 
 /* Verbs ops struct */
-extern const struct mlx5_verbs_ops mlx5_verbs_ops;
+extern const struct mlx5_mr_ops mlx5_mr_verbs_ops;
 extern struct mlx5_obj_ops ibv_obj_ops;
-
 #endif /* RTE_PMD_MLX5_VERBS_H_ */
drivers/net/mlx5/mlx5.h +6 -0
index 2186677810..a9db597f2b 100644
@@ -917,6 +917,12 @@ struct mlx5_obj_ops {
 
 #define MLX5_RSS_HASH_FIELDS_LEN RTE_DIM(mlx5_rss_hash_fields)
 
+/* MR operations structure. */
+struct mlx5_mr_ops {
+	mlx5_reg_mr_t reg_mr;
+	mlx5_dereg_mr_t dereg_mr;
+};
+
 struct mlx5_priv {
 	struct rte_eth_dev_data *dev_data;  /* Pointer to device data. */
 	struct mlx5_dev_ctx_shared *sh; /* Shared device context. */
Signature · 1 line
2.16.1.windows.4