freebsd-skq/contrib/ofed/libmlx4/fixes/userspace_dev_lims.patch

80 lines
2.1 KiB
Diff

When creating a new user context, query device for
various limits, for use in sanity checks and
other resource limitation needs.
Passing needed info back to userspace in this manner is
preferable to breaking the ABI.
(OFED 1.3 commit 43ca5e9225658b22ef8180bf0eff4faa7f5940cf)
Signed-off-by: Jack Morgenstein <jackm@dev.mellanox.co.il>
Index: libmlx4/src/mlx4.c
===================================================================
--- libmlx4.orig/src/mlx4.c 2008-06-03 15:45:18.000000000 +0300
+++ libmlx4/src/mlx4.c 2008-06-04 08:24:10.000000000 +0300
@@ -104,6 +104,7 @@ static struct ibv_context *mlx4_alloc_co
struct ibv_get_context cmd;
struct mlx4_alloc_ucontext_resp resp;
int i;
+ struct ibv_device_attr dev_attrs;
context = calloc(1, sizeof *context);
if (!context)
@@ -156,8 +157,20 @@ static struct ibv_context *mlx4_alloc_co
context->ibv_ctx.ops = mlx4_ctx_ops;
+ if (mlx4_query_device(&context->ibv_ctx, &dev_attrs))
+ goto query_free;
+
+ context->max_qp_wr = dev_attrs.max_qp_wr;
+ context->max_sge = dev_attrs.max_sge;
+ context->max_cqe = dev_attrs.max_cqe;
+
return &context->ibv_ctx;
+query_free:
+ munmap(context->uar, to_mdev(ibdev)->page_size);
+ if (context->bf_page)
+ munmap(context->bf_page, to_mdev(ibdev)->page_size);
+
err_free:
free(context);
return NULL;
Index: libmlx4/src/mlx4.h
===================================================================
--- libmlx4.orig/src/mlx4.h 2008-06-03 15:45:18.000000000 +0300
+++ libmlx4/src/mlx4.h 2008-06-04 08:24:10.000000000 +0300
@@ -83,6 +83,20 @@
#define PFX "mlx4: "
+#ifndef max
+#define max(a,b) \
+ ({ typeof (a) _a = (a); \
+ typeof (b) _b = (b); \
+ _a > _b ? _a : _b; })
+#endif
+
+#ifndef min
+#define min(a,b) \
+ ({ typeof (a) _a = (a); \
+ typeof (b) _b = (b); \
+ _a < _b ? _a : _b; })
+#endif
+
enum {
MLX4_CQ_ENTRY_SIZE = 0x20
};
@@ -156,6 +170,9 @@ struct mlx4_context {
int num_qps;
int qp_table_shift;
int qp_table_mask;
+ int max_qp_wr;
+ int max_sge;
+ int max_cqe;
struct mlx4_db_page *db_list[MLX4_NUM_DB_TYPE];
pthread_mutex_t db_list_mutex;