[ofw][patch][mlx4] added initialization of port type to default values and improved debug prints.

Leonid Keller leonid at mellanox.co.il
Mon Nov 16 00:41:55 PST 2009


We come across a case, when Port type from Registry has not been read.

 
Index: V:/svn/winib/trunk/hw/mlx4/kernel/bus/net/main.c
===================================================================
--- V:/svn/winib/trunk/hw/mlx4/kernel/bus/net/main.c (revision 5024)
+++ V:/svn/winib/trunk/hw/mlx4/kernel/bus/net/main.c (revision 5025)
@@ -274,10 +274,16 @@
   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 @@
     (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];
Index: V:/svn/winib/trunk/hw/mlx4/kernel/bus/drv/drv.c
===================================================================
--- V:/svn/winib/trunk/hw/mlx4/kernel/bus/drv/drv.c (revision 5024)
+++ V:/svn/winib/trunk/hw/mlx4/kernel/bus/drv/drv.c (revision 5025)
@@ -276,28 +276,31 @@
 }
 
 BOOLEAN __read_setup_params(PUNICODE_STRING puvalue)
-{    
-    NTSTATUS    status;    
-    WDFKEY hParamsKey = NULL;
- DECLARE_CONST_UNICODE_STRING(KeyName,
L"\\REGISTRY\\MACHINE\\SOFTWARE\\Mellanox");
+{
+ NTSTATUS    status;    
+ WDFKEY hParamsKey = NULL;
+ DECLARE_CONST_UNICODE_STRING(KeyName,
L"\\Registry\\Machine\\SOFTWARE\\Mellanox");
  DECLARE_CONST_UNICODE_STRING(PortType, L"PortType");
-    
+
  status = WdfRegistryOpenKey(NULL, &KeyName, STANDARD_RIGHTS_ALL,
WDF_NO_OBJECT_ATTRIBUTES, &hParamsKey);
  if( !NT_SUCCESS( status ) ) 
-    {
-  MLX4_PRINT( TRACE_LEVEL_ERROR  ,MLX4_DBG_DEV  ,("WdfRegistryOpenKey
Failed status = 0x%x\n", status));
-        return FALSE;
+ {
+  MLX4_PRINT( TRACE_LEVEL_WARNING  ,MLX4_DBG_DEV  ,
+   ("WdfRegistryOpenKey(\\Registry\\Machine\\SOFTWARE\\Mellanox) Failed
status = 0x%x\n", status));
+  return FALSE;
  }
-    
-    status = WdfRegistryQueryUnicodeString(hParamsKey, &PortType, NULL,
puvalue);    
+
+ status = WdfRegistryQueryUnicodeString(hParamsKey, &PortType, NULL,
puvalue);    
  if( !NT_SUCCESS( status ) ) 
-    {
-        WdfRegistryClose(hParamsKey);
-        return FALSE;
+ {
+  MLX4_PRINT( TRACE_LEVEL_ERROR  ,MLX4_DBG_DEV  ,
+   ("WdfRegistryQueryUnicodeString(PortType) Failed status = 0x%x\n",
status));
+  WdfRegistryClose(hParamsKey);
+  return FALSE;
  }
 
-    WdfRegistryClose(hParamsKey);    
-    return TRUE;    
+ WdfRegistryClose(hParamsKey);    
+ return TRUE;    
 }
 
 NTSTATUS
@@ -306,7 +309,7 @@
  NTSTATUS status = STATUS_SUCCESS;
  WDFKEY hKey = NULL;
  WDFKEY hParamsKey = NULL;
-    BOOLEAN bRet = FALSE;
+ BOOLEAN bRet = FALSE;
  DECLARE_CONST_UNICODE_STRING(Parameters, L"Parameters");
  DECLARE_CONST_UNICODE_STRING(PortType, L"PortType");
 
@@ -316,31 +319,36 @@
  uvalue.Buffer = uvalue_data;
  uvalue.MaximumLength = MAX_UVALUE;
  uvalue.Length = 0;
-    
+
+ // default values
+ dev_params->mod_port_type[0] = MLX4_PORT_TYPE_IB;
+ dev_params->mod_port_type[1] = MLX4_PORT_TYPE_IB;
+
  status = WdfDeviceOpenRegistryKey(Device, PLUGPLAY_REGKEY_DRIVER, 
   STANDARD_RIGHTS_ALL, WDF_NO_OBJECT_ATTRIBUTES, &hKey);
  if( !NT_SUCCESS( status ) ) {
-  MLX4_PRINT( TRACE_LEVEL_ERROR  ,MLX4_DBG_DEV
,("WdfDeviceOpenRegistryKey Failed status = 0x%x\n", status));
+  MLX4_PRINT( TRACE_LEVEL_ERROR  ,MLX4_DBG_DEV  ,
+   ("WdfDeviceOpenRegistryKey(\\Registry\\Machine\\Control\\Class\\...)
Failed status = 0x%x\n", status));
   goto err;
  }
 
  status = WdfRegistryOpenKey(hKey, &Parameters, STANDARD_RIGHTS_ALL,
WDF_NO_OBJECT_ATTRIBUTES, &hParamsKey);
  if( !NT_SUCCESS( status ) ) {
-  MLX4_PRINT( TRACE_LEVEL_ERROR  ,MLX4_DBG_DEV  ,("WdfRegistryOpenKey
Failed status = 0x%x\n", status));
+  MLX4_PRINT( TRACE_LEVEL_ERROR  ,MLX4_DBG_DEV
,("WdfRegistryOpenKey(Prameters) Failed status = 0x%x\n", status));
   goto err;
  }
 
-    bRet = __read_setup_params(&uvalue);
-    if (bRet == TRUE)
-    {
-        status = WdfRegistryAssignValue(hParamsKey, &PortType,
REG_SZ,uvalue.Length,uvalue.Buffer);        
-        if( !NT_SUCCESS( status ) ) {
-            MLX4_PRINT( TRACE_LEVEL_ERROR  ,MLX4_DBG_DEV
,("WdfRegistryAssignValue Failed status = 0x%x\n", status));
-            goto err;
-        }        
-        uvalue.Length = 0;
-    }
-    
+ bRet = __read_setup_params(&uvalue);
+ if (bRet == TRUE)
+ {
+  status = WdfRegistryAssignValue(hParamsKey, &PortType,
REG_SZ,uvalue.Length,uvalue.Buffer);        
+  if( !NT_SUCCESS( status ) ) {
+   MLX4_PRINT( TRACE_LEVEL_ERROR  ,MLX4_DBG_DEV
,("WdfRegistryAssignValue(PortType) Failed status = 0x%x\n", status));
+   goto err;
+  }
+  uvalue.Length = 0;
+ }
+
  status = WdfRegistryQueryUnicodeString(hParamsKey, &PortType, NULL,
&uvalue);
  if (NT_SUCCESS (status)) {
   if (!wcscmp(uvalue_data, L"ib,ib")) {
@@ -360,10 +368,6 @@
    dev_params->mod_port_type[1] = MLX4_PORT_TYPE_ETH;
   }
  }
- else {
-  dev_params->mod_port_type[0] = MLX4_PORT_TYPE_IB;
-  dev_params->mod_port_type[1] = MLX4_PORT_TYPE_IB;
- }
 
 err:
  if (hKey != NULL) 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openfabrics.org/pipermail/ofw/attachments/20091116/311aa7e9/attachment.html>


More information about the ofw mailing list