1219820SjeffWhen creating a new user context, query device for 2219820Sjeff 3219820Sjeffvarious limits, for use in sanity checks and 4219820Sjeffother resource limitation needs. 5219820Sjeff 6219820SjeffPassing needed info back to userspace in this manner is 7219820Sjeffpreferable to breaking the ABI. 8219820Sjeff(OFED 1.3 commit 43ca5e9225658b22ef8180bf0eff4faa7f5940cf) 9219820Sjeff 10219820SjeffSigned-off-by: Jack Morgenstein <jackm@dev.mellanox.co.il> 11219820Sjeff 12219820SjeffIndex: libmlx4/src/mlx4.c 13219820Sjeff=================================================================== 14219820Sjeff--- libmlx4.orig/src/mlx4.c 2008-06-03 15:45:18.000000000 +0300 15219820Sjeff+++ libmlx4/src/mlx4.c 2008-06-04 08:24:10.000000000 +0300 16219820Sjeff@@ -104,6 +104,7 @@ static struct ibv_context *mlx4_alloc_co 17219820Sjeff struct ibv_get_context cmd; 18219820Sjeff struct mlx4_alloc_ucontext_resp resp; 19219820Sjeff int i; 20219820Sjeff+ struct ibv_device_attr dev_attrs; 21219820Sjeff 22219820Sjeff context = calloc(1, sizeof *context); 23219820Sjeff if (!context) 24219820Sjeff@@ -156,8 +157,20 @@ static struct ibv_context *mlx4_alloc_co 25219820Sjeff 26219820Sjeff context->ibv_ctx.ops = mlx4_ctx_ops; 27219820Sjeff 28219820Sjeff+ if (mlx4_query_device(&context->ibv_ctx, &dev_attrs)) 29219820Sjeff+ goto query_free; 30219820Sjeff+ 31219820Sjeff+ context->max_qp_wr = dev_attrs.max_qp_wr; 32219820Sjeff+ context->max_sge = dev_attrs.max_sge; 33219820Sjeff+ context->max_cqe = dev_attrs.max_cqe; 34219820Sjeff+ 35219820Sjeff return &context->ibv_ctx; 36219820Sjeff 37219820Sjeff+query_free: 38219820Sjeff+ munmap(context->uar, to_mdev(ibdev)->page_size); 39219820Sjeff+ if (context->bf_page) 40219820Sjeff+ munmap(context->bf_page, to_mdev(ibdev)->page_size); 41219820Sjeff+ 42219820Sjeff err_free: 43219820Sjeff free(context); 44219820Sjeff return NULL; 45219820SjeffIndex: libmlx4/src/mlx4.h 46219820Sjeff=================================================================== 47219820Sjeff--- libmlx4.orig/src/mlx4.h 2008-06-03 15:45:18.000000000 +0300 48219820Sjeff+++ libmlx4/src/mlx4.h 2008-06-04 08:24:10.000000000 +0300 49219820Sjeff@@ -83,6 +83,20 @@ 50219820Sjeff 51219820Sjeff #define PFX "mlx4: " 52219820Sjeff 53219820Sjeff+#ifndef max 54219820Sjeff+#define max(a,b) \ 55219820Sjeff+ ({ typeof (a) _a = (a); \ 56219820Sjeff+ typeof (b) _b = (b); \ 57219820Sjeff+ _a > _b ? _a : _b; }) 58219820Sjeff+#endif 59219820Sjeff+ 60219820Sjeff+#ifndef min 61219820Sjeff+#define min(a,b) \ 62219820Sjeff+ ({ typeof (a) _a = (a); \ 63219820Sjeff+ typeof (b) _b = (b); \ 64219820Sjeff+ _a < _b ? _a : _b; }) 65219820Sjeff+#endif 66219820Sjeff+ 67219820Sjeff enum { 68219820Sjeff MLX4_CQ_ENTRY_SIZE = 0x20 69219820Sjeff }; 70219820Sjeff@@ -156,6 +170,9 @@ struct mlx4_context { 71219820Sjeff int num_qps; 72219820Sjeff int qp_table_shift; 73219820Sjeff int qp_table_mask; 74219820Sjeff+ int max_qp_wr; 75219820Sjeff+ int max_sge; 76219820Sjeff+ int max_cqe; 77219820Sjeff 78219820Sjeff struct mlx4_db_page *db_list[MLX4_NUM_DB_TYPE]; 79219820Sjeff pthread_mutex_t db_list_mutex; 80