linux-rdma.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH rdma-core 0/6] Add RSS support in mlx4
@ 2017-09-12 12:53 Yishai Hadas
       [not found] ` <1505220788-23849-1-git-send-email-yishaih-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
  0 siblings, 1 reply; 8+ messages in thread
From: Yishai Hadas @ 2017-09-12 12:53 UTC (permalink / raw)
  To: linux-rdma-u79uwXL29TY76Z2rM5mHXA
  Cc: yishaih-VPRAkNaXOzVWk0Htik3J/w, guyle-VPRAkNaXOzVWk0Htik3J/w,
	majd-VPRAkNaXOzVWk0Htik3J/w

This patch set from Guy Levi implements the RSS related verbs for ConnectX-3
devices in the mlx4 provider.

The matching kernel part was already merged into 4.14.

PR was sent:
https://github.com/linux-rdma/rdma-core/pull/218

Guy Levi (6):
  mlx4: Add support for WQ control path related verbs
  mlx4: Introduce the direct verb mlx4dv_set_ctx_attr
  mlx4: Add support for WQ indirection table related verbs
  mlx4: Add support for RSS QP
  mlx4: Add WQ data path support
  mlx4: Support WQ object type in direct verb mlx4dv_init_obj

 debian/ibverbs-providers.symbols     |   1 +
 providers/mlx4/cq.c                  |   5 +-
 providers/mlx4/libmlx4.map           |   1 +
 providers/mlx4/man/mlx4dv_init_obj.3 |  20 +++
 providers/mlx4/mlx4-abi.h            |  33 ++++
 providers/mlx4/mlx4.c                |  42 +++++
 providers/mlx4/mlx4.h                |  30 +++-
 providers/mlx4/mlx4dv.h              |  32 +++-
 providers/mlx4/qp.c                  |  34 +++-
 providers/mlx4/verbs.c               | 339 ++++++++++++++++++++++++++++++++++-
 10 files changed, 525 insertions(+), 12 deletions(-)

-- 
1.8.3.1

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* [PATCH rdma-core 1/6] mlx4: Add support for WQ control path related verbs
       [not found] ` <1505220788-23849-1-git-send-email-yishaih-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
@ 2017-09-12 12:53   ` Yishai Hadas
  2017-09-12 12:53   ` [PATCH rdma-core 2/6] mlx4: Introduce the direct verb mlx4dv_set_ctx_attr Yishai Hadas
                     ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Yishai Hadas @ 2017-09-12 12:53 UTC (permalink / raw)
  To: linux-rdma-u79uwXL29TY76Z2rM5mHXA
  Cc: yishaih-VPRAkNaXOzVWk0Htik3J/w, guyle-VPRAkNaXOzVWk0Htik3J/w,
	majd-VPRAkNaXOzVWk0Htik3J/w

From: Guy Levi <guyle-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>

