[MLX4] added initialization of port type to default values and improved debug prints...
authorleonidk <leonidk@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Tue, 17 Nov 2009 14:26:45 +0000 (14:26 +0000)
committerleonidk <leonidk@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Tue, 17 Nov 2009 14:26:45 +0000 (14:26 +0000)
We come across a case, when Port type from Registry has not been read.

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

hw/mlx4/kernel/bus/drv/drv.c
hw/mlx4/kernel/bus/net/main.c

index e720feb..06a6086 100644 (file)
@@ -276,28 +276,31 @@ end:
 }\r
 \r
 BOOLEAN __read_setup_params(PUNICODE_STRING puvalue)\r
-{    \r
-    NTSTATUS    status;    \r
-    WDFKEY hParamsKey = NULL;\r
-       DECLARE_CONST_UNICODE_STRING(KeyName, L"\\REGISTRY\\MACHINE\\SOFTWARE\\Mellanox");\r
+{\r
+       NTSTATUS    status;    \r
+       WDFKEY hParamsKey = NULL;\r
+       DECLARE_CONST_UNICODE_STRING(KeyName, L"\\Registry\\Machine\\SOFTWARE\\Mellanox");\r
        DECLARE_CONST_UNICODE_STRING(PortType, L"PortType");\r
-    \r
+\r
        status = WdfRegistryOpenKey(NULL, &KeyName, STANDARD_RIGHTS_ALL, WDF_NO_OBJECT_ATTRIBUTES, &hParamsKey);\r
        if( !NT_SUCCESS( status ) ) \r
-    {\r
-               MLX4_PRINT( TRACE_LEVEL_ERROR  ,MLX4_DBG_DEV  ,("WdfRegistryOpenKey Failed status = 0x%x\n", status));\r
-        return FALSE;\r
+       {\r
+               MLX4_PRINT( TRACE_LEVEL_WARNING  ,MLX4_DBG_DEV  ,\r
+                       ("WdfRegistryOpenKey(\\Registry\\Machine\\SOFTWARE\\Mellanox) Failed status = 0x%x\n", status));\r
+               return FALSE;\r
        }\r
-    \r
-    status = WdfRegistryQueryUnicodeString(hParamsKey, &PortType, NULL, puvalue);    \r
+\r
+       status = WdfRegistryQueryUnicodeString(hParamsKey, &PortType, NULL, puvalue);    \r
        if( !NT_SUCCESS( status ) ) \r
-    {\r
-        WdfRegistryClose(hParamsKey);\r
-        return FALSE;\r
+       {\r
+               MLX4_PRINT( TRACE_LEVEL_ERROR  ,MLX4_DBG_DEV  ,\r
+                       ("WdfRegistryQueryUnicodeString(PortType) Failed status = 0x%x\n", status));\r
+               WdfRegistryClose(hParamsKey);\r
+               return FALSE;\r
        }\r
 \r
-    WdfRegistryClose(hParamsKey);    \r
-    return TRUE;    \r
+       WdfRegistryClose(hParamsKey);    \r
+       return TRUE;    \r
 }\r
 \r
 NTSTATUS\r
@@ -306,7 +309,7 @@ __read_dev_params(IN WDFDEVICE  Device, struct mlx4_dev_params *dev_params)
        NTSTATUS status = STATUS_SUCCESS;\r
        WDFKEY hKey = NULL;\r
        WDFKEY hParamsKey = NULL;\r
-    BOOLEAN bRet = FALSE;\r
+       BOOLEAN bRet = FALSE;\r
        DECLARE_CONST_UNICODE_STRING(Parameters, L"Parameters");\r
        DECLARE_CONST_UNICODE_STRING(PortType, L"PortType");\r
 \r
@@ -316,31 +319,36 @@ __read_dev_params(IN WDFDEVICE  Device, struct mlx4_dev_params *dev_params)
        uvalue.Buffer = uvalue_data;\r
        uvalue.MaximumLength = MAX_UVALUE;\r
        uvalue.Length = 0;\r
-    \r
+\r
+       // default values\r
+       dev_params->mod_port_type[0] = MLX4_PORT_TYPE_IB;\r
+       dev_params->mod_port_type[1] = MLX4_PORT_TYPE_IB;\r
+\r
        status = WdfDeviceOpenRegistryKey(Device, PLUGPLAY_REGKEY_DRIVER, \r
                STANDARD_RIGHTS_ALL, WDF_NO_OBJECT_ATTRIBUTES, &hKey);\r
        if( !NT_SUCCESS( status ) ) {\r
-               MLX4_PRINT( TRACE_LEVEL_ERROR  ,MLX4_DBG_DEV  ,("WdfDeviceOpenRegistryKey Failed status = 0x%x\n", status));\r
+               MLX4_PRINT( TRACE_LEVEL_ERROR  ,MLX4_DBG_DEV  ,\r
+                       ("WdfDeviceOpenRegistryKey(\\Registry\\Machine\\Control\\Class\\...) Failed status = 0x%x\n", status));\r
                goto err;\r
        }\r
 \r
        status = WdfRegistryOpenKey(hKey, &Parameters, STANDARD_RIGHTS_ALL, WDF_NO_OBJECT_ATTRIBUTES, &hParamsKey);\r
        if( !NT_SUCCESS( status ) ) {\r
-               MLX4_PRINT( TRACE_LEVEL_ERROR  ,MLX4_DBG_DEV  ,("WdfRegistryOpenKey Failed status = 0x%x\n", status));\r
+               MLX4_PRINT( TRACE_LEVEL_ERROR  ,MLX4_DBG_DEV  ,("WdfRegistryOpenKey(Prameters) Failed status = 0x%x\n", status));\r
                goto err;\r
        }\r
 \r
-    bRet = __read_setup_params(&uvalue);\r
-    if (bRet == TRUE)\r
-    {\r
-        status = WdfRegistryAssignValue(hParamsKey, &PortType, REG_SZ,uvalue.Length,uvalue.Buffer);        \r
-        if( !NT_SUCCESS( status ) ) {\r
-            MLX4_PRINT( TRACE_LEVEL_ERROR  ,MLX4_DBG_DEV  ,("WdfRegistryAssignValue Failed status = 0x%x\n", status));\r
-            goto err;\r
-        }        \r
-        uvalue.Length = 0;\r
-    }\r
-    \r
+       bRet = __read_setup_params(&uvalue);\r
+       if (bRet == TRUE)\r
+       {\r
+               status = WdfRegistryAssignValue(hParamsKey, &PortType, REG_SZ,uvalue.Length,uvalue.Buffer);        \r
+               if( !NT_SUCCESS( status ) ) {\r
+                       MLX4_PRINT( TRACE_LEVEL_ERROR  ,MLX4_DBG_DEV  ,("WdfRegistryAssignValue(PortType) Failed status = 0x%x\n", status));\r
+                       goto err;\r
+               }\r
+               uvalue.Length = 0;\r
+       }\r
+\r
     memset(&uvalue_data,0,sizeof(uvalue_data));\r
 \r
        status = WdfRegistryQueryUnicodeString(hParamsKey, &PortType, NULL, &uvalue);\r
@@ -366,10 +374,6 @@ __read_dev_params(IN WDFDEVICE  Device, struct mlx4_dev_params *dev_params)
                 L"%s",uvalue_data);                \r
                }\r
        }\r
