<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=us-ascii">
<META content="MSHTML 6.00.2900.3243" name=GENERATOR></HEAD>
<BODY>
<DIV><FONT face=Arial size=2><SPAN class=518044613-25032009>This patch is a 
logical successor to one, removing registration of HCA with IBAL 
(2019).</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN class=518044613-25032009>It returns MLX4_HCA 
to its original WDF form, but still keeps the current WDM form under 
preprocessor flag.</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN 
class=518044613-25032009></SPAN></FONT> </DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Index: 
hw/mlx4/kernel/hca/drv.c<BR>===================================================================<BR>--- 
hw/mlx4/kernel/hca/drv.c (revision 2055)<BR>+++ 
hw/mlx4/kernel/hca/drv.c (working copy)<BR>@@ -42,9 +42,6 
@@<BR> #include "drv.tmh"<BR> #endif <BR> <BR>-#define 
DRV_VERSION "1.0"<BR>-#define 
DRV_RELDATE "02/01/2008"<BR>-<BR> GLOBALS 
g;<BR> <BR> /*<BR>@@ -53,16 +50,6 @@<BR>  
*/<BR> char   mlnx_uvp_lib_name[MAX_LIB_NAME] = 
{"mlx4u"};<BR> <BR>-<BR>-static 
void<BR>-__put_ifc(<BR>-  IN PINTERFACE  p_ifc 
)<BR>-{<BR>- HCA_ENTER( HCA_DBG_PNP 
);<BR>- p_ifc->InterfaceDereference( p_ifc->Context 
);<BR>- HCA_EXIT( HCA_DBG_PNP );<BR>-}<BR>-<BR> static int 
__get_dev_info(PFDO_DEVICE_DATA p_fdo, __be64 *node_guid, u32 
*hw_id)<BR> {<BR>  struct ib_device_attr device_attr;<BR>@@ 
-94,174 +81,7 @@<BR> //<BR> <BR> <BR>-static 
NTSTATUS<BR>-__get_ci_interface(<BR>- IN     PFDO_DEVICE_DATA    p_fdo 
)<BR>-{<BR>- NTSTATUS   status;<BR>- IRP     *p_irp;<BR>- IO_STATUS_BLOCK  ioStatus;<BR>- IO_STACK_LOCATION *pIoStack;<BR>- KEVENT    event;<BR> <BR>- HCA_ENTER( 
HCA_DBG_PNP );<BR>-<BR>- KeInitializeEvent( &event, NotificationEvent, 
FALSE );<BR>-<BR>- /* Query for the verbs interface. */<BR>- p_irp = 
IoBuildSynchronousFsdRequest( IRP_MJ_PNP, 
p_fdo->p_al_dev,<BR>-  NULL, 0, NULL, &event, &ioStatus 
);<BR>- if( !p_irp )<BR>- {<BR>-  HCA_PRINT( 
TRACE_LEVEL_ERROR, HCA_DBG_PNP, 
<BR>-   ("IoBuildSynchronousFsdRequest 
failed.\n"));<BR>-  return 
STATUS_INSUFFICIENT_RESOURCES;<BR>- }<BR>-<BR>- /* Format the IRP. 
*/<BR>- pIoStack = IoGetNextIrpStackLocation( p_irp 
);<BR>- pIoStack->MinorFunction = 
IRP_MN_QUERY_INTERFACE;<BR>- pIoStack->Parameters.QueryInterface.Version 
= IB_CI_INTERFACE_VERSION;<BR>- pIoStack->Parameters.QueryInterface.Size 

sizeof(ib_ci_ifc_t);<BR>- pIoStack->Parameters.QueryInterface.Interface 

<BR>-  (INTERFACE*)&p_fdo->ci_ifc;<BR>- pIoStack->Parameters.QueryInterface.InterfaceSpecificData 
= NULL;<BR>- pIoStack->Parameters.QueryInterface.InterfaceType = 
<BR>-  &GUID_IB_CI_INTERFACE;<BR>- p_irp->IoStatus.Status 
= STATUS_NOT_SUPPORTED;<BR>-<BR>- /* Send the IRP. */<BR>- status = 
IoCallDriver( p_fdo->p_al_dev, p_irp );<BR>- if( status == 
STATUS_PENDING )<BR>- {<BR>-  KeWaitForSingleObject( &event, 
Executive, KernelMode, <BR>-   FALSE, NULL 
);<BR>-<BR>-  status = ioStatus.Status;<BR>- }<BR>-<BR>- if( 
!NT_SUCCESS( status ) )<BR>- {<BR>-  HCA_PRINT( 
TRACE_LEVEL_ERROR,HCA_DBG_PNP, <BR>-   ("Query interface for 
verbs returned %08x.\n", status));<BR>-  return 
status;<BR>- }<BR>-<BR>- HCA_EXIT( HCA_DBG_PNP );<BR>- return 
status;<BR>-}<BR>-<BR>-<BR>-static 
NTSTATUS<BR>-__pnp_notify_target(<BR>- IN    void      *pNotifyStruct,<BR>- IN    void      *context 
)<BR>-{<BR>- NTSTATUS       status = 
STATUS_SUCCESS;<BR>- PFDO_DEVICE_DATA      p_fdo 
= context;<BR>- PDEVICE_OBJECT p_dev_obj = 
WdfDeviceWdmGetDeviceObject(p_fdo->FdoDevice);<BR>- TARGET_DEVICE_REMOVAL_NOTIFICATION *pNotify;<BR>-<BR>- HCA_ENTER( 
HCA_DBG_PNP );<BR>-<BR>- pNotify = 
(TARGET_DEVICE_REMOVAL_NOTIFICATION*)pNotifyStruct;<BR>-<BR>- if( 
IsEqualGUID( &pNotify->Event, &GUID_TARGET_DEVICE_QUERY_REMOVE ) 
)<BR>- {<BR>-  if ( p_fdo->state == HCA_REGISTERED) 
{<BR>-   /* Release AL's CI interface. 
*/<BR>-   p_fdo->ci_ifc.wdm.InterfaceDereference( 
p_fdo->ci_ifc.wdm.Context );<BR>-   p_fdo->state = 
HCA_IFC_DEREFERENCED;<BR>-  }<BR>-<BR>-  /* Release AL's 
file object so that it can unload. */<BR>-  CL_ASSERT( 
p_fdo->p_al_dev );<BR>-  CL_ASSERT( p_fdo->p_al_file_obj 
);<BR>-  CL_ASSERT( p_fdo->p_al_file_obj == pNotify->FileObject 
);<BR>-  if( p_fdo->p_al_file_obj ) 
{<BR>-   ObDereferenceObject( p_fdo->p_al_file_obj 
);<BR>-   p_fdo->p_al_file_obj = 
NULL;<BR>-   p_fdo->p_al_dev = 
NULL;<BR>-  }<BR>- }<BR>- else if( IsEqualGUID( 
&pNotify->Event, <BR>-  &GUID_TARGET_DEVICE_REMOVE_COMPLETE 
) )<BR>- {<BR>-  if (p_fdo->ci_ifc.deregister_ca) 
{<BR>-   /* Notify AL that the CA is being removed. 
*/<BR>-   p_fdo->ci_ifc.deregister_ca( p_fdo->hca.guid 
);<BR>-   p_fdo->ci_ifc.deregister_ca = 
NULL;<BR>-  }<BR>-<BR>-  if ( p_fdo->state == 
HCA_REGISTERED) {<BR>-   /* Release AL's CI interface. 
*/<BR>-   p_fdo->ci_ifc.wdm.InterfaceDereference( 
p_fdo->ci_ifc.wdm.Context 
);<BR>-  }<BR>-  p_fdo->state = 
HCA_STARTED;<BR>-<BR>-  /* Release AL's file object so that it can 
unload. */<BR>-  if( p_fdo->p_al_file_obj 
)<BR>-  {<BR>-   ObDereferenceObject( 
p_fdo->p_al_file_obj );<BR>-   p_fdo->p_al_file_obj = 
NULL;<BR>-   p_fdo->p_al_dev = 
NULL;<BR>-  }<BR>-<BR>-  /* Cancel our target device change 
registration. */<BR>-  if (p_fdo->pnp_target_entry) 
{<BR>-   IoUnregisterPlugPlayNotification( 
p_fdo->pnp_target_entry );<BR>-   p_fdo->pnp_target_entry = 
NULL;<BR>-  }<BR>-<BR>- }<BR>- else if( IsEqualGUID( 
&pNotify->Event, 
<BR>-  &GUID_TARGET_DEVICE_REMOVE_CANCELLED ) 
)<BR>- {<BR>-  /* Cancel our target device change registration. 
*/<BR>-  if (p_fdo->pnp_target_entry) 
{<BR>-   IoUnregisterPlugPlayNotification( 
p_fdo->pnp_target_entry );<BR>-   p_fdo->pnp_target_entry = 
NULL;<BR>-  }<BR>-<BR>-  /* Get the device object pointer 
for the AL. */<BR>-  CL_ASSERT( !p_fdo->p_al_file_obj 
);<BR>-  CL_ASSERT( !p_fdo->p_al_dev );<BR>-  /* Get the 
AL device object. */<BR>-  HCA_PRINT( 
TRACE_LEVEL_INFORMATION ,HCA_DBG_SHIM  ,("Calling 
IoGetDeviceObjectPointer.\n"));<BR>-  status = 
IoGetDeviceObjectPointer( 
&p_fdo->al_sym_name,<BR>-   FILE_ALL_ACCESS, 
&p_fdo->p_al_file_obj, &p_fdo->p_al_dev );<BR>-  if( 
!NT_SUCCESS( status ) )<BR>-  {<BR>-   HCA_PRINT( 
TRACE_LEVEL_ERROR, HCA_DBG_SHIM, 
<BR>-    ("IoGetDeviceObjectPointer returned %08x.\n", 
status ));<BR>-   return 
STATUS_SUCCESS;<BR>-  }<BR>-<BR>-  /* Register for removal 
notification of the IB Fabric root device. */<BR>-  status = 
IoRegisterPlugPlayNotification( 
<BR>-   EventCategoryTargetDeviceChange, 0, 
p_fdo->p_al_file_obj, <BR>-   p_dev_obj->DriverObject, 
__pnp_notify_target, p_fdo, 
<BR>-   &p_fdo->pnp_target_entry );<BR>-  if( 
!NT_SUCCESS( status ) )<BR>-  {<BR>-   HCA_PRINT( 
TRACE_LEVEL_ERROR, HCA_DBG_PNP, 
<BR>-    ("IoRegisterPlugPlayNotification returned %08x.\n", 
status));<BR>-   return 
status;<BR>-  }<BR>-<BR>-  CL_ASSERT( p_fdo->state == 
HCA_IFC_DEREFERENCED );<BR>-  if ( p_fdo->state == 
HCA_IFC_DEREFERENCED) {<BR>-   /* Release AL's CI interface. 
*/<BR>-   p_fdo->ci_ifc.wdm.InterfaceReference( 
p_fdo->ci_ifc.wdm.Context );<BR>-   p_fdo->state = 
HCA_REGISTERED;<BR>-  }<BR>- }<BR>-<BR>- HCA_EXIT( 
HCA_DBG_PNP );<BR>- return status;<BR>-}<BR>-<BR>-<BR> static 
ci_interface_t*<BR> __alloc_hca_ifc(<BR>  IN    PFDO_DEVICE_DATA 
const  p_fdo )<BR>@@ -293,191 +113,6 
@@<BR> }<BR> <BR> static 
void<BR>-__hca_deregister(<BR>- IN    PFDO_DEVICE_DATA    p_fdo 
)<BR>-{<BR>- HCA_ENTER( HCA_DBG_PNP );<BR>- <BR>- if ( 
p_fdo->state == HCA_REGISTERED) {<BR>-  if 
(p_fdo->ci_ifc.deregister_ca) {<BR>-   /* Notify AL that the 
CA is being removed. */<BR>-   p_fdo->ci_ifc.deregister_ca( 
p_fdo->hca.guid );<BR>-   p_fdo->ci_ifc.deregister_ca = 
NULL;<BR>-   /* Release AL's CI interface. 
*/<BR>-   p_fdo->ci_ifc.wdm.InterfaceDereference( 
p_fdo->ci_ifc.wdm.Context );<BR>-   p_fdo->state = 
HCA_STARTED;<BR>-   HCA_PRINT( 
TRACE_LEVEL_INFORMATION ,HCA_DBG_PNP,<BR>-    ("***** 
HCA deregistered \n"));<BR>-  }<BR>- }<BR>-<BR>- HCA_EXIT( 
HCA_DBG_PNP );<BR>-}<BR>-<BR>-static 
NTSTATUS<BR>-__hca_register(<BR>- IN    PFDO_DEVICE_DATA    p_fdo 
)<BR>-{<BR>- NTSTATUS    status;<BR>- ib_api_status_t   ib_status;<BR>- ci_interface_t   *p_hca_ifc;<BR>-<BR>- HCA_ENTER( 
HCA_DBG_PNP );<BR>- <BR>- ASSERT( p_fdo->state == HCA_STARTED 
);<BR>- ASSERT( p_fdo->p_al_dev );<BR>-<BR>- /* Get the AL's lower 
interface. */<BR>- status = __get_ci_interface( p_fdo );<BR>- if( 
!NT_SUCCESS( status ) )<BR>- {<BR>-  HCA_PRINT( 
TRACE_LEVEL_ERROR,HCA_DBG_PNP, <BR>-   ("__get_ci_interface 
returned %08x.\n", status));<BR>-  goto 
exit;<BR>- }<BR>-<BR>- /* Allocate and populate our HCA interface 
structure. */<BR>- p_hca_ifc = __alloc_hca_ifc( p_fdo );<BR>- if( 
!p_hca_ifc )<BR>- {<BR>-  HCA_PRINT( TRACE_LEVEL_ERROR  
,HCA_DBG_PNP  ,("__alloc_hca_ifc failed.\n"));<BR>-  status = 
STATUS_NO_MEMORY;<BR>-  goto exit;<BR>- }<BR>-<BR>- /* 
Notify AL that we're available... */<BR>- ib_status = 
p_fdo->ci_ifc.register_ca( p_hca_ifc );<BR>- ExFreePool( p_hca_ifc 
);<BR>- if( ib_status != IB_SUCCESS 
)<BR>- {<BR>-  p_fdo->ci_ifc.wdm.InterfaceDereference( 
p_fdo->ci_ifc.wdm.Context );<BR>-  status = 
STATUS_INSUFFICIENT_RESOURCES;<BR>-  goto 
exit;<BR>- }<BR>-<BR>- p_fdo->state = 
HCA_REGISTERED;<BR>- HCA_PRINT( TRACE_LEVEL_INFORMATION  
,HCA_DBG_PNP,<BR>-  ("***** HCA registered 
\n"));<BR>-exit:<BR>- HCA_EXIT( HCA_DBG_PNP );<BR>- return 
status;<BR>-}<BR>-<BR>-static 
NTSTATUS<BR>-__pnp_notify_ifc(<BR>- IN    void      *pNotifyStruct,<BR>- IN    void      *context 
)<BR>-{<BR>- NTSTATUS        status 

STATUS_SUCCESS;<BR>- DEVICE_INTERFACE_CHANGE_NOTIFICATION *pNotify;<BR>- PFDO_DEVICE_DATA      p_fdo 
= context;<BR>- PDEVICE_OBJECT p_dev_obj = 
WdfDeviceWdmGetDeviceObject(p_fdo->FdoDevice);<BR>-<BR>- HCA_ENTER( 
HCA_DBG_PNP );<BR>-<BR>- pNotify = 
(DEVICE_INTERFACE_CHANGE_NOTIFICATION*)pNotifyStruct;<BR>-<BR>- if( 
!IsEqualGUID( &pNotify->Event, &GUID_DEVICE_INTERFACE_ARRIVAL ) 
)<BR>-  goto done;<BR>-<BR>- /*<BR>-  * Sanity check.  
We should only be getting notifications of the <BR>-  * CI interface 
exported by AL.<BR>-  */<BR>- ASSERT( <BR>-  IsEqualGUID( 
&pNotify->InterfaceClassGuid, &GUID_IB_CI_INTERFACE ) 
);<BR>-<BR>- if( p_fdo->state != HCA_STARTED 
)<BR>- {<BR>-  HCA_PRINT( TRACE_LEVEL_ERROR  
,HCA_DBG_PNP  ,("Invalid state: %d\n", 
p_fdo->state));<BR>-  goto done;<BR>- }<BR>-<BR>- /* save 
symbolic name of IBAL for a case of cancelled IBAL removal */<BR>- if 
(!p_fdo->al_sym_name.Buffer) {<BR>-  p_fdo->al_sym_name.Length = 
pNotify->SymbolicLinkName->Length;<BR>-  p_fdo->al_sym_name.MaximumLength 

pNotify->SymbolicLinkName->MaximumLength;<BR>-  p_fdo->al_sym_name.Buffer 
= ExAllocatePoolWithTag( NonPagedPool, 
<BR>-   p_fdo->al_sym_name.MaximumLength * sizeof(wchar_t), 
MT_TAG_KERNEL );<BR>-  if 
(!p_fdo->al_sym_name.Buffer)<BR>-  {<BR>-   HCA_PRINT( 
TRACE_LEVEL_ERROR  ,HCA_DBG_PNP  ,("allocation of sym IBAL name 
failed.\n"));<BR>-   goto 
done;<BR>-  }<BR>-  RtlCopyUnicodeString( 
&p_fdo->al_sym_name, pNotify->SymbolicLinkName 
);<BR>- }<BR>-<BR>- ASSERT( !p_fdo->p_al_dev );<BR>- ASSERT( 
!p_fdo->p_al_file_obj );<BR>-<BR>- /* Get the AL device object. 
*/<BR>- HCA_PRINT( TRACE_LEVEL_INFORMATION  ,HCA_DBG_PNP  
,("Calling IoGetDeviceObjectPointer.\n"));<BR>- status = 
IoGetDeviceObjectPointer( 
pNotify->SymbolicLinkName,<BR>-  FILE_ALL_ACCESS, 
&p_fdo->p_al_file_obj, &p_fdo->p_al_dev );<BR>- if( 
!NT_SUCCESS( status ) )<BR>- {<BR>-  HCA_PRINT( 
TRACE_LEVEL_ERROR, HCA_DBG_PNP, 
<BR>-   ("IoGetDeviceObjectPointer returned %08x.\n", status 
));<BR>-  goto done;<BR>- }<BR>-<BR>- /* Register for 
removal notification of the IB Fabric root device. */<BR>- HCA_PRINT( 
TRACE_LEVEL_INFORMATION, HCA_DBG_PNP, <BR>-  ("Registering for target 
notifications.\n"));<BR>- status = IoRegisterPlugPlayNotification( 
<BR>-  EventCategoryTargetDeviceChange, 0, p_fdo->p_al_file_obj, 
<BR>-  p_dev_obj->DriverObject, __pnp_notify_target, p_fdo, 
<BR>-  &p_fdo->pnp_target_entry );<BR>- if( !NT_SUCCESS( 
status ) )<BR>- {<BR>-  HCA_PRINT( TRACE_LEVEL_ERROR, 
HCA_DBG_PNP, <BR>-   ("IoRegisterPlugPlayNotification returned 
%08x.\n", status));<BR>-  goto 
err_reg_notify;<BR>- }<BR>-<BR>- status = __hca_register( p_fdo 
);<BR>- if( !NT_SUCCESS( status ) )<BR>- {<BR>-  HCA_PRINT( 
TRACE_LEVEL_ERROR, HCA_DBG_PNP, <BR>-   ("__get_ci_interface 
returned %08x.\n", status));<BR>-  goto 
err_reg_hca;<BR>- }<BR>- goto 
done;<BR>- <BR>-err_reg_hca:<BR>- IoUnregisterPlugPlayNotification( 
p_fdo->pnp_target_entry );<BR>- p_fdo->pnp_target_entry = 
NULL;<BR>-err_reg_notify:<BR>- ObDereferenceObject( p_fdo->p_al_file_obj 
);<BR>- p_fdo->p_al_file_obj = NULL;<BR>- p_fdo->p_al_dev = 
NULL;<BR>-done:<BR>- HCA_EXIT( HCA_DBG_PNP );<BR>- return 
status;<BR>-}<BR>-<BR>-/* Forwards the request to the HCA's PDO. */<BR>-static 
NTSTATUS<BR>-__get_ifc(<BR>- IN    WDFDEVICE 
const   FdoDevice,<BR>- IN  const GUID* 
const    p_guid,<BR>- IN    USHORT     size,<BR>- IN    USHORT     Version,<BR>- IN 
OUT   PVOID     InterfaceSpecificData,<BR>- OUT    PINTERFACE    p_ifc 
)<BR>-{<BR>- NTSTATUS status;<BR>-<BR>- HCA_ENTER( HCA_DBG_PNP 
);<BR>- <BR>- status = WdfFdoQueryForInterface( FdoDevice, p_guid, 
p_ifc,<BR>-  size, Version, InterfaceSpecificData 
);<BR>-<BR>- HCA_EXIT( HCA_DBG_PNP );<BR>- return 
status;<BR>-}<BR>-<BR>-static 
void<BR> __unmap_hca_memory(<BR>  IN    PFDO_DEVICE_DATA 
const p_fdo )<BR> {<BR>@@ -507,71 +142,66 
@@<BR> <BR>  switch( p_fdo->state 
)<BR>  {<BR>- case 
HCA_REGISTERED:<BR>-  __hca_deregister( p_fdo 
);<BR>-<BR>-  /* Fall through. */<BR>  case 
HCA_STARTED:<BR>   /* dequeue HCA  
*/<BR>   mlnx_hca_remove( &p_fdo->hca 
);<BR>  }<BR>-<BR>- if (p_fdo->al_sym_name.Buffer) 
{<BR>-  ExFreePool( p_fdo->al_sym_name.Buffer 
);<BR>-  p_fdo->al_sym_name.Buffer = 
NULL;<BR>- }<BR>  <BR>- if( p_fdo->pnp_target_entry 
)<BR>- {<BR>-  ASSERT( p_fdo->pnp_ifc_entry 
);<BR>-  IoUnregisterPlugPlayNotification( p_fdo->pnp_target_entry 
);<BR>-  p_fdo->pnp_target_entry = 
NULL;<BR>- }<BR>+ __unmap_hca_memory( p_fdo );<BR> <BR>- if( 
p_fdo->pnp_ifc_entry ) {<BR>-  IoUnregisterPlugPlayNotification( 
p_fdo->pnp_ifc_entry );<BR>-  p_fdo->pnp_ifc_entry = 
NULL;<BR>- }<BR>+ p_fdo->state = HCA_ADDED;<BR> <BR>- if( 
p_fdo->p_al_file_obj ) {<BR>-  ObDereferenceObject( 
p_fdo->p_al_file_obj );<BR>-  p_fdo->p_al_file_obj = 
NULL;<BR>- }<BR>+ HCA_EXIT( HCA_DBG_PNP 
);<BR>+}<BR> <BR>- __unmap_hca_memory( p_fdo );<BR>+static 
void<BR>+__ref_ifc(<BR>+ IN    DEVICE_OBJECT*    p_dev_obj 
)<BR>+{<BR>+ PFDO_DEVICE_DATA p_fdo = 
(PFDO_DEVICE_DATA)p_dev_obj->DeviceExtension;<BR> <BR>- p_fdo->state 
= HCA_ADDED;<BR>+ HCA_ENTER( HCA_DBG_PNP 
);<BR> <BR>+ cl_atomic_inc( &p_fdo->n_hca_ifc_ref 
);<BR>+ ObReferenceObject( p_dev_obj );<BR>+<BR>+ HCA_PRINT( 
TRACE_LEVEL_ERROR, HCA_DBG_PNP, <BR>+  ("MLX4_HCA: CA_guid %I64x, 
hca_ifc_ref %d\n",<BR>+  p_fdo->hca.guid, p_fdo->n_hca_ifc_ref) 
);<BR>+<BR>  HCA_EXIT( HCA_DBG_PNP );<BR> }<BR> <BR>+static 
void<BR>+__deref_ifc(<BR>+ IN    DEVICE_OBJECT*    p_dev_obj 
)<BR>+{<BR>+ PFDO_DEVICE_DATA p_fdo = 
(PFDO_DEVICE_DATA)p_dev_obj->DeviceExtension;<BR>+<BR>+ HCA_ENTER( 
HCA_DBG_PNP );<BR>+<BR>+ cl_atomic_dec( &p_fdo->n_hca_ifc_ref 
);<BR>+ ObDereferenceObject( p_dev_obj );<BR>+<BR>+ HCA_PRINT( 
TRACE_LEVEL_ERROR, HCA_DBG_PNP, <BR>+  ("MLX4_HCA: CA_guid %I64x, 
hca_ifc_ref %d\n",<BR>+  p_fdo->hca.guid, p_fdo->n_hca_ifc_ref) 
);<BR>+<BR>+ HCA_EXIT( HCA_DBG_PNP 
);<BR>+}<BR>+<BR>+<BR>+<BR> NTSTATUS<BR> EvtDeviceD0Entry(<BR>  IN 
WDFDEVICE  Device,<BR>  IN WDF_POWER_DEVICE_STATE  
PreviousState<BR>  )<BR> {<BR>- PFDO_DEVICE_DATA p_fdo = 
FdoGetData(Device);<BR>- NTSTATUS status = 
STATUS_SUCCESS;<BR>-<BR>+ UNUSED_PARAM(Device);<BR>  UNUSED_PARAM(PreviousState);<BR>  HCA_ENTER( 
HCA_DBG_PNP );<BR>-<BR>  HCA_PRINT(TRACE_LEVEL_INFORMATION, 
HCA_DBG_PNP, ("EvtDeviceD0Entry: PreviousState 0x%x\n", 
PreviousState));<BR>-<BR>- /* Connect to IBAL */<BR>- HCA_PRINT( 
TRACE_LEVEL_INFORMATION, HCA_DBG_PO, <BR>-  ("***** Connect to IBAL, 
IRQL %d\n", KeGetCurrentIrql()));<BR>-<BR>- if( p_fdo->p_al_dev 
&& p_fdo->state == HCA_STARTED) {<BR>-  status = 
__hca_register( p_fdo );<BR>-  if( !NT_SUCCESS( status ) ) 
{<BR>-   HCA_PRINT( TRACE_LEVEL_ERROR, HCA_DBG_PO, 
<BR>-    ("!!! __hca_register failed (%#x) \n", 
status));<BR>-   status = 
STATUS_UNSUCCESSFUL;<BR>-  }<BR>- }<BR>-<BR>  HCA_EXIT( 
HCA_DBG_PNP );<BR>  return STATUS_SUCCESS;<BR> }<BR>@@ -598,7 
+228,6 @@<BR>   }<BR>   /* Fall through. 
*/<BR>  default:<BR>-  __hca_deregister( p_fdo 
);<BR>   status = 
STATUS_SUCCESS;<BR>   break;<BR>  }<BR>@@ -617,8 
+246,10 @@<BR>  int err;<BR>  NTSTATUS 
status;<BR>  PFDO_DEVICE_DATA p_fdo  = 
FdoGetData(Device);<BR>- PDEVICE_OBJECT p_dev_obj = 
WdfDeviceWdmGetDeviceObject(Device);<BR>  BUS_INTERFACE_STANDARD bus_pci_ifc;<BR>+ ci_interface_t 
*p_hca_ifc;<BR>+ RDMA_INTERFACE_VERBS rdma_ifc, *p_ifc = 
&rdma_ifc;<BR>+ WDF_QUERY_INTERFACE_CONFIG 
qiConfig;<BR>   <BR>  UNUSED_PARAM(ResourcesRaw);<BR>  UNUSED_PARAM(ResourcesTranslated);<BR>@@ 
-627,11 +258,9 
@@<BR>  <BR>  HCA_PRINT(TRACE_LEVEL_INFORMATION, 
HCA_DBG_PNP, ("EvtPrepareHardware: 
\n"));<BR> <BR>- ASSERT(p_dev_obj);<BR>-<BR>  /* get PCI BUS 
interface */<BR>- status = __get_ifc( Device, 
&GUID_BUS_INTERFACE_STANDARD,<BR>-  sizeof(BUS_INTERFACE_STANDARD), 
1, NULL, (PINTERFACE)&bus_pci_ifc);<BR>+ status = 
WdfFdoQueryForInterface( Device, 
&GUID_BUS_INTERFACE_STANDARD,<BR>+  (PINTERFACE)&bus_pci_ifc, 
sizeof(BUS_INTERFACE_STANDARD), 1, NULL );<BR>  if( !NT_SUCCESS( 
status ) ) {<BR>   HCA_PRINT(TRACE_LEVEL_ERROR, HCA_DBG_PNP, 
("Getting PCI BUS interface failed: status=0x%x\n", 
status));<BR>   return status;<BR>@@ -640,8 +269,8 
@@<BR>  p_fdo->bus_pci_ifc_taken = 
TRUE;<BR>  <BR>  /* get MLX4_BUS IB interface 
*/<BR>- status = __get_ifc( Device, 
&MLX4_BUS_IB_INTERFACE_GUID,<BR>-  sizeof(MLX4_BUS_IB_INTERFACE), 
MLX4_BUS_IB_INTERFACE_VERSION, NULL, 
(PINTERFACE)&p_fdo->bus_ib_ifc);<BR>+ status = 
WdfFdoQueryForInterface( Device, 
&MLX4_BUS_IB_INTERFACE_GUID,<BR>+  (PINTERFACE)&p_fdo->bus_ib_ifc, 
sizeof(MLX4_BUS_IB_INTERFACE), MLX4_BUS_IB_INTERFACE_VERSION, NULL 
);<BR>  if( !NT_SUCCESS( status ) ) 
{<BR>   HCA_PRINT(TRACE_LEVEL_ERROR, HCA_DBG_PNP, ("Getting MLX4 
BUS interface failed: status=0x%x\n", status));<BR>   return 
status;<BR>@@ -665,27 +294,41 @@<BR>  /* queue HCA  
*/<BR>  mlnx_hca_insert( &p_fdo->hca );<BR> <BR>+ /* 
Allocate and populate our HCA interface structure. */<BR>+ p_hca_ifc = 
__alloc_hca_ifc( p_fdo );<BR>+ if( !p_hca_ifc ) 
{<BR>+  HCA_PRINT( TRACE_LEVEL_ERROR  ,HCA_DBG_PNP  
,("__alloc_hca_ifc failed.\n"));<BR>+  return 
STATUS_NO_MEMORY;<BR>+ }<BR>+<BR>+ /* fill interface fields 
*/<BR>+ p_ifc->InterfaceHeader.Size = 
sizeof(RDMA_INTERFACE_VERBS);<BR>+ p_ifc->InterfaceHeader.Version = 
VerbsVersion(VERBS_MAJOR_VER, 
VERBS_MINOR_VER);<BR>+ p_ifc->InterfaceHeader.Context = 
p_fdo->p_dev_obj;<BR>+ p_ifc->InterfaceHeader.InterfaceReference = 
__ref_ifc;<BR>+ p_ifc->InterfaceHeader.InterfaceDereference = 
__deref_ifc;<BR>+ p_ifc->Verbs = 
*p_hca_ifc;<BR>+ p_ifc->p_hca_obj = 
&p_fdo->hca;<BR>+ ExFreePool( p_hca_ifc );<BR>+<BR>+ /* create 
an upper interface */<BR>+ WDF_QUERY_INTERFACE_CONFIG_INIT( &qiConfig, 
(PINTERFACE)p_ifc,<BR>+  &GUID_RDMA_INTERFACE_VERBS, 
NULL);<BR>+<BR>+ status = WdfDeviceAddQueryInterface( Device, &qiConfig 
);<BR>+ if (!NT_SUCCESS(status)) {<BR>+  HCA_PRINT( 
TRACE_LEVEL_ERROR  ,HCA_DBG_PNP  ,("WdfDeviceAddQueryInterface failed 
%#x\n", status));<BR>+  return 
status;<BR>+ }<BR>+<BR>  /*<BR>   * Change the state 
since the PnP callback can happen<BR>   * before the callback 
returns.<BR>   */<BR>  p_fdo->state = 
HCA_STARTED;<BR>  <BR>- /* Register for interface arrival of the 
IB_AL device. */<BR>- status = 
IoRegisterPlugPlayNotification(<BR>-  EventCategoryDeviceInterfaceChange,<BR>-  PNPNOTIFY_DEVICE_INTERFACE_INCLUDE_EXISTING_INTERFACES,<BR>-  (void*)&GUID_IB_CI_INTERFACE, 
p_dev_obj->DriverObject,<BR>-  __pnp_notify_ifc, p_fdo, 
&p_fdo->pnp_ifc_entry );<BR>- if( !NT_SUCCESS( status ) 
)<BR>- {<BR>-  p_fdo->state = 
HCA_ADDED;<BR>-  HCA_PRINT( TRACE_LEVEL_ERROR, 
HCA_DBG_PNP,<BR>-   ("IoRegisterPlugPlayNotification returned 
%08x.\n", status));<BR>- }<BR>-<BR>  HCA_EXIT( HCA_DBG_PNP 
);<BR>- return status;<BR>+ return 
STATUS_SUCCESS;<BR> }<BR> <BR> <BR>@@ -708,14 +351,16 
@@<BR> <BR>  // release MLX4_BUS 
resources<BR>  if(p_fdo->bus_ib_ifc_taken) 
{<BR>+  PINTERFACE p_ifc = 
(PINTERFACE)&p_fdo->bus_ib_ifc;<BR>+  p_ifc->InterfaceDereference( 
p_ifc->Context );<BR>   p_fdo->bus_ib_ifc_taken = 
FALSE;<BR>-  __put_ifc( (PINTERFACE)&p_fdo->bus_ib_ifc 
);<BR>  }<BR> <BR>  // release PCI BUS 
resources<BR>  if(p_fdo->bus_pci_ifc_taken) 
{<BR>+  PINTERFACE p_ifc = 
(PINTERFACE)&p_fdo->bus_pci_ifc;<BR>+  p_ifc->InterfaceDereference( 
p_ifc->Context );<BR>   p_fdo->bus_pci_ifc_taken = 
FALSE;<BR>-  __put_ifc( (PINTERFACE)&p_fdo->bus_pci_ifc 
);<BR>  }<BR> <BR>  HCA_EXIT( HCA_DBG_PNP );<BR>@@ 
-730,7 +375,7 @@<BR>  PFDO_DEVICE_DATA p_fdo = 
FdoGetData(Device);<BR>  HCA_ENTER( HCA_DBG_PNP );<BR>  if 
(atomic_read(&p_fdo->usecnt)) {<BR>-  cl_dbg_out( "MLX4: Can't 
get unloaded. %d applications are still in work\n", 
p_fdo->usecnt);<BR>+  cl_dbg_out( "MLX4_HCA: Can't get unloaded. %d 
applications are still in work\n", 
p_fdo->usecnt);<BR>   return 
STATUS_UNSUCCESSFUL;<BR>  }<BR>  HCA_EXIT( HCA_DBG_PNP 
);<BR>@@ -739,14 +384,14 
@@<BR> <BR> <BR> NTSTATUS<BR>-EvtDeviceAdd(<BR>+EvtDriverDeviceAdd(<BR>  IN 
WDFDRIVER        Driver,<BR>  IN 
PWDFDEVICE_INIT  DeviceInit<BR>  )<BR> /*++<BR> Routine 
Description:<BR> <BR>- EvtDeviceAdd is called by the framework in 
response to AddDevice<BR>+ EvtDriverDeviceAdd is called by the framework in 
response to AddDevice<BR>  call from the PnP manager. We create and 
initialize a device object to<BR>  represent a new instance of mxe 
bus.<BR> <BR>@@ -772,7 +417,7 @@<BR> <BR>  PAGED_CODE 
();<BR>  <BR>- HCA_PRINT(TRACE_LEVEL_INFORMATION, HCA_DBG_PNP, 
("EvtDeviceAdd: 0x%p\n", Driver));<BR>+ HCA_PRINT(TRACE_LEVEL_INFORMATION, 
HCA_DBG_PNP, ("EvtDriverDeviceAdd: 0x%p\n", 
Driver));<BR>  //<BR>  // register PnP & Power 
stuff<BR>  //<BR>@@ -806,7 +451,7 
@@<BR>  //<BR>  status = WdfDeviceCreate(&DeviceInit, 
&attributes, &device);<BR>  if (!NT_SUCCESS(status)) 
{<BR>-  HCA_PRINT(TRACE_LEVEL_VERBOSE, HCA_DBG_PNP, ("EvtDeviceAdd: 
WdfDeviceCreate failed with 0x%x\n", 
status));<BR>+  HCA_PRINT(TRACE_LEVEL_VERBOSE, HCA_DBG_PNP, 
("EvtDriverDeviceAdd: WdfDeviceCreate failed with 0x%x\n", 
status));<BR>   goto end;<BR>  }<BR> <BR>@@ -816,6 
+461,7 @@<BR>  p_fdo = 
FdoGetData(device);<BR>  RtlZeroMemory(p_fdo, 
sizeof(FDO_DEVICE_DATA));<BR>  p_fdo->FdoDevice = 
device;<BR>+ p_fdo->p_dev_obj = WdfDeviceWdmGetDeviceObject( device 
);<BR>  spin_lock_init( &p_fdo->uctx_lock 
);<BR>  cl_qlist_init( &p_fdo->uctx_list 
);<BR>  atomic_set(&p_fdo->usecnt, 0);<BR>@@ -887,9 +533,7 
@@<BR>  g.DebugPrintLevel = 
TRACE_LEVEL_VERBOSE;<BR>  g.DebugPrintFlags = 
0xffff;<BR>  HCA_ENTER( HCA_DBG_PNP 
);<BR>- HCA_PRINT(TRACE_LEVEL_INFORMATION, HCA_DBG_PNP, 
<BR>-  ("Built %s %s, Version %s, RelDate %s\n", 
<BR>-  __DATE__, __TIME__, DRV_VERSION, 
DRV_RELDATE));<BR>+<BR>  status = mlnx_hcas_init();<BR>  if( 
status  != STATUS_SUCCESS ) {<BR>   HCA_PRINT( 
TRACE_LEVEL_ERROR ,HCA_DBG_PNP ,<BR>@@ -906,7 +550,7 
@@<BR>  //<BR> <BR>  WDF_DRIVER_CONFIG_INIT(<BR>-  &config, 
EvtDeviceAdd );<BR>+  &config, EvtDriverDeviceAdd 
);<BR>  config.EvtDriverUnload = 
EvtDriverUnload;<BR> <BR>  //<BR>@@ -949,6 +593,8 
@@<BR>  }<BR> <BR> end:<BR>+ HCA_PRINT( 
TRACE_LEVEL_ERROR ,HCA_DBG_PNP ,<BR>+  ("exit status %#x.\n", 
status));<BR>  HCA_EXIT( HCA_DBG_PNP );<BR>  return 
status;<BR> <BR>@@ -1133,6 +779,15 @@<BR>  return 
status;<BR> }<BR> <BR>+static 
void<BR>+__put_ifc(<BR>+  IN PINTERFACE  p_ifc 
)<BR>+{<BR>+ HCA_ENTER( HCA_DBG_PNP 
);<BR>+ p_ifc->InterfaceDereference( p_ifc->Context 
);<BR>+ HCA_EXIT( HCA_DBG_PNP );<BR>+}<BR>+<BR> /* Forwards the 
request to the HCA's PDO. */<BR> static NTSTATUS<BR> __get_ifc(<BR>@@ 
-2301,9 +1956,6 @@<BR>  g.DebugPrintFlags = 
0xffff;<BR> <BR>  HCA_ENTER( HCA_DBG_PNP 
);<BR>- HCA_PRINT(TRACE_LEVEL_INFORMATION, HCA_DBG_PNP, 
<BR>-  ("Built %s %s, Version %s, RelDate %s\n", 
<BR>-  __DATE__, __TIME__, DRV_VERSION, 
DRV_RELDATE));<BR> <BR>  status = 
mlnx_hcas_init();<BR>  if( status  != STATUS_SUCCESS ) 
{<BR>Index: 
hw/mlx4/kernel/hca/drv.h<BR>===================================================================<BR>--- 
hw/mlx4/kernel/hca/drv.h (revision 2055)<BR>+++ 
hw/mlx4/kernel/hca/drv.h (working copy)<BR>@@ -150,16 +150,19 
@@<BR>  *  WDF DATA  <BR>  * 
------------------------------------------------ 
*/<BR>  WDFDEVICE     FdoDevice;<BR>+ DEVICE_OBJECT   * p_dev_obj;  /* 
WDM dev object 
*/<BR> #endif<BR> <BR>  HCA_WMI_STD_DATA   WmiData;<BR> <BR>+#ifdef 
USE_WDM_FRAMEWORK<BR>  /* 
-------------------------------------------------<BR>  *  PNP 
DATA   <BR>  * ------------------------------------------------ 
*/<BR>  void     * pnp_ifc_entry;   /* 
Notification entry for PnP interface events. 
*/<BR>  void     * pnp_target_entry; /* 
Notification entry for PnP target events. 
*/<BR>  PNP_DEVICE_STATE   pnpState; /* state for PnP 
Manager */<BR>+#endif <BR> <BR>  /* 
-------------------------------------------------<BR>  *  IBAL 
DATA   <BR>@@ -167,9 +170,11 @@<BR>  /* Number of references on 
the upper interface. 
*/<BR>  atomic32_t     n_hca_ifc_ref;<BR>  hca_reg_state_t    state;    /* 
State for tracking registration with AL */<BR>+#ifdef 
USE_WDM_FRAMEWORK<BR>  DEVICE_OBJECT   * p_al_dev;  /* 
IB_AL FDO 
*/<BR>  FILE_OBJECT    * p_al_file_obj; /* 
IB_AL file object 
*/<BR>  UNICODE_STRING    al_sym_name; /* 
IB_AL symbolic name */<BR>+#endif <BR> <BR>  /* 
-------------------------------------------------<BR>  *  SHIM 
DATA  <BR>@@ -300,7 +305,7 
@@<BR>  );<BR> <BR> NTSTATUS<BR>-EvtDeviceAdd(<BR>+EvtDriverDeviceAdd(<BR>  IN 
WDFDRIVER Driver,<BR>  IN PWDFDEVICE_INIT 
Device<BR>  );<BR>Index: 
hw/mlx4/kernel/hca/mlx4_hca.inx<BR>===================================================================<BR>--- 
hw/mlx4/kernel/hca/mlx4_hca.inx (revision 2055)<BR>+++ 
hw/mlx4/kernel/hca/mlx4_hca.inx (working copy)<BR>@@ -391,12 +391,6 
@@<BR> DelService = Ibbus,%SPSVCINST_STOPSERVICE%<BR> DelService = 
mlx4_hca,%SPSVCINST_STOPSERVICE%<BR> <BR>-<BR>-;<BR>-; It should be 
uncommented after returning MLX4_HCA to WDF model.<BR>-; WinVerbs is a WDF, KMDF 
driver.<BR>-;<BR>-<BR> ;*****************************************<BR> ; 
WDF Coinstaller installation 
section<BR> ;*****************************************<BR>@@ -420,14 
+414,17 
@@<BR> WdfCoInstaller01007.dll<BR> <BR> [MLX4HCA.DDInstall.ntx86.Wdf]<BR>+KmdfService 
= mlx4_hca,WvWdfSect<BR> KmdfService = 
WinVerbs,WvWdfSect<BR> KmdfService = 
WinMad,WvWdfSect<BR> <BR> [MLX4HCA.DDInstall.ntamd64.Wdf]<BR>+KmdfService 
= mlx4_hca,WvWdfSect<BR> KmdfService = 
WinVerbs,WvWdfSect<BR> KmdfService = 
WinMad,WvWdfSect<BR> <BR> [MLX4HCA.DDInstall.ntia64.Wdf]<BR>+KmdfService 
= mlx4_hca,WvWdfSect<BR> KmdfService = 
WinVerbs,WvWdfSect<BR> KmdfService = WinMad,WvWdfSect<BR> <BR>Index: 
hw/mlx4/kernel/hca/SOURCES<BR>===================================================================<BR>--- 
hw/mlx4/kernel/hca/SOURCES (revision 2055)<BR>+++ 
hw/mlx4/kernel/hca/SOURCES (working copy)<BR>@@ -42,7 +42,8 
@@<BR> <BR> KMDF_VERSION=1<BR> <BR>-C_DEFINES=$(C_DEFINES) 
-DDRIVER -DDEPRECATE_DDK_FUNCTIONS -D__LITTLE_ENDIAN -DUSE_WDM_FRAMEWORK 
-DUSE_WDM_INTERRUPTS<BR>+C_DEFINES=$(C_DEFINES) -DDRIVER 
-DDEPRECATE_DDK_FUNCTIONS -D__LITTLE_ENDIAN <BR>+#-DUSE_WDM_FRAMEWORK 
<BR> <BR> TARGETLIBS= 
\<BR>  $(TARGETPATH)\*\complib.lib \<BR></FONT></DIV></BODY></HTML>