1 When creating a new user context, query device for
3 various limits, for use in sanity checks and
4 other resource limitation needs.
6 Passing needed info back to userspace in this manner is
7 preferable to breaking the ABI.
8 (OFED 1.3 commit 43ca5e9225658b22ef8180bf0eff4faa7f5940cf)
10 Signed-off-by: Jack Morgenstein <jackm@dev.mellanox.co.il>
12 Index: libmlx4/src/mlx4.c
13 ===================================================================
14 --- libmlx4.orig/src/mlx4.c 2008-06-03 15:45:18.000000000 +0300
15 +++ libmlx4/src/mlx4.c 2008-06-04 08:24:10.000000000 +0300
16 @@ -104,6 +104,7 @@ static struct ibv_context *mlx4_alloc_co
17 struct ibv_get_context cmd;
18 struct mlx4_alloc_ucontext_resp resp;
20 + struct ibv_device_attr dev_attrs;
22 context = calloc(1, sizeof *context);
24 @@ -156,8 +157,20 @@ static struct ibv_context *mlx4_alloc_co
26 context->ibv_ctx.ops = mlx4_ctx_ops;
28 + if (mlx4_query_device(&context->ibv_ctx, &dev_attrs))
31 + context->max_qp_wr = dev_attrs.max_qp_wr;
32 + context->max_sge = dev_attrs.max_sge;
33 + context->max_cqe = dev_attrs.max_cqe;
35 return &context->ibv_ctx;
38 + munmap(context->uar, to_mdev(ibdev)->page_size);
39 + if (context->bf_page)
40 + munmap(context->bf_page, to_mdev(ibdev)->page_size);
45 Index: libmlx4/src/mlx4.h
46 ===================================================================
47 --- libmlx4.orig/src/mlx4.h 2008-06-03 15:45:18.000000000 +0300
48 +++ libmlx4/src/mlx4.h 2008-06-04 08:24:10.000000000 +0300
55 + ({ typeof (a) _a = (a); \
56 + typeof (b) _b = (b); \
57 + _a > _b ? _a : _b; })
62 + ({ typeof (a) _a = (a); \
63 + typeof (b) _b = (b); \
64 + _a < _b ? _a : _b; })
68 MLX4_CQ_ENTRY_SIZE = 0x20
70 @@ -156,6 +170,9 @@ struct mlx4_context {
78 struct mlx4_db_page *db_list[MLX4_NUM_DB_TYPE];
79 pthread_mutex_t db_list_mutex;