[ofw][patch][mlx4] MLX4_HCA in WDF form

Leonid Keller leonid at mellanox.co.il
Sun Mar 29 08:32:15 PDT 2009


Applied in 2063.


________________________________

	From: ofw-bounces at lists.openfabrics.org
[mailto:ofw-bounces at lists.openfabrics.org] On Behalf Of Leonid Keller
	Sent: Wednesday, March 25, 2009 3:50 PM
	To: ofw at lists.openfabrics.org
	Subject: [ofw][patch][mlx4] MLX4_HCA in WDF form
	
	
	This patch is a logical successor to one, removing registration
of HCA with IBAL (2019).
	It returns MLX4_HCA to its original WDF form, but still keeps
the current WDM form under preprocessor flag.
	 
	 
	Index: hw/mlx4/kernel/hca/drv.c
	
===================================================================
	--- hw/mlx4/kernel/hca/drv.c (revision 2055)
	+++ hw/mlx4/kernel/hca/drv.c (working copy)
	@@ -42,9 +42,6 @@
	 #include "drv.tmh"
	 #endif 
	 
	-#define DRV_VERSION "1.0"
	-#define DRV_RELDATE "02/01/2008"
	-
	 GLOBALS g;
	 
	 /*
	@@ -53,16 +50,6 @@
	  */
	 char   mlnx_uvp_lib_name[MAX_LIB_NAME] = {"mlx4u"};
	 
	-
	-static void
	-__put_ifc(
	-  IN PINTERFACE  p_ifc )
	-{
	- HCA_ENTER( HCA_DBG_PNP );
	- p_ifc->InterfaceDereference( p_ifc->Context );
	- HCA_EXIT( HCA_DBG_PNP );
	-}
	-
	 static int __get_dev_info(PFDO_DEVICE_DATA p_fdo, __be64
*node_guid, u32 *hw_id)
	 {
	  struct ib_device_attr device_attr;
	@@ -94,174 +81,7 @@
	 //
	 
	 
	-static NTSTATUS
	-__get_ci_interface(
	- IN     PFDO_DEVICE_DATA    p_fdo )
	-{
	- NTSTATUS   status;
	- IRP     *p_irp;
	- IO_STATUS_BLOCK  ioStatus;
	- IO_STACK_LOCATION *pIoStack;
	- KEVENT    event;
	 
	- HCA_ENTER( HCA_DBG_PNP );
	-
	- KeInitializeEvent( &event, NotificationEvent, FALSE );
	-
	- /* Query for the verbs interface. */
	- p_irp = IoBuildSynchronousFsdRequest( IRP_MJ_PNP,
p_fdo->p_al_dev,
	-  NULL, 0, NULL, &event, &ioStatus );
	- if( !p_irp )
	- {
	-  HCA_PRINT( TRACE_LEVEL_ERROR, HCA_DBG_PNP, 
	-   ("IoBuildSynchronousFsdRequest failed.\n"));
	-  return STATUS_INSUFFICIENT_RESOURCES;
	- }
	-
	- /* Format the IRP. */
	- pIoStack = IoGetNextIrpStackLocation( p_irp );
	- pIoStack->MinorFunction = IRP_MN_QUERY_INTERFACE;
	- pIoStack->Parameters.QueryInterface.Version =
IB_CI_INTERFACE_VERSION;
	- pIoStack->Parameters.QueryInterface.Size =
sizeof(ib_ci_ifc_t);
	- pIoStack->Parameters.QueryInterface.Interface = 
	-  (INTERFACE*)&p_fdo->ci_ifc;
	- pIoStack->Parameters.QueryInterface.InterfaceSpecificData =
NULL;
	- pIoStack->Parameters.QueryInterface.InterfaceType = 
	-  &GUID_IB_CI_INTERFACE;
	- p_irp->IoStatus.Status = STATUS_NOT_SUPPORTED;
	-
	- /* Send the IRP. */
	- status = IoCallDriver( p_fdo->p_al_dev, p_irp );
	- if( status == STATUS_PENDING )
	- {
	-  KeWaitForSingleObject( &event, Executive, KernelMode, 
	-   FALSE, NULL );
	-
	-  status = ioStatus.Status;
	- }
	-
	- if( !NT_SUCCESS( status ) )
	- {
	-  HCA_PRINT( TRACE_LEVEL_ERROR,HCA_DBG_PNP, 
	-   ("Query interface for verbs returned %08x.\n", status));
	-  return status;
	- }
	-
	- HCA_EXIT( HCA_DBG_PNP );
	- return status;
	-}
	-
	-
	-static NTSTATUS
	-__pnp_notify_target(
	- IN    void      *pNotifyStruct,
	- IN    void      *context )
	-{
	- NTSTATUS       status = STATUS_SUCCESS;
	- PFDO_DEVICE_DATA      p_fdo = context;
	- PDEVICE_OBJECT p_dev_obj =
WdfDeviceWdmGetDeviceObject(p_fdo->FdoDevice);
	- TARGET_DEVICE_REMOVAL_NOTIFICATION *pNotify;
	-
	- HCA_ENTER( HCA_DBG_PNP );
	-
	- pNotify = (TARGET_DEVICE_REMOVAL_NOTIFICATION*)pNotifyStruct;
	-
	- if( IsEqualGUID( &pNotify->Event,
&GUID_TARGET_DEVICE_QUERY_REMOVE ) )
	- {
	-  if ( p_fdo->state == HCA_REGISTERED) {
	-   /* Release AL's CI interface. */
	-   p_fdo->ci_ifc.wdm.InterfaceDereference(
p_fdo->ci_ifc.wdm.Context );
	-   p_fdo->state = HCA_IFC_DEREFERENCED;
	-  }
	-
	-  /* Release AL's file object so that it can unload. */
	-  CL_ASSERT( p_fdo->p_al_dev );
	-  CL_ASSERT( p_fdo->p_al_file_obj );
	-  CL_ASSERT( p_fdo->p_al_file_obj == pNotify->FileObject );
	-  if( p_fdo->p_al_file_obj ) {
	-   ObDereferenceObject( p_fdo->p_al_file_obj );
	-   p_fdo->p_al_file_obj = NULL;
	-   p_fdo->p_al_dev = NULL;
	-  }
	- }
	- else if( IsEqualGUID( &pNotify->Event, 
	-  &GUID_TARGET_DEVICE_REMOVE_COMPLETE ) )
	- {
	-  if (p_fdo->ci_ifc.deregister_ca) {
	-   /* Notify AL that the CA is being removed. */
	-   p_fdo->ci_ifc.deregister_ca( p_fdo->hca.guid );
	-   p_fdo->ci_ifc.deregister_ca = NULL;
	-  }
	-
	-  if ( p_fdo->state == HCA_REGISTERED) {
	-   /* Release AL's CI interface. */
	-   p_fdo->ci_ifc.wdm.InterfaceDereference(
p_fdo->ci_ifc.wdm.Context );
	-  }
	-  p_fdo->state = HCA_STARTED;
	-
	-  /* Release AL's file object so that it can unload. */
	-  if( p_fdo->p_al_file_obj )
	-  {
	-   ObDereferenceObject( p_fdo->p_al_file_obj );
	-   p_fdo->p_al_file_obj = NULL;
	-   p_fdo->p_al_dev = NULL;
	-  }
	-
	-  /* Cancel our target device change registration. */
	-  if (p_fdo->pnp_target_entry) {
	-   IoUnregisterPlugPlayNotification( p_fdo->pnp_target_entry );
	-   p_fdo->pnp_target_entry = NULL;
	-  }
	-
	- }
	- else if( IsEqualGUID( &pNotify->Event, 
	-  &GUID_TARGET_DEVICE_REMOVE_CANCELLED ) )
	- {
	-  /* Cancel our target device change registration. */
	-  if (p_fdo->pnp_target_entry) {
	-   IoUnregisterPlugPlayNotification( p_fdo->pnp_target_entry );
	-   p_fdo->pnp_target_entry = NULL;
	-  }
	-
	-  /* Get the device object pointer for the AL. */
	-  CL_ASSERT( !p_fdo->p_al_file_obj );
	-  CL_ASSERT( !p_fdo->p_al_dev );
	-  /* Get the AL device object. */
	-  HCA_PRINT( TRACE_LEVEL_INFORMATION ,HCA_DBG_SHIM  ,("Calling
IoGetDeviceObjectPointer.\n"));
	-  status = IoGetDeviceObjectPointer( &p_fdo->al_sym_name,
	-   FILE_ALL_ACCESS, &p_fdo->p_al_file_obj, &p_fdo->p_al_dev );
	-  if( !NT_SUCCESS( status ) )
	-  {
	-   HCA_PRINT( TRACE_LEVEL_ERROR, HCA_DBG_SHIM, 
	-    ("IoGetDeviceObjectPointer returned %08x.\n", status ));
	-   return STATUS_SUCCESS;
	-  }
	-
	-  /* Register for removal notification of the IB Fabric root
device. */
	-  status = IoRegisterPlugPlayNotification( 
	-   EventCategoryTargetDeviceChange, 0, p_fdo->p_al_file_obj, 
	-   p_dev_obj->DriverObject, __pnp_notify_target, p_fdo, 
	-   &p_fdo->pnp_target_entry );
	-  if( !NT_SUCCESS( status ) )
	-  {
	-   HCA_PRINT( TRACE_LEVEL_ERROR, HCA_DBG_PNP, 
	-    ("IoRegisterPlugPlayNotification returned %08x.\n",
status));
	-   return status;
	-  }
	-
	-  CL_ASSERT( p_fdo->state == HCA_IFC_DEREFERENCED );
	-  if ( p_fdo->state == HCA_IFC_DEREFERENCED) {
	-   /* Release AL's CI interface. */
	-   p_fdo->ci_ifc.wdm.InterfaceReference(
p_fdo->ci_ifc.wdm.Context );
	-   p_fdo->state = HCA_REGISTERED;
	-  }
	- }
	-
	- HCA_EXIT( HCA_DBG_PNP );
	- return status;
	-}
	-
	-
	 static ci_interface_t*
	 __alloc_hca_ifc(
	  IN    PFDO_DEVICE_DATA const  p_fdo )
	@@ -293,191 +113,6 @@
	 }
	 
	 static void
	-__hca_deregister(
	- IN    PFDO_DEVICE_DATA    p_fdo )
	-{
	- HCA_ENTER( HCA_DBG_PNP );
	- 
	- if ( p_fdo->state == HCA_REGISTERED) {
	-  if (p_fdo->ci_ifc.deregister_ca) {
	-   /* Notify AL that the CA is being removed. */
	-   p_fdo->ci_ifc.deregister_ca( p_fdo->hca.guid );
	-   p_fdo->ci_ifc.deregister_ca = NULL;
	-   /* Release AL's CI interface. */
	-   p_fdo->ci_ifc.wdm.InterfaceDereference(
p_fdo->ci_ifc.wdm.Context );
	-   p_fdo->state = HCA_STARTED;
	-   HCA_PRINT( TRACE_LEVEL_INFORMATION ,HCA_DBG_PNP,
	-    ("***** HCA deregistered \n"));
	-  }
	- }
	-
	- HCA_EXIT( HCA_DBG_PNP );
	-}
	-
	-static NTSTATUS
	-__hca_register(
	- IN    PFDO_DEVICE_DATA    p_fdo )
	-{
	- NTSTATUS    status;
	- ib_api_status_t   ib_status;
	- ci_interface_t   *p_hca_ifc;
	-
	- HCA_ENTER( HCA_DBG_PNP );
	- 
	- ASSERT( p_fdo->state == HCA_STARTED );
	- ASSERT( p_fdo->p_al_dev );
	-
	- /* Get the AL's lower interface. */
	- status = __get_ci_interface( p_fdo );
	- if( !NT_SUCCESS( status ) )
	- {
	-  HCA_PRINT( TRACE_LEVEL_ERROR,HCA_DBG_PNP, 
	-   ("__get_ci_interface returned %08x.\n", status));
	-  goto exit;
	- }
	-
	- /* Allocate and populate our HCA interface structure. */
	- p_hca_ifc = __alloc_hca_ifc( p_fdo );
	- if( !p_hca_ifc )
	- {
	-  HCA_PRINT( TRACE_LEVEL_ERROR  ,HCA_DBG_PNP
,("__alloc_hca_ifc failed.\n"));
	-  status = STATUS_NO_MEMORY;
	-  goto exit;
	- }
	-
	- /* Notify AL that we're available... */
	- ib_status = p_fdo->ci_ifc.register_ca( p_hca_ifc );
	- ExFreePool( p_hca_ifc );
	- if( ib_status != IB_SUCCESS )
	- {
	-  p_fdo->ci_ifc.wdm.InterfaceDereference(
p_fdo->ci_ifc.wdm.Context );
	-  status = STATUS_INSUFFICIENT_RESOURCES;
	-  goto exit;
	- }
	-
	- p_fdo->state = HCA_REGISTERED;
	- HCA_PRINT( TRACE_LEVEL_INFORMATION  ,HCA_DBG_PNP,
	-  ("***** HCA registered \n"));
	-exit:
	- HCA_EXIT( HCA_DBG_PNP );
	- return status;
	-}
	-
	-static NTSTATUS
	-__pnp_notify_ifc(
	- IN    void      *pNotifyStruct,
	- IN    void      *context )
	-{
	- NTSTATUS        status = STATUS_SUCCESS;
	- DEVICE_INTERFACE_CHANGE_NOTIFICATION *pNotify;
	- PFDO_DEVICE_DATA      p_fdo = context;
	- PDEVICE_OBJECT p_dev_obj =
WdfDeviceWdmGetDeviceObject(p_fdo->FdoDevice);
	-
	- HCA_ENTER( HCA_DBG_PNP );
	-
	- pNotify =
(DEVICE_INTERFACE_CHANGE_NOTIFICATION*)pNotifyStruct;
	-
	- if( !IsEqualGUID( &pNotify->Event,
&GUID_DEVICE_INTERFACE_ARRIVAL ) )
	-  goto done;
	-
	- /*
	-  * Sanity check.  We should only be getting notifications of
the 
	-  * CI interface exported by AL.
	-  */
	- ASSERT( 
	-  IsEqualGUID( &pNotify->InterfaceClassGuid,
&GUID_IB_CI_INTERFACE ) );
	-
	- if( p_fdo->state != HCA_STARTED )
	- {
	-  HCA_PRINT( TRACE_LEVEL_ERROR  ,HCA_DBG_PNP  ,("Invalid state:
%d\n", p_fdo->state));
	-  goto done;
	- }
	-
	- /* save symbolic name of IBAL for a case of cancelled IBAL
removal */
	- if (!p_fdo->al_sym_name.Buffer) {
	-  p_fdo->al_sym_name.Length =
pNotify->SymbolicLinkName->Length;
	-  p_fdo->al_sym_name.MaximumLength =
pNotify->SymbolicLinkName->MaximumLength;
	-  p_fdo->al_sym_name.Buffer = ExAllocatePoolWithTag(
NonPagedPool, 
	-   p_fdo->al_sym_name.MaximumLength * sizeof(wchar_t),
MT_TAG_KERNEL );
	-  if (!p_fdo->al_sym_name.Buffer)
	-  {
	-   HCA_PRINT( TRACE_LEVEL_ERROR  ,HCA_DBG_PNP  ,("allocation of
sym IBAL name failed.\n"));
	-   goto done;
	-  }
	-  RtlCopyUnicodeString( &p_fdo->al_sym_name,
pNotify->SymbolicLinkName );
	- }
	-
	- ASSERT( !p_fdo->p_al_dev );
	- ASSERT( !p_fdo->p_al_file_obj );
	-
	- /* Get the AL device object. */
	- HCA_PRINT( TRACE_LEVEL_INFORMATION  ,HCA_DBG_PNP  ,("Calling
IoGetDeviceObjectPointer.\n"));
	- status = IoGetDeviceObjectPointer( pNotify->SymbolicLinkName,
	-  FILE_ALL_ACCESS, &p_fdo->p_al_file_obj, &p_fdo->p_al_dev );
	- if( !NT_SUCCESS( status ) )
	- {
	-  HCA_PRINT( TRACE_LEVEL_ERROR, HCA_DBG_PNP, 
	-   ("IoGetDeviceObjectPointer returned %08x.\n", status ));
	-  goto done;
	- }
	-
	- /* Register for removal notification of the IB Fabric root
device. */
	- HCA_PRINT( TRACE_LEVEL_INFORMATION, HCA_DBG_PNP, 
	-  ("Registering for target notifications.\n"));
	- status = IoRegisterPlugPlayNotification( 
	-  EventCategoryTargetDeviceChange, 0, p_fdo->p_al_file_obj, 
	-  p_dev_obj->DriverObject, __pnp_notify_target, p_fdo, 
	-  &p_fdo->pnp_target_entry );
	- if( !NT_SUCCESS( status ) )
	- {
	-  HCA_PRINT( TRACE_LEVEL_ERROR, HCA_DBG_PNP, 
	-   ("IoRegisterPlugPlayNotification returned %08x.\n",
status));
	-  goto err_reg_notify;
	- }
	-
	- status = __hca_register( p_fdo );
	- if( !NT_SUCCESS( status ) )
	- {
	-  HCA_PRINT( TRACE_LEVEL_ERROR, HCA_DBG_PNP, 
	-   ("__get_ci_interface returned %08x.\n", status));
	-  goto err_reg_hca;
	- }
	- goto done;
	- 
	-err_reg_hca:
	- IoUnregisterPlugPlayNotification( p_fdo->pnp_target_entry );
	- p_fdo->pnp_target_entry = NULL;
	-err_reg_notify:
	- ObDereferenceObject( p_fdo->p_al_file_obj );
	- p_fdo->p_al_file_obj = NULL;
	- p_fdo->p_al_dev = NULL;
	-done:
	- HCA_EXIT( HCA_DBG_PNP );
	- return status;
	-}
	-
	-/* Forwards the request to the HCA's PDO. */
	-static NTSTATUS
	-__get_ifc(
	- IN    WDFDEVICE const   FdoDevice,
	- IN  const GUID* const    p_guid,
	- IN    USHORT     size,
	- IN    USHORT     Version,
	- IN OUT   PVOID     InterfaceSpecificData,
	- OUT    PINTERFACE    p_ifc )
	-{
	- NTSTATUS status;
	-
	- HCA_ENTER( HCA_DBG_PNP );
	- 
	- status = WdfFdoQueryForInterface( FdoDevice, p_guid, p_ifc,
	-  size, Version, InterfaceSpecificData );
	-
	- HCA_EXIT( HCA_DBG_PNP );
	- return status;
	-}
	-
	-static void
	 __unmap_hca_memory(
	  IN    PFDO_DEVICE_DATA const p_fdo )
	 {
	@@ -507,71 +142,66 @@
	 
	  switch( p_fdo->state )
	  {
	- case HCA_REGISTERED:
	-  __hca_deregister( p_fdo );
	-
	-  /* Fall through. */
	  case HCA_STARTED:
	   /* dequeue HCA  */
	   mlnx_hca_remove( &p_fdo->hca );
	  }
	-
	- if (p_fdo->al_sym_name.Buffer) {
	-  ExFreePool( p_fdo->al_sym_name.Buffer );
	-  p_fdo->al_sym_name.Buffer = NULL;
	- }
	  
	- if( p_fdo->pnp_target_entry )
	- {
	-  ASSERT( p_fdo->pnp_ifc_entry );
	-  IoUnregisterPlugPlayNotification( p_fdo->pnp_target_entry );
	-  p_fdo->pnp_target_entry = NULL;
	- }
	+ __unmap_hca_memory( p_fdo );
	 
	- if( p_fdo->pnp_ifc_entry ) {
	-  IoUnregisterPlugPlayNotification( p_fdo->pnp_ifc_entry );
	-  p_fdo->pnp_ifc_entry = NULL;
	- }
	+ p_fdo->state = HCA_ADDED;
	 
	- if( p_fdo->p_al_file_obj ) {
	-  ObDereferenceObject( p_fdo->p_al_file_obj );
	-  p_fdo->p_al_file_obj = NULL;
	- }
	+ HCA_EXIT( HCA_DBG_PNP );
	+}
	 
	- __unmap_hca_memory( p_fdo );
	+static void
	+__ref_ifc(
	+ IN    DEVICE_OBJECT*    p_dev_obj )
	+{
	+ PFDO_DEVICE_DATA p_fdo =
(PFDO_DEVICE_DATA)p_dev_obj->DeviceExtension;
	 
	- p_fdo->state = HCA_ADDED;
	+ HCA_ENTER( HCA_DBG_PNP );
	 
	+ cl_atomic_inc( &p_fdo->n_hca_ifc_ref );
	+ ObReferenceObject( p_dev_obj );
	+
	+ HCA_PRINT( TRACE_LEVEL_ERROR, HCA_DBG_PNP, 
	+  ("MLX4_HCA: CA_guid %I64x, hca_ifc_ref %d\n",
	+  p_fdo->hca.guid, p_fdo->n_hca_ifc_ref) );
	+
	  HCA_EXIT( HCA_DBG_PNP );
	 }
	 
	+static void
	+__deref_ifc(
	+ IN    DEVICE_OBJECT*    p_dev_obj )
	+{
	+ PFDO_DEVICE_DATA p_fdo =
(PFDO_DEVICE_DATA)p_dev_obj->DeviceExtension;
	+
	+ HCA_ENTER( HCA_DBG_PNP );
	+
	+ cl_atomic_dec( &p_fdo->n_hca_ifc_ref );
	+ ObDereferenceObject( p_dev_obj );
	+
	+ HCA_PRINT( TRACE_LEVEL_ERROR, HCA_DBG_PNP, 
	+  ("MLX4_HCA: CA_guid %I64x, hca_ifc_ref %d\n",
	+  p_fdo->hca.guid, p_fdo->n_hca_ifc_ref) );
	+
	+ HCA_EXIT( HCA_DBG_PNP );
	+}
	+
	+
	+
	 NTSTATUS
	 EvtDeviceD0Entry(
	  IN WDFDEVICE  Device,
	  IN WDF_POWER_DEVICE_STATE  PreviousState
	  )
	 {
	- PFDO_DEVICE_DATA p_fdo = FdoGetData(Device);
	- NTSTATUS status = STATUS_SUCCESS;
	-
	+ UNUSED_PARAM(Device);
	  UNUSED_PARAM(PreviousState);
	  HCA_ENTER( HCA_DBG_PNP );
	-
	  HCA_PRINT(TRACE_LEVEL_INFORMATION, HCA_DBG_PNP,
("EvtDeviceD0Entry: PreviousState 0x%x\n", PreviousState));
	-
	- /* Connect to IBAL */
	- HCA_PRINT( TRACE_LEVEL_INFORMATION, HCA_DBG_PO, 
	-  ("***** Connect to IBAL, IRQL %d\n", KeGetCurrentIrql()));
	-
	- if( p_fdo->p_al_dev && p_fdo->state == HCA_STARTED) {
	-  status = __hca_register( p_fdo );
	-  if( !NT_SUCCESS( status ) ) {
	-   HCA_PRINT( TRACE_LEVEL_ERROR, HCA_DBG_PO, 
	-    ("!!! __hca_register failed (%#x) \n", status));
	-   status = STATUS_UNSUCCESSFUL;
	-  }
	- }
	-
	  HCA_EXIT( HCA_DBG_PNP );
	  return STATUS_SUCCESS;
	 }
	@@ -598,7 +228,6 @@
	   }
	   /* Fall through. */
	  default:
	-  __hca_deregister( p_fdo );
	   status = STATUS_SUCCESS;
	   break;
	  }
	@@ -617,8 +246,10 @@
	  int err;
	  NTSTATUS status;
	  PFDO_DEVICE_DATA p_fdo  = FdoGetData(Device);
	- PDEVICE_OBJECT p_dev_obj =
WdfDeviceWdmGetDeviceObject(Device);
	  BUS_INTERFACE_STANDARD bus_pci_ifc;
	+ ci_interface_t *p_hca_ifc;
	+ RDMA_INTERFACE_VERBS rdma_ifc, *p_ifc = &rdma_ifc;
	+ WDF_QUERY_INTERFACE_CONFIG qiConfig;
	   
	  UNUSED_PARAM(ResourcesRaw);
	  UNUSED_PARAM(ResourcesTranslated);
	@@ -627,11 +258,9 @@
	  
	  HCA_PRINT(TRACE_LEVEL_INFORMATION, HCA_DBG_PNP,
("EvtPrepareHardware: \n"));
	 
	- ASSERT(p_dev_obj);
	-
	  /* get PCI BUS interface */
	- status = __get_ifc( Device, &GUID_BUS_INTERFACE_STANDARD,
	-  sizeof(BUS_INTERFACE_STANDARD), 1, NULL,
(PINTERFACE)&bus_pci_ifc);
	+ status = WdfFdoQueryForInterface( Device,
&GUID_BUS_INTERFACE_STANDARD,
	+  (PINTERFACE)&bus_pci_ifc, sizeof(BUS_INTERFACE_STANDARD), 1,
NULL );
	  if( !NT_SUCCESS( status ) ) {
	   HCA_PRINT(TRACE_LEVEL_ERROR, HCA_DBG_PNP, ("Getting PCI BUS
interface failed: status=0x%x\n", status));
	   return status;
	@@ -640,8 +269,8 @@
	  p_fdo->bus_pci_ifc_taken = TRUE;
	  
	  /* get MLX4_BUS IB interface */
	- status = __get_ifc( Device, &MLX4_BUS_IB_INTERFACE_GUID,
	-  sizeof(MLX4_BUS_IB_INTERFACE), MLX4_BUS_IB_INTERFACE_VERSION,
NULL, (PINTERFACE)&p_fdo->bus_ib_ifc);
	+ status = WdfFdoQueryForInterface( Device,
&MLX4_BUS_IB_INTERFACE_GUID,
	+  (PINTERFACE)&p_fdo->bus_ib_ifc,
sizeof(MLX4_BUS_IB_INTERFACE), MLX4_BUS_IB_INTERFACE_VERSION, NULL );
	  if( !NT_SUCCESS( status ) ) {
	   HCA_PRINT(TRACE_LEVEL_ERROR, HCA_DBG_PNP, ("Getting MLX4 BUS
interface failed: status=0x%x\n", status));
	   return status;
	@@ -665,27 +294,41 @@
	  /* queue HCA  */
	  mlnx_hca_insert( &p_fdo->hca );
	 
	+ /* Allocate and populate our HCA interface structure. */
	+ p_hca_ifc = __alloc_hca_ifc( p_fdo );
	+ if( !p_hca_ifc ) {
	+  HCA_PRINT( TRACE_LEVEL_ERROR  ,HCA_DBG_PNP
,("__alloc_hca_ifc failed.\n"));
	+  return STATUS_NO_MEMORY;
	+ }
	+
	+ /* fill interface fields */
	+ p_ifc->InterfaceHeader.Size = sizeof(RDMA_INTERFACE_VERBS);
	+ p_ifc->InterfaceHeader.Version = VerbsVersion(VERBS_MAJOR_VER,
VERBS_MINOR_VER);
	+ p_ifc->InterfaceHeader.Context = p_fdo->p_dev_obj;
	+ p_ifc->InterfaceHeader.InterfaceReference = __ref_ifc;
	+ p_ifc->InterfaceHeader.InterfaceDereference = __deref_ifc;
	+ p_ifc->Verbs = *p_hca_ifc;
	+ p_ifc->p_hca_obj = &p_fdo->hca;
	+ ExFreePool( p_hca_ifc );
	+
	+ /* create an upper interface */
	+ WDF_QUERY_INTERFACE_CONFIG_INIT( &qiConfig, (PINTERFACE)p_ifc,
	+  &GUID_RDMA_INTERFACE_VERBS, NULL);
	+
	+ status = WdfDeviceAddQueryInterface( Device, &qiConfig );
	+ if (!NT_SUCCESS(status)) {
	+  HCA_PRINT( TRACE_LEVEL_ERROR  ,HCA_DBG_PNP
,("WdfDeviceAddQueryInterface failed %#x\n", status));
	+  return status;
	+ }
	+
	  /*
	   * Change the state since the PnP callback can happen
	   * before the callback returns.
	   */
	  p_fdo->state = HCA_STARTED;
	  
	- /* Register for interface arrival of the IB_AL device. */
	- status = IoRegisterPlugPlayNotification(
	-  EventCategoryDeviceInterfaceChange,
	-  PNPNOTIFY_DEVICE_INTERFACE_INCLUDE_EXISTING_INTERFACES,
	-  (void*)&GUID_IB_CI_INTERFACE, p_dev_obj->DriverObject,
	-  __pnp_notify_ifc, p_fdo, &p_fdo->pnp_ifc_entry );
	- if( !NT_SUCCESS( status ) )
	- {
	-  p_fdo->state = HCA_ADDED;
	-  HCA_PRINT( TRACE_LEVEL_ERROR, HCA_DBG_PNP,
	-   ("IoRegisterPlugPlayNotification returned %08x.\n",
status));
	- }
	-
	  HCA_EXIT( HCA_DBG_PNP );
	- return status;
	+ return STATUS_SUCCESS;
	 }
	 
	 
	@@ -708,14 +351,16 @@
	 
	  // release MLX4_BUS resources
	  if(p_fdo->bus_ib_ifc_taken) {
	+  PINTERFACE p_ifc = (PINTERFACE)&p_fdo->bus_ib_ifc;
	+  p_ifc->InterfaceDereference( p_ifc->Context );
	   p_fdo->bus_ib_ifc_taken = FALSE;
	-  __put_ifc( (PINTERFACE)&p_fdo->bus_ib_ifc );
	  }
	 
	  // release PCI BUS resources
	  if(p_fdo->bus_pci_ifc_taken) {
	+  PINTERFACE p_ifc = (PINTERFACE)&p_fdo->bus_pci_ifc;
	+  p_ifc->InterfaceDereference( p_ifc->Context );
	   p_fdo->bus_pci_ifc_taken = FALSE;
	-  __put_ifc( (PINTERFACE)&p_fdo->bus_pci_ifc );
	  }
	 
	  HCA_EXIT( HCA_DBG_PNP );
	@@ -730,7 +375,7 @@
	  PFDO_DEVICE_DATA p_fdo = FdoGetData(Device);
	  HCA_ENTER( HCA_DBG_PNP );
	  if (atomic_read(&p_fdo->usecnt)) {
	-  cl_dbg_out( "MLX4: Can't get unloaded. %d applications are
still in work\n", p_fdo->usecnt);
	+  cl_dbg_out( "MLX4_HCA: Can't get unloaded. %d applications
are still in work\n", p_fdo->usecnt);
	   return STATUS_UNSUCCESSFUL;
	  }
	  HCA_EXIT( HCA_DBG_PNP );
	@@ -739,14 +384,14 @@
	 
	 
	 NTSTATUS
	-EvtDeviceAdd(
	+EvtDriverDeviceAdd(
	  IN WDFDRIVER        Driver,
	  IN PWDFDEVICE_INIT  DeviceInit
	  )
	 /*++
	 Routine Description:
	 
	- EvtDeviceAdd is called by the framework in response to
AddDevice
	+ EvtDriverDeviceAdd is called by the framework in response to
AddDevice
	  call from the PnP manager. We create and initialize a device
object to
	  represent a new instance of mxe bus.
	 
	@@ -772,7 +417,7 @@
	 
	  PAGED_CODE ();
	  
	- HCA_PRINT(TRACE_LEVEL_INFORMATION, HCA_DBG_PNP,
("EvtDeviceAdd: 0x%p\n", Driver));
	+ HCA_PRINT(TRACE_LEVEL_INFORMATION, HCA_DBG_PNP,
("EvtDriverDeviceAdd: 0x%p\n", Driver));
	  //
	  // register PnP & Power stuff
	  //
	@@ -806,7 +451,7 @@
	  //
	  status = WdfDeviceCreate(&DeviceInit, &attributes, &device);
	  if (!NT_SUCCESS(status)) {
	-  HCA_PRINT(TRACE_LEVEL_VERBOSE, HCA_DBG_PNP, ("EvtDeviceAdd:
WdfDeviceCreate failed with 0x%x\n", status));
	+  HCA_PRINT(TRACE_LEVEL_VERBOSE, HCA_DBG_PNP,
("EvtDriverDeviceAdd: WdfDeviceCreate failed with 0x%x\n", status));
	   goto end;
	  }
	 
	@@ -816,6 +461,7 @@
	  p_fdo = FdoGetData(device);
	  RtlZeroMemory(p_fdo, sizeof(FDO_DEVICE_DATA));
	  p_fdo->FdoDevice = device;
	+ p_fdo->p_dev_obj = WdfDeviceWdmGetDeviceObject( device );
	  spin_lock_init( &p_fdo->uctx_lock );
	  cl_qlist_init( &p_fdo->uctx_list );
	  atomic_set(&p_fdo->usecnt, 0);
	@@ -887,9 +533,7 @@
	  g.DebugPrintLevel = TRACE_LEVEL_VERBOSE;
	  g.DebugPrintFlags = 0xffff;
	  HCA_ENTER( HCA_DBG_PNP );
	- HCA_PRINT(TRACE_LEVEL_INFORMATION, HCA_DBG_PNP, 
	-  ("Built %s %s, Version %s, RelDate %s\n", 
	-  __DATE__, __TIME__, DRV_VERSION, DRV_RELDATE));
	+
	  status = mlnx_hcas_init();
	  if( status  != STATUS_SUCCESS ) {
	   HCA_PRINT( TRACE_LEVEL_ERROR ,HCA_DBG_PNP ,
	@@ -906,7 +550,7 @@
	  //
	 
	  WDF_DRIVER_CONFIG_INIT(
	-  &config, EvtDeviceAdd );
	+  &config, EvtDriverDeviceAdd );
	  config.EvtDriverUnload = EvtDriverUnload;
	 
	  //
	@@ -949,6 +593,8 @@
	  }
	 
	 end:
	+ HCA_PRINT( TRACE_LEVEL_ERROR ,HCA_DBG_PNP ,
	+  ("exit status %#x.\n", status));
	  HCA_EXIT( HCA_DBG_PNP );
	  return status;
	 
	@@ -1133,6 +779,15 @@
	  return status;
	 }
	 
	+static void
	+__put_ifc(
	+  IN PINTERFACE  p_ifc )
	+{
	+ HCA_ENTER( HCA_DBG_PNP );
	+ p_ifc->InterfaceDereference( p_ifc->Context );
	+ HCA_EXIT( HCA_DBG_PNP );
	+}
	+
	 /* Forwards the request to the HCA's PDO. */
	 static NTSTATUS
	 __get_ifc(
	@@ -2301,9 +1956,6 @@
	  g.DebugPrintFlags = 0xffff;
	 
	  HCA_ENTER( HCA_DBG_PNP );
	- HCA_PRINT(TRACE_LEVEL_INFORMATION, HCA_DBG_PNP, 
	-  ("Built %s %s, Version %s, RelDate %s\n", 
	-  __DATE__, __TIME__, DRV_VERSION, DRV_RELDATE));
	 
	  status = mlnx_hcas_init();
	  if( status  != STATUS_SUCCESS ) {
	Index: hw/mlx4/kernel/hca/drv.h
	
===================================================================
	--- hw/mlx4/kernel/hca/drv.h (revision 2055)
	+++ hw/mlx4/kernel/hca/drv.h (working copy)
	@@ -150,16 +150,19 @@
	  *  WDF DATA  
	  * ------------------------------------------------ */
	  WDFDEVICE     FdoDevice;
	+ DEVICE_OBJECT   * p_dev_obj;  /* WDM dev object */
	 #endif
	 
	  HCA_WMI_STD_DATA   WmiData;
	 
	+#ifdef USE_WDM_FRAMEWORK
	  /* -------------------------------------------------
	  *  PNP DATA   
	  * ------------------------------------------------ */
	  void     * pnp_ifc_entry;   /* Notification entry for PnP
interface events. */
	  void     * pnp_target_entry; /* Notification entry for PnP
target events. */
	  PNP_DEVICE_STATE   pnpState; /* state for PnP Manager */
	+#endif 
	 
	  /* -------------------------------------------------
	  *  IBAL DATA   
	@@ -167,9 +170,11 @@
	  /* Number of references on the upper interface. */
	  atomic32_t     n_hca_ifc_ref;
	  hca_reg_state_t    state;    /* State for tracking
registration with AL */
	+#ifdef USE_WDM_FRAMEWORK
	  DEVICE_OBJECT   * p_al_dev;  /* IB_AL FDO */
	  FILE_OBJECT    * p_al_file_obj; /* IB_AL file object */
	  UNICODE_STRING    al_sym_name; /* IB_AL symbolic name */
	+#endif 
	 
	  /* -------------------------------------------------
	  *  SHIM DATA  
	@@ -300,7 +305,7 @@
	  );
	 
	 NTSTATUS
	-EvtDeviceAdd(
	+EvtDriverDeviceAdd(
	  IN WDFDRIVER Driver,
	  IN PWDFDEVICE_INIT Device
	  );
	Index: hw/mlx4/kernel/hca/mlx4_hca.inx
	
===================================================================
	--- hw/mlx4/kernel/hca/mlx4_hca.inx (revision 2055)
	+++ hw/mlx4/kernel/hca/mlx4_hca.inx (working copy)
	@@ -391,12 +391,6 @@
	 DelService = Ibbus,%SPSVCINST_STOPSERVICE%
	 DelService = mlx4_hca,%SPSVCINST_STOPSERVICE%
	 
	-
	-;
	-; It should be uncommented after returning MLX4_HCA to WDF
model.
	-; WinVerbs is a WDF, KMDF driver.
	-;
	-
	 ;*****************************************
	 ; WDF Coinstaller installation section
	 ;*****************************************
	@@ -420,14 +414,17 @@
	 WdfCoInstaller01007.dll
	 
	 [MLX4HCA.DDInstall.ntx86.Wdf]
	+KmdfService = mlx4_hca,WvWdfSect
	 KmdfService = WinVerbs,WvWdfSect
	 KmdfService = WinMad,WvWdfSect
	 
	 [MLX4HCA.DDInstall.ntamd64.Wdf]
	+KmdfService = mlx4_hca,WvWdfSect
	 KmdfService = WinVerbs,WvWdfSect
	 KmdfService = WinMad,WvWdfSect
	 
	 [MLX4HCA.DDInstall.ntia64.Wdf]
	+KmdfService = mlx4_hca,WvWdfSect
	 KmdfService = WinVerbs,WvWdfSect
	 KmdfService = WinMad,WvWdfSect
	 
	Index: hw/mlx4/kernel/hca/SOURCES
	
===================================================================
	--- hw/mlx4/kernel/hca/SOURCES (revision 2055)
	+++ hw/mlx4/kernel/hca/SOURCES (working copy)
	@@ -42,7 +42,8 @@
	 
	 KMDF_VERSION=1
	 
	-C_DEFINES=$(C_DEFINES) -DDRIVER -DDEPRECATE_DDK_FUNCTIONS
-D__LITTLE_ENDIAN -DUSE_WDM_FRAMEWORK -DUSE_WDM_INTERRUPTS
	+C_DEFINES=$(C_DEFINES) -DDRIVER -DDEPRECATE_DDK_FUNCTIONS
-D__LITTLE_ENDIAN 
	+#-DUSE_WDM_FRAMEWORK 
	 
	 TARGETLIBS= \
	  $(TARGETPATH)\*\complib.lib \
	

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openfabrics.org/pipermail/ofw/attachments/20090329/9411b28a/attachment.html>


More information about the ofw mailing list