diff mbox series

[rdma-core,2/3] mlx5: Add loopback flags to QP creation

Message ID 1539099695-11323-3-git-send-email-yishaih@mellanox.com (mailing list archive)
State Not Applicable
Headers show
Series mlx5: Enhance RAW QP support via the DV API | expand

Commit Message

Yishai Hadas Oct. 9, 2018, 3:41 p.m. UTC
From: Mark Bloch <markb@mellanox.com>

Introduce two new QP create dv flags:
MLX5DV_QP_CREATE_TIR_ALLOW_SELF_LOOPBACK_UC
MLX5DV_QP_CREATE_TIR_ALLOW_SELF_LOOPBACK_MC

By default, self-loopback traffic is blocked. Meaning, an
IBV_QPT_RAW_PACKET qp type, will not receive traffic generated
(post_sent) by similar QP's sharing the same ibv_context.

These new flags can be used at creation time of an IBV_QPT_RAW_PACKET QP
type in order to allow QP's on the same ibv_context to receive
self-loopback traffic (unicast and multicast).

Signed-off-by: Mark Bloch <markb@mellanox.com>
Signed-off-by: Yishai Hadas <yishaih@mellanox.com>
---
 providers/mlx5/man/CMakeLists.txt        |  1 +
 providers/mlx5/man/mlx5dv_create_qp.3.md | 98 ++++++++++++++++++++++++++++++++
 providers/mlx5/mlx5dv.h                  |  2 +
 providers/mlx5/verbs.c                   | 27 +++++++--
 4 files changed, 124 insertions(+), 4 deletions(-)
 create mode 100644 providers/mlx5/man/mlx5dv_create_qp.3.md
diff mbox series

Patch

