Skip to contentSkip to conversation

ConnectX-3 RSS Implementation

PATCH In review Leon Romanovsky 1 participant 6 messages Jun 22, 2017 – Jul 4, 2017 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover ConnectX-3 RSS Implementation

Hi Doug,

This patch set adds to ConnectX-3 devices the ability to use RSS feature, which was initially implemented in mlx5-based devices [1].

The backport of RSS feature to ConnectX-3 hardware was a challenge task due to differences in architectures between mlx4 and mlx5 based devices.

It caused to a limited number of usage limitations, mentioned in the relevant commit messages where it applies.

This series supports all RSS related verbs.

Thanks.

[1] https://www.spinics.net/lists/linux-rdma/msg36526.html

---
We based this series on our previous mlx4 submissions to reduce merge conflicts. For your convenience, I prepared the branch with the following merge sequence:
"topic/no-io" -> "topic/mlx4-resource-utilization" -> "topic/mlx4-receive-inline"

Available in the "topic/mlx4-rss" topic branch of this git repo:
git://git.kernel.org/pub/scm/linux/kernel/git/leon/linux-rdma.git

Or for browsing:
https://git.kernel.org/cgit/linux/kernel/git/leon/linux-rdma.git/log/?h=topic/mlx4-rss

Thanks

Guy Levi (4):
IB/mlx4: Add support for WQ related verbs IB/mlx4: Add support for WQ indirection table related verbs IB/mlx4: Add support for RSS QP
IB/mlx4: Expose RSS capabilities

 drivers/infiniband/hw/mlx4/main.c    |  51 ++
 drivers/infiniband/hw/mlx4/mlx4_ib.h |  32 +-
 drivers/infiniband/hw/mlx4/qp.c      | 907 ++++++++++++++++++++++++++++++++---
 include/uapi/rdma/mlx4-abi.h         |  49 ++
 4 files changed, 975 insertions(+), 64 deletions(-)

--
2.13.1

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 20170622134412.7680-1-leon-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org

#2 lore raw

PATCH 1/4 IB/mlx4: Add support for WQ related verbs

From: Guy Levi <guyle-VPRAkNaXOzVWk0Htik3J/[email protected]>

Support create/modify/destroy WQ related verbs.

The base IB object to enable RSS functionality is a WQ (i.e. ib_wq). This patch implements the related WQ verbs as of create, modify and destroy.

In downstream patches the WQ will be used as part of an indirection table (i.e. ib_rwq_ind_table) to enable RSS QP creation.

Notes:
ConnectX-3 hardware requires consecutive WQNs list as receive descriptor queues for the RSS QP. Hence, the driver reserves 128 consecutive WQNs per user context which will be allocated for the created WQs. Destroying the WQ will not return the WQN back to the reserve list.

Since the WQ object is not a natural object in the hardware, the driver implements the WQ by the hardware QP.

As such, the WQ inherits its port from his RSS QP parent upon its RST->INIT transition and by that time its state is applied to the hardware.

---
 drivers/infiniband/hw/mlx4/main.c    |  40 ++++
 drivers/infiniband/hw/mlx4/mlx4_ib.h |  18 +-
 drivers/infiniband/hw/mlx4/qp.c      | 417 ++++++++++++++++++++++++++++++-----
 include/uapi/rdma/mlx4-abi.h         |  12 +
 4 files changed, 429 insertions(+), 58 deletions(-)
drivers/infiniband/hw/mlx4/main.c +40 -0
index bfdd4e117813..e084eb88d44b 100644
@@ -81,6 +81,8 @@ static const char mlx4_ib_version[] =
 	DRV_VERSION "\n";
 
 static void do_slave_init(struct mlx4_ib_dev *ibdev, int slave, int do_init);
+static enum rdma_link_layer mlx4_ib_port_link_layer(struct ib_device *device,
+						    u8 port_num);
 
 static struct workqueue_struct *wq;
 
