[MLX4] added new Registry parameter for number of FC_EXCHs and added a sanity check...
[mirror/winof/.git] / hw / mlx4 / kernel / bus / net / qp.c
index 9b5c52d..9213819 100644 (file)
@@ -287,6 +287,8 @@ int mlx4_init_qp_table(struct mlx4_dev *dev)
        struct mlx4_qp_table *qp_table = &mlx4_priv(dev)->qp_table;
        int err;
        int reserved_from_top = 0;
+// hard to believe, that someone will require less !
+#define MIN_QPS_TO_WORK_WITH   16
 
        spin_lock_init(&qp_table->lock);
        INIT_RADIX_TREE(&dev->qp_table_tree, GFP_ATOMIC);
@@ -327,12 +329,23 @@ int mlx4_init_qp_table(struct mlx4_dev *dev)
 
        }
 
-       err = mlx4_bitmap_init_with_effective_max(&qp_table->bitmap,
-                                                 dev->caps.num_qps,
-                                                 (1 << 23) - 1,
-                                                 dev->caps.sqp_start + 8,
-                                                 dev->caps.num_qps -
-                                                       reserved_from_top);
+       dev->caps.total_reserved_qps = dev->caps.sqp_start + 8 + reserved_from_top;
+       if ( dev->caps.total_reserved_qps + MIN_QPS_TO_WORK_WITH > dev->caps.num_qps ) {
+               err= -EINVAL;
+               mlx4_dbg(dev, "Not enough QPs to work with. Requested %d, reserved %d\n", 
+                       dev->caps.num_qps, dev->caps.total_reserved_qps );
+               WriteEventLogEntryData( dev->pdev->p_self_do, (ULONG)EVENT_MLX4_ERROR_NOT_ENOUGH_QPS, 0, 0, 2,
+                       L"%d", dev->caps.num_qps, 
+                       L"%d", dev->caps.total_reserved_qps 
+                       );
+       }
+       else {
+               err = mlx4_bitmap_init_with_effective_max(&qp_table->bitmap,
+                               dev->caps.num_qps,
+                               (1 << 23) - 1,
+                               dev->caps.sqp_start + 8,
+                               dev->caps.num_qps - reserved_from_top);
+       }
 
        if (err)
                return err;