[MLX4] added new Registry parameter for number of FC_EXCHs and added a sanity check...
authorleonidk <leonidk@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Mon, 13 Jul 2009 18:28:40 +0000 (18:28 +0000)
committerleonidk <leonidk@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Mon, 13 Jul 2009 18:28:40 +0000 (18:28 +0000)
It came to fix a bug: if the number of reserved QPs is greater then the number of QPs requested, the bug causes eventual allocation of reserved QPs, which is forbidden.
The bug happened due two reasons:
  - absense of sanity check, comparing reserved and total number of QPs;
  - a large built-in number of FC_EXCH QPs, which are not in use at all today.
The patch replaces the built-in value to Registry taken one and set it to O.
It also changes the number of MACs from 1 to 0 for there is no need in reservation for MACs.

git-svn-id: svn://openib.tc.cornell.edu/gen1/trunk@2292 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86

hw/mlx4/kernel/bus/drv/drv.c
hw/mlx4/kernel/bus/drv/mlx4_bus.inx
hw/mlx4/kernel/bus/ib/main.c
hw/mlx4/kernel/bus/inc/device.h
hw/mlx4/kernel/bus/net/mlx4.h
hw/mlx4/kernel/bus/net/qp.c

index a4ca954..e4f17dc 100644 (file)
@@ -1127,7 +1127,7 @@ __read_registry(WDFDRIVER *hDriver)
        // "log maximum number of memory translation table segments per HCA"\r
        DECLARE_CONST_UNICODE_STRING(numMtt, L"LogNumMtt");     \r
 \r
-       // "Maximum number of MACs per ETH port (1-127, default 1"\r
+       // "Maximum number of MACs per ETH port (1-127, default 0"\r
        DECLARE_CONST_UNICODE_STRING(numMac, L"NumMac");        \r
 \r
        // "Maximum number of VLANs per ETH port (0-126, default 0)"\r
@@ -1136,6 +1136,9 @@ __read_registry(WDFDRIVER *hDriver)
        // "Enable steering by VLAN priority on ETH ports (0/1, default 0)"\r
        DECLARE_CONST_UNICODE_STRING(usePrio, L"UsePrio");      \r
 \r
+       // "max number of FC_EXCH (0-N, default 0)"\r
+       DECLARE_CONST_UNICODE_STRING(numFcExch, L"NumFcExch");  \r
+\r
        // "Enable Quality of Service support in the HCA if > 0, (default 1)"\r
        DECLARE_CONST_UNICODE_STRING(enableQoS, L"EnableQoS");  \r
 \r
@@ -1200,7 +1203,7 @@ __read_registry(WDFDRIVER *hDriver)
                if (NT_SUCCESS (status)) \r
                        g.mod_num_mac = value;\r
                else\r
-                       g.mod_num_mac = 1;\r
+                       g.mod_num_mac = 0;\r
 \r
                status = WdfRegistryQueryULong(hKey, &numVlan, &value);\r
                if (NT_SUCCESS (status)) \r
@@ -1214,6 +1217,12 @@ __read_registry(WDFDRIVER *hDriver)
                else\r
                        g.mod_use_prio = 0;\r
 \r
+               status = WdfRegistryQueryULong(hKey, &numFcExch, &value);\r
+               if (NT_SUCCESS (status)) \r
+                       g.mod_num_fc_exch= value;\r
+               else\r
+                       g.mod_num_fc_exch = 0;\r
+\r
                status = WdfRegistryQueryULong(hKey, &enableQoS, &value);\r
                if (NT_SUCCESS (status)) \r
                        g.mod_enable_qos = value;\r
index 4de535c..2741df1 100644 (file)
@@ -203,9 +203,10 @@ HKR,"Parameters","EnableQoS",%REG_DWORD%,0x00000000
 HKR,"Parameters","BlockMcastLoopBack",%REG_DWORD%,0x00000000\r
 HKR,"Parameters","InterruptFromFirstPacket",%REG_DWORD%,0x00000001\r
 \r
-HKR,"Parameters","NumMac",%REG_DWORD%,0x00000001\r
+HKR,"Parameters","NumMac",%REG_DWORD%,0x00000000\r
 HKR,"Parameters","NumVlan",%REG_DWORD%,0x00000000\r
 HKR,"Parameters","UsePrio",%REG_DWORD%,0x00000000\r
+HKR,"Parameters","NumFcExch",%REG_DWORD%,0x00000000\r
 \r
 \r
 \r
index a886302..79375d9 100644 (file)
@@ -101,8 +101,7 @@ static int mlx4_ib_query_device(struct ib_device *ibdev,
 
        props->max_mr_size         = ~0ull;
        props->page_size_cap       = dev->dev->caps.page_size_cap;
-       props->max_qp              = dev->dev->caps.num_qps - dev->dev->caps.reserved_qps_cnt[MLX4_QP_REGION_FW] - 
-                                dev->dev->caps.reserved_qps_cnt[MLX4_QP_REGION_FC_EXCH];
+       props->max_qp              = dev->dev->caps.num_qps - dev->dev->caps.total_reserved_qps;
        props->max_qp_wr           = dev->dev->caps.max_wqes - MLX4_IB_SQ_MAX_SPARE;
 
        props->max_sge             = min(dev->dev->caps.max_sq_sg,
index 98aa4d6..ed0d329 100644 (file)
@@ -142,9 +142,13 @@ enum qp_region {
        MLX4_QP_REGION_COUNT            /* Must be last */
 };
 
+#if 0
+// not in use now
+// should be set as default to numFcExch
 enum {
        MLX4_NUM_FEXCH          = 64 * 1024,
 };
+#endif
 
 
 struct mlx4_caps {
@@ -202,8 +206,10 @@ struct mlx4_caps {
        int                     log_num_macs;
        int                     log_num_vlans;
        int                     log_num_prios;
+       int                     num_fc_exch;
        enum mlx4_port_type     port_type[MLX4_MAX_PORTS + 1];
        int                     reserved_fexch_mpts_base;   
+       int                     total_reserved_qps;
 };
 
 struct mlx4_buf_list {
index d3f74cb..9e208ae 100644 (file)
@@ -81,6 +81,7 @@ typedef struct _GLOBALS {
        int mod_num_mac;
        int mod_num_vlan;
        int mod_use_prio;
+       int mod_num_fc_exch;
 
        int mod_enable_qos;
        int mod_mlx4_blck_lb;
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;