diff --git a/providers/mlx5/man/CMakeLists.txt b/providers/mlx5/man/CMakeLists.txt
index 5765691..e8405a2 100644
--- a/providers/mlx5/man/CMakeLists.txt
+++ b/providers/mlx5/man/CMakeLists.txt
@@ -3,6 +3,7 @@  rdma_man_pages(
   mlx5dv_create_flow_action_modify_header.3.md
   mlx5dv_create_flow_action_packet_reformat.3.md
   mlx5dv_create_flow_matcher.3.md
+  mlx5dv_create_qp.3.md
   mlx5dv_flow_action_esp.3.md
   mlx5dv_get_clock_info.3
   mlx5dv_init_obj.3
diff --git a/providers/mlx5/man/mlx5dv_create_qp.3.md b/providers/mlx5/man/mlx5dv_create_qp.3.md
new file mode 100644
index 0000000..e7de364
--- /dev/null
+++ b/providers/mlx5/man/mlx5dv_create_qp.3.md
@@ -0,0 +1,98 @@ 
+---
+layout: page
+title: mlx5dv_create_qp
+section: 3
+tagline: Verbs
+date: 2018-9-1
+header: "mlx5 Programmer's Manual"
+footer: mlx5
+---
+
+# NAME
+
+mlx5dv_create_qp - creates a queue pair (QP)
+
+# SYNOPSIS
+
+```c
+#include <infiniband/mlx5dv.h>
+
+struct ibv_qp *mlx5dv_create_qp(struct ibv_context         *context,
+                                struct ibv_qp_init_attr_ex *qp_attr,
+                                struct mlx5dv_qp_init_attr *mlx5_qp_attr)
+```
+
+
+# DESCRIPTION
+
+**mlx5dv_create_qp()** creates a queue pair (QP) with specific driver properties.
+
+# ARGUMENTS
+
+Please see *ibv_create_qp_ex(3)* man page for *context* and *qp_attr*.
+
+## mlx5_qp_attr
+
+```c
+struct mlx5dv_qp_init_attr {
+	uint64_t comp_mask;
+	uint32_t create_flags;
+	struct mlx5dv_dc_init_attr  dc_init_attr;
+};
+```
+
+*comp_mask*
+:	Bitmask specifying what fields in the structure are valid:
+	MLX5DV_QP_INIT_ATTR_MASK_QP_CREATE_FLAGS:
+		valid values in *create_flags*
+	MLX5DV_QP_INIT_ATTR_MASK_DC:
+		valid values in *dc_init_attr*
+
+*create_flags*
+:	A bitwise OR of the various values described below.
+
+	MLX5DV_QP_CREATE_TUNNEL_OFFLOADS:
+		Enable offloading such as checksum and LRO for incoming
+		tunneling traffic.
+
+	MLX5DV_QP_CREATE_TIR_ALLOW_SELF_LOOPBACK_UC:
+		Allow receiving loopback unicast traffic.
+
+	MLX5DV_QP_CREATE_TIR_ALLOW_SELF_LOOPBACK_MC:
+		Allow receiving loopback multicast traffic.
+
+*dc_init_attr*
+:	DC init attributes.
+
+## *dc_init_attr*
+
+```c
+struct mlx5dv_dc_init_attr {
+	enum mlx5dv_dc_type	dc_type;
+	uint64_t dct_access_key;
+};
+```
+
+*dc_type*
+:	MLX5DV_DCTYPE_DCT
+		QP type: Target DC.
+	MLX5DV_DCTYPE_DCI
+		QP type: Initiator DC.
+
+*dct_access_key*
+:	used to create a DCT QP.
+
+
+# RETURN VALUE
+
+**mlx5dv_create_qp()**
+returns a pointer to the created QP, on error NULL will be returned and errno will be set.
+
+
+# SEE ALSO
+
+**ibv_query_device_ex**(3), **ibv_create_qp_ex**(3),
+
+# AUTHOR
+
+Yonatan Cohen <yonatanc@mellanox.com>
diff --git a/providers/mlx5/mlx5dv.h b/providers/mlx5/mlx5dv.h
index 69af319..d340fdd 100644
--- a/providers/mlx5/mlx5dv.h
+++ b/providers/mlx5/mlx5dv.h
@@ -158,6 +158,8 @@  struct ibv_cq_ex *mlx5dv_create_cq(struct ibv_context *context,
 
 enum mlx5dv_qp_create_flags {
 	MLX5DV_QP_CREATE_TUNNEL_OFFLOADS = 1 << 0,
+	MLX5DV_QP_CREATE_TIR_ALLOW_SELF_LOOPBACK_UC = 1 << 1,
+	MLX5DV_QP_CREATE_TIR_ALLOW_SELF_LOOPBACK_MC = 1 << 2,
 };
 
 enum mlx5dv_qp_init_attr_mask {
diff --git a/providers/mlx5/verbs.c b/providers/mlx5/verbs.c
index 81e93dd..54d229e 100644
--- a/providers/mlx5/verbs.c
+++ b/providers/mlx5/verbs.c
@@ -1598,6 +1598,13 @@  enum {
 					IBV_QP_INIT_ATTR_RX_HASH),
 };
 
+enum {
+	MLX5DV_QP_CREATE_SUP_FLAGS =
+		(MLX5DV_QP_CREATE_TUNNEL_OFFLOADS |
+		 MLX5DV_QP_CREATE_TIR_ALLOW_SELF_LOOPBACK_UC |
+		 MLX5DV_QP_CREATE_TIR_ALLOW_SELF_LOOPBACK_MC),
+};
+
 static int create_dct(struct ibv_context *context,
 		      struct ibv_qp_init_attr_ex *attr,
 		      struct mlx5dv_qp_init_attr *mlx5_qp_attr,
@@ -1720,15 +1727,27 @@  static struct ibv_qp *create_qp(struct ibv_context *context,
 		}
 		if (mlx5_qp_attr->comp_mask &
 		    MLX5DV_QP_INIT_ATTR_MASK_QP_CREATE_FLAGS) {
-			if (mlx5_qp_attr->create_flags &
-			    MLX5DV_QP_CREATE_TUNNEL_OFFLOADS) {
-				mlx5_create_flags = MLX5_QP_FLAG_TUNNEL_OFFLOADS;
-			} else {
+			if (!check_comp_mask(mlx5_qp_attr->create_flags,
+					     MLX5DV_QP_CREATE_SUP_FLAGS)) {
 				mlx5_dbg(fp, MLX5_DBG_QP,
 					 "Unsupported creation flags requested for create_qp\n");
 				errno = EINVAL;
 				goto err;
 			}
+			if (mlx5_qp_attr->create_flags &
+			    MLX5DV_QP_CREATE_TUNNEL_OFFLOADS) {
+				mlx5_create_flags |= MLX5_QP_FLAG_TUNNEL_OFFLOADS;
+			}
+			if (mlx5_qp_attr->create_flags &
+			    MLX5DV_QP_CREATE_TIR_ALLOW_SELF_LOOPBACK_UC) {
+				mlx5_create_flags |=
+					MLX5_QP_FLAG_TIR_ALLOW_SELF_LB_UC;
+			}
+			if (mlx5_qp_attr->create_flags &
+			    MLX5DV_QP_CREATE_TIR_ALLOW_SELF_LOOPBACK_MC) {
+				mlx5_create_flags |=
+					MLX5_QP_FLAG_TIR_ALLOW_SELF_LB_MC;
+			}
 		}
 
 		if (attr->qp_type == IBV_QPT_DRIVER) {