]> git.openfabrics.org - ~shefty/rdma-win.git/commitdiff
[mthca-kmdf] link, possible initialize OK.
authorstansmith <stansmith@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Thu, 13 Mar 2008 17:01:29 +0000 (17:01 +0000)
committerstansmith <stansmith@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Thu, 13 Mar 2008 17:01:29 +0000 (17:01 +0000)
git-svn-id: svn://openib.tc.cornell.edu/gen1@990 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86

branches/IBFD/hw/mthca/kmdf/SOURCES
branches/IBFD/hw/mthca/kmdf/hca.rc
branches/IBFD/hw/mthca/kmdf/hca_driver.c
branches/IBFD/hw/mthca/kmdf/hca_pnp.c
branches/IBFD/hw/mthca/kmdf/hca_pnp.h

index 4d97c63cc1b1353b2e4486438cb9f52f2519d2ab..6a38dc425bf53320c8bbf031c1139ba08ef2525e 100644 (file)
@@ -64,8 +64,7 @@ SOURCES= \
 INCLUDES=$(INCLUDES);\\r
        ..; \\r
        $(TRUNK)\inc;   \\r
-       $(TRUNK)\inc\kernel; \\r
-       $(TARGETPATH)\*;\r
+       $(TRUNK)\inc\kernel; \r
        \r
 C_DEFINES=$(C_DEFINES) -DDRIVER -DDEPRECATE_DDK_FUNCTIONS -D__LITTLE_ENDIAN\r
 \r
@@ -93,5 +92,5 @@ RUN_WPP= $(SOURCES) -km -ext: .c .h .C .H \
 #      -func:HCA_PRINT_EV(LEVEL,FLAGS,(MSG,...)) \\r
 \r
 MSC_OPTIMIZATION=/Oi\r
-# ignore volatile ignored warning @ line 318 in mt_atmoic.h\r
+# FIX ASAP - ignore volatile warning @ line 318 in mt_atmoic.h\r
 MSC_WARNING_LEVEL= /W4 /wd4197 /wd4201 /wd4324\r
index 88cc9c03b08b441c28483b78e5d47eb51604d2c8..ce8ec4ffc3085b9c5f377de6ddcdd85dc1831d46 100644 (file)
@@ -35,9 +35,9 @@
 #define VER_FILETYPE                           VFT_DRV\r
 #define VER_FILESUBTYPE                                VFT2_DRV_SYSTEM\r
 #ifdef DBG\r
-#define VER_FILEDESCRIPTION_STR     "WDF-KMDF HCA Driver (checked)"\r
+#define VER_FILEDESCRIPTION_STR     "InfiniBand HCA Driver [KMDF] (checked)"\r
 #else\r
-#define VER_FILEDESCRIPTION_STR     "WDF-KMDF HCA Driver"\r
+#define VER_FILEDESCRIPTION_STR     "InfiniBand HCA Driver [KMDF]"\r
 #endif\r
 #define VER_INTERNALNAME_STR        "mthca.sys"\r
 #define VER_ORIGINALFILENAME_STR    "mthca.sys"\r