@@ -552,6 +554,11 @@ static int mlx4_ib_query_device(struct ib_device *ibdev,
 	props->timestamp_mask = 0xFFFFFFFFFFFFULL;
 	props->max_ah = INT_MAX;
 
+	if ((dev->dev->caps.flags2 & MLX4_DEV_CAP_FLAG2_RSS) &&
+	    (mlx4_ib_port_link_layer(ibdev, 1) == IB_LINK_LAYER_ETHERNET ||
+	     mlx4_ib_port_link_layer(ibdev, 2) == IB_LINK_LAYER_ETHERNET))
+		props->max_wq_type_rq = MLX4_IB_MAX_CTX_WQS;
+
 	if (!mlx4_is_slave(dev->dev))
 		err = mlx4_get_internal_clock_params(dev->dev, &clock_params);
 
@@ -1087,6 +1094,21 @@ static struct ib_ucontext *mlx4_ib_alloc_ucontext(struct ib_device *ibdev,
 		return ERR_PTR(-EFAULT);
 	}
 
+	context->wq_use_cnt = MLX4_IB_MAX_CTX_WQS; /* WQs pool is empty */
+	context->base_wqn = 0xFFFFFFFF; /* invalid wqn */
+
+	if ((rdma_port_get_link_layer(ibdev, 1) == IB_LINK_LAYER_ETHERNET) ||
+	    (rdma_port_get_link_layer(ibdev, 2) == IB_LINK_LAYER_ETHERNET)) {
+		if (!mlx4_qp_reserve_range(dev->dev, MLX4_IB_MAX_CTX_WQS,
+					   MLX4_IB_MAX_CTX_WQS,
+					   &context->base_wqn, 0,
+					   MLX4_RES_USAGE_USER_VERBS)) {
+			context->wq_use_cnt = 0;
+		} else {
+			pr_warn("Failed to reserve WQNs for user context\n");
+		}
+	}
+
 	return &context->ibucontext;
 }
 
