[ofw] Allow mlx4 to support Ethernet devices

Tzachi Dar tzachid at mellanox.co.il
Sun May 18 23:56:27 PDT 2008


The following checkin, is the first one needed in order to allow
Connectx to support IB devices as well as Ethernet devices.
 
More changes will follow in the future.
 
Thanks
Tzachi
 
Index: mlx4/kernel/bus/drv/drv.c
===================================================================
--- mlx4/kernel/bus/drv/drv.c (revision 1182)
+++ mlx4/kernel/bus/drv/drv.c (working copy)
@@ -105,6 +105,7 @@
 __create_child(
  __in WDFDEVICE  Device,
  __in PWCHAR     HardwareIds,
+ __in PWCHAR     DeviceDescription,
  __in ULONG      SerialNo
  )
 
@@ -189,7 +190,7 @@
   // the list locked for enumeration.  The enumeration lock applies
only
   // to enumeration, not addition or removal.
   //
-  status = create_pdo(Device, HardwareIds, SerialNo);
+  status = create_pdo(Device, HardwareIds, DeviceDescription,
SerialNo);
  }
 
  WdfFdoUnlockStaticChildListFromIteration(Device);
@@ -199,7 +200,18 @@
  return status;
 }
 
+// TODO: Replace this functions with real ones
+int mlx4_count_ib_ports() {
+ return 1;
+}
 