-       else {\r
-               dev_params->mod_port_type[0] = MLX4_PORT_TYPE_IB;\r
-               dev_params->mod_port_type[1] = MLX4_PORT_TYPE_IB;\r
-       }\r
 \r
 err:\r
        if (hKey != NULL) \r
index b9087d4..c9fdc1d 100644 (file)
@@ -274,10 +274,16 @@ static int mlx4_dev_cap(struct mlx4_dev *dev, struct mlx4_dev_cap *dev_cap)
                if (port_type[i-1] & dev_cap->supported_port_types[i])
                        dev->caps.port_type[i] = port_type[i-1];
                else {
+                       if (dev_cap->supported_port_types[i] & MLX4_PORT_TYPE_IB)
+                               dev->caps.port_type[i] = MLX4_PORT_TYPE_IB;
+                       else
+                               dev->caps.port_type[i] = MLX4_PORT_TYPE_ETH;
+
                        MLX4_PRINT_EV(TRACE_LEVEL_WARNING,MLX4_DBG_DRV ,
-                               ("Requested port type %#x for port %d is "
-                               "not supported by HW. Supported %#x. We'll working to the supported one! \n", 
-                               port_type[i-1], i, (int)dev_cap->supported_port_types[i]));
+                               ("Port %d: Unsupported requested port type %#x. We'll use #%x from supported %#x! \n", 
+                               i, port_type[i-1], dev->caps.port_type[i], 
+                               (int)dev_cap->supported_port_types[i]));
+                       
                        MLX4_PRINT_EV(TRACE_LEVEL_WARNING ,MLX4_DBG_DRV ,
                                ("Ven %x Dev %d Fw %d.%d.%d, IsBurnDevice %s\n", 
                                (unsigned)dev->pdev->ven_id, (unsigned)dev->pdev->dev_id,
@@ -286,8 +292,6 @@ static int mlx4_dev_cap(struct mlx4_dev *dev, struct mlx4_dev_cap *dev_cap)
                                (int) (dev->caps.fw_ver & 0xffff),
                                mlx4_is_livefish(dev) ? "Y" : "N"
                                ));
-                       
-                       dev->caps.port_type[i] = dev_cap->supported_port_types[i];
                }
                if (dev->caps.log_num_macs > dev_cap->log_max_macs[i]) {
                        dev->caps.log_num_macs = dev_cap->log_max_macs[i];