@@ -1094,6 +1116,10 @@ static int mlx4_ib_dealloc_ucontext(struct ib_ucontext *ibcontext)
 {
 	struct mlx4_ib_ucontext *context = to_mucontext(ibcontext);
 
+	if (context->base_wqn != 0xFFFFFFFF)
+		mlx4_qp_release_range(to_mdev(ibcontext->device)->dev,
+				      context->base_wqn, MLX4_IB_MAX_CTX_WQS);
+
 	mlx4_uar_free(to_mdev(ibcontext->device)->dev, &context->uar);
 	kfree(context);
 
@@ -2720,6 +2746,20 @@ static void *mlx4_ib_add(struct mlx4_dev *dev)
 	ibdev->ib_dev.get_dev_fw_str    = get_fw_ver_str;
 	ibdev->ib_dev.disassociate_ucontext = mlx4_ib_disassociate_ucontext;
 
+	if ((dev->caps.flags2 & MLX4_DEV_CAP_FLAG2_RSS) &&
+	    ((mlx4_ib_port_link_layer(&ibdev->ib_dev, 1) ==
+	    IB_LINK_LAYER_ETHERNET) ||
+	    (mlx4_ib_port_link_layer(&ibdev->ib_dev, 2) ==
+	    IB_LINK_LAYER_ETHERNET))) {
+		ibdev->ib_dev.create_wq		= mlx4_ib_create_wq;
+		ibdev->ib_dev.modify_wq		= mlx4_ib_modify_wq;
+		ibdev->ib_dev.destroy_wq	= mlx4_ib_destroy_wq;
+		ibdev->ib_dev.uverbs_ex_cmd_mask |=
+			(1ull << IB_USER_VERBS_EX_CMD_CREATE_WQ) |
+			(1ull << IB_USER_VERBS_EX_CMD_MODIFY_WQ) |
+			(1ull << IB_USER_VERBS_EX_CMD_DESTROY_WQ);
+	}
+
 	if (!mlx4_is_slave(ibdev->dev)) {
 		ibdev->ib_dev.alloc_fmr		= mlx4_ib_fmr_alloc;
 		ibdev->ib_dev.map_phys_fmr	= mlx4_ib_map_phys_fmr;
drivers/infiniband/hw/mlx4/mlx4_ib.h +17 -1
index a6337f3161cf..6d8ef6506f09 100644
@@ -82,12 +82,16 @@ struct mlx4_ib_vma_private_data {
 	struct vm_area_struct *vma;
 };
 
+#define MLX4_IB_MAX_CTX_WQS 128
+
 struct mlx4_ib_ucontext {
 	struct ib_ucontext	ibucontext;
 	struct mlx4_uar		uar;
 	struct list_head	db_page_list;
 	struct mutex		db_page_mutex;
 	struct mlx4_ib_vma_private_data hw_bar_info[HW_BAR_COUNT];
+	int			base_wqn;
+	int			wq_use_cnt;
 };
 
 struct mlx4_ib_pd {
@@ -290,7 +294,10 @@ struct mlx4_roce_smac_vlan_info {
 };
 
 struct mlx4_ib_qp {
-	struct ib_qp		ibqp;
+	union {
+		struct ib_qp	ibqp;
+		struct ib_wq	ibwq;
+	};
 	struct mlx4_qp		mqp;
 	struct mlx4_buf		buf;
 
@@ -329,6 +336,8 @@ struct mlx4_ib_qp {
 	struct list_head	cq_recv_list;
 	struct list_head	cq_send_list;
 	struct counter_index	*counter_index;
+	/* Number of RSS QP parents that uses this WQ */
+	u32			rss_usecnt;
 };
 
 struct mlx4_ib_srq {
@@ -893,4 +902,11 @@ void mlx4_sched_ib_sl2vl_update_work(struct mlx4_ib_dev *ibdev,
 
 void mlx4_ib_sl2vl_update(struct mlx4_ib_dev *mdev, int port);
 
+struct ib_wq *mlx4_ib_create_wq(struct ib_pd *pd,
+				struct ib_wq_init_attr *init_attr,
+				struct ib_udata *udata);
+int mlx4_ib_destroy_wq(struct ib_wq *wq);
+int mlx4_ib_modify_wq(struct ib_wq *wq, struct ib_wq_attr *wq_attr,
+		      u32 wq_attr_mask, struct ib_udata *udata);
+
 #endif /* MLX4_IB_H */
drivers/infiniband/hw/mlx4/qp.c +360 -57

657 lines not on this page · raw message

include/uapi/rdma/mlx4-abi.h +12 -0
index bf3bdba2f326..12b23b80dae5 100644
@@ -105,4 +105,16 @@ struct mlx4_ib_create_qp {
 	__u8	reserved;
 };
 
+struct mlx4_ib_create_wq {
+	__u64	buf_addr;
+	__u64	db_addr;
+	__u32   comp_mask;
+	__u32   reserved;
+};
+
+struct mlx4_ib_modify_wq {
+	__u32	comp_mask;
+	__u32	reserved;
+};
+
 #endif /* MLX4_ABI_USER_H */

--
2.13.1

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#3 lore raw

PATCH 2/4 IB/mlx4: Add support for WQ indirection table related verbs

In reply to a message not in the archive

From: Guy Levi <guyle-VPRAkNaXOzVWk0Htik3J/[email protected]>

To enable RSS functionality the IB indirection table object (i.e. ib_rwq_ind_table) should be used.
This patch implements the related verbs as of create and destroy an indirection table.
In downstream patches the indirection table will be used as part of RSS QP creation.

---
 drivers/infiniband/hw/mlx4/main.c    | 12 +++++--
 drivers/infiniband/hw/mlx4/mlx4_ib.h |  6 ++++
 drivers/infiniband/hw/mlx4/qp.c      | 69 ++++++++++++++++++++++++++++++++++++
 include/uapi/rdma/mlx4-abi.h         |  4 +++
 4 files changed, 88 insertions(+), 3 deletions(-)
drivers/infiniband/hw/mlx4/main.c +9 -3
index e084eb88d44b..97b82b0c680c 100644
@@ -2754,10 +2754,16 @@ static void *mlx4_ib_add(struct mlx4_dev *dev)
 		ibdev->ib_dev.create_wq		= mlx4_ib_create_wq;
 		ibdev->ib_dev.modify_wq		= mlx4_ib_modify_wq;
 		ibdev->ib_dev.destroy_wq	= mlx4_ib_destroy_wq;
+		ibdev->ib_dev.create_rwq_ind_table  =
+			mlx4_ib_create_rwq_ind_table;
+		ibdev->ib_dev.destroy_rwq_ind_table =
+			mlx4_ib_destroy_rwq_ind_table;
 		ibdev->ib_dev.uverbs_ex_cmd_mask |=
-			(1ull << IB_USER_VERBS_EX_CMD_CREATE_WQ) |
-			(1ull << IB_USER_VERBS_EX_CMD_MODIFY_WQ) |
-			(1ull << IB_USER_VERBS_EX_CMD_DESTROY_WQ);
+			(1ull << IB_USER_VERBS_EX_CMD_CREATE_WQ)	  |
+			(1ull << IB_USER_VERBS_EX_CMD_MODIFY_WQ)	  |
+			(1ull << IB_USER_VERBS_EX_CMD_DESTROY_WQ)	  |
+			(1ull << IB_USER_VERBS_EX_CMD_CREATE_RWQ_IND_TBL) |
+			(1ull << IB_USER_VERBS_EX_CMD_DESTROY_RWQ_IND_TBL);
 	}
 
 	if (!mlx4_is_slave(ibdev->dev)) {
drivers/infiniband/hw/mlx4/mlx4_ib.h +6 -0
index 6d8ef6506f09..352b8bc975d6 100644
@@ -909,4 +909,10 @@ int mlx4_ib_destroy_wq(struct ib_wq *wq);
 int mlx4_ib_modify_wq(struct ib_wq *wq, struct ib_wq_attr *wq_attr,
 		      u32 wq_attr_mask, struct ib_udata *udata);
 
+struct ib_rwq_ind_table
+*mlx4_ib_create_rwq_ind_table(struct ib_device *device,
+			      struct ib_rwq_ind_table_init_attr *init_attr,
+			      struct ib_udata *udata);
+int mlx4_ib_destroy_rwq_ind_table(struct ib_rwq_ind_table *wq_ind_table);
+
 #endif /* MLX4_IB_H */
drivers/infiniband/hw/mlx4/qp.c +69 -0

72 lines not on this page · raw message

include/uapi/rdma/mlx4-abi.h +4 -0
index 12b23b80dae5..2371d41156b1 100644
@@ -117,4 +117,8 @@ struct mlx4_ib_modify_wq {
 	__u32	reserved;
 };
 
+struct mlx4_ib_create_rwq_ind_tbl_resp {
+	__u32	response_length;
+	__u32	reserved;
+};
 #endif /* MLX4_ABI_USER_H */

--
2.13.1

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#4 lore raw

PATCH 3/4 IB/mlx4: Add support for RSS QP

In reply to a message not in the archive

From: Guy Levi <guyle-VPRAkNaXOzVWk0Htik3J/[email protected]>

Add support to work with a RSS QP by using an indirection table object upon QP creation.
Other related QP verbs (e.g. modify/destroy/query) were updated as well for that QP mode.

Notes:
- The RX hash properties are supplied as driver private data.
- The RSS QP port is used on the associated WQs in its indirection table. Applying different ports during WQ life time is not allowed.
- The expected RSS QP flow is: create, modify(RST->INIT), modify(RST->RTR), destroy.

---
 drivers/infiniband/hw/mlx4/mlx4_ib.h |   8 +
 drivers/infiniband/hw/mlx4/qp.c      | 453 +++++++++++++++++++++++++++++++++--
 include/uapi/rdma/mlx4-abi.h         |  33 +++
 3 files changed, 472 insertions(+), 22 deletions(-)
drivers/infiniband/hw/mlx4/mlx4_ib.h +8 -0
index 352b8bc975d6..6a71e159d1b2 100644
@@ -46,6 +46,7 @@
 
 #include <linux/mlx4/device.h>
 #include <linux/mlx4/doorbell.h>
+#include <linux/mlx4/qp.h>
 
 #define MLX4_IB_DRV_NAME	"mlx4_ib"
 
@@ -293,6 +294,12 @@ struct mlx4_roce_smac_vlan_info {
 	int update_vid;
 };
 
+struct mlx4_ib_rss {
+	unsigned int		base_qpn_tbl_sz;
+	u8			flags;
+	u8			rss_key[MLX4_EN_RSS_KEY_SIZE];
+};
+
 struct mlx4_ib_qp {
 	union {
 		struct ib_qp	ibqp;
@@ -338,6 +345,7 @@ struct mlx4_ib_qp {
 	struct counter_index	*counter_index;
 	/* Number of RSS QP parents that uses this WQ */
 	u32			rss_usecnt;
+	struct mlx4_ib_rss	*rss_ctx;
 };
 
 struct mlx4_ib_srq {
drivers/infiniband/hw/mlx4/qp.c +431 -22

567 lines not on this page · raw message

include/uapi/rdma/mlx4-abi.h +33 -0
index 2371d41156b1..61c868c35578 100644
@@ -95,6 +95,16 @@ struct mlx4_ib_create_srq_resp {
 	__u32	reserved;
 };
 
+struct mlx4_ib_create_qp_rss {
+	__u64   rx_hash_fields_mask;
+	__u8    rx_hash_function;
+	__u8    rx_key_len;
+	__u8    reserved[6];
+	__u8    rx_hash_key[40];
+	__u32   comp_mask;
+	__u32   reserved1;
+};
+
 struct mlx4_ib_create_qp {
 	__u64	buf_addr;
 	__u64	db_addr;
@@ -121,4 +131,27 @@ struct mlx4_ib_create_rwq_ind_tbl_resp {
 	__u32	response_length;
 	__u32	reserved;
 };
+
+/* RX Hash function flags */
+enum mlx4_ib_rx_hash_function_flags {
+	MLX4_IB_RX_HASH_FUNC_TOEPLITZ	= 1 << 0,
+};
+
+/*
+ * RX Hash flags, these flags allows to set which incoming packet's field should
+ * participates in RX Hash. Each flag represent certain packet's field,
+ * when the flag is set the field that is represented by the flag will
+ * participate in RX Hash calculation.
+ */
+enum mlx4_ib_rx_hash_fields {
+	MLX4_IB_RX_HASH_SRC_IPV4	= 1 << 0,
+	MLX4_IB_RX_HASH_DST_IPV4	= 1 << 1,
+	MLX4_IB_RX_HASH_SRC_IPV6	= 1 << 2,
+	MLX4_IB_RX_HASH_DST_IPV6	= 1 << 3,
+	MLX4_IB_RX_HASH_SRC_PORT_TCP	= 1 << 4,
+	MLX4_IB_RX_HASH_DST_PORT_TCP	= 1 << 5,
+	MLX4_IB_RX_HASH_SRC_PORT_UDP	= 1 << 6,
+	MLX4_IB_RX_HASH_DST_PORT_UDP	= 1 << 7
+};
+
 #endif /* MLX4_ABI_USER_H */

--
2.13.1

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#5 lore raw

PATCH 4/4 IB/mlx4: Expose RSS capabilities

In reply to a message not in the archive

From: Guy Levi <guyle-VPRAkNaXOzVWk0Htik3J/[email protected]>

As a final step to support RSS feature, expose the RSS capabilities in query device verb.

It includes:
- Max rwq indirection tables.
- Max rwq indirection table size.
- Supported qp types.

---
 drivers/infiniband/hw/mlx4/main.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/infiniband/hw/mlx4/main.c +6 -1
index 97b82b0c680c..6c11aed181a5 100644
@@ -556,8 +556,13 @@ static int mlx4_ib_query_device(struct ib_device *ibdev,
 
 	if ((dev->dev->caps.flags2 & MLX4_DEV_CAP_FLAG2_RSS) &&
 	    (mlx4_ib_port_link_layer(ibdev, 1) == IB_LINK_LAYER_ETHERNET ||
-	     mlx4_ib_port_link_layer(ibdev, 2) == IB_LINK_LAYER_ETHERNET))
+	     mlx4_ib_port_link_layer(ibdev, 2) == IB_LINK_LAYER_ETHERNET)) {
+		props->rss_caps.max_rwq_indirection_tables = 128;
+		props->rss_caps.max_rwq_indirection_table_size =
+			dev->dev->caps.max_rss_tbl_sz;
+		props->rss_caps.supported_qpts = 1 << IB_QPT_RAW_PACKET;
 		props->max_wq_type_rq = MLX4_IB_MAX_CTX_WQS;
+	}
 
 	if (!mlx4_is_slave(dev->dev))
 		err = mlx4_get_internal_clock_params(dev->dev, &clock_params);

--
2.13.1

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#6 lore raw
In reply to a message not in the archive
Quoted 37 lines · Leon Romanovsky

Hi Doug,

This patch set adds to ConnectX-3 devices the ability to use RSS feature, which was initially implemented in mlx5-based devices [1].

The backport of RSS feature to ConnectX-3 hardware was a challenge task due to differences in architectures between mlx4 and mlx5 based devices.

It caused to a limited number of usage limitations, mentioned in the relevant commit messages where it applies.

This series supports all RSS related verbs.

Thanks.

[1] https://www.spinics.net/lists/linux-rdma/msg36526.html

---
We based this series on our previous mlx4 submissions to reduce merge conflicts. For your convenience, I prepared the branch with the following merge sequence:
"topic/no-io" -> "topic/mlx4-resource-utilization" -> "topic/mlx4-receive-inline"

Available in the "topic/mlx4-rss" topic branch of this git repo:
git://git.kernel.org/pub/scm/linux/kernel/git/leon/linux-rdma.git

Or for browsing:
https://git.kernel.org/cgit/linux/kernel/git/leon/linux-rdma.git/log/?h=topic/mlx4-rss

Thanks

Guy Levi (4):
IB/mlx4: Add support for WQ related verbs IB/mlx4: Add support for WQ indirection table related verbs IB/mlx4: Add support for RSS QP
IB/mlx4: Expose RSS capabilities

Quoted 7 lines
 drivers/infiniband/hw/mlx4/main.c    |  51 ++
 drivers/infiniband/hw/mlx4/mlx4_ib.h |  32 +-
 drivers/infiniband/hw/mlx4/qp.c      | 907 ++++++++++++++++++++++++++++++++---
 include/uapi/rdma/mlx4-abi.h         |  49 ++
 4 files changed, 975 insertions(+), 64 deletions(-)

--

Please drop this series in favor of v1.

Thanks