index d0a1b4138f565c56dc6a2e11c233bab8dd20f3c7..407bf4a40321f3eb60a1d9eb92df5640b79fb2f8 100644 (file)
@@ -1286,9 +1286,6 @@ HcaEvtDeviceAdd (
     // be discouraged, it is possible to handle it by doing device init and\r
     // tear down in these routines rather than in EvtDeviceD0Entry and\r
     // EvtDeviceD0Exit.\r
-    //\r
-    // In this sample these callbacks don't do anything.\r
-    //\r
 \r
     pnpPowerCallbacks.EvtDeviceD0EntryPostInterruptsEnabled =\r
                                                                        HcaEvtDeviceD0EntryPostInterruptsEnabled;\r
index d95e14f710e3e012024b51a2cb8f1ed0c4a2e130..dc41141d6ec8ca222b248b77e13f004f4462d12b 100644 (file)
@@ -2,7 +2,6 @@
 ** END_ICS_COPYRIGHT   ****************************************/\r
 /*\r
  * Copyright (c) 2008 Intel corporation.  All rights reserved.\r
- * Copyright (c) 2005 SilverStorm Technologies.  All rights reserved.\r
  *\r
  * This software is available to you under the OpenIB.org BSD license\r
  * below:\r
 \r
 extern const char *mthca_version;\r
 \r
+#ifdef NOT_USED_XXX\r
 NTSTATUS\r
 hca_add_device(\r
-       IN                              PDRIVER_OBJECT                          pDriverObj,\r
-       IN                              PDEVICE_OBJECT                          pPdo,\r
-       IN                              PDEVICE_OBJECT                          p_dev_obj );\r
+       IN      PDRIVER_OBJECT                  pDriverObj,\r
+       IN      PDEVICE_OBJECT                  pPdo,\r
+       IN      PDEVICE_OBJECT                  p_dev_obj );\r
+#endif\r
 \r
 static NTSTATUS\r
 hca_start(\r
-       IN                              DEVICE_OBJECT* const            p_dev_obj,\r
-       IN                              IRP* const                                      p_irp, \r
-               OUT                     cl_irp_action_t* const          p_action );\r
+       IN   DEVICE_OBJECT* const       p_dev_obj,\r
+       IN       hca_dev_ext_t*                 p_ext,\r
+       IN       WDFCMRESLIST                   Resources,\r
+       IN       WDFCMRESLIST                   ResourcesTranslated );\r
 \r
 static NTSTATUS\r
 hca_query_stop(\r
@@ -91,7 +93,8 @@ hca_query_remove(
 \r
 static void\r
 hca_release_resources(\r
-       IN                              DEVICE_OBJECT* const            p_dev_obj );\r
+       IN                              DEVICE_OBJECT* const            p_dev_obj,\r
+       IN                              hca_dev_ext_t*                          p_ext );\r
 \r
 static NTSTATUS\r
 hca_cancel_remove(\r
@@ -177,7 +180,6 @@ __pnp_notify_ifc(
 #pragma alloc_text (PAGE, HcaEvtDeviceWakeArmSx)\r
 #pragma alloc_text (PAGE, HcaSetPowerPolicy)\r
 \r
-#pragma alloc_text (PAGE, hca_add_device)\r
 #pragma alloc_text (PAGE, hca_start)\r
 #pragma alloc_text (PAGE, hca_query_stop)\r
 #pragma alloc_text (PAGE, hca_stop)\r
@@ -210,12 +212,12 @@ void
 hca_init_vfptr( void )\r
 {\r
        vfptrHcaPnp.identity = "HCA driver";\r
-       vfptrHcaPnp.pfn_start = hca_start;\r
+       vfptrHcaPnp.pfn_start = cl_irp_ignore /*hca_start*/;\r
        vfptrHcaPnp.pfn_query_stop = hca_query_stop;\r
        vfptrHcaPnp.pfn_stop = hca_stop;\r
        vfptrHcaPnp.pfn_cancel_stop = hca_cancel_stop;\r
        vfptrHcaPnp.pfn_query_remove = hca_query_remove;\r
-       vfptrHcaPnp.pfn_release_resources = hca_release_resources;\r
+       vfptrHcaPnp.pfn_release_resources = cl_irp_ignore /*hca_release_resources*/;\r
        vfptrHcaPnp.pfn_remove = cl_do_remove;\r
        vfptrHcaPnp.pfn_cancel_remove = hca_cancel_remove;\r
        vfptrHcaPnp.pfn_surprise_remove = hca_surprise_remove;\r
@@ -686,19 +688,23 @@ done:
  *     - Configuration Space: not prefetchable, read/write\r
  *     - UAR space: prefetchable, write only.\r
  *     - DDR: prefetchable, read/write.\r
+ *\r
+ * Inputs:\r
+ *     p_ext                   - fdoData (device extension)\r
+ *     pHcaResList             - Raw (bus relative addresses) Resource list\r
+ *     pHostResList    - Translated (to system addresses) Resource list\r
+ *\r
  */\r
 static NTSTATUS\r
-__SetupHcaResources(\r
-       IN                              DEVICE_OBJECT* const            p_dev_obj,\r
-       IN                              CM_RESOURCE_LIST* const         pHcaResList,\r
-       IN                              CM_RESOURCE_LIST* const         pHostResList )\r
+__SetupHcaResources( IN   hca_dev_ext_t*               p_ext,\r
+                                        IN   WDFCMRESLIST                      pHcaResList,\r
+                                        IN   WDFCMRESLIST                      pHostResList )\r
 {\r
-       NTSTATUS                                                status = STATUS_SUCCESS;\r
-       hca_dev_ext_t                                   *p_ext;\r
-       USHORT                                                  i;\r
-       hca_bar_type_t                                  type = HCA_BAR_TYPE_HCR;\r
+       NTSTATUS                status = STATUS_SUCCESS;\r
+       USHORT                  i;\r
+       hca_bar_type_t  type = HCA_BAR_TYPE_HCR;\r
 \r
-       CM_PARTIAL_RESOURCE_DESCRIPTOR  *pHcaRes, *pHostRes;\r
+       PCM_PARTIAL_RESOURCE_DESCRIPTOR pHcaRes, pHostRes;\r
 \r
        HCA_ENTER( HCA_DBG_PNP );\r
 \r
@@ -706,18 +712,20 @@ __SetupHcaResources(
        if (!pHcaResList || !pHostResList)\r
                goto done;\r
                \r
-       p_ext = (hca_dev_ext_t*)p_dev_obj->DeviceExtension;\r
-\r
        // store the bus number for reset of Tavor\r
-       p_ext->bus_number = pHostResList->List[0].BusNumber;\r
+       pHostRes = WdfCmResourceListGetDescriptor(pHostResList, 0);  \r
+       p_ext->bus_number = pHostRes->u.BusNumber.Start; // XXX Correct bus # ?\r
        \r
-       for( i = 0; i < pHostResList->List[0].PartialResourceList.Count; i++ )\r
+       for( i = 0; i <WdfCmResourceListGetCount(pHostResList); i++ )\r
        {\r
-               pHcaRes =\r
-                       &pHcaResList->List[0].PartialResourceList.PartialDescriptors[i];\r
-               pHostRes = \r
-                       &pHostResList->List[0].PartialResourceList.PartialDescriptors[i];\r
-\r
+               pHcaRes = WdfCmResourceListGetDescriptor(pHcaResList, i); \r
+               pHostRes = WdfCmResourceListGetDescriptor(pHostResList, i);  \r
+        if(!pHcaRes || !pHostRes){\r
+            TraceEvents(TRACE_LEVEL_ERROR, DBG_INIT,\r
+                                       "WdfResourceCmGetDescriptor() err pHcaRes %p pHostRes %p\n",\r
+                                       pHcaRes, pHostRes);\r
+            return STATUS_DEVICE_CONFIGURATION_ERROR;\r
+        }\r
 \r
                /*\r
                 * Save the interrupt information so that we can power the device\r
@@ -816,7 +824,8 @@ __UnmapHcaMemoryResources(
 }\r
 \r
 \r
-static int mthca_get_livefish_info(struct mthca_dev *mdev, __be64 *node_guid, u32 *hw_id)\r
+static int\r
+mthca_get_livefish_info(struct mthca_dev *mdev, __be64 *node_guid, u32 *hw_id)\r
 {\r
        *node_guid = cl_hton64((uint64_t)(ULONG_PTR)mdev);\r
        mdev->ib_dev.node_guid = *node_guid;\r
@@ -824,33 +833,36 @@ static int mthca_get_livefish_info(struct mthca_dev *mdev, __be64 *node_guid, u3
        return 0;\r
 }\r
 \r
+\r
+/*\r
+       p_dev_obj - DEVICE_OBJECT*\r
+       p_ext - FDO_DATA* device extension data\r
+    ResourcesRaw - Handle to a collection of framework resource objects.\r
+                   This collection identifies the raw (bus-relative) hardware\r
+                   resources that have been assigned to the device.\r
+\r
+    ResourcesTranslated - Handle to a collection of framework resource objects.\r
+                This collection identifies the translated (system-physical)\r
+                hardware resources that have been assigned to the device.\r
+                The resources appear from the CPU's point of view.\r
+                Use this list of resources to map I/O space and\r
+                device-accessible memory into virtual address space\r
+*/\r
+\r
 static NTSTATUS\r
 hca_start(\r
-       IN                              DEVICE_OBJECT* const            p_dev_obj,\r
-       IN                              IRP* const                                      p_irp, \r
-               OUT                     cl_irp_action_t* const          p_action )\r
+       IN   DEVICE_OBJECT* const       p_dev_obj,\r
+       IN       hca_dev_ext_t*                 p_ext,\r
+       WDFCMRESLIST                            ResourcesRaw,\r
+       WDFCMRESLIST                            ResourcesTranslated )\r
 {\r
        NTSTATUS                        status;\r
-       hca_dev_ext_t           *p_ext;\r
-       IO_STACK_LOCATION       *pIoStack;\r
        POWER_STATE                     powerState;\r
        DEVICE_DESCRIPTION      devDesc;\r
+       DEVICE_OBJECT           *pdo;\r
 \r
        HCA_ENTER( HCA_DBG_PNP );\r
 \r
-       p_ext = (hca_dev_ext_t*)p_dev_obj->DeviceExtension;\r
-\r
-       /* Handled on the way up. */\r
-       status = cl_do_sync_pnp( p_dev_obj, p_irp, p_action );\r
-       if( !NT_SUCCESS( status ) )\r
-       {\r
-               HCA_PRINT( TRACE_LEVEL_ERROR, HCA_DBG_PNP, \r
-                       ("Lower drivers failed IRP_MN_START_DEVICE (%#x).\n", status));\r
-               return status;\r
-       }\r
-\r
-       pIoStack = IoGetCurrentIrpStackLocation( p_irp );\r
-\r
        /*\r
         * Walk the resource lists and store the information.  The write-only\r
         * flag is not set for the UAR region, so it is indistinguishable from the\r
@@ -860,13 +872,12 @@ hca_start(
         *      - UAR space: prefetchable, write only.\r
         *      - DDR: prefetchable, read/write.\r
         */\r
-       status = __SetupHcaResources( p_dev_obj,\r
-               pIoStack->Parameters.StartDevice.AllocatedResources,\r
-               pIoStack->Parameters.StartDevice.AllocatedResourcesTranslated );\r
+       status = __SetupHcaResources( p_ext, ResourcesRaw, ResourcesTranslated );\r
+\r
        if( !NT_SUCCESS( status ) )\r
        {\r
                HCA_PRINT( TRACE_LEVEL_ERROR, HCA_DBG_PNP, \r
-                       ("__ProcessResources returned %08X.\n", status));\r
+                       ("__SetupHcaResources failed %08X.\n", status));\r
                return status;\r
        }\r
        \r
@@ -888,8 +899,10 @@ hca_start(
        // get the adapter object\r
        // 0x80000000 is a threshold, that's why - 1\r
        devDesc.MaximumLength = 0x80000000 - 1;\r
-       p_ext->p_dma_adapter = IoGetDmaAdapter(\r
-               p_ext->cl_ext.p_pdo, &devDesc, &p_ext->n_map_regs );\r
+       pdo = WdfDeviceWdmGetPhysicalDevice(p_ext->WdfDevice);\r
+       p_ext->p_dma_adapter = IoGetDmaAdapter( pdo,\r
+                                                                                       &devDesc,\r
+                                                                                       &p_ext->n_map_regs );\r
        if( !p_ext->p_dma_adapter )\r
        {\r
                HCA_PRINT( TRACE_LEVEL_ERROR, HCA_DBG_PNP, \r
@@ -911,10 +924,13 @@ hca_start(
        {\r
                int err;\r
                if (mthca_is_livefish(p_ext->hca.mdev)) \r
-                       err = mthca_get_livefish_info( p_ext->hca.mdev, &p_ext->hca.guid, &p_ext->hca.hw_ver );\r
+                       err = mthca_get_livefish_info( p_ext->hca.mdev,\r
+                                                                                  &p_ext->hca.guid,\r
+                                                                                  &p_ext->hca.hw_ver );\r
                else\r
-                       err = mthca_get_dev_info( p_ext->hca.mdev, &p_ext->hca.guid, &p_ext->hca.hw_ver );\r
-\r
+                       err = mthca_get_dev_info( p_ext->hca.mdev,\r
+                                                                         &p_ext->hca.guid,\r
+                                                                         &p_ext->hca.hw_ver );\r
                if (err) {\r
 \r
                        //TODO: no cleanup on error\r
@@ -933,12 +949,13 @@ hca_start(
         */\r
        p_ext->state = HCA_STARTED;\r
        \r
+// XXX STAN - Is this call needed? I think so, will it work?\r
        /* Register for interface arrival of the IB_AL device. */\r
        status = IoRegisterPlugPlayNotification(\r
-               EventCategoryDeviceInterfaceChange,\r
-               PNPNOTIFY_DEVICE_INTERFACE_INCLUDE_EXISTING_INTERFACES,\r
-               (void*)&GUID_IB_CI_INTERFACE, p_dev_obj->DriverObject,\r
-               __pnp_notify_ifc, p_dev_obj, &p_ext->pnp_ifc_entry );\r
+                                               EventCategoryDeviceInterfaceChange,\r
+                                               PNPNOTIFY_DEVICE_INTERFACE_INCLUDE_EXISTING_INTERFACES,\r
+                                               (void*)&GUID_IB_CI_INTERFACE, p_dev_obj->DriverObject,\r
+                                               __pnp_notify_ifc, p_dev_obj, &p_ext->pnp_ifc_entry );\r
        if( !NT_SUCCESS( status ) )\r
        {\r
                p_ext->state = HCA_ADDED;\r
@@ -946,11 +963,14 @@ hca_start(
                        ("IoRegisterPlugPlayNotification returned %08x.\n", status));\r
        }\r
 \r
+// XXX STAN - how does this interface with KMDF D0 pwr state callback?\r
+\r
        /* We get started fully powered. */\r
        p_ext->DevicePowerState = PowerDeviceD0;\r
        powerState.DeviceState = PowerDeviceD0;\r
        powerState = PoSetPowerState (  p_ext->cl_ext.p_self_do,\r
-                                                                       DevicePowerState, powerState );\r
+                                                                       DevicePowerState,\r
+                                                                       powerState );\r
        HCA_PRINT( TRACE_LEVEL_INFORMATION, HCA_DBG_PNP, \r
                ("PoSetPowerState: old state %d, new state to %d\n", \r
                powerState.DeviceState, p_ext->DevicePowerState ));\r
@@ -960,11 +980,12 @@ hca_start(
                struct mthca_dev *mdev = p_ext->hca.mdev;\r
                HCA_PRINT_EV(TRACE_LEVEL_INFORMATION ,HCA_DBG_LOW ,\r
                        ("Ven %x Dev %d Hw %x Fw %d.%d.%d Drv %s (%s)", \r
-                       (unsigned)p_ext->hcaConfig.VendorID, (unsigned)p_ext->hcaConfig.DeviceID,\r
+                       (unsigned)p_ext->hcaConfig.VendorID,\r
+                       (unsigned)p_ext->hcaConfig.DeviceID,\r
                        p_ext->hca.hw_ver,      (int) (mdev->fw_ver >> 32),\r
                        (int) (mdev->fw_ver >> 16) & 0xffff, (int) (mdev->fw_ver & 0xffff),\r
-                       DRV_VERSION, DRV_RELDATE\r
-                       ));\r
+                       DRV_VERSION, DRV_RELDATE ));\r
+\r
                HCA_PRINT_EV(TRACE_LEVEL_INFORMATION ,HCA_DBG_LOW ,\r
                        ("Flags %s%s%s%s%s%s%s\n", \r
                        (mdev->mthca_flags & MTHCA_FLAG_LIVEFISH) ? "Flash Recovery Mode:" : "",\r
@@ -973,10 +994,8 @@ hca_start(
                        (mdev->mthca_flags & MTHCA_FLAG_FMR) ? "Fmr:" : "",\r
                        (mdev->mthca_flags & MTHCA_FLAG_SRQ) ? "Srq:" : "",\r
                        (mdev->mthca_flags & MTHCA_FLAG_DDR_HIDDEN) ? "HideDdr:" : "",\r
-                       (mdev->mthca_flags & MTHCA_FLAG_PCIE) ? "PciEx:" : ""\r
-                       ));\r
+                       (mdev->mthca_flags & MTHCA_FLAG_PCIE) ? "PciEx:" : "" ));\r
        }\r
-\r
        HCA_EXIT( HCA_DBG_PNP );\r
        return status;\r
 }\r
@@ -984,10 +1003,9 @@ hca_start(
 \r
 /* release the resources, allocated in hca_start */\r
 static void\r
-__hca_release_resources( IN   DEVICE_OBJECT* const  p_dev_obj )\r
+__hca_release_resources( IN   DEVICE_OBJECT* const  p_dev_obj,\r
+                                                IN   hca_dev_ext_t*            p_ext )\r
 {\r
-       hca_dev_ext_t           *p_ext = (hca_dev_ext_t*)p_dev_obj->DeviceExtension;\r
-\r
        HCA_ENTER( HCA_DBG_PNP );\r
 \r
        switch( p_ext->state )\r
@@ -1026,13 +1044,12 @@ __hca_release_resources( IN   DEVICE_OBJECT* const  p_dev_obj )
        mthca_remove_one( p_ext );\r
 \r
        if( p_ext->p_dma_adapter ) {\r
-               p_ext->p_dma_adapter->DmaOperations->PutDmaAdapter( p_ext->p_dma_adapter );\r
+               p_ext->p_dma_adapter->DmaOperations->PutDmaAdapter(p_ext->p_dma_adapter);\r
                p_ext->p_dma_adapter = NULL;\r
        }\r
 \r
        hca_disable_pci( &p_ext->hcaBusIfc );\r
 \r
-       //cl_event_destroy( &p_ext->mutex );\r
        __UnmapHcaMemoryResources( p_dev_obj );\r
 \r
        p_ext->state = HCA_ADDED;\r
@@ -1042,24 +1059,22 @@ __hca_release_resources( IN   DEVICE_OBJECT* const  p_dev_obj )
 \r
 \r
 static void\r
-hca_release_resources(\r
-       IN                              DEVICE_OBJECT* const            p_dev_obj )\r
+hca_release_resources( IN  DEVICE_OBJECT* const        p_dev_obj,\r
+                                          IN  hca_dev_ext_t*           p_ext )\r
 {\r
-       hca_dev_ext_t           *p_ext;\r
        POWER_STATE             powerState;\r
 \r
        HCA_ENTER( HCA_DBG_PNP );\r
 \r
-       p_ext = (hca_dev_ext_t*)p_dev_obj->DeviceExtension;\r
-\r
        /* release all the resources, allocated in hca_start */\r
-       __hca_release_resources(p_dev_obj);\r
+       __hca_release_resources( p_dev_obj, p_ext );\r
 \r
        /* Notify the power manager that the device is powered down. */\r
        p_ext->DevicePowerState = PowerDeviceD3;\r
        powerState.DeviceState = PowerDeviceD3;\r
        powerState = PoSetPowerState (  p_ext->cl_ext.p_self_do,\r
-                                                                       DevicePowerState, powerState );\r
+                                                                       DevicePowerState,\r
+                                                                       powerState );\r
 \r
        HCA_PRINT( TRACE_LEVEL_INFORMATION, HCA_DBG_PNP, \r
                ("PoSetPowerState: old state %d, new state to %d\n", \r
@@ -1528,8 +1543,9 @@ __DevicePowerUpCompletionWorkItem(
        }\r
 \r
        p_ext->DevicePowerState = pIoStack->Parameters.Power.State.DeviceState;\r
-       powerState = PoSetPowerState( p_dev_obj, DevicePowerState,\r
-               pIoStack->Parameters.Power.State );\r
+       powerState = PoSetPowerState( p_dev_obj,\r
+                                                                 DevicePowerState,\r
+                                                                 pIoStack->Parameters.Power.State );\r
 \r
        HCA_PRINT( TRACE_LEVEL_INFORMATION, HCA_DBG_PO, \r
                ("PoSetPowerState: old state %d, new state to %d\n", \r
@@ -1641,8 +1657,9 @@ __DevicePowerDownWorkItem(
        p_ext->pPoWorkItem = NULL;\r
 \r
        p_ext->DevicePowerState = pIoStack->Parameters.Power.State.DeviceState;\r
-       powerState = PoSetPowerState( p_dev_obj, DevicePowerState,\r
-               pIoStack->Parameters.Power.State );\r
+       powerState = PoSetPowerState( p_dev_obj,\r
+                                                                 DevicePowerState,\r
+                                                                 pIoStack->Parameters.Power.State );\r
 \r
        HCA_PRINT( TRACE_LEVEL_INFORMATION, HCA_DBG_PO, \r
                ("PoSetPowerState: old state %d, new state to %d, IRQL %d\n", \r
@@ -1835,9 +1852,9 @@ Arguments:
 \r
     Device - Handle to a framework device object.\r
 \r
-    Resources - Handle to a collection of framework resource objects.\r
-                This collection identifies the raw (bus-relative) hardware\r
-                resources that have been assigned to the device.\r
+    ResourcesRaw - Handle to a collection of framework resource objects.\r
+                   This collection identifies the raw (bus-relative) hardware\r
+                   resources that have been assigned to the device.\r
 \r
     ResourcesTranslated - Handle to a collection of framework resource objects.\r
                 This collection identifies the translated (system-physical)\r
@@ -1845,7 +1862,6 @@ Arguments:
                 The resources appear from the CPU's point of view.\r
                 Use this list of resources to map I/O space and\r
                 device-accessible memory into virtual address space\r
-\r
 Return Value:\r
 \r
     WDF status code\r
@@ -1855,16 +1871,13 @@ Return Value:
 NTSTATUS\r
 HcaEvtDevicePrepareHardware (\r
     WDFDEVICE      Device,\r
-    WDFCMRESLIST   Resources,\r
+    WDFCMRESLIST   ResourcesRaw,\r
     WDFCMRESLIST   ResourcesTranslated )\r
 {\r
     NTSTATUS           status = STATUS_SUCCESS;\r
     PFDO_DATA          fdoData = NULL;\r
        DEVICE_OBJECT*  p_dev_obj;\r
 \r
-    UNREFERENCED_PARAMETER(Resources);\r
-    UNREFERENCED_PARAMETER(ResourcesTranslated);\r
-\r
     PAGED_CODE();\r
 \r
     TraceEvents(TRACE_LEVEL_INFORMATION, DBG_PNP, "--> %s()\n", __FUNCTION__);\r
@@ -1872,6 +1885,13 @@ HcaEvtDevicePrepareHardware (
     fdoData = FdoGetData(Device);\r
        p_dev_obj = WdfDeviceWdmGetAttachedDevice(Device),\r
 \r
+    status = hca_start(p_dev_obj, fdoData, ResourcesRaw, ResourcesTranslated);\r
+    if (!NT_SUCCESS (status))\r
+       {\r
+        TraceEvents(TRACE_LEVEL_ERROR, DBG_PNP,\r
+                    "hca_start() failed: %!STATUS!\n", status);\r
+        return status;\r
+    }\r
 #if 0\r
     status = NICMapHWResources(fdoData, ResourcesTranslated);\r
     if (!NT_SUCCESS (status)){\r
@@ -1880,8 +1900,6 @@ HcaEvtDevicePrepareHardware (
         return status;\r
     }\r
 #endif\r
-\r
-\r
     TraceEvents(TRACE_LEVEL_INFORMATION, DBG_PNP,\r
                 "<-- %s() ret %x\n", __FUNCTION__, status);\r
 \r
@@ -1935,13 +1953,10 @@ HcaEvtDeviceReleaseHardware(
     fdoData = FdoGetData(Device);\r
        p_dev_obj = WdfDeviceWdmGetAttachedDevice(Device),\r
 \r
-#if 0\r
-    //\r
     // Unmap any I/O ports. Disconnecting from the interrupt will be done\r
     // automatically by the framework.\r
-    //\r
-    NICUnmapHWResources(fdoData);\r
-#endif\r
+\r
+       hca_release_resources( p_dev_obj, fdoData );\r
 \r
     TraceEvents(TRACE_LEVEL_INFORMATION, DBG_PNP, "<-- %s()\n", __FUNCTION__);\r
 \r
@@ -1984,6 +1999,40 @@ DbgDevicePowerString( IN WDF_POWER_DEVICE_STATE Type )
 }\r
 \r
 \r
+void\r
+SetPowerLow( FDO_DATA *fdoData, WDF_POWER_DEVICE_STATE TargetState )\r
+{\r
+       UNREFERENCED_PARAMETER(fdoData);\r
+\r
+    TraceEvents(TRACE_LEVEL_INFORMATION, DBG_POWER,\r
+                               "--> %s() target state %s\n", __FUNCTION__,\r
+                               DbgDevicePowerString(TargetState));\r
+\r
+    TraceEvents(TRACE_LEVEL_INFORMATION, DBG_POWER, "<-- %s()\n", __FUNCTION__);\r
+}\r
+\r
+void\r
+SetPowerD0( FDO_DATA   *fdoData )\r
+{\r
+       UNREFERENCED_PARAMETER(fdoData);\r
+\r
+    TraceEvents(TRACE_LEVEL_INFORMATION, DBG_POWER, "--> %s()\n", __FUNCTION__);\r
+    TraceEvents(TRACE_LEVEL_INFORMATION, DBG_POWER, "<-- %s()\n", __FUNCTION__);\r
+}\r
+\r
+void\r
+SetPowerShutdown( FDO_DATA     *fdoData )\r
+{\r
+       UNREFERENCED_PARAMETER(fdoData);\r
+\r
+    TraceEvents(TRACE_LEVEL_INFORMATION, DBG_POWER,\r
+                               "--> %s() D3 Final\n", __FUNCTION__);\r
+        // Reset and put the device into a known initial state we're shutting\r
+        // down for the last time.\r
+    TraceEvents(TRACE_LEVEL_INFORMATION, DBG_POWER, "<-- %s()\n", __FUNCTION__);\r
+}\r
+\r
+\r
 /*++\r
 \r
 Routine Description:\r
@@ -2028,7 +2077,7 @@ HcaEvtDeviceD0Entry(
     PFDO_DATA               fdoData;\r
 \r
     TraceEvents(TRACE_LEVEL_INFORMATION, DBG_POWER,\r
-                "-->HcaEvtDeviceD0Entry - coming from %s\n",\r
+                "--> %s() - coming from %s\n", __FUNCTION__,\r
                 DbgDevicePowerString(PreviousState));\r
 \r
     fdoData = FdoGetData(Device);\r
@@ -2037,26 +2086,17 @@ HcaEvtDeviceD0Entry(
 \r
     fdoData->DevicePowerState = PowerDeviceD0;\r
 \r
-    if(IsPoMgmtSupported(fdoData)){\r
-\r
-        TraceEvents(TRACE_LEVEL_VERBOSE, DBG_POWER,\r
-                    "Entering fully on state\n");\r
-#ifdef XXX\r
-        MPSetPowerD0 (fdoData);\r
-#endif\r
+    if(IsPoMgmtSupported(fdoData))\r
+       {\r
+        SetPowerD0(fdoData);\r
     }\r
-\r
-    TraceEvents(TRACE_LEVEL_INFORMATION, DBG_POWER, "<--HcaEvtDeviceD0Entry\n");\r
+    TraceEvents(TRACE_LEVEL_INFORMATION, DBG_POWER, "<-- %s()\n", __FUNCTION__);\r
 \r
     return STATUS_SUCCESS;\r
 }\r
 \r
 \r
-NTSTATUS\r
-HcaEvtDeviceD0Exit(\r
-    IN  WDFDEVICE Device,\r
-    IN  WDF_POWER_DEVICE_STATE TargetState\r
-    )\r
+\r
 /*++\r
 \r
 Routine Description:\r
@@ -2096,20 +2136,25 @@ Return Value:
     device stack being torn down.\r
 \r
 --*/\r
+\r
+NTSTATUS\r
+HcaEvtDeviceD0Exit(\r
+    IN  WDFDEVICE Device,\r
+    IN  WDF_POWER_DEVICE_STATE TargetState )\r
 {\r
     PFDO_DATA    fdoData;\r
 \r
-    UNREFERENCED_PARAMETER(Device);\r
+    fdoData = FdoGetData(Device);\r
 \r
     TraceEvents(TRACE_LEVEL_INFORMATION, DBG_POWER,\r
-                "-->HcaEvtDeviceD0Exit - moving to %s\n",\r
+                "--> %s() current %s - moving to %s\n",\r
+                DbgDevicePowerString(fdoData->DevicePowerState),\r
                 DbgDevicePowerString(TargetState));\r
 \r
-    fdoData = FdoGetData(Device);\r
-\r
     fdoData->DevicePowerState = TargetState;\r
 \r
-    switch (TargetState) {\r
+    switch (TargetState)\r
+       {\r
     case WdfPowerDeviceD1:\r
     case WdfPowerDeviceD2:\r
     case WdfPowerDeviceD3:\r
@@ -2118,9 +2163,7 @@ Return Value:
 \r
             TraceEvents(TRACE_LEVEL_VERBOSE, DBG_POWER,\r
                         "Entering a deeper sleep state\n");\r
-#ifdef XXX\r
-            MPSetPowerLow (fdoData, TargetState);\r
-#endif\r
+            SetPowerLow(fdoData, TargetState);\r
         }\r
         break;\r
 \r
@@ -2132,7 +2175,9 @@ Return Value:
         // in the paging path (or being a parent or grandparent of a paging\r
         // path device) then this whole case can be deleted.\r
         //\r
-        ASSERT(FALSE); // This driver shouldn't get this.\r
+               TraceEvents(TRACE_LEVEL_ERROR, DBG_POWER,\r
+                                       "%s() Hibernation? not supported.\n", __FUNCTION__);\r
+        //ASSERT(FALSE); // This driver shouldn't get this.\r
         break;\r
 \r
     case WdfPowerDeviceD3Final:\r
@@ -2140,17 +2185,17 @@ Return Value:
         // Reset and put the device into a known initial state we're shutting\r
         // down for the last time.\r
         //\r
-#if 0\r
-        NICShutdown(fdoData);\r
-#endif\r
+        SetPowerShutdown(fdoData);\r
         break;\r
 \r
     default:\r
+               TraceEvents(TRACE_LEVEL_ERROR, DBG_POWER,\r
+                                       "%s() Unsupported Power state %s\n", __FUNCTION__,\r
+                                       DbgDevicePowerString(TargetState));\r
         break;\r
     }\r
 \r
-\r
-    TraceEvents(TRACE_LEVEL_INFORMATION, DBG_POWER, "<--HcaEvtDeviceD0Exit\n");\r
+    TraceEvents(TRACE_LEVEL_INFORMATION, DBG_POWER, "<-- %s()\n", __FUNCTION__);\r
 \r
     return STATUS_SUCCESS;\r
 }\r
@@ -2377,7 +2422,6 @@ HcaEvtDeviceWakeTriggeredS0( IN WDFDEVICE Device )
 \r
     TraceEvents(TRACE_LEVEL_INFORMATION, DBG_PNP, "--> %s\n", __FUNCTION__);\r
 \r
-\r
     TraceEvents(TRACE_LEVEL_INFORMATION, DBG_PNP, "<-- %s\n", __FUNCTION__);\r
 }\r
 \r
@@ -2417,8 +2461,6 @@ HcaEvtDeviceWakeTriggeredSx( IN WDFDEVICE Device )
     UNREFERENCED_PARAMETER(Device);\r
 \r
     TraceEvents(TRACE_LEVEL_INFORMATION, DBG_PNP, "--> %s", __FUNCTION__);\r
-\r
-\r
     TraceEvents(TRACE_LEVEL_INFORMATION, DBG_PNP, "<-- %s", __FUNCTION__);\r
 \r
     return;\r
@@ -2517,9 +2559,7 @@ HcaEvtDeviceD0ExitPreInterruptsDisabled(
 Routine Description:\r
 \r
     This event is called so that driver can do PASSIVE_LEVEL work after\r
-    the interrupt is connected and enabled. Here we start the watchdog timer.\r
-    Watch dog timer is used to do the initial link detection during\r
-    start and then used to make sure the device is not stuck for any reason.\r
+    the interrupt is connected and enabled.\r
 \r
     This function is not marked pageable because this function is in the\r
     device power up path. When a function is marked pagable and the code\r
@@ -2558,3 +2598,86 @@ HcaEvtDeviceD0EntryPostInterruptsEnabled(
 \r
 }\r
 \r
+\r
+/*++\r
+\r
+Routine Description:\r
+\r
+    This event is called when the Framework moves the device to D0, and after\r
+    EvtDeviceD0Entry.  The driver should enable its interrupt here.\r
+\r
+    This function will be called at the device's assigned interrupt\r
+    IRQL (DIRQL.)\r
+\r
+Arguments:\r
+\r
+    Interrupt - Handle to a Framework interrupt object.\r
+\r
+    AssociatedDevice - Handle to a Framework device object.\r
+\r
+Return Value:\r
+\r
+    BOOLEAN - TRUE indicates that the interrupt was successfully enabled.\r
+\r
+--*/\r
+\r
+NTSTATUS\r
+HcaEvtInterruptEnable(\r
+    IN WDFINTERRUPT  Interrupt,\r
+    IN WDFDEVICE     AssociatedDevice )\r
+{\r
+       PFDO_DATA               fdoData;\r
+       UNREFERENCED_PARAMETER(Interrupt);\r
+\r
+    TraceEvents(TRACE_LEVEL_VERBOSE, DBG_PNP, "--> %s()\n", __FUNCTION__);\r
+\r
+    fdoData = FdoGetData(AssociatedDevice);\r
+\r
+    //NICEnableInterrupt(Interrupt, fdoData);\r
+\r
+    TraceEvents(TRACE_LEVEL_VERBOSE, DBG_PNP, "<-- %s()\n", __FUNCTION__);\r
+\r
+    return STATUS_SUCCESS;\r
+}\r
+\r
+/*++\r
+\r
+Routine Description:\r
+\r
+    This event is called before the Framework moves the device to D1, D2 or D3\r
+    and before EvtDeviceD0Exit.  The driver should disable its interrupt here.\r
+\r
+    This function will be called at the device's assigned interrupt\r
+    IRQL (DIRQL.)\r
+\r
+Arguments:\r
+\r
+    Interrupt - Handle to a Framework interrupt object.\r
+\r
+    AssociatedDevice - Handle to a Framework device object.\r
+\r
+Return Value:\r
+\r
+    STATUS_SUCCESS -  indicates success.\r
+\r
+--*/\r
+\r
+NTSTATUS\r
+HcaEvtInterruptDisable(\r
+    IN WDFINTERRUPT  Interrupt,\r
+    IN WDFDEVICE     AssociatedDevice )\r
+{\r
+    PFDO_DATA          fdoData;\r
+    UNREFERENCED_PARAMETER(Interrupt);\r
+\r
+    TraceEvents(TRACE_LEVEL_VERBOSE, DBG_PNP, "--> %s()\n", __FUNCTION__);\r
+\r
+    fdoData = FdoGetData(AssociatedDevice);\r
+\r
+//    NICDisableInterrupt(fdoData);\r
+\r
+    TraceEvents(TRACE_LEVEL_VERBOSE, DBG_PNP, "<-- %s()\n", __FUNCTION__);\r
+\r
+    return STATUS_SUCCESS;\r
+}\r
+\r
index ff06505a302cc8e6de005b1e2419e0d861e282de..9e75be92a21f28f8b8593e9dc8bef2bd3d24fd9e 100644 (file)
@@ -1,7 +1,8 @@
 /*
+ * Copyright (c) 2008 Intel Corporation.  All rights reserved.
  * Copyright (c) 2005 SilverStorm Technologies.  All rights reserved.
  *
- * This software is available to you under the OpenIB.org BSD license
+ * This software is available to you under the OpenFabrics.org BSD license
  * below:
  *
  *     Redistribution and use in source and binary forms, with or