+BOOLEAN mlx4_is_eth_port(int port_id)
+{
+ if ( port_id == 0 )return FALSE;
+ return FALSE;
+}
+
+
 NTSTATUS
 __do_static_enumeration(
  IN WDFDEVICE Device
@@ -220,15 +232,36 @@
 --*/
 
 {
- NTSTATUS status;
+ NTSTATUS status = STATUS_SUCCESS;
+ int i;
+ int number_of_ib_ports;
 
+ // TODO:Need to add an event log in the case of errors
+
  MLX4_ENTER(MLX4_DBG_DRV);
 
-  // eventually we'll have all information about children in Registry
+ // eventually we'll have all information about children in Registry
  // DriverEntry will read it into a Global storage and
  // this routine will create all the children on base on this info
+ number_of_ib_ports = mlx4_count_ib_ports();
+ ASSERT(number_of_ib_ports >=0 && number_of_ib_ports <=2);
+ 
+ if(number_of_ib_ports > 0) {
+  status = __create_child(Device, BUS_HARDWARE_IDS,
BUS_HARDWARE_DESCRIPTION, 0 );
+  if (!NT_SUCCESS(status)) {
+    MLX4_PRINT(TRACE_LEVEL_ERROR, MLX4_DBG_DRV, ("__create_child
(ib)failed with 0x%x\n", status));
+  }
+ }
 
- status = __create_child(Device, BUS_HARDWARE_IDS, 0 );
+ // Create ethernet ports if needed
+ for (i = 0; i < MLX4_MAX_PORTS; i++) {
+  if(mlx4_is_eth_port(i)) {
+   status = __create_child(Device, ETH_HARDWARE_IDS,
ETH_HARDWARE_DESCRIPTION, i+1 );
+   if (!NT_SUCCESS(status)) {
+     MLX4_PRINT(TRACE_LEVEL_ERROR, MLX4_DBG_DRV, ("__create_child (eth)
failed with 0x%x\n", status));
+   }
+  }
+ }
 
  MLX4_EXIT( MLX4_DBG_DRV );
  return status;
@@ -251,7 +284,7 @@
 
  status = __do_static_enumeration(Device);
  if (!NT_SUCCESS(status)) {
-   MLX4_PRINT(TRACE_LEVEL_ERROR, MLX4_DBG_DRV, ("DoStaticEnumeration
failed with 0x%x\n", status));
+   MLX4_PRINT(TRACE_LEVEL_ERROR, MLX4_DBG_DRV,
("__do_static_enumeration failed with 0x%x\n", status));
  }
 
  {
@@ -516,7 +549,7 @@
  // get resources
  status = __get_resources( p_fdo, ResourcesRaw, ResourcesTranslated );
  if( !NT_SUCCESS( status ) ) {
-  MLX4_PRINT(TRACE_LEVEL_ERROR, MLX4_DBG_DRV, ("__get_bus_ifc failed:
status=0x%x\n", status));
+  MLX4_PRINT(TRACE_LEVEL_ERROR, MLX4_DBG_DRV, ("__get_resources failed:
status=0x%x\n", status));
   goto err;
  }
 
@@ -567,11 +600,11 @@
  //
 
  // fill the header
- p_fdo->bus_ib_ifc.Size = sizeof(MLX4_BUS_IB_INTERFACE);
- p_fdo->bus_ib_ifc.Version = MLX4_BUS_IB_INTERFACE_VERSION;
+ p_fdo->bus_ib_ifc.i.Size = sizeof(MLX4_BUS_IB_INTERFACE);
+ p_fdo->bus_ib_ifc.i.Version = MLX4_BUS_IB_INTERFACE_VERSION;
  // Let the framework handle reference counting.
- p_fdo->bus_ib_ifc.InterfaceReference =
WdfDeviceInterfaceReferenceNoOp;
- p_fdo->bus_ib_ifc.InterfaceDereference =
WdfDeviceInterfaceDereferenceNoOp;
+ p_fdo->bus_ib_ifc.i.InterfaceReference =
WdfDeviceInterfaceReferenceNoOp;
+ p_fdo->bus_ib_ifc.i.InterfaceDereference =
WdfDeviceInterfaceDereferenceNoOp;
 
  p_fdo->bus_ib_ifc.pdev = &p_fdo->pci_dev;
  p_fdo->bus_ib_ifc.p_ibdev = p_fdo->pci_dev.ib_dev;
@@ -1001,3 +1034,4 @@
 }
 
 
+
Index: mlx4/kernel/bus/drv/drv.h
===================================================================
--- mlx4/kernel/bus/drv/drv.h (revision 1182)
+++ mlx4/kernel/bus/drv/drv.h (working copy)
@@ -67,6 +67,8 @@
  int       dma_adapter_taken;
  res_interrupt_t    interrupt[MLX4_MAX_INTERRUPTS];
  MLX4_BUS_IB_INTERFACE  bus_ib_ifc;
+ // Data for the Ethernet device
+ struct VipBusIfc   mtnic_Ifc;
 
 } FDO_DEVICE_DATA, *PFDO_DEVICE_DATA;
 
@@ -216,6 +218,8 @@
 create_pdo(
  __in WDFDEVICE  Device,
  __in PWCHAR     HardwareIds,
+ __in PWCHAR     DeviceDescription,
  __in ULONG      SerialNo
 );
 
+
Index: mlx4/kernel/bus/drv/pdo.c
===================================================================
--- mlx4/kernel/bus/drv/pdo.c (revision 1182)
+++ mlx4/kernel/bus/drv/pdo.c (working copy)
@@ -16,6 +16,7 @@
 create_pdo(
  __in WDFDEVICE  Device,
  __in PWCHAR     HardwareIds,
+ __in PWCHAR     DeviceDescription,
  __in ULONG      SerialNo
 )
 /*++
@@ -40,13 +41,14 @@
  WDF_OBJECT_ATTRIBUTES       pdoAttributes;
  WDF_DEVICE_PNP_CAPABILITIES pnpCaps;
  WDF_DEVICE_POWER_CAPABILITIES powerCaps;
- DECLARE_CONST_UNICODE_STRING(compatId, BUSENUM_COMPATIBLE_IDS);
+ UNICODE_STRING compatId;
  DECLARE_CONST_UNICODE_STRING(deviceLocation, L"MLX4 Bus 0");
  UNICODE_STRING deviceId;
  DECLARE_UNICODE_STRING_SIZE(buffer, MAX_ID_LEN);
 
  MLX4_PRINT(TRACE_LEVEL_INFORMATION, MLX4_DBG_DRV, ("Entered
CreatePdo\n"));
 
+ RtlInitUnicodeString(&compatId, HardwareIds);
  PAGED_CODE();
 
  //
@@ -107,7 +109,8 @@
  // coinstallers to display in the device manager. FriendlyName takes
  // precedence over the DeviceDesc from the INF file.
  //
- status = RtlUnicodeStringPrintf(&buffer,L"Mellanox ConnectX Virtual
Infiniband Adapter (#%02d)", SerialNo );
+ status = RtlUnicodeStringPrintf(&buffer,DeviceDescription  , SerialNo
);
+ 
  if (!NT_SUCCESS(status)) {
   goto Cleanup;
  }
@@ -181,11 +184,14 @@
 
  WdfDeviceSetPowerCapabilities(hChild, &powerCaps);
 
+ p_fdo->bus_ib_ifc.port_id = SerialNo;
+ p_fdo->bus_ib_ifc.pVipBusIfc = &p_fdo->mtnic_Ifc;
+ p_fdo->bus_ib_ifc.pVipBusIfc->ulAllocatePortObjSize = MAX_PORT_SIZE;
  //
  // Create a custom interface so that other drivers can
  // query (IRP_MN_QUERY_INTERFACE) and use our callbacks directly.
  //
- p_fdo->bus_ib_ifc.Context = p_pdo;
+ p_fdo->bus_ib_ifc.i.Context = p_pdo;
 
  WDF_QUERY_INTERFACE_CONFIG_INIT( &p_pdo->qiMlx4Bus,
   (PINTERFACE) &p_fdo->bus_ib_ifc,
@@ -238,3 +244,4 @@
  return status;
 }
 
+
Index: mlx4/kernel/bus/drv/precomp.h
===================================================================
--- mlx4/kernel/bus/drv/precomp.h (revision 1182)
+++ mlx4/kernel/bus/drv/precomp.h (working copy)
@@ -6,6 +6,7 @@
 #include "public.h"
 #include "l2w.h"
 #include "ib\mlx4_ib.h"
+#include "vip_dev.h"
 #include "drv.h"
 #if 0
 #include "mxe_hca.h"
@@ -16,3 +17,4 @@
 #include "mxe_drv.h"
 #endif
 
+
Index: mlx4/kernel/bus/inc/bus_intf.h
===================================================================
--- mlx4/kernel/bus/inc/bus_intf.h (revision 1182)
+++ mlx4/kernel/bus/inc/bus_intf.h (working copy)
@@ -1,17 +1,21 @@
 #pragma once
 
-#define MLX4_BUS_IB_INTERFACE_VERSION  1
+#define MLX4_BUS_IB_INTERFACE_VERSION  2
 
 //
 // Interface for work with MLX4 IB driver
 //
+
 #pragma warning(disable:4201) // nameless struct/union
 typedef struct _MLX4_BUS_IB_INTERFACE{
- INTERFACE;
+ INTERFACE i;
  struct ib_device  * p_ibdev;
  struct pci_dev   * pdev;
  int       is_livefish;
+ ULONG      port_id;
+ struct VipBusIfc   *pVipBusIfc;
  
 } MLX4_BUS_IB_INTERFACE, *PMLX4_BUS_IB_INTERFACE;
 #pragma warning(default:4201) // nameless struct/union
 
+

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openfabrics.org/pipermail/ofw/attachments/20080519/c302b31d/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mlx4_eth.patch
Type: application/octet-stream
Size: 7580 bytes
Desc: mlx4_eth.patch
URL: <http://lists.openfabrics.org/pipermail/ofw/attachments/20080519/c302b31d/attachment.obj>


More information about the ofw mailing list