The base IB object to enable RSS functionality is a WQ (i.e. ibv_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 to enable RSS QP creation.

Since ConnectX-3 hardware requires consecutive WQNs list as receive
descriptor queues for the RSS QP, a range size for a consecutive
WQNs set is delivered in the driver data of the create WQ related
verb. This range size value will be set by a direct verb which will
be introduced in the downstream patches.

Signed-off-by: Guy Levi <guyle-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
Reviewed-by: Yishai Hadas <yishaih-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
---
 providers/mlx4/mlx4-abi.h |  19 ++++++
 providers/mlx4/mlx4.c     |   3 +
 providers/mlx4/mlx4.h     |  17 ++++-
 providers/mlx4/qp.c       |   4 +-
 providers/mlx4/verbs.c    | 171 +++++++++++++++++++++++++++++++++++++++++++++-
 5 files changed, 209 insertions(+), 5 deletions(-)

diff --git a/providers/mlx4/mlx4-abi.h b/providers/mlx4/mlx4-abi.h
index ded1a4c..1cf6d5b 100644
--- a/providers/mlx4/mlx4-abi.h
+++ b/providers/mlx4/mlx4-abi.h
@@ -159,4 +159,23 @@ struct mlx4_create_qp_resp_ex {
 	struct ibv_create_qp_resp_ex	ibv_resp;
 };
 
+struct mlx4_drv_create_wq {
+	__u64		buf_addr;
+	__u64		db_addr;
+	__u8		log_range_size;
+	__u8		reserved[3];
+	__u32		comp_mask;
+};
+
+struct mlx4_create_wq {
+	struct ibv_create_wq		ibv_cmd;
+	struct mlx4_drv_create_wq	drv;
+};
+
+struct mlx4_modify_wq {
+	struct ibv_modify_wq	ibv_cmd;
+	__u32			comp_mask;
+	__u32			reserved;
+};
+
 #endif /* MLX4_ABI_H */
diff --git a/providers/mlx4/mlx4.c b/providers/mlx4/mlx4.c
index bd4cd5e..600daea 100644
--- a/providers/mlx4/mlx4.c
+++ b/providers/mlx4/mlx4.c
@@ -256,6 +256,9 @@ static int mlx4_init_context(struct verbs_device *v_device,
 	verbs_set_ctx_op(verbs_ctx, create_cq_ex, mlx4_create_cq_ex);
 	verbs_set_ctx_op(verbs_ctx, query_device_ex, mlx4_query_device_ex);
 	verbs_set_ctx_op(verbs_ctx, query_rt_values, mlx4_query_rt_values);
+	verbs_set_ctx_op(verbs_ctx, create_wq, mlx4_create_wq);
+	verbs_set_ctx_op(verbs_ctx, modify_wq, mlx4_modify_wq);
+	verbs_set_ctx_op(verbs_ctx, destroy_wq, mlx4_destroy_wq);
 
 	return 0;
 
diff --git a/providers/mlx4/mlx4.h b/providers/mlx4/mlx4.h
index 7d463f3..204542b 100644
--- a/providers/mlx4/mlx4.h
+++ b/providers/mlx4/mlx4.h
@@ -134,6 +134,7 @@ struct mlx4_context {
 	} core_clock;
 	void			       *hca_core_clock;
 	uint32_t			max_inl_recv_sz;
+	uint8_t				log_wqs_range_sz;
 };
 
 struct mlx4_buf {
@@ -198,7 +199,10 @@ struct mlx4_wq {
 };
 
 struct mlx4_qp {
-	struct verbs_qp			verbs_qp;
+	union {
+		struct verbs_qp		verbs_qp;
+		struct ibv_wq		wq;
+	};
 	struct mlx4_buf			buf;
 	int				max_inline_data;
 	int				buf_size;
@@ -274,6 +278,11 @@ static inline struct mlx4_qp *to_mqp(struct ibv_qp *ibqp)
 			    struct mlx4_qp, verbs_qp);
 }
 
+static inline struct mlx4_qp *wq_to_mqp(struct ibv_wq *ibwq)
+{
+	return container_of(ibwq, struct mlx4_qp, wq);
+}
+
 static inline struct mlx4_ah *to_mah(struct ibv_ah *ibah)
 {
 	return to_mxxx(ah, ah);
@@ -385,7 +394,7 @@ int mlx4_post_recv(struct ibv_qp *ibqp, struct ibv_recv_wr *wr,
 			  struct ibv_recv_wr **bad_wr);
 void mlx4_calc_sq_wqe_size(struct ibv_qp_cap *cap, enum ibv_qp_type type,
 			   struct mlx4_qp *qp);
-int mlx4_alloc_qp_buf(struct ibv_context *context, struct ibv_qp_cap *cap,
+int mlx4_alloc_qp_buf(struct ibv_context *context, uint32_t max_recv_sge,
 		       enum ibv_qp_type type, struct mlx4_qp *qp,
 		       struct mlx4dv_qp_init_attr *mlx4qp_attr);
 void mlx4_set_sq_sizes(struct mlx4_qp *qp, struct ibv_qp_cap *cap,
@@ -398,5 +407,9 @@ int mlx4_destroy_ah(struct ibv_ah *ah);
 int mlx4_alloc_av(struct mlx4_pd *pd, struct ibv_ah_attr *attr,
 		   struct mlx4_ah *ah);
 void mlx4_free_av(struct mlx4_ah *ah);
+struct ibv_wq *mlx4_create_wq(struct ibv_context *context,
+			      struct ibv_wq_init_attr *attr);
+int mlx4_modify_wq(struct ibv_wq *wq, struct ibv_wq_attr *attr);
+int mlx4_destroy_wq(struct ibv_wq *wq);
 
 #endif /* MLX4_H */
diff --git a/providers/mlx4/qp.c b/providers/mlx4/qp.c
index 63f66d7..8f33f0e 100644
--- a/providers/mlx4/qp.c
+++ b/providers/mlx4/qp.c
@@ -650,13 +650,13 @@ void mlx4_calc_sq_wqe_size(struct ibv_qp_cap *cap, enum ibv_qp_type type,
 		; /* nothing */
 }
 
-int mlx4_alloc_qp_buf(struct ibv_context *context, struct ibv_qp_cap *cap,
+int mlx4_alloc_qp_buf(struct ibv_context *context, uint32_t max_recv_sge,
 		      enum ibv_qp_type type, struct mlx4_qp *qp,
 		      struct mlx4dv_qp_init_attr *mlx4qp_attr)
 {
 	int wqe_size;
 
-	qp->rq.max_gs	 = cap->max_recv_sge;
+	qp->rq.max_gs	 = max_recv_sge;
 	wqe_size = qp->rq.max_gs * sizeof(struct mlx4_wqe_data_seg);
 	if (mlx4qp_attr &&
 	    mlx4qp_attr->comp_mask & MLX4DV_QP_INIT_ATTR_MASK_INL_RECV &&
diff --git a/providers/mlx4/verbs.c b/providers/mlx4/verbs.c
index abb447d..5ded2c5 100644
--- a/providers/mlx4/verbs.c
+++ b/providers/mlx4/verbs.c
@@ -839,7 +839,7 @@ static struct ibv_qp *create_qp_ex(struct ibv_context *context,
 			attr->cap.max_recv_wr = 1;
 	}
 
-	if (mlx4_alloc_qp_buf(context, &attr->cap, attr->qp_type, qp,
+	if (mlx4_alloc_qp_buf(context, attr->cap.max_recv_sge, attr->qp_type, qp,
 			      mlx4qp_attr))
 		goto err;
 
@@ -1272,3 +1272,172 @@ int mlx4_destroy_ah(struct ibv_ah *ah)
 
 	return 0;
 }
+
+struct ibv_wq *mlx4_create_wq(struct ibv_context *context,
+			      struct ibv_wq_init_attr *attr)
+{
+	struct mlx4_context		*ctx = to_mctx(context);
+	struct mlx4_create_wq		cmd = {};
+	struct ibv_create_wq_resp	resp = {};
+	struct mlx4_qp			*qp;
+	int				ret;
+
+	if (attr->wq_type != IBV_WQT_RQ) {
+		errno = ENOTSUP;
+		return NULL;
+	}
+
+	/* Sanity check QP size before proceeding */
+	if (ctx->max_qp_wr) { /* mlx4_query_device succeeded */
+		if (attr->max_wr  > ctx->max_qp_wr ||
+		    attr->max_sge > ctx->max_sge) {
+			errno = EINVAL;
+			return NULL;
+		}
+	} else {
+		if (attr->max_wr  > 65536 ||
+		    attr->max_sge > 64) {
+			errno = EINVAL;
+			return NULL;
+		}
+	}
+
+	if (attr->comp_mask) {
+		errno = ENOTSUP;
+		return NULL;
+	}
+
+	qp = calloc(1, sizeof(*qp));
+	if (!qp)
+		return NULL;
+
+	if (attr->max_sge < 1)
+		attr->max_sge = 1;
+
+	if (attr->max_wr < 1)
+		attr->max_wr = 1;
+
+	/* Kernel driver requires a dummy SQ with minimum properties */
+	qp->sq.wqe_shift = 6;
+	qp->sq.wqe_cnt = 1;
+
+	qp->rq.wqe_cnt = align_queue_size(attr->max_wr);
+
+	if (mlx4_alloc_qp_buf(context, attr->max_sge, IBV_QPT_RAW_PACKET, qp, NULL))
+		goto err;
+
+	mlx4_init_qp_indices(qp);
+	mlx4_qp_init_sq_ownership(qp); /* For dummy SQ */
+
+	if (pthread_spin_init(&qp->rq.lock, PTHREAD_PROCESS_PRIVATE))
+		goto err_free;
+
+	qp->db = mlx4_alloc_db(to_mctx(context), MLX4_DB_TYPE_RQ);
+	if (!qp->db)
+		goto err_free;
+
+	*qp->db = 0;
+	cmd.drv.db_addr = (uintptr_t)qp->db;
+
+	cmd.drv.buf_addr = (uintptr_t)qp->buf.buf;
+
+	cmd.drv.log_range_size = ctx->log_wqs_range_sz;
+
+	pthread_mutex_lock(&to_mctx(context)->qp_table_mutex);
+
+	ret = ibv_cmd_create_wq(context, attr, &qp->wq, &cmd.ibv_cmd,
+				sizeof(cmd.ibv_cmd),
+				sizeof(cmd),
+				&resp, sizeof(resp),
+				sizeof(resp));
+	if (ret)
+		goto err_rq_db;
+
+	ret = mlx4_store_qp(to_mctx(context), qp->wq.wq_num, qp);
+	if (ret)
+		goto err_destroy;
+
+	pthread_mutex_unlock(&to_mctx(context)->qp_table_mutex);
+
+	ctx->log_wqs_range_sz = 0;
+
+	qp->rq.max_post = attr->max_wr;
+	qp->rq.wqe_cnt = attr->max_wr;
+	qp->rq.max_gs  = attr->max_sge;
+
+	qp->wq.state = IBV_WQS_RESET;
+
+	return &qp->wq;
+
+err_destroy:
+	ibv_cmd_destroy_wq(&qp->wq);
+
+err_rq_db:
+	pthread_mutex_unlock(&to_mctx(context)->qp_table_mutex);
+	mlx4_free_db(to_mctx(context), MLX4_DB_TYPE_RQ, qp->db);
+
+err_free:
+	free(qp->rq.wrid);
+	mlx4_free_buf(&qp->buf);
+
+err:
+	free(qp);
+
+	return NULL;
+}
+
+int mlx4_modify_wq(struct ibv_wq *ibwq, struct ibv_wq_attr *attr)
+{
+	struct mlx4_qp *qp = wq_to_mqp(ibwq);
+	struct mlx4_modify_wq cmd = {};
+	int ret;
+
+	ret = ibv_cmd_modify_wq(ibwq, attr, &cmd.ibv_cmd,  sizeof(cmd.ibv_cmd),
+				sizeof(cmd));
+
+	if (!ret && (attr->attr_mask & IBV_WQ_ATTR_STATE) &&
+	    (ibwq->state == IBV_WQS_RESET)) {
+		mlx4_cq_clean(to_mcq(ibwq->cq), ibwq->wq_num, NULL);
+
+		mlx4_init_qp_indices(qp);
+		*qp->db = 0;
+	}
+
+	return ret;
+}
+
+int mlx4_destroy_wq(struct ibv_wq *ibwq)
+{
+	struct mlx4_context *mcontext = to_mctx(ibwq->context);
+	struct mlx4_qp *qp = wq_to_mqp(ibwq);
+	struct mlx4_cq *cq = NULL;
+	int ret;
+
+	pthread_mutex_lock(&mcontext->qp_table_mutex);
+
+	ret = ibv_cmd_destroy_wq(ibwq);
+	if (ret && !cleanup_on_fatal(ret)) {
+		pthread_mutex_unlock(&mcontext->qp_table_mutex);
+		return ret;
+	}
+
+	cq = to_mcq(ibwq->cq);
+	pthread_spin_lock(&cq->lock);
+	__mlx4_cq_clean(cq, ibwq->wq_num, NULL);
+
+	mlx4_clear_qp(mcontext, ibwq->wq_num);
+
+	pthread_spin_unlock(&cq->lock);
+
+	pthread_mutex_unlock(&mcontext->qp_table_mutex);
+
+	mlx4_free_db(mcontext, MLX4_DB_TYPE_RQ, qp->db);
+	free(qp->rq.wrid);
+	free(qp->sq.wrid);
+
+	mlx4_free_buf(&qp->buf);
+
+	free(qp);
+
+	return 0;
+}
-- 
1.8.3.1

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* [PATCH rdma-core 2/6] mlx4: Introduce the direct verb mlx4dv_set_ctx_attr
       [not found] ` <1505220788-23849-1-git-send-email-yishaih-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
  2017-09-12 12:53   ` [PATCH rdma-core 1/6] mlx4: Add support for WQ control path related verbs Yishai Hadas
@ 2017-09-12 12:53   ` Yishai Hadas
  2017-09-12 12:53   ` [PATCH rdma-core 3/6] mlx4: Add support for WQ indirection table related verbs Yishai Hadas
                     ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Yishai Hadas @ 2017-09-12 12:53 UTC (permalink / raw)
  To: linux-rdma-u79uwXL29TY76Z2rM5mHXA
  Cc: yishaih-VPRAkNaXOzVWk0Htik3J/w, guyle-VPRAkNaXOzVWk0Htik3J/w,
	majd-VPRAkNaXOzVWk0Htik3J/w

From: Guy Levi <guyle-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>

mlx4dv_set_ctx_attr lets the user application to set for a mlx4
context varied attributes which are exposed in mlx4dv.h.

First attribute type which is introduced here is used to set the
WQs range size.

Signed-off-by: Guy Levi <guyle-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
Reviewed-by: Yishai Hadas <yishaih-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
---
 debian/ibverbs-providers.symbols |  1 +
 providers/mlx4/libmlx4.map       |  1 +
 providers/mlx4/mlx4.c            | 17 +++++++++++++++++
 providers/mlx4/mlx4dv.h          | 13 ++++++++++++-
 4 files changed, 31 insertions(+), 1 deletion(-)

diff --git a/debian/ibverbs-providers.symbols b/debian/ibverbs-providers.symbols
index 34d1315..cb21dc5 100644
--- a/debian/ibverbs-providers.symbols
+++ b/debian/ibverbs-providers.symbols
@@ -3,6 +3,7 @@ libmlx4.so.1 ibverbs-providers #MINVER#
  mlx4dv_init_obj@MLX4_1.0 15
  mlx4dv_query_device@MLX4_1.0 15
  mlx4dv_create_qp@MLX4_1.0 15
+ mlx4dv_set_context_attr@MLX4_1.0 15
 libmlx5.so.1 ibverbs-providers #MINVER#
  MLX5_1.0@MLX5_1.0 13
  MLX5_1.1@MLX5_1.1 14
diff --git a/providers/mlx4/libmlx4.map b/providers/mlx4/libmlx4.map
index 6de4348..ac2c772 100644
--- a/providers/mlx4/libmlx4.map
+++ b/providers/mlx4/libmlx4.map
@@ -5,5 +5,6 @@ MLX4_1.0 {
 		mlx4dv_init_obj;
 		mlx4dv_query_device;
 		mlx4dv_create_qp;
+		mlx4dv_set_context_attr;
 	local: *;
 };
diff --git a/providers/mlx4/mlx4.c b/providers/mlx4/mlx4.c
index 600daea..6158924 100644
--- a/providers/mlx4/mlx4.c
+++ b/providers/mlx4/mlx4.c
@@ -443,3 +443,20 @@ int mlx4dv_query_device(struct ibv_context *ctx_in,
 
 	return 0;
 }
+
+int mlx4dv_set_context_attr(struct ibv_context *context,
+			    enum mlx4dv_set_ctx_attr_type attr_type,
+			    void *attr)
+{
+	struct mlx4_context *ctx = to_mctx(context);
+
+	switch (attr_type) {
+	case MLX4DV_SET_CTX_ATTR_LOG_WQS_RANGE_SZ:
+		ctx->log_wqs_range_sz = *((uint8_t *)attr);
+		break;
+	default:
+		return ENOTSUP;
+	}
+
+	return 0;
+}
diff --git a/providers/mlx4/mlx4dv.h b/providers/mlx4/mlx4dv.h
index 5a47e65..453de55 100644
--- a/providers/mlx4/mlx4dv.h
+++ b/providers/mlx4/mlx4dv.h
@@ -498,5 +498,16 @@ void mlx4dv_set_data_seg(struct mlx4_wqe_data_seg *seg,
 int mlx4dv_query_device(struct ibv_context *ctx_in,
 			struct mlx4dv_context *attrs_out);
 
-#endif /* _MLX4DV_H_ */
+enum mlx4dv_set_ctx_attr_type {
+	/* Attribute type uint8_t */
+	MLX4DV_SET_CTX_ATTR_LOG_WQS_RANGE_SZ	= 0,
+};
 
+/*
+ * Returns 0 on success, or the value of errno on failure
+ * (which indicates the failure reason).
+ */
+int mlx4dv_set_context_attr(struct ibv_context *context,
+			    enum mlx4dv_set_ctx_attr_type attr_type,
+			    void *attr);
+#endif /* _MLX4DV_H_ */
-- 
1.8.3.1

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* [PATCH rdma-core 3/6] mlx4: Add support for WQ indirection table related verbs
       [not found] ` <1505220788-23849-1-git-send-email-yishaih-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
  2017-09-12 12:53   ` [PATCH rdma-core 1/6] mlx4: Add support for WQ control path related verbs Yishai Hadas
  2017-09-12 12:53   ` [PATCH rdma-core 2/6] mlx4: Introduce the direct verb mlx4dv_set_ctx_attr Yishai Hadas
@ 2017-09-12 12:53   ` Yishai Hadas
  2017-09-12 12:53   ` [PATCH rdma-core 4/6] mlx4: Add support for RSS QP Yishai Hadas
                     ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Yishai Hadas @ 2017-09-12 12:53 UTC (permalink / raw)
  To: linux-rdma-u79uwXL29TY76Z2rM5mHXA
  Cc: yishaih-VPRAkNaXOzVWk0Htik3J/w, guyle-VPRAkNaXOzVWk0Htik3J/w,
	majd-VPRAkNaXOzVWk0Htik3J/w

From: Guy Levi <guyle-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>

To enable RSS functionality the IB indirection table object 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.

Signed-off-by: Guy Levi <guyle-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
Reviewed-by: Yishai Hadas <yishaih-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
---
 providers/mlx4/mlx4.c  |  2 ++
 providers/mlx4/mlx4.h  |  3 +++
 providers/mlx4/verbs.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 60 insertions(+)

diff --git a/providers/mlx4/mlx4.c b/providers/mlx4/mlx4.c
index 6158924..5daea3b 100644
--- a/providers/mlx4/mlx4.c
+++ b/providers/mlx4/mlx4.c
@@ -259,6 +259,8 @@ static int mlx4_init_context(struct verbs_device *v_device,
 	verbs_set_ctx_op(verbs_ctx, create_wq, mlx4_create_wq);
 	verbs_set_ctx_op(verbs_ctx, modify_wq, mlx4_modify_wq);
 	verbs_set_ctx_op(verbs_ctx, destroy_wq, mlx4_destroy_wq);
+	verbs_set_ctx_op(verbs_ctx, create_rwq_ind_table, mlx4_create_rwq_ind_table);
+	verbs_set_ctx_op(verbs_ctx, destroy_rwq_ind_table, mlx4_destroy_rwq_ind_table);
 
 	return 0;
 
diff --git a/providers/mlx4/mlx4.h b/providers/mlx4/mlx4.h
index 204542b..13a561f 100644
--- a/providers/mlx4/mlx4.h
+++ b/providers/mlx4/mlx4.h
@@ -411,5 +411,8 @@ struct ibv_wq *mlx4_create_wq(struct ibv_context *context,
 			      struct ibv_wq_init_attr *attr);
 int mlx4_modify_wq(struct ibv_wq *wq, struct ibv_wq_attr *attr);
 int mlx4_destroy_wq(struct ibv_wq *wq);
+struct ibv_rwq_ind_table *mlx4_create_rwq_ind_table(struct ibv_context *context,
+						    struct ibv_rwq_ind_table_init_attr *init_attr);
+int mlx4_destroy_rwq_ind_table(struct ibv_rwq_ind_table *rwq_ind_table);
 
 #endif /* MLX4_H */
diff --git a/providers/mlx4/verbs.c b/providers/mlx4/verbs.c
index 5ded2c5..369f437 100644
--- a/providers/mlx4/verbs.c
+++ b/providers/mlx4/verbs.c
@@ -1441,3 +1441,58 @@ int mlx4_destroy_wq(struct ibv_wq *ibwq)
 
 	return 0;
 }
+
+struct ibv_rwq_ind_table *mlx4_create_rwq_ind_table(struct ibv_context *context,
+						    struct ibv_rwq_ind_table_init_attr *init_attr)
+{
+	struct ibv_create_rwq_ind_table *cmd;
+	struct ibv_create_rwq_ind_table_resp resp = {};
+	struct ibv_rwq_ind_table *ind_table;
+	uint32_t required_tbl_size;
+	unsigned int num_tbl_entries;
+	int cmd_size;
+	int err;
+
+	num_tbl_entries = 1 << init_attr->log_ind_tbl_size;
+	/* Data must be u64 aligned */
+	required_tbl_size =
+		(num_tbl_entries * sizeof(uint32_t)) < sizeof(uint64_t) ?
+			sizeof(uint64_t) : (num_tbl_entries * sizeof(uint32_t));
+
+	cmd_size = required_tbl_size + sizeof(*cmd);
+	cmd = calloc(1, cmd_size);
+	if (!cmd)
+		return NULL;
+
+	ind_table = calloc(1, sizeof(*ind_table));
+	if (!ind_table)
+		goto free_cmd;
+
+	err = ibv_cmd_create_rwq_ind_table(context, init_attr, ind_table, cmd,
+					   cmd_size, cmd_size, &resp,
+					   sizeof(resp), sizeof(resp));
+	if (err)
+		goto err;
+
+	free(cmd);
+	return ind_table;
+
+err:
+	free(ind_table);
+free_cmd:
+	free(cmd);
+	return NULL;
+}
+
+int mlx4_destroy_rwq_ind_table(struct ibv_rwq_ind_table *rwq_ind_table)
+{
+	int ret;
+
+	ret = ibv_cmd_destroy_rwq_ind_table(rwq_ind_table);
+
+	if (ret && !cleanup_on_fatal(ret))
+		return ret;
+
+	free(rwq_ind_table);
+	return 0;
+}
-- 
1.8.3.1

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* [PATCH rdma-core 4/6] mlx4: Add support for RSS QP
       [not found] ` <1505220788-23849-1-git-send-email-yishaih-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
                     ` (2 preceding siblings ...)
  2017-09-12 12:53   ` [PATCH rdma-core 3/6] mlx4: Add support for WQ indirection table related verbs Yishai Hadas
@ 2017-09-12 12:53   ` Yishai Hadas
  2017-09-12 12:53   ` [PATCH rdma-core 5/6] mlx4: Add WQ data path support Yishai Hadas
                     ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Yishai Hadas @ 2017-09-12 12:53 UTC (permalink / raw)
  To: linux-rdma-u79uwXL29TY76Z2rM5mHXA
  Cc: yishaih-VPRAkNaXOzVWk0Htik3J/w, guyle-VPRAkNaXOzVWk0Htik3J/w,
	majd-VPRAkNaXOzVWk0Htik3J/w

From: Guy Levi <guyle-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>

Add support to work with a RSS QP by using an indirection table
object and RX Hash attributes as a driver data upon QP creation.

Signed-off-by: Guy Levi <guyle-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
Reviewed-by: Yishai Hadas <yishaih-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
---
 providers/mlx4/mlx4-abi.h |  14 ++++++
 providers/mlx4/mlx4.h     |   6 +++
 providers/mlx4/verbs.c    | 106 ++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 126 insertions(+)

diff --git a/providers/mlx4/mlx4-abi.h b/providers/mlx4/mlx4-abi.h
index 1cf6d5b..4f2132c 100644
--- a/providers/mlx4/mlx4-abi.h
+++ b/providers/mlx4/mlx4-abi.h
@@ -141,6 +141,20 @@ struct mlx4_create_qp {
 	__u32				inl_recv_sz;
 };
 
+struct mlx4_create_qp_drv_ex_rss {
+	__u64		hash_fields_mask; /* enum ibv_rx_hash_fields */
+	__u8		hash_function; /* enum ibv_rx_hash_function_flags */
+	__u8		reserved[7];
+	__u8		hash_key[40];
+	__u32		comp_mask;
+	__u32		reserved1;
+};
+
+struct mlx4_create_qp_ex_rss {
+	struct ibv_create_qp_ex		 ibv_cmd;
+	struct mlx4_create_qp_drv_ex_rss drv_ex;
+};
+
 struct mlx4_create_qp_drv_ex {
 	__u64		buf_addr;
 	__u64		db_addr;
diff --git a/providers/mlx4/mlx4.h b/providers/mlx4/mlx4.h
index 13a561f..83dd551 100644
--- a/providers/mlx4/mlx4.h
+++ b/providers/mlx4/mlx4.h
@@ -198,6 +198,11 @@ struct mlx4_wq {
 	int				offset;
 };
 
+enum mlx4_rsc_type {
+	MLX4_RSC_TYPE_QP	= 0,
+	MLX4_RSC_TYPE_RSS_QP	= 1,
+};
+
 struct mlx4_qp {
 	union {
 		struct verbs_qp		verbs_qp;
@@ -216,6 +221,7 @@ struct mlx4_qp {
 	struct mlx4_wq			rq;
 
 	uint8_t				link_layer;
+	uint8_t				type; /* enum mlx4_rsc_type */
 	uint32_t			qp_cap_cache;
 };
 
diff --git a/providers/mlx4/verbs.c b/providers/mlx4/verbs.c
index 369f437..5f2266a 100644
--- a/providers/mlx4/verbs.c
+++ b/providers/mlx4/verbs.c
@@ -745,6 +745,70 @@ int mlx4_destroy_srq(struct ibv_srq *srq)
 	return 0;
 }
 
+static int mlx4_cmd_create_qp_ex_rss(struct ibv_context *context,
+				     struct ibv_qp_init_attr_ex *attr,
+				     struct mlx4_create_qp *cmd,
+				     struct mlx4_qp *qp)
+{
+	struct mlx4_create_qp_ex_rss cmd_ex = {};
+	struct mlx4_create_qp_resp_ex resp;
+	int ret;
+
+	if (attr->rx_hash_conf.rx_hash_key_len !=
+	    sizeof(cmd_ex.drv_ex.hash_key)) {
+		errno = ENOTSUP;
+		return errno;
+	}
+
+	cmd_ex.drv_ex.hash_fields_mask =
+		attr->rx_hash_conf.rx_hash_fields_mask;
+	cmd_ex.drv_ex.hash_function =
+		attr->rx_hash_conf.rx_hash_function;
+	memcpy(cmd_ex.drv_ex.hash_key, attr->rx_hash_conf.rx_hash_key,
+	       sizeof(cmd_ex.drv_ex.hash_key));
+
+	ret = ibv_cmd_create_qp_ex2(context, &qp->verbs_qp,
+				    sizeof(qp->verbs_qp), attr,
+				    &cmd_ex.ibv_cmd, sizeof(cmd_ex.ibv_cmd),
+				    sizeof(cmd_ex), &resp.ibv_resp,
+				    sizeof(resp.ibv_resp), sizeof(resp));
+	return ret;
+}
+
+static struct ibv_qp *_mlx4_create_qp_ex_rss(struct ibv_context *context,
+					     struct ibv_qp_init_attr_ex *attr)
+{
+	struct mlx4_create_qp cmd = {};
+	struct mlx4_qp *qp;
+	int ret;
+
+	if (!(attr->comp_mask & IBV_QP_INIT_ATTR_RX_HASH) ||
+	    !(attr->comp_mask & IBV_QP_INIT_ATTR_IND_TABLE))
+		return NULL;
+
+	if (attr->qp_type != IBV_QPT_RAW_PACKET)
+		return NULL;
+
+	qp = calloc(1, sizeof(*qp));
+	if (!qp)
+		return NULL;
+
+	if (pthread_spin_init(&qp->sq.lock, PTHREAD_PROCESS_PRIVATE) ||
+	    pthread_spin_init(&qp->rq.lock, PTHREAD_PROCESS_PRIVATE))
+		goto err;
+
+	ret = mlx4_cmd_create_qp_ex_rss(context, attr, &cmd, qp);
+	if (ret)
+		goto err;
+
+	qp->type = MLX4_RSC_TYPE_RSS_QP;
+
+	return &qp->verbs_qp.qp;
+err:
+	free(qp);
+	return NULL;
+}
+
 static int mlx4_cmd_create_qp_ex(struct ibv_context *context,
 				 struct ibv_qp_init_attr_ex *attr,
 				 struct mlx4_create_qp *cmd,
@@ -792,6 +856,11 @@ static struct ibv_qp *create_qp_ex(struct ibv_context *context,
 	struct mlx4_qp		 *qp;
 	int			  ret;
 
+	if (attr->comp_mask & (IBV_QP_INIT_ATTR_RX_HASH |
+			       IBV_QP_INIT_ATTR_IND_TABLE)) {
+		return _mlx4_create_qp_ex_rss(context, attr);
+	}
+
 	/* Sanity check QP size before proceeding */
 	if (ctx->max_qp_wr) { /* mlx4_query_device succeeded */
 		if (attr->cap.max_send_wr  > ctx->max_qp_wr ||
@@ -987,6 +1056,9 @@ int mlx4_query_qp(struct ibv_qp *ibqp, struct ibv_qp_attr *attr,
 	struct mlx4_qp *qp = to_mqp(ibqp);
 	int ret;
 
+	if (qp->type == MLX4_RSC_TYPE_RSS_QP)
+		return ENOTSUP;
+
 	ret = ibv_cmd_query_qp(ibqp, attr, attr_mask, init_attr, &cmd, sizeof cmd);
 	if (ret)
 		return ret;
@@ -1000,6 +1072,20 @@ int mlx4_query_qp(struct ibv_qp *ibqp, struct ibv_qp_attr *attr,
 	return 0;
 }
 
+static int _mlx4_modify_qp_rss(struct ibv_qp *qp, struct ibv_qp_attr *attr,
+			       int attr_mask)
+{
+	struct ibv_modify_qp cmd = {};
+
+	if (attr_mask & ~(IBV_QP_STATE | IBV_QP_PORT))
+		return ENOTSUP;
+
+	if (attr->qp_state > IBV_QPS_RTR)
+		return ENOTSUP;
+
+	return ibv_cmd_modify_qp(qp, attr, attr_mask, &cmd, sizeof(cmd));
+}
+
 int mlx4_modify_qp(struct ibv_qp *qp, struct ibv_qp_attr *attr,
 		    int attr_mask)
 {
@@ -1009,6 +1095,9 @@ int mlx4_modify_qp(struct ibv_qp *qp, struct ibv_qp_attr *attr,
 	struct ibv_device_attr device_attr;
 	int ret;
 
+	if (mqp->type == MLX4_RSC_TYPE_RSS_QP)
+		return _mlx4_modify_qp_rss(qp, attr, attr_mask);
+
 	memset(&device_attr, 0, sizeof(device_attr));
 	if (attr_mask & IBV_QP_PORT) {
 		ret = ibv_query_port(qp->context, attr->port_num,
@@ -1108,11 +1197,28 @@ static void mlx4_unlock_cqs(struct ibv_qp *qp)
 	}
 }
 
+static int _mlx4_destroy_qp_rss(struct ibv_qp *ibqp)
+{
+	struct mlx4_qp *qp = to_mqp(ibqp);
+	int ret;
+
+	ret = ibv_cmd_destroy_qp(ibqp);
+	if (ret && !cleanup_on_fatal(ret))
+		return ret;
+
+	free(qp);
+
+	return 0;
+}
+
 int mlx4_destroy_qp(struct ibv_qp *ibqp)
 {
 	struct mlx4_qp *qp = to_mqp(ibqp);
 	int ret;
 
+	if (qp->type == MLX4_RSC_TYPE_RSS_QP)
+		return _mlx4_destroy_qp_rss(ibqp);
+
 	pthread_mutex_lock(&to_mctx(ibqp->context)->qp_table_mutex);
 	ret = ibv_cmd_destroy_qp(ibqp);
 	if (ret && !cleanup_on_fatal(ret)) {
-- 
1.8.3.1

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* [PATCH rdma-core 5/6] mlx4: Add WQ data path support
       [not found] ` <1505220788-23849-1-git-send-email-yishaih-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
                     ` (3 preceding siblings ...)
  2017-09-12 12:53   ` [PATCH rdma-core 4/6] mlx4: Add support for RSS QP Yishai Hadas
@ 2017-09-12 12:53   ` Yishai Hadas
  2017-09-12 12:53   ` [PATCH rdma-core 6/6] mlx4: Support WQ object type in direct verb mlx4dv_init_obj Yishai Hadas
  2017-09-14  8:22   ` [PATCH rdma-core 0/6] Add RSS support in mlx4 Yishai Hadas
  6 siblings, 0 replies; 8+ messages in thread
From: Yishai Hadas @ 2017-09-12 12:53 UTC (permalink / raw)
  To: linux-rdma-u79uwXL29TY76Z2rM5mHXA
  Cc: yishaih-VPRAkNaXOzVWk0Htik3J/w, guyle-VPRAkNaXOzVWk0Htik3J/w,
	majd-VPRAkNaXOzVWk0Htik3J/w

From: Guy Levi <guyle-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>

It includes:
1) Adding support for post receive to a WQ.
2) Adding support in the poll CQ flow to handle QP and WQ.

Signed-off-by: Guy Levi <guyle-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
Reviewed-by: Yishai Hadas <yishaih-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
---
 providers/mlx4/cq.c    |  5 +++--
 providers/mlx4/mlx4.h  |  4 ++++
 providers/mlx4/qp.c    | 30 ++++++++++++++++++++++++++----
 providers/mlx4/verbs.c |  7 +++++++
 4 files changed, 40 insertions(+), 6 deletions(-)

diff --git a/providers/mlx4/cq.c b/providers/mlx4/cq.c
index 5c7723b..8ced49e 100644
--- a/providers/mlx4/cq.c
+++ b/providers/mlx4/cq.c
@@ -229,7 +229,7 @@ static inline int mlx4_parse_cqe(struct mlx4_cq *cq,
 		if (!srq)
 			return CQ_POLL_ERR;
 	} else {
-		if (!*cur_qp || (qpn != (*cur_qp)->verbs_qp.qp.qp_num)) {
+		if (!*cur_qp || (qpn != (*cur_qp)->qpn_cache)) {
 			/*
 			 * We do not have to take the QP table lock here,
 			 * because CQs will be locked while QPs are removed
@@ -239,7 +239,8 @@ static inline int mlx4_parse_cqe(struct mlx4_cq *cq,
 			if (!*cur_qp)
 				return CQ_POLL_ERR;
 		}
-		srq = ((*cur_qp)->verbs_qp.qp.srq) ? to_msrq((*cur_qp)->verbs_qp.qp.srq) : NULL;
+		srq = ((*cur_qp)->type == MLX4_RSC_TYPE_SRQ) ?
+			to_msrq((*cur_qp)->verbs_qp.qp.srq) : NULL;
 	}
 
 	pwr_id = lazy ? &cq->ibv_cq.wr_id : &wc->wr_id;
diff --git a/providers/mlx4/mlx4.h b/providers/mlx4/mlx4.h
index 83dd551..14f2720 100644
--- a/providers/mlx4/mlx4.h
+++ b/providers/mlx4/mlx4.h
@@ -201,6 +201,7 @@ struct mlx4_wq {
 enum mlx4_rsc_type {
 	MLX4_RSC_TYPE_QP	= 0,
 	MLX4_RSC_TYPE_RSS_QP	= 1,
+	MLX4_RSC_TYPE_SRQ	= 2,
 };
 
 struct mlx4_qp {
@@ -223,6 +224,7 @@ struct mlx4_qp {
 	uint8_t				link_layer;
 	uint8_t				type; /* enum mlx4_rsc_type */
 	uint32_t			qp_cap_cache;
+	uint32_t			qpn_cache;
 };
 
 struct mlx4_ah {
@@ -420,5 +422,7 @@ int mlx4_destroy_wq(struct ibv_wq *wq);
 struct ibv_rwq_ind_table *mlx4_create_rwq_ind_table(struct ibv_context *context,
 						    struct ibv_rwq_ind_table_init_attr *init_attr);
 int mlx4_destroy_rwq_ind_table(struct ibv_rwq_ind_table *rwq_ind_table);
+int mlx4_post_wq_recv(struct ibv_wq *ibwq, struct ibv_recv_wr *wr,
+		      struct ibv_recv_wr **bad_wr);
 
 #endif /* MLX4_H */
diff --git a/providers/mlx4/qp.c b/providers/mlx4/qp.c
index 8f33f0e..61f69ee 100644
--- a/providers/mlx4/qp.c
+++ b/providers/mlx4/qp.c
@@ -509,10 +509,14 @@ out:
 	return ret;
 }
 
-int mlx4_post_recv(struct ibv_qp *ibqp, struct ibv_recv_wr *wr,
-		   struct ibv_recv_wr **bad_wr)
+static inline int _mlx4_post_recv(struct mlx4_qp *qp, struct mlx4_cq *cq,
+				  struct ibv_recv_wr *wr,
+				  struct ibv_recv_wr **bad_wr)
+				  ALWAYS_INLINE;
+static inline int _mlx4_post_recv(struct mlx4_qp *qp, struct mlx4_cq *cq,
+				  struct ibv_recv_wr *wr,
+				  struct ibv_recv_wr **bad_wr)
 {
-	struct mlx4_qp *qp = to_mqp(ibqp);
 	struct mlx4_wqe_data_seg *scat;
 	int ret = 0;
 	int nreq;
@@ -526,7 +530,7 @@ int mlx4_post_recv(struct ibv_qp *ibqp, struct ibv_recv_wr *wr,
 	ind = qp->rq.head & (qp->rq.wqe_cnt - 1);
 
 	for (nreq = 0; wr; ++nreq, wr = wr->next) {
-		if (wq_overflow(&qp->rq, nreq, to_mcq(ibqp->recv_cq))) {
+		if (wq_overflow(&qp->rq, nreq, cq)) {
 			ret = ENOMEM;
 			*bad_wr = wr;
 			goto out;
@@ -572,6 +576,24 @@ out:
 	return ret;
 }
 
+int mlx4_post_recv(struct ibv_qp *ibqp, struct ibv_recv_wr *wr,
+		   struct ibv_recv_wr **bad_wr)
+{
+	struct mlx4_qp *qp = to_mqp(ibqp);
+	struct mlx4_cq *cq = to_mcq(ibqp->recv_cq);
+
+	return _mlx4_post_recv(qp, cq, wr, bad_wr);
+}
+
+int mlx4_post_wq_recv(struct ibv_wq *ibwq, struct ibv_recv_wr *wr,
+		      struct ibv_recv_wr **bad_wr)
+{
+	struct mlx4_qp *qp = wq_to_mqp(ibwq);
+	struct mlx4_cq *cq = to_mcq(ibwq->cq);
+
+	return _mlx4_post_recv(qp, cq, wr, bad_wr);
+}
+
 static int num_inline_segs(int data, enum ibv_qp_type type)
 {
 	/*
diff --git a/providers/mlx4/verbs.c b/providers/mlx4/verbs.c
index 5f2266a..b966ef2 100644
--- a/providers/mlx4/verbs.c
+++ b/providers/mlx4/verbs.c
@@ -976,6 +976,9 @@ static struct ibv_qp *create_qp_ex(struct ibv_context *context,
 	else
 		qp->sq_signal_bits = 0;
 
+	qp->qpn_cache = qp->verbs_qp.qp.qp_num;
+	qp->type = attr->srq ? MLX4_RSC_TYPE_SRQ : MLX4_RSC_TYPE_QP;
+
 	return &qp->verbs_qp.qp;
 
 err_destroy:
@@ -1473,6 +1476,10 @@ struct ibv_wq *mlx4_create_wq(struct ibv_context *context,
 
 	qp->wq.state = IBV_WQS_RESET;
 
+	qp->wq.post_recv = mlx4_post_wq_recv;
+
+	qp->qpn_cache = qp->wq.wq_num;
+
 	return &qp->wq;
 
 err_destroy:
-- 
1.8.3.1

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* [PATCH rdma-core 6/6] mlx4: Support WQ object type in direct verb mlx4dv_init_obj
       [not found] ` <1505220788-23849-1-git-send-email-yishaih-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
                     ` (4 preceding siblings ...)
  2017-09-12 12:53   ` [PATCH rdma-core 5/6] mlx4: Add WQ data path support Yishai Hadas
@ 2017-09-12 12:53   ` Yishai Hadas
  2017-09-14  8:22   ` [PATCH rdma-core 0/6] Add RSS support in mlx4 Yishai Hadas
  6 siblings, 0 replies; 8+ messages in thread
From: Yishai Hadas @ 2017-09-12 12:53 UTC (permalink / raw)
  To: linux-rdma-u79uwXL29TY76Z2rM5mHXA
  Cc: yishaih-VPRAkNaXOzVWk0Htik3J/w, guyle-VPRAkNaXOzVWk0Htik3J/w,
	majd-VPRAkNaXOzVWk0Htik3J/w

From: Guy Levi <guyle-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>

Exposing relevant data-path attributes from the mlx4 object which
is used for WQ (i.e. from mlx4_qp) to let user working directly over
hardware specification.

Signed-off-by: Guy Levi <guyle-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
Reviewed-by: Yishai Hadas <yishaih-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
---
 providers/mlx4/man/mlx4dv_init_obj.3 | 20 ++++++++++++++++++++
 providers/mlx4/mlx4.c                | 20 ++++++++++++++++++++
 providers/mlx4/mlx4dv.h              | 19 +++++++++++++++++++
 3 files changed, 59 insertions(+)

diff --git a/providers/mlx4/man/mlx4dv_init_obj.3 b/providers/mlx4/man/mlx4dv_init_obj.3
index c6d8d2b..d2a2bb0 100644
--- a/providers/mlx4/man/mlx4dv_init_obj.3
+++ b/providers/mlx4/man/mlx4dv_init_obj.3
@@ -83,6 +83,26 @@ uint64_t        comp_mask;
 .in -8
 };
 
+struct mlx4dv_rwq {
+.in +8
+__be32          *rdb;
+struct {
+.in +8
+uint32_t        wqe_cnt;
+int             wqe_shift;
+int             offset;
+.in -8
+} rq;
+struct {
+.in +8
+void            *buf;
+size_t          length;
+.in -8
+} buf;
+uint64_t        comp_mask;
+.in -8
+};
+
 struct mlx4dv_obj {
 .in +8
 struct {
diff --git a/providers/mlx4/mlx4.c b/providers/mlx4/mlx4.c
index 5daea3b..3571234 100644
--- a/providers/mlx4/mlx4.c
+++ b/providers/mlx4/mlx4.c
@@ -419,6 +419,24 @@ static int mlx4dv_get_srq(struct ibv_srq *srq_in,
 	return 0;
 }
 
+static int mlx4dv_get_rwq(struct ibv_wq *wq_in, struct mlx4dv_rwq *wq_out)
+{
+	struct mlx4_qp *mqp = wq_to_mqp(wq_in);
+
+	wq_out->comp_mask = 0;
+
+	wq_out->buf.buf = mqp->buf.buf;
+	wq_out->buf.length = mqp->buf.length;
+
+	wq_out->rdb = mqp->db;
+
+	wq_out->rq.wqe_cnt = mqp->rq.wqe_cnt;
+	wq_out->rq.wqe_shift = mqp->rq.wqe_shift;
+	wq_out->rq.offset = mqp->rq.offset;
+
+	return 0;
+}
+
 int mlx4dv_init_obj(struct mlx4dv_obj *obj, uint64_t obj_type)
 {
 	int ret = 0;
@@ -429,6 +447,8 @@ int mlx4dv_init_obj(struct mlx4dv_obj *obj, uint64_t obj_type)
 		ret = mlx4dv_get_cq(obj->cq.in, obj->cq.out);
 	if (!ret && (obj_type & MLX4DV_OBJ_SRQ))
 		ret = mlx4dv_get_srq(obj->srq.in, obj->srq.out);
+	if (!ret && (obj_type & MLX4DV_OBJ_RWQ))
+		ret = mlx4dv_get_rwq(obj->rwq.in, obj->rwq.out);
 
 	return ret;
 }
diff --git a/providers/mlx4/mlx4dv.h b/providers/mlx4/mlx4dv.h
index 453de55..d47d3cd 100644
--- a/providers/mlx4/mlx4dv.h
+++ b/providers/mlx4/mlx4dv.h
@@ -197,6 +197,20 @@ struct mlx4dv_srq {
 	uint64_t			comp_mask;
 };
 
+struct mlx4dv_rwq {
+	__be32			*rdb;
+	struct {
+		uint32_t	wqe_cnt;
+		int		wqe_shift;
+		int		offset;
+	} rq;
+	struct {
+		void			*buf;
+		size_t			length;
+	} buf;
+	uint64_t		comp_mask;
+};
+
 struct mlx4dv_obj {
 	struct {
 		struct ibv_qp		*in;
@@ -210,12 +224,17 @@ struct mlx4dv_obj {
 		struct ibv_srq		*in;
 		struct mlx4dv_srq	*out;
 	} srq;
+	struct {
+		struct ibv_wq		*in;
+		struct mlx4dv_rwq	*out;
+	} rwq;
 };
 
 enum mlx4dv_obj_type {
 	MLX4DV_OBJ_QP	= 1 << 0,
 	MLX4DV_OBJ_CQ	= 1 << 1,
 	MLX4DV_OBJ_SRQ	= 1 << 2,
+	MLX4DV_OBJ_RWQ	= 1 << 3,
 };
 
 /*
-- 
1.8.3.1

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH rdma-core 0/6] Add RSS support in mlx4
       [not found] ` <1505220788-23849-1-git-send-email-yishaih-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
                     ` (5 preceding siblings ...)
  2017-09-12 12:53   ` [PATCH rdma-core 6/6] mlx4: Support WQ object type in direct verb mlx4dv_init_obj Yishai Hadas
@ 2017-09-14  8:22   ` Yishai Hadas
  6 siblings, 0 replies; 8+ messages in thread
From: Yishai Hadas @ 2017-09-14  8:22 UTC (permalink / raw)
  To: guyle-VPRAkNaXOzVWk0Htik3J/w
  Cc: Yishai Hadas, linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	majd-VPRAkNaXOzVWk0Htik3J/w

On 9/12/2017 3:53 PM, Yishai Hadas wrote:
> This patch set from Guy Levi implements the RSS related verbs for ConnectX-3
> devices in the mlx4 provider.
> 
> The matching kernel part was already merged into 4.14.
> 
> PR was sent:
> https://github.com/linux-rdma/rdma-core/pull/218
> 
> Guy Levi (6):
>    mlx4: Add support for WQ control path related verbs
>    mlx4: Introduce the direct verb mlx4dv_set_ctx_attr
>    mlx4: Add support for WQ indirection table related verbs
>    mlx4: Add support for RSS QP
>    mlx4: Add WQ data path support
>    mlx4: Support WQ object type in direct verb mlx4dv_init_obj
> 
>   debian/ibverbs-providers.symbols     |   1 +
>   providers/mlx4/cq.c                  |   5 +-
>   providers/mlx4/libmlx4.map           |   1 +
>   providers/mlx4/man/mlx4dv_init_obj.3 |  20 +++
>   providers/mlx4/mlx4-abi.h            |  33 ++++
>   providers/mlx4/mlx4.c                |  42 +++++
>   providers/mlx4/mlx4.h                |  30 +++-
>   providers/mlx4/mlx4dv.h              |  32 +++-
>   providers/mlx4/qp.c                  |  34 +++-
>   providers/mlx4/verbs.c               | 339 ++++++++++++++++++++++++++++++++++-
>   10 files changed, 525 insertions(+), 12 deletions(-)
> 

Series was merged, thanks.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

end of thread, other threads:[~2017-09-14  8:22 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-12 12:53 [PATCH rdma-core 0/6] Add RSS support in mlx4 Yishai Hadas
     [not found] ` <1505220788-23849-1-git-send-email-yishaih-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2017-09-12 12:53   ` [PATCH rdma-core 1/6] mlx4: Add support for WQ control path related verbs Yishai Hadas
2017-09-12 12:53   ` [PATCH rdma-core 2/6] mlx4: Introduce the direct verb mlx4dv_set_ctx_attr Yishai Hadas
2017-09-12 12:53   ` [PATCH rdma-core 3/6] mlx4: Add support for WQ indirection table related verbs Yishai Hadas
2017-09-12 12:53   ` [PATCH rdma-core 4/6] mlx4: Add support for RSS QP Yishai Hadas
2017-09-12 12:53   ` [PATCH rdma-core 5/6] mlx4: Add WQ data path support Yishai Hadas
2017-09-12 12:53   ` [PATCH rdma-core 6/6] mlx4: Support WQ object type in direct verb mlx4dv_init_obj Yishai Hadas
2017-09-14  8:22   ` [PATCH rdma-core 0/6] Add RSS support in mlx4 Yishai Hadas

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