Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 29 Nov 2014 04:21:40 +0000 (UTC)
From:      Hans Petter Selasky <hselasky@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject:   svn commit: r275229 - stable/9/contrib/ofed/libmlx4/src
Message-ID:  <201411290421.sAT4LeTX034182@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: hselasky
Date: Sat Nov 29 04:21:40 2014
New Revision: 275229
URL: https://svnweb.freebsd.org/changeset/base/275229

Log:
  MFC r275109:
  Add support for 64-byte CQE size.
  
  Sponsored by:	Mellanox Technologies

Modified:
  stable/9/contrib/ofed/libmlx4/src/cq.c
  stable/9/contrib/ofed/libmlx4/src/mlx4-abi.h
  stable/9/contrib/ofed/libmlx4/src/mlx4.c
  stable/9/contrib/ofed/libmlx4/src/mlx4.h
  stable/9/contrib/ofed/libmlx4/src/verbs.c
Directory Properties:
  stable/9/contrib/   (props changed)

Modified: stable/9/contrib/ofed/libmlx4/src/cq.c
==============================================================================
--- stable/9/contrib/ofed/libmlx4/src/cq.c	Sat Nov 29 04:18:56 2014	(r275228)
+++ stable/9/contrib/ofed/libmlx4/src/cq.c	Sat Nov 29 04:21:40 2014	(r275229)
@@ -109,15 +109,16 @@ struct mlx4_err_cqe {
 
 static struct mlx4_cqe *get_cqe(struct mlx4_cq *cq, int entry)
 {
-	return cq->buf.buf + entry * MLX4_CQ_ENTRY_SIZE;
+	return cq->buf.buf + entry * cq->cqe_size;
 }
 
 static void *get_sw_cqe(struct mlx4_cq *cq, int n)
 {
 	struct mlx4_cqe *cqe = get_cqe(cq, n & cq->ibv_cq.cqe);
+	struct mlx4_cqe *tcqe = cq->cqe_size == 64 ? cqe + 1 : cqe;
 
-	return (!!(cqe->owner_sr_opcode & MLX4_CQE_OWNER_MASK) ^
-		!!(n & (cq->ibv_cq.cqe + 1))) ? NULL : cqe;
+	return (!!(tcqe->owner_sr_opcode & MLX4_CQE_OWNER_MASK) ^
+		!!(n & (cq->ibv_cq.cqe + 1))) ? NULL : tcqe;
 }
 
 static struct mlx4_cqe *next_cqe_sw(struct mlx4_cq *cq)
@@ -402,6 +403,7 @@ void __mlx4_cq_clean(struct mlx4_cq *cq,
 	uint8_t owner_bit;
 	int nfreed = 0;
 	int is_xrc_srq = 0;
+	int cqe_inc = cq->cqe_size == 64 ? 1 : 0;
 
 	if (srq && srq->ibv_srq.xrc_cq)
 		is_xrc_srq = 1;
@@ -423,6 +425,7 @@ void __mlx4_cq_clean(struct mlx4_cq *cq,
 	 */
 	while ((int) --prod_index - (int) cq->cons_index >= 0) {
 		cqe = get_cqe(cq, prod_index & cq->ibv_cq.cqe);
+		cqe += cqe_inc;
 		if (is_xrc_srq &&
 		    (ntohl(cqe->g_mlpath_rqpn & 0xffffff) == srq->srqn) &&
 		    !(cqe->owner_sr_opcode & MLX4_CQE_IS_SEND_MASK)) {
@@ -434,6 +437,7 @@ void __mlx4_cq_clean(struct mlx4_cq *cq,
 			++nfreed;
 		} else if (nfreed) {
 			dest = get_cqe(cq, (prod_index + nfreed) & cq->ibv_cq.cqe);
+			dest += cqe_inc;
 			owner_bit = dest->owner_sr_opcode & MLX4_CQE_OWNER_MASK;
 			memcpy(dest, cqe, sizeof *cqe);
 			dest->owner_sr_opcode = owner_bit |
@@ -473,28 +477,32 @@ void mlx4_cq_resize_copy_cqes(struct mlx
 {
 	struct mlx4_cqe *cqe;
 	int i;
+	int cqe_inc = cq->cqe_size == 64 ? 1 : 0;
 
 	i = cq->cons_index;
 	cqe = get_cqe(cq, (i & old_cqe));
+	cqe += cqe_inc;
 
 	while ((cqe->owner_sr_opcode & MLX4_CQE_OPCODE_MASK) != MLX4_CQE_OPCODE_RESIZE) {
 		cqe->owner_sr_opcode = (cqe->owner_sr_opcode & ~MLX4_CQE_OWNER_MASK) |
 			(((i + 1) & (cq->ibv_cq.cqe + 1)) ? MLX4_CQE_OWNER_MASK : 0);
-		memcpy(buf + ((i + 1) & cq->ibv_cq.cqe) * MLX4_CQ_ENTRY_SIZE,
-		       cqe, MLX4_CQ_ENTRY_SIZE);
+		memcpy(buf + ((i + 1) & cq->ibv_cq.cqe) * cq->cqe_size,
+		       cqe - cqe_inc, cq->cqe_size);
 		++i;
 		cqe = get_cqe(cq, (i & old_cqe));
+		cqe += cqe_inc;
 	}
 
 	++cq->cons_index;
 }
 
-int mlx4_alloc_cq_buf(struct mlx4_device *dev, struct mlx4_buf *buf, int nent)
+int mlx4_alloc_cq_buf(struct mlx4_device *dev, struct mlx4_buf *buf, int nent,
+			int entry_size)
 {
-	if (mlx4_alloc_buf(buf, align(nent * MLX4_CQ_ENTRY_SIZE, dev->page_size),
+	if (mlx4_alloc_buf(buf, align(nent * entry_size, dev->page_size),
 			   dev->page_size))
 		return -1;
-	memset(buf->buf, 0, nent * MLX4_CQ_ENTRY_SIZE);
+	memset(buf->buf, 0, nent * entry_size);
 
 	return 0;
 }

Modified: stable/9/contrib/ofed/libmlx4/src/mlx4-abi.h
==============================================================================
--- stable/9/contrib/ofed/libmlx4/src/mlx4-abi.h	Sat Nov 29 04:18:56 2014	(r275228)
+++ stable/9/contrib/ofed/libmlx4/src/mlx4-abi.h	Sat Nov 29 04:21:40 2014	(r275229)
@@ -40,9 +40,11 @@
 
 struct mlx4_alloc_ucontext_resp {
 	struct ibv_get_context_resp	ibv_resp;
+	__u32				dev_caps;
 	__u32				qp_tab_size;
 	__u16				bf_reg_size;
 	__u16				bf_regs_per_page;
+	__u32				cqe_size;
 };
 
 struct mlx4_alloc_pd_resp {

Modified: stable/9/contrib/ofed/libmlx4/src/mlx4.c
==============================================================================
--- stable/9/contrib/ofed/libmlx4/src/mlx4.c	Sat Nov 29 04:18:56 2014	(r275228)
+++ stable/9/contrib/ofed/libmlx4/src/mlx4.c	Sat Nov 29 04:21:40 2014	(r275229)
@@ -201,6 +201,7 @@ static struct ibv_context *mlx4_alloc_co
 		context->bf_buf_size = 0;
 	}
 
+	context->cqe_size = resp.cqe_size;
 	pthread_spin_init(&context->uar_lock, PTHREAD_PROCESS_PRIVATE);
 
 	context->ibv_ctx.ops = mlx4_ctx_ops;

Modified: stable/9/contrib/ofed/libmlx4/src/mlx4.h
==============================================================================
--- stable/9/contrib/ofed/libmlx4/src/mlx4.h	Sat Nov 29 04:18:56 2014	(r275228)
+++ stable/9/contrib/ofed/libmlx4/src/mlx4.h	Sat Nov 29 04:21:40 2014	(r275229)
@@ -103,10 +103,6 @@
 #endif
 
 enum {
-	MLX4_CQ_ENTRY_SIZE		= 0x20
-};
-
-enum {
 	MLX4_STAT_RATE_OFFSET		= 5
 };
 
@@ -192,6 +188,7 @@ struct mlx4_context {
 	int				max_qp_wr;
 	int				max_sge;
 	int				max_cqe;
+	int				cqe_size;
 
 	struct {
 		struct mlx4_srq       **table;
@@ -226,6 +223,7 @@ struct mlx4_cq {
 	uint32_t		       *set_ci_db;
 	uint32_t		       *arm_db;
 	int				arm_sn;
+	int				cqe_size;
 };
 
 struct mlx4_srq {
@@ -369,7 +367,8 @@ int mlx4_dereg_mr(struct ibv_mr *mr);
 struct ibv_cq *mlx4_create_cq(struct ibv_context *context, int cqe,
 			       struct ibv_comp_channel *channel,
 			       int comp_vector);
-int mlx4_alloc_cq_buf(struct mlx4_device *dev, struct mlx4_buf *buf, int nent);
+int mlx4_alloc_cq_buf(struct mlx4_device *dev, struct mlx4_buf *buf, int nent,
+		      int entry_size);
 int mlx4_resize_cq(struct ibv_cq *cq, int cqe);
 int mlx4_destroy_cq(struct ibv_cq *cq);
 int mlx4_poll_cq(struct ibv_cq *cq, int ne, struct ibv_wc *wc);

Modified: stable/9/contrib/ofed/libmlx4/src/verbs.c
==============================================================================
--- stable/9/contrib/ofed/libmlx4/src/verbs.c	Sat Nov 29 04:18:56 2014	(r275228)
+++ stable/9/contrib/ofed/libmlx4/src/verbs.c	Sat Nov 29 04:21:40 2014	(r275229)
@@ -168,6 +168,7 @@ struct ibv_cq *mlx4_create_cq(struct ibv
 	struct mlx4_create_cq_resp resp;
 	struct mlx4_cq		  *cq;
 	int			   ret;
+	struct mlx4_context	   *mctx = to_mctx(context);
 
 	/* Sanity check CQ size before proceeding */
 	if (cqe > 0x3fffff)
@@ -184,9 +185,11 @@ struct ibv_cq *mlx4_create_cq(struct ibv
 
 	cqe = align_queue_size(cqe + 1);
 
-	if (mlx4_alloc_cq_buf(to_mdev(context->device), &cq->buf, cqe))
+	if (mlx4_alloc_cq_buf(to_mdev(context->device), &cq->buf, cqe, mctx->cqe_size))
 		goto err;
 
+	cq->cqe_size = mctx->cqe_size;
+
 	cq->set_ci_db  = mlx4_alloc_db(to_mctx(context), MLX4_DB_TYPE_CQ);
 	if (!cq->set_ci_db)
 		goto err_buf;
@@ -247,7 +250,8 @@ int mlx4_resize_cq(struct ibv_cq *ibcq, 
 		goto out;
 	}
 
-	ret = mlx4_alloc_cq_buf(to_mdev(ibcq->context->device), &buf, cqe);
+	ret = mlx4_alloc_cq_buf(to_mdev(ibcq->context->device), &buf, cqe,
+					cq->cqe_size);
 	if (ret)
 		goto out;
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201411290421.sAT4LeTX034182>