summaryrefslogtreecommitdiffstats
path: root/contrib/ofed
diff options
context:
space:
mode:
authorhselasky <hselasky@FreeBSD.org>2015-01-11 15:00:08 +0000
committerhselasky <hselasky@FreeBSD.org>2015-01-11 15:00:08 +0000
commit2cb62f75edda07048ed79f56daa9642a452537c3 (patch)
tree36124d186d462ca463a1c8354004eb13a4e60f1c /contrib/ofed
parent77e42966ca3a4b288a858f1f80625b31310198a8 (diff)
downloadFreeBSD-src-2cb62f75edda07048ed79f56daa9642a452537c3.zip
FreeBSD-src-2cb62f75edda07048ed79f56daa9642a452537c3.tar.gz
Fix support for ConnectX2 hardware.
MFC after: 3 days Sponsored by: Mellanox Technologies
Diffstat (limited to 'contrib/ofed')
-rw-r--r--contrib/ofed/libmlx4/src/mlx4-abi.h7
-rw-r--r--contrib/ofed/libmlx4/src/mlx4.c32
-rw-r--r--contrib/ofed/libmlx4/src/mlx4.h1
3 files changed, 32 insertions, 8 deletions
diff --git a/contrib/ofed/libmlx4/src/mlx4-abi.h b/contrib/ofed/libmlx4/src/mlx4-abi.h
index 86be5c7..f2d0010 100644
--- a/contrib/ofed/libmlx4/src/mlx4-abi.h
+++ b/contrib/ofed/libmlx4/src/mlx4-abi.h
@@ -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;
diff --git a/contrib/ofed/libmlx4/src/mlx4.c b/contrib/ofed/libmlx4/src/mlx4.c
index caabced..a8ec332 100644
--- a/contrib/ofed/libmlx4/src/mlx4.c
+++ b/contrib/ofed/libmlx4/src/mlx4.c
@@ -142,8 +142,10 @@ static struct ibv_context *mlx4_alloc_context(struct ibv_device *ibdev, int cmd_
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_context(struct ibv_device *ibdev, int cmd_
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_context(struct ibv_device *ibdev, int cmd_
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_context(struct ibv_device *ibdev, int cmd_
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_context(struct ibv_device *ibdev, int cmd_
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_context(struct ibv_device *ibdev, int cmd_
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;
}
diff --git a/contrib/ofed/libmlx4/src/mlx4.h b/contrib/ofed/libmlx4/src/mlx4.h
index cf5b963..208ebd0 100644
--- a/contrib/ofed/libmlx4/src/mlx4.h
+++ b/contrib/ofed/libmlx4/src/mlx4.h
@@ -162,6 +162,7 @@ enum {
struct mlx4_device {
struct ibv_device ibv_dev;
int page_size;
+ int driver_abi_ver;
};
struct mlx4_db_page;
OpenPOWER on IntegriCloud