Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 11 Jan 2015 15:00:08 +0000 (UTC)
From:      Hans Petter Selasky <hselasky@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r276981 - head/contrib/ofed/libmlx4/src
Message-ID:  <201501111500.t0BF08xT070470@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: hselasky
Date: Sun Jan 11 15:00:08 2015
New Revision: 276981
URL: https://svnweb.freebsd.org/changeset/base/276981

Log:
  Fix support for ConnectX2 hardware.
  
  MFC after:	3 days
  Sponsored by:	Mellanox Technologies

Modified:
  head/contrib/ofed/libmlx4/src/mlx4-abi.h
  head/contrib/ofed/libmlx4/src/mlx4.c
  head/contrib/ofed/libmlx4/src/mlx4.h

Modified: head/contrib/ofed/libmlx4/src/mlx4-abi.h
==============================================================================
--- head/contrib/ofed/libmlx4/src/mlx4-abi.h	Sun Jan 11 14:49:18 2015	(r276980)
+++ head/contrib/ofed/libmlx4/src/mlx4-abi.h	Sun Jan 11 15:00:08 2015	(r276981)
@@ -38,6 +38,13 @@
 #define MLX4_UVERBS_MIN_ABI_VERSION	2
 #define MLX4_UVERBS_MAX_ABI_VERSION	4
 
+struct mlx4_alloc_ucontext_resp_v3 {
+	struct ibv_get_context_resp	ibv_resp;
+	__u32				qp_tab_size;
+	__u16				bf_reg_size;
+	__u16				bf_regs_per_page;
+};
+
 struct mlx4_alloc_ucontext_resp {
 	struct ibv_get_context_resp	ibv_resp;
 	__u32				dev_caps;

Modified: head/contrib/ofed/libmlx4/src/mlx4.c
==============================================================================
--- head/contrib/ofed/libmlx4/src/mlx4.c	Sun Jan 11 14:49:18 2015	(r276980)
+++ head/contrib/ofed/libmlx4/src/mlx4.c	Sun Jan 11 15:00:08 2015	(r276981)
@@ -142,8 +142,10 @@ static struct ibv_context *mlx4_alloc_co
 	struct mlx4_context	       *context;
 	struct ibv_get_context		cmd;
 	struct mlx4_alloc_ucontext_resp resp;
+	struct mlx4_alloc_ucontext_resp_v3 resp_v3;
 	int				i;
 	struct ibv_device_attr		dev_attrs;
+	unsigned int			bf_reg_size;
 
 	context = calloc(1, sizeof *context);
 	if (!context)
@@ -151,11 +153,26 @@ static struct ibv_context *mlx4_alloc_co
 
 	context->ibv_ctx.cmd_fd = cmd_fd;
 
-	if (ibv_cmd_get_context(&context->ibv_ctx, &cmd, sizeof cmd,
-				&resp.ibv_resp, sizeof resp))
-		goto err_free;
+	if (to_mdev(ibdev)->driver_abi_ver > 3) {
+		if (ibv_cmd_get_context(&context->ibv_ctx, &cmd, sizeof cmd,
+					&resp.ibv_resp, sizeof resp))
+			goto err_free;
+
+		context->num_qps	= resp.qp_tab_size;
+		context->num_xrc_srqs	= resp.qp_tab_size;
+		bf_reg_size		= resp.bf_reg_size;
+		context->cqe_size	= resp.cqe_size;
+	} else {
+		if (ibv_cmd_get_context(&context->ibv_ctx, &cmd, sizeof cmd,
+					&resp_v3.ibv_resp, sizeof resp_v3))
+			goto err_free;
+
+		context->num_qps	= resp_v3.qp_tab_size;
+		context->num_xrc_srqs	= resp_v3.qp_tab_size;
+		bf_reg_size		= resp_v3.bf_reg_size;
+		context->cqe_size	= 32;
+	}
 
-	context->num_qps	= resp.qp_tab_size;
 	context->qp_table_shift = ffs(context->num_qps) - 1 - MLX4_QP_TABLE_BITS;
 	context->qp_table_mask	= (1 << context->qp_table_shift) - 1;
 
@@ -163,7 +180,6 @@ static struct ibv_context *mlx4_alloc_co
 	for (i = 0; i < MLX4_QP_TABLE_SIZE; ++i)
 		context->qp_table[i].refcnt = 0;
 
-	context->num_xrc_srqs = resp.qp_tab_size;
 	context->xrc_srq_table_shift = ffs(context->num_xrc_srqs) - 1
 				       - MLX4_XRC_SRQ_TABLE_BITS;
 	context->xrc_srq_table_mask = (1 << context->xrc_srq_table_shift) - 1;
@@ -182,7 +198,7 @@ static struct ibv_context *mlx4_alloc_co
 	if (context->uar == MAP_FAILED)
 		goto err_free;
 
-	if (resp.bf_reg_size) {
+	if (bf_reg_size) {
 		context->bf_page = mmap(NULL, to_mdev(ibdev)->page_size,
 					PROT_WRITE, MAP_SHARED, cmd_fd,
 					to_mdev(ibdev)->page_size);
@@ -192,7 +208,7 @@ static struct ibv_context *mlx4_alloc_co
 				context->bf_page     = NULL;
 				context->bf_buf_size = 0;
 		} else {
-			context->bf_buf_size = resp.bf_reg_size / 2;
+			context->bf_buf_size = bf_reg_size / 2;
 			context->bf_offset   = 0;
 			pthread_spin_init(&context->bf_lock, PTHREAD_PROCESS_PRIVATE);
 		}
@@ -201,7 +217,6 @@ 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;
@@ -294,6 +309,7 @@ found:
 
 	dev->ibv_dev.ops = mlx4_dev_ops;
 	dev->page_size   = sysconf(_SC_PAGESIZE);
+	dev->driver_abi_ver = abi_version;
 
 	return &dev->ibv_dev;
 }

Modified: head/contrib/ofed/libmlx4/src/mlx4.h
==============================================================================
--- head/contrib/ofed/libmlx4/src/mlx4.h	Sun Jan 11 14:49:18 2015	(r276980)
+++ head/contrib/ofed/libmlx4/src/mlx4.h	Sun Jan 11 15:00:08 2015	(r276981)
@@ -162,6 +162,7 @@ enum {
 struct mlx4_device {
 	struct ibv_device		ibv_dev;
 	int				page_size;
+	int				driver_abi_ver;
 };
 
 struct mlx4_db_page;



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