[ofw] [patch] Support different parameters for different mlx4 cards.

Tzachi Dar tzachid at mellanox.co.il
Sun Mar 29 08:55:45 PDT 2009


Index: Q:/projinf4/trunk/hw/mlx4/kernel/bus/net/main.c
===================================================================
--- Q:/projinf4/trunk/hw/mlx4/kernel/bus/net/main.c (revision 4206)
+++ Q:/projinf4/trunk/hw/mlx4/kernel/bus/net/main.c (revision 4207)
@@ -159,7 +159,7 @@
  struct mlx4_dev *mdev = dev;
 
  for (i = 0; i < MLX4_MAX_PORTS; i++) 
-  port_type[i] = g.mod_port_type[i];
+  port_type[i] = dev->dev_params.mod_port_type[i];
 
  err = mlx4_QUERY_DEV_CAP(dev, dev_cap);
  if (err) {
@@ -886,13 +886,15 @@
  return NULL;
 }
 
-int mlx4_init_one(struct pci_dev *pdev)
+
+int mlx4_init_one(struct pci_dev *pdev, struct mlx4_dev_params
*dev_params)
 {
  struct pci_device_id *id;
  struct mlx4_priv *priv;
  struct mlx4_dev *dev;
  int err;
  NTSTATUS status;
+ int i;
 
 #ifdef FORCE_LIVEFISH
   if (pdev)
@@ -964,6 +966,9 @@
   goto end;
  }
 
+ for (i = 0; i < MLX4_MAX_PORTS; i++) 
+  dev->dev_params.mod_port_type[i] = dev_params->mod_port_type[i];
+
  /*
   * Now reset the HCA before we touch the PCI capabilities or
   * attempt a firmware command, since a boot ROM may have left
@@ -1077,8 +1082,11 @@
 
 int mlx4_restart_one(struct pci_dev *pdev)
 {
+ struct mlx4_dev_params dev_params;
+ mlx4_copy_dev_params(&dev_params, &pdev->dev->dev_params);
+
  mlx4_remove_one(pdev, FALSE);
- return mlx4_init_one(pdev);
+ return mlx4_init_one(pdev, &dev_params);
 }
 
 void mlx4_net_init()
Index: Q:/projinf4/trunk/hw/mlx4/kernel/bus/net/mlx4.h
===================================================================
--- Q:/projinf4/trunk/hw/mlx4/kernel/bus/net/mlx4.h (revision 4206)
+++ Q:/projinf4/trunk/hw/mlx4/kernel/bus/net/mlx4.h (revision 4207)
@@ -83,7 +83,6 @@
 
  int mod_enable_qos;
  int mod_mlx4_blck_lb;
- enum mlx4_port_type mod_port_type[MLX4_MAX_PORTS];
  int mod_interrupt_from_first;
 
  int mod_affinity;
@@ -421,7 +420,7 @@
 
 void mlx4_handle_catas_err(struct mlx4_dev *dev);
 
-int mlx4_init_one(struct pci_dev *pdev);
+int mlx4_init_one(struct pci_dev *pdev, struct mlx4_dev_params
*dev_params);
 
 void mlx4_remove_one(struct pci_dev *pdev, int reset);
 
Index: Q:/projinf4/trunk/hw/mlx4/kernel/bus/inc/device.h
===================================================================
--- Q:/projinf4/trunk/hw/mlx4/kernel/bus/inc/device.h (revision 4206)
+++ Q:/projinf4/trunk/hw/mlx4/kernel/bus/inc/device.h (revision 4207)
@@ -337,6 +337,17 @@
 
 #define MLX4_DEV_SIGNATURE 0xf1b34a6e
 
+struct mlx4_dev_params {
+ enum mlx4_port_type mod_port_type[MLX4_MAX_PORTS];
+} ;
+
+static inline void mlx4_copy_dev_params(
+ struct mlx4_dev_params *dst,
+ struct mlx4_dev_params *src)
+{
+ *dst = *src;
+}
+
 struct mlx4_dev {
  u32   signature;
  struct pci_dev        *pdev;
@@ -346,6 +357,7 @@
  struct radix_tree_root qp_table_tree;
  u32   rev_id;
  char   board_id[MLX4_BOARD_ID_LEN];
+ struct mlx4_dev_params dev_params;
 };
 
 struct mlx4_init_port_param {
Index: Q:/projinf4/trunk/hw/mlx4/kernel/bus/drv/mlx4_bus.inx
===================================================================
--- Q:/projinf4/trunk/hw/mlx4/kernel/bus/drv/mlx4_bus.inx (revision
4206)
+++ Q:/projinf4/trunk/hw/mlx4/kernel/bus/drv/mlx4_bus.inx (revision
4207)
@@ -138,12 +138,15 @@
 
 [MLX4BUS.DDInstall.ntx86]
 CopyFiles = MLX4BUS.CopyFiles
+AddReg    = MLX4BUS.SoftwareReg
 
 [MLX4BUS.DDInstall.ntamd64]
 CopyFiles = MLX4BUS.CopyFiles
+AddReg    = MLX4BUS.SoftwareReg
 
 [MLX4BUS.DDInstall.ntia64]
 CopyFiles = MLX4BUS.CopyFiles
+AddReg    = MLX4BUS.SoftwareReg
 
 [MLX4BUS.DDInstall.ntx86.Services]
 AddService =
mlx4_bus,%SPSVCINST_ASSOCSERVICE%,MLX4BUS.ServiceInstall,MLX4BUS.EventLo
g
@@ -178,6 +181,9 @@
 HKR, , EventMessageFile, 0x00020000,
"%%SystemRoot%%\System32\IoLogMsg.dll;%%SystemRoot%%\System32\drivers\ml
x4_bus.sys"
 HKR, , TypesSupported,   0x00010001, 7
 
+[MLX4BUS.SoftwareReg]
+HKR,"Parameters","PortType",%REG_SZ%,"ib,ib"
+
 [MLX4BUS.ParamsReg]
 HKR,,DeviceCharacteristics,0x10001,0x0100         ; Use same security
checks on relative opens
 HKR,,Security,,"D:P(A;;GA;;;BA)(A;;GA;;;SY)"      ; Allow generic-all
access to Built-in administrators and Local system 
@@ -197,9 +203,9 @@
 HKR,"Parameters","NumMac",%REG_DWORD%,0x00000001
 HKR,"Parameters","NumVlan",%REG_DWORD%,0x00000000
 HKR,"Parameters","UsePrio",%REG_DWORD%,0x00000000
-HKR,"Parameters","PortType",%REG_SZ%,"ib,ib"
 
 
+
 
HKLM,"System\CurrentControlSet\Control\WMI\GlobalLogger\E51BB6E2-914A-4e
21-93C0-192F4801BBFF","Flags",%REG_DWORD%,0xffff
 
HKLM,"System\CurrentControlSet\Control\WMI\GlobalLogger\E51BB6E2-914A-4e
21-93C0-192F4801BBFF","Level",%REG_DWORD%,0x3
 
Index: Q:/projinf4/trunk/hw/mlx4/kernel/bus/drv/drv.c
===================================================================
--- Q:/projinf4/trunk/hw/mlx4/kernel/bus/drv/drv.c (revision 4206)
+++ Q:/projinf4/trunk/hw/mlx4/kernel/bus/drv/drv.c (revision 4207)
@@ -257,9 +257,74 @@
  return status;
 }
 
+ 
+NTSTATUS
+__read_dev_params(IN WDFDEVICE  Device, struct mlx4_dev_params
*dev_params)
+{
+ NTSTATUS status = STATUS_SUCCESS;
+ WDFKEY hKey = NULL;
+ WDFKEY hParamsKey = NULL;
+ DECLARE_CONST_UNICODE_STRING(Parameters, L"Parameters");
+ DECLARE_CONST_UNICODE_STRING(PortType, L"PortType");
+#define  MAX_UVALUE 100
+ WCHAR uvalue_data[MAX_UVALUE];
+ UNICODE_STRING uvalue;
+ 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));
+  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));
+  goto err;
+ }
+
+ uvalue.Buffer = uvalue_data;
+ uvalue.MaximumLength = MAX_UVALUE;
+ uvalue.Length = 0;
+
+ status = WdfRegistryQueryUnicodeString(hParamsKey, &PortType, NULL,
&uvalue);
+ if (NT_SUCCESS (status)) {
+  if (!wcscmp(uvalue_data, L"ib,ib")) {
+   dev_params->mod_port_type[0] = MLX4_PORT_TYPE_IB;
+   dev_params->mod_port_type[1] = MLX4_PORT_TYPE_IB;
+  } else
+  if (!wcscmp(uvalue_data, L"ib,eth")) {
+   dev_params->mod_port_type[0] = MLX4_PORT_TYPE_IB;
+   dev_params->mod_port_type[1] = MLX4_PORT_TYPE_ETH;
+  } else
+  if (!wcscmp(uvalue_data, L"eth,ib")) {
+   dev_params->mod_port_type[0] = MLX4_PORT_TYPE_ETH;
+   dev_params->mod_port_type[1] = MLX4_PORT_TYPE_IB;
+  } else
+  if (!wcscmp(uvalue_data, L"eth,eth")) {
+   dev_params->mod_port_type[0] = MLX4_PORT_TYPE_ETH;
+   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) 
+  WdfRegistryClose(hKey);
+
+ if (hParamsKey != NULL) 
+  WdfRegistryClose(hParamsKey);
+
+ return status;
+}
+
+
 static 
 NTSTATUS
-__start_card( 
+__start_card(
+ IN WDFDEVICE  Device,
  IN PFDO_DEVICE_DATA p_fdo 
  )
 {
@@ -269,12 +334,17 @@
  int err;
  NTSTATUS status = STATUS_SUCCESS;
  struct pci_dev *pdev = &p_fdo->pci_dev;
+ struct mlx4_dev_params dev_params;
 
  MLX4_ENTER(MLX4_DBG_DRV);
 
  if ( p_fdo->card_started )
   goto err; 
-  
+
+ status = __read_dev_params(Device, &dev_params);
+ if( !NT_SUCCESS( status ) ) 
+  goto err;
+
  // enable the card
  status = pci_hca_enable( &pdev->bus_pci_ifc, &pdev->pci_cfg_space );
  if( !NT_SUCCESS( status ) ) 
@@ -291,7 +361,7 @@
 #endif 
 
  // NET library
- err = mlx4_init_one( &p_fdo->pci_dev );
+ err = mlx4_init_one( &p_fdo->pci_dev, &dev_params );
  if (err) {
   status = errno_to_ntstatus(err);
   goto err;
@@ -323,12 +393,12 @@
 
  p_fdo->bus_ib_ifc.pdev = &p_fdo->pci_dev;
  p_fdo->bus_ib_ifc.p_ibdev = p_fdo->pci_dev.ib_dev;
-    p_fdo->bus_ib_ifc.is_livefish =
mlx4_is_livefish(p_fdo->pci_dev.dev);    
-    if ( p_fdo->bus_ib_ifc.is_livefish == 0 ) {
-        p_fdo->bus_ib_ifc.pmlx4_dev =
to_mdev(p_fdo->pci_dev.ib_dev)->dev;    
-     if ( p_fdo->bus_ib_ifc.pmlx4_dev->flags & MLX4_FLAG_MSI_X )
-      p_fdo->bus_ib_ifc.n_msi_vectors = p_fdo->pci_dev.n_msi_vectors -
2;
-    }
+ p_fdo->bus_ib_ifc.is_livefish = mlx4_is_livefish(p_fdo->pci_dev.dev);

+ if ( p_fdo->bus_ib_ifc.is_livefish == 0 ) {
+  p_fdo->bus_ib_ifc.pmlx4_dev = to_mdev(p_fdo->pci_dev.ib_dev)->dev;

+  if ( p_fdo->bus_ib_ifc.pmlx4_dev->flags & MLX4_FLAG_MSI_X )
+   p_fdo->bus_ib_ifc.n_msi_vectors = p_fdo->pci_dev.n_msi_vectors - 2;
+ }
 
  p_fdo->card_started = TRUE;
 
@@ -367,7 +437,7 @@
 
  // start card (needed after Hibernetion)
  if (PreviousState > WdfPowerDeviceD0)
-  __start_card( p_fdo );
+  __start_card( Device, p_fdo );
  mdev = pdev->dev;
 
  // create child device
@@ -685,7 +755,7 @@
  }
 
  // start the card
- status = __start_card( p_fdo );
+ status = __start_card(Device, p_fdo );
  
 err:
  MLX4_EXIT( MLX4_DBG_DRV );
@@ -991,19 +1061,12 @@
  // "Measure the interrupt from the first packet (default 1)"
  DECLARE_CONST_UNICODE_STRING(InterruptFromFirstPacket,
L"InterruptFromFirstPacket"); 
 
- // "Ports L2 type (ib/eth/auto, entry per port, comma seperated,
default ib for all)"
- DECLARE_CONST_UNICODE_STRING(PortType, L"PortType");
-
  // "ProcessorAffinity"
  DECLARE_CONST_UNICODE_STRING(ProcessorAffinity, L"ProcessorAffinity");
 
  ULONG value;
  WDFKEY hKey = NULL;
  NTSTATUS status = STATUS_SUCCESS;
-
- UNICODE_STRING uvalue;
-#define  MAX_UVALUE 100
- WCHAR uvalue_data[MAX_UVALUE];
  
  status = WdfDriverOpenParametersRegistryKey( *hDriver,
   STANDARD_RIGHTS_ALL, WDF_NO_OBJECT_ATTRIBUTES, &hKey );
@@ -1093,35 +1156,7 @@
   else
    g.mod_affinity = 0;
   
-  uvalue.Buffer = uvalue_data;
-  uvalue.MaximumLength = MAX_UVALUE;
-  uvalue.Length = 0;
 
-  status = WdfRegistryQueryUnicodeString(hKey, &PortType, NULL,
&uvalue);
-  if (NT_SUCCESS (status)) {
-   if (!wcscmp(uvalue_data, L"ib,ib")) {
-    g.mod_port_type [0] = MLX4_PORT_TYPE_IB;
-    g.mod_port_type [1] = MLX4_PORT_TYPE_IB;
-   } else
-   if (!wcscmp(uvalue_data, L"ib,eth")) {
-    g.mod_port_type [0] = MLX4_PORT_TYPE_IB;
-    g.mod_port_type [1] = MLX4_PORT_TYPE_ETH;
-   } else
-   if (!wcscmp(uvalue_data, L"eth,ib")) {
-    g.mod_port_type [0] = MLX4_PORT_TYPE_ETH;
-    g.mod_port_type [1] = MLX4_PORT_TYPE_IB;
-   } else
-   if (!wcscmp(uvalue_data, L"eth,eth")) {
-    g.mod_port_type [0] = MLX4_PORT_TYPE_ETH;
-    g.mod_port_type [1] = MLX4_PORT_TYPE_ETH;
-   }
-  }
-  else {
-   g.mod_port_type [0] = MLX4_PORT_TYPE_IB;
-   g.mod_port_type [1] = MLX4_PORT_TYPE_IB;
-  }
-
-
   WdfRegistryClose(hKey);
   status = STATUS_SUCCESS;
  }

 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openfabrics.org/pipermail/ofw/attachments/20090329/d6bc8955/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mlx4_dev_params.diff
Type: application/octet-stream
Size: 10854 bytes
Desc: mlx4_dev_params.diff
URL: <http://lists.openfabrics.org/pipermail/ofw/attachments/20090329/d6bc8955/attachment.obj>


More information about the ofw mailing list