[MTHCA] Burning support improvements:
authorleonidk <leonidk@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Mon, 3 Apr 2006 13:54:30 +0000 (13:54 +0000)
committerleonidk <leonidk@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Mon, 3 Apr 2006 13:54:30 +0000 (13:54 +0000)
1. added support of multiple simult. pciconf devices;
2. removed support for several CR space mappings for one process;
3. PCI bus interface is now taken only once;
4. Fixed bug with handling positive non-zero NTSTATUSes;
5. Removed unused unmap_crspace structure;
6. General cleaning;

git-svn-id: svn://openib.tc.cornell.edu/gen1/trunk@272 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86

hw/mthca/kernel/hca_driver.c
hw/mthca/kernel/hca_driver.h
hw/mthca/kernel/hca_pci.c
hw/mthca/kernel/hca_pci.h
hw/mthca/kernel/hca_pnp.c
hw/mthca/kernel/hca_verbs.c
hw/mthca/kernel/ib_verbs.h
hw/mthca/kernel/mthca_main.c
inc/mthca/mthca_vc.h

index 139f978..762fce4 100644 (file)
@@ -438,25 +438,18 @@ End:
        return status;\r
 }\r
 \r
-typedef struct _mthca_map_space {\r
-       struct list_head list;\r
-       PMDL    p_mdl;\r
-       PVOID   va;\r
-} mthca_map_space;\r
-\r
 static NTSTATUS\r
 __map_crspace(\r
-       IN                              struct ib_ucontext *                    p_context,\r
-       IN                              mlnx_hob_t                      *       p_hob,\r
-       IN                              PVOID                                           p_buf,\r
-       IN                              ULONG                                           buf_size\r
+       IN              struct ib_ucontext *                    p_context,\r
+       IN              mlnx_hob_t                      *       p_hob,\r
+       IN              PVOID                                           p_buf,\r
+       IN              ULONG                                           buf_size\r
        )\r
 {\r
        NTSTATUS status;\r
        PMDL p_mdl;\r
        PVOID ua, ka;\r
        ULONG sz;\r
-       mthca_map_space *p_map;\r
        hca_dev_ext_t *p_ext = EXT_FROM_HOB(p_hob);\r
        map_crspace *p_res = (map_crspace *)p_buf;\r
 \r
@@ -468,16 +461,6 @@ __map_crspace(
                goto err_invalid_params;\r
        }\r
 \r
-       // allocate a structure\r
-       p_map = (mthca_map_space *)kmalloc(sizeof *p_map, GFP_KERNEL);\r
-       if (p_map == NULL) {\r
-               status = STATUS_INSUFFICIENT_RESOURCES;\r
-               goto err_no_memory;\r
-       }\r
-\r
-       // support several sim clients \r
-       down( &p_context->mutex );\r
-       \r
        // map memory\r
        sz =(ULONG)p_ext->bar[HCA_BAR_TYPE_HCR].size;\r
        if (!p_ext->bar[HCA_BAR_TYPE_HCR].virt) {\r
@@ -525,11 +508,9 @@ __map_crspace(
        p_res->size = sz;\r
 \r
        // resource tracking\r
-       p_map->p_mdl = p_mdl;\r
-       p_map->va = ua;\r
-       list_add_tail(&p_map->list, &p_context->map_list);\r
+       p_context->p_mdl = p_mdl;\r
+       p_context->va = ua;\r
        \r
-       up( &p_context->mutex );\r
        status = STATUS_SUCCESS;\r
        goto out;\r
 \r
@@ -537,9 +518,6 @@ err_map_to_user:
        IoFreeMdl( p_mdl );\r
 err_alloc_mdl:\r
 err_map_to_kernel:\r
-       up( &p_context->mutex );\r
-       kfree( p_map );\r
-err_no_memory:\r
 err_invalid_params:    \r
 out:   \r
        HCA_EXIT( HCA_DBG_PNP );\r
@@ -547,81 +525,47 @@ out:
 }\r
 \r
 \r
-static NTSTATUS\r
+static void\r
 __unmap_crspace(\r
-       IN                              struct ib_ucontext *                    p_context,\r
-       IN                              PVOID                                           p_buf,\r
-       IN                              ULONG                                           buf_size\r
+       IN              struct ib_ucontext *                    p_context\r
        )\r
 {\r
-       NTSTATUS status;\r
-       unmap_crspace *parm = (unmap_crspace *)p_buf;\r
-       mthca_map_space *p_map, *p_tmp;\r
-       int found = FALSE;\r
-\r
        HCA_ENTER( HCA_DBG_PNP );\r
 \r
-       // sanity checks\r
-       if ( buf_size < sizeof *parm || !p_buf ) {\r
-               status = STATUS_INVALID_PARAMETER;\r
-               goto err_invalid_params;\r
+       if (p_context->va && p_context->p_mdl) {\r
+               MmUnmapLockedPages(p_context->va, p_context->p_mdl);\r
+               IoFreeMdl( p_context->p_mdl );\r
+               p_context->va = p_context->p_mdl = NULL;\r
+               //NB: the unmap of IO space is being done in __UnmapHcaMemoryResources\r
        }\r
 \r
-       // support several sim clients \r
-       down( &p_context->mutex );\r
-\r
-       // look for the mapping info\r
-       list_for_each_entry_safe(p_map, p_tmp, &p_context->map_list, list, \r
-               mthca_map_space, mthca_map_space) {\r
-               if (p_map->va == parm->va) {\r
-                       found = TRUE;\r
-                       break;\r
-               }\r
-       }\r
+       HCA_EXIT( HCA_DBG_PNP );\r
+}\r
 \r
-       if (!found) {\r
-               HCA_PRINT(TRACE_LEVEL_ERROR  , HCA_DBG_SHIM, \r
-                       ("Not found internal info for unmappipng.%p for PID %d.\n" , \r
-                       parm->va, (int)(INT_PTR)PsGetCurrentProcessId()));\r
-               status = STATUS_INVALID_PARAMETER;\r
-               goto err_not_found;\r
+static void \r
+__close_fw_access(\r
+       IN              struct ib_ucontext *    p_context,\r
+       IN              PBUS_INTERFACE_STANDARD p_bus_interface\r
+       )\r
+{\r
+       if (p_context->fw_if_open ) {\r
+               p_bus_interface->InterfaceDereference((PVOID)p_bus_interface->Context);\r
+               p_context->fw_if_open = FALSE;\r
        }\r
-\r
-       // release the resources\r
-       list_del( &p_map->list );\r
-       MmUnmapLockedPages(p_map->va, p_map->p_mdl);\r
-       IoFreeMdl( p_map->p_mdl );\r
-       kfree( p_map );\r
-\r
-       up( &p_context->mutex );\r
-       status = STATUS_SUCCESS;\r
-       goto out;\r
-\r
-err_not_found:\r
-       up( &p_context->mutex );\r
-err_invalid_params:    \r
-out:   \r
-       HCA_EXIT( HCA_DBG_PNP );\r
-       return status;\r
 }\r
 \r
 void\r
 unmap_crspace_for_all( struct ib_ucontext *p_context )\r
 {\r
-       mthca_map_space *p_map, *p_tmp;\r
+       mlnx_hob_t      *p_hob = HOB_FROM_IBDEV( p_context->device );\r
+       hca_dev_ext_t *p_ext = EXT_FROM_HOB(p_hob);\r
+       PBUS_INTERFACE_STANDARD    p_bus_interface = &p_ext->hcaBusIfc;\r
 \r
        HCA_ENTER( HCA_DBG_PNP );\r
 \r
        down( &p_context->mutex );\r
-\r
-       list_for_each_entry_safe(p_map, p_tmp, &p_context->map_list, list, \r
-               mthca_map_space, mthca_map_space) {\r
-               list_del( &p_map->list );\r
-               MmUnmapLockedPages(p_map->va, p_map->p_mdl);\r
-               IoFreeMdl( p_map->p_mdl );\r
-               kfree( p_map );\r
-       }\r
-\r
+       __unmap_crspace( p_context);\r
+       __close_fw_access(p_context, p_bus_interface);\r
        up( &p_context->mutex );\r
 \r
        HCA_EXIT( HCA_DBG_PNP );\r
@@ -636,35 +580,36 @@ fw_access_ctrl(
        IN      OUT                     ci_umv_buf_t                            *p_umv_buf )\r
 {\r
        DEVICE_OBJECT                           *p_dev_obj;\r
-       static BUS_INTERFACE_STANDARD    BusInterface;\r
-       static uint32_t                         if_ready;\r
-       NTSTATUS                                        status;\r
+       PBUS_INTERFACE_STANDARD    p_bus_interface;\r
+       NTSTATUS                                        status = STATUS_SUCCESS;\r
        PVOID                                           p_data;\r
        ULONG                                           offset;\r
        ULONG POINTER_ALIGNMENT         length;\r
-       mlnx_hob_t                                      *p_hob;\r
        struct ib_ucontext *                    p_context;\r
+       mlnx_hob_t                                      *p_hob;\r
+       hca_dev_ext_t *p_ext;\r
 \r
        UNREFERENCED_PARAMETER(handle_array);\r
        UNREFERENCED_PARAMETER(num_handles);\r
-       UNREFERENCED_PARAMETER(p_umv_buf);\r
-\r
-       status = STATUS_INVALID_DEVICE_REQUEST;\r
 \r
        if( !p_umv_buf )\r
                return IB_UNSUPPORTED;\r
 \r
        p_context = (struct ib_ucontext *)h_ca;\r
-       p_hob = HOB_FROM_IBDEV( ((struct ib_ucontext*)h_ca)->device );\r
-       p_dev_obj = (DEVICE_OBJECT *)EXT_FROM_HOB(p_hob)->cl_ext.p_self_do;\r
+       p_hob = HOB_FROM_IBDEV( p_context->device );\r
+       p_ext = EXT_FROM_HOB(p_hob);\r
+       p_dev_obj = (DEVICE_OBJECT *)p_ext->cl_ext.p_self_do;\r
+       p_bus_interface = &p_ext->hcaBusIfc;\r
 \r
-       if ( !p_ci_op || !p_ci_op->buf_size )\r
+       if ( !p_ci_op )\r
                return IB_INVALID_PARAMETER;\r
 \r
        length = p_ci_op->buf_size;\r
        offset = p_ci_op->buf_info;\r
        p_data = p_ci_op->p_buf;\r
 \r
+       down( &p_context->mutex );\r
+\r
        switch ( p_ci_op->command )\r
        {\r
        case FW_MAP_CRSPACE:\r
@@ -672,80 +617,61 @@ fw_access_ctrl(
                break;\r
                \r
        case FW_UNMAP_CRSPACE:\r
-               status = __unmap_crspace(p_context, p_data, length);\r
+               __unmap_crspace(p_context);\r
                break;\r
                                \r
+       case FW_OPEN_IF: // open BusInterface\r
+               if ( !p_context->fw_if_open ) {\r
+                       status = fw_get_pci_bus_interface(p_dev_obj, p_bus_interface);\r
+                       if ( NT_SUCCESS( status ) ) {\r
+                               p_context->fw_if_open = TRUE;\r
+                               // status can be positive, but != STATUS_SUCCESS\r
+                               status = STATUS_SUCCESS;\r
+                       }\r
+               }\r
+               break;\r
+\r
        case FW_READ: // read data from flash\r
-               if ( if_ready )\r
-                       status = fw_flash_read_data(&BusInterface, p_data, offset, length);\r
+               if ( p_context->fw_if_open )\r
+                       status = fw_flash_read_data(p_bus_interface, p_data, offset, length);\r
                break;\r
 \r
        case FW_WRITE: // write data to flash\r
-               if ( if_ready )\r
-                       status = fw_flash_write_data(&BusInterface, p_data, offset, length);\r
+               if ( p_context->fw_if_open )\r
+                       status = fw_flash_write_data(p_bus_interface, p_data, offset, length);\r
                break;\r
 \r
        case FW_READ_CMD:\r
-               if ( if_ready )\r
-                       status = fw_access_pciconf(&BusInterface, 0 , p_data, offset, 4);\r
+               if ( p_context->fw_if_open )\r
+                       status = fw_access_pciconf(p_bus_interface, 0 , p_data, offset, 4);\r
                break;\r
 \r
        case FW_WRITE_CMD:\r
-               if ( if_ready )\r
-                       status = fw_access_pciconf(&BusInterface, 1 , p_data, offset, 4);\r
+               if ( p_context->fw_if_open )\r
+                       status = fw_access_pciconf(p_bus_interface, 1 , p_data, offset, 4);\r
                break;\r
 \r
        case FW_CLOSE_IF: // close BusInterface\r
-               if (if_ready )\r
-               {\r
-                       if_ready = 0;\r
-                       BusInterface.InterfaceDereference((PVOID)BusInterface.Context);\r
-               }\r
-               return IB_SUCCESS;\r
-\r
-       case FW_OPEN_IF: // open BusInterface\r
-               if ( !if_ready )\r
-               {\r
-                       status = fw_get_pci_bus_interface(p_dev_obj, &BusInterface);\r
-\r
-                       if ( NT_SUCCESS( status ) )\r
-                       {\r
-                               if_ready = 1;\r
-                       }\r
-               }\r
-               else\r
-               {\r
-                       status = STATUS_SUCCESS;\r
-               }\r
+               __close_fw_access(p_context, p_bus_interface);\r
                break;\r
 \r
        default:\r
                status = STATUS_INVALID_DEVICE_REQUEST;\r
        }\r
 \r
-       if ( status != STATUS_SUCCESS )\r
-       {\r
-               if ( if_ready )\r
-               {\r
-                       if_ready = 0;\r
-                       BusInterface.InterfaceDereference((PVOID)BusInterface.Context);\r
-               }\r
+       if ( status != STATUS_SUCCESS ) {\r
+               __close_fw_access(p_context, p_bus_interface);\r
                HCA_PRINT( TRACE_LEVEL_ERROR, HCA_DBG_INIT, \r
                        ("fw_access_ctrl failed, ntstatus: %08x.\n", status));\r
        }\r
-       switch( status )\r
-       {\r
-       case STATUS_SUCCESS:\r
-               return IB_SUCCESS;\r
-\r
-       case STATUS_INVALID_DEVICE_REQUEST:\r
-               return IB_UNSUPPORTED;\r
 \r
-       case STATUS_INSUFFICIENT_RESOURCES:\r
-               return IB_INSUFFICIENT_RESOURCES;\r
+       up( &p_context->mutex );\r
 \r
-       default:\r
-               return IB_ERROR;\r
+       switch( status ) {\r
+               case STATUS_SUCCESS:                                    return IB_SUCCESS;\r
+               case STATUS_INVALID_DEVICE_REQUEST:     return IB_UNSUPPORTED;\r
+               case STATUS_INSUFFICIENT_RESOURCES:     return IB_INSUFFICIENT_RESOURCES;\r
+               default:                                                                        return IB_ERROR;\r
        }\r
 }\r
 \r
@@ -760,6 +686,9 @@ fw_flash_write_data (
        uint32_t                cnt = 0;\r
        uint32_t                lcl_data;\r
 \r
+       if (!length)\r
+               return IB_INVALID_PARAMETER;\r
+       \r
        lcl_data = (*((uint32_t*)p_buffer) << 24);\r
 \r
        status = fw_access_pciconf(p_BusInterface, FW_WRITE , &lcl_data, FLASH_OFFSET+4, length );\r
@@ -799,6 +728,9 @@ fw_flash_read_data (
        NTSTATUS        status = STATUS_SUCCESS;\r
        uint32_t        cnt = 0;\r
        uint32_t        lcl_data = ( READ_BIT | (offset & ADDR_MSK));\r
+\r
+       if (!length)\r
+               return IB_INVALID_PARAMETER;\r
        \r
        status = fw_access_pciconf(p_BusInterface, FW_WRITE, &lcl_data, FLASH_OFFSET, 4 );\r
        if ( status != STATUS_SUCCESS )\r
index 2a34fec..e673412 100644 (file)
@@ -143,6 +143,7 @@ typedef struct _hca_dev_ext
        PKINTERRUPT                                             int_obj;                                                                                /* HCA interrupt object */\r
        spinlock_t                                                      isr_lock;                                                                       /* lock for the ISR */\r
        ULONG                                                                   bus_number;                                                     /* HCA's bus number */\r
+       BUS_INTERFACE_STANDARD                  hcaBusIfc;      /* PCI bus interface */\r
 \r
        /* -------------------------------------------------\r
        *               VARIABLES        \r
index 171549d..083b9db 100644 (file)
@@ -710,18 +710,18 @@ tweakErr:
 \r
 NTSTATUS\r
 hca_enable_pci(\r
-       IN                              DEVICE_OBJECT* const            pDevObj,\r
-       OUT                     PCI_COMMON_CONFIG*      pHcaConfig\r
+       IN              DEVICE_OBJECT* const            pDevObj,\r
+       OUT             PBUS_INTERFACE_STANDARD phcaBusIfc,\r
+       OUT             PCI_COMMON_CONFIG*      pHcaConfig\r
        )\r
 {\r
                NTSTATUS                                status;\r
-               BUS_INTERFACE_STANDARD  hcaBusIfc;\r
                ULONG                           len;\r
        \r
                HCA_ENTER( HCA_DBG_PNP );\r
        \r
                /* Get the HCA's bus interface. */\r
-               status = __get_bus_ifc( pDevObj, &GUID_BUS_INTERFACE_STANDARD, &hcaBusIfc );\r
+               status = __get_bus_ifc( pDevObj, &GUID_BUS_INTERFACE_STANDARD, phcaBusIfc );\r
                if( !NT_SUCCESS( status ) )\r
                {\r
                        HCA_PRINT( TRACE_LEVEL_ERROR  , HCA_DBG_PNP  ,("Failed to get HCA bus interface.\n"));\r
@@ -729,7 +729,7 @@ hca_enable_pci(
                }\r
        \r
                /* Save the HCA's configuration. */\r
-               status = __save_pci_config( &hcaBusIfc, pHcaConfig );\r
+               status = __save_pci_config( phcaBusIfc, pHcaConfig );\r
                if( !NT_SUCCESS( status ) )\r
                {\r
                        HCA_PRINT( TRACE_LEVEL_ERROR, HCA_DBG_PNP,\r
@@ -740,7 +740,7 @@ hca_enable_pci(
                /* fix command register (set PCI Master bit) */\r
                // NOTE: we change here the saved value of the command register\r
                pHcaConfig->Command |= 7;\r
-          len = hcaBusIfc.SetBusData( hcaBusIfc.Context, PCI_WHICHSPACE_CONFIG,\r
+          len = phcaBusIfc->SetBusData( phcaBusIfc->Context, PCI_WHICHSPACE_CONFIG,\r
                (PVOID)&pHcaConfig->Command , 4, sizeof(ULONG) ); \r
                if( len != sizeof(ULONG) )\r
                {\r
@@ -748,10 +748,19 @@ hca_enable_pci(
                        status = STATUS_DEVICE_NOT_READY;\r
                        goto pciErr;\r
                }\r
+               status = STATUS_SUCCESS;\r
+               goto out;\r
 \r
        pciErr:\r
-               hcaBusIfc.InterfaceDereference( hcaBusIfc.Context );\r
-       \r
+               phcaBusIfc->InterfaceDereference( phcaBusIfc->Context );\r
+       out:\r
                HCA_EXIT( HCA_DBG_PNP );\r
                return status;\r
 }\r
+\r
+void hca_disable_pci(PBUS_INTERFACE_STANDARD   phcaBusIfc)\r
+{\r
+       // no need to disable the card, so just release the PCI bus i/f\r
+       phcaBusIfc->InterfaceDereference( phcaBusIfc->Context );\r
+}\r
+\r
index 6393414..fd82e37 100644 (file)
@@ -4,16 +4,20 @@
 
 NTSTATUS
 hca_reset(
-       IN                              DEVICE_OBJECT* const            pDevObj, int is_tavor );
+       IN              DEVICE_OBJECT* const            pDevObj, int is_tavor );
 
 NTSTATUS
 hca_enable_pci(
-       IN                              DEVICE_OBJECT* const            pDevObj,
-       OUT                     PCI_COMMON_CONFIG*      pHcaConfig
+       IN              DEVICE_OBJECT* const            pDevObj,
+       OUT     PBUS_INTERFACE_STANDARD phcaBusIfc,
+       OUT     PCI_COMMON_CONFIG*      pHcaConfig
        );
 
+void hca_disable_pci(
+       IN              PBUS_INTERFACE_STANDARD phcaBusIfc);
+
 NTSTATUS
 hca_tune_pci(
-       IN                              DEVICE_OBJECT* const            pDevObj );
+       IN              DEVICE_OBJECT* const            pDevObj );
 
 #endif
index 24c2e73..bb1b387 100644 (file)
@@ -733,8 +733,8 @@ hca_start(
                return status;\r
        }\r
        \r
-       /* save PCI configuration info and enable device */\r
-       hca_enable_pci( p_dev_obj, &p_ext->hcaConfig );\r
+       /* save PCI bus i/f, PCI configuration info and enable device */\r
+       hca_enable_pci( p_dev_obj, &p_ext->hcaBusIfc, &p_ext->hcaConfig );\r
 \r
        /*\r
         * Get the DMA adapter representing the HCA so we can\r
@@ -872,6 +872,8 @@ hca_release_resources(
        if( p_ext->p_dma_adapter )\r
                p_ext->p_dma_adapter->DmaOperations->PutDmaAdapter( p_ext->p_dma_adapter );\r
 \r
+       hca_disable_pci( &p_ext->hcaBusIfc );\r
+\r
        //cl_event_destroy( &p_ext->mutex );\r
        __UnmapHcaMemoryResources( p_dev_obj );\r
 \r
index 4b51c56..1f5b79c 100644 (file)
@@ -363,7 +363,7 @@ mlnx_um_open(
        mlnx_hob_t                      *hob_p = (mlnx_hob_t *)h_ca;\r
        hca_dev_ext_t *ext_p = EXT_FROM_HOB( hob_p );\r
        struct ib_device *ib_dev = IBDEV_FROM_HOB( hob_p );\r
-       struct ib_ucontext *context_p;\r
+       struct ib_ucontext *p_context;\r
        struct mthca_alloc_ucontext_resp *uresp_p;\r
        struct ibv_alloc_pd_resp resp;\r
        ci_umv_buf_t umv_buf;\r
@@ -374,22 +374,22 @@ mlnx_um_open(
        ASSERT( p_umv_buf );\r
        if( !p_umv_buf->command )\r
        {\r
-               context_p = cl_zalloc( sizeof(struct ib_ucontext) );\r
-               if( !context_p )\r
+               p_context = cl_zalloc( sizeof(struct ib_ucontext) );\r
+               if( !p_context )\r
                {\r
                        status = IB_INSUFFICIENT_MEMORY;\r
                        goto err_alloc_ucontext;\r
                }\r
                /* Copy the dev info. */\r
-               context_p->device = ib_dev;\r
+               p_context->device = ib_dev;\r
                p_umv_buf->output_size = 0;\r
                goto done;\r
        }\r
 \r
        // create user context in kernel\r
-       context_p = mthca_alloc_ucontext(ib_dev, p_umv_buf);\r
-       if (IS_ERR(context_p)) {\r
-               err = PTR_ERR(context_p);\r
+       p_context = mthca_alloc_ucontext(ib_dev, p_umv_buf);\r
+       if (IS_ERR(p_context)) {\r
+               err = PTR_ERR(p_context);\r
                HCA_PRINT(TRACE_LEVEL_ERROR  ,HCA_DBG_SHIM,\r
                        ("mthca_alloc_ucontext failed (%d)\n", err));\r
                status = errno_to_iberr(err);\r
@@ -401,9 +401,9 @@ mlnx_um_open(
        umv_buf.p_inout_buf = &resp;\r
        //NB: Pay attention ! Ucontext parameter is important here:\r
        // when it is present (i.e. - for user space) - mthca_alloc_pd won't create MR\r
-       context_p->pd = ibv_alloc_pd(ib_dev, context_p, &umv_buf);\r
-       if (IS_ERR(context_p->pd)) {\r
-               err = PTR_ERR(context_p->pd);\r
+       p_context->pd = ibv_alloc_pd(ib_dev, p_context, &umv_buf);\r
+       if (IS_ERR(p_context->pd)) {\r
+               err = PTR_ERR(p_context->pd);\r
                HCA_PRINT(TRACE_LEVEL_ERROR  , HCA_DBG_SHIM,\r
                        ("ibv_alloc_pd failed (%d)\n", err));\r
                status = errno_to_iberr(err);\r
@@ -412,7 +412,7 @@ mlnx_um_open(
        \r
        // fill more parameters for user (sanity checks are in mthca_alloc_ucontext)\r
        uresp_p = (struct mthca_alloc_ucontext_resp *)(void*)p_umv_buf->p_inout_buf;\r
-       uresp_p->uar_addr = (uint64_t)(UINT_PTR)context_p->user_uar;\r
+       uresp_p->uar_addr = (uint64_t)(UINT_PTR)p_context->user_uar;\r
        uresp_p->pd_handle = resp.pd_handle;\r
        uresp_p->pdn = resp.pdn;\r
        uresp_p->vend_id = (uint32_t)ext_p->hcaConfig.VendorID;\r
@@ -420,17 +420,18 @@ mlnx_um_open(
 \r
 done:\r
        // some more inits\r
-       INIT_LIST_HEAD(&context_p->map_list);\r
-       KeInitializeMutex( &context_p->mutex, 0 );\r
+       p_context->va = p_context->p_mdl = NULL;\r
+       p_context->fw_if_open = FALSE;\r
+       KeInitializeMutex( &p_context->mutex, 0 );\r
        \r
        // return the result\r
-       if (ph_um_ca) *ph_um_ca = (ib_ca_handle_t)context_p;\r
+       if (ph_um_ca) *ph_um_ca = (ib_ca_handle_t)p_context;\r
 \r
        status = IB_SUCCESS;\r
        goto end;\r
        \r
 err_alloc_pd:\r
-       mthca_dealloc_ucontext(context_p);\r
+       mthca_dealloc_ucontext(p_context);\r
 err_alloc_ucontext: \r
 end:\r
        if (p_umv_buf && p_umv_buf->command) \r
@@ -470,7 +471,7 @@ mlnx_allocate_pd (
 {\r
        ib_api_status_t         status;\r
        struct ib_device *ib_dev;\r
-       struct ib_ucontext *context_p;\r
+       struct ib_ucontext *p_context;\r
        struct ib_pd *ib_pd_p;\r
        int err;\r
 \r
@@ -480,17 +481,17 @@ mlnx_allocate_pd (
        HCA_ENTER(HCA_DBG_SHIM);\r
 \r
        if( p_umv_buf ) {\r
-               context_p = (struct ib_ucontext *)h_ca;\r
-               ib_dev = context_p->device;\r
+               p_context = (struct ib_ucontext *)h_ca;\r
+               ib_dev = p_context->device;\r
        }\r
        else {\r
                mlnx_hob_t                      *hob_p = (mlnx_hob_t *)h_ca;\r
-               context_p = NULL;\r
+               p_context = NULL;\r
                ib_dev = IBDEV_FROM_HOB( hob_p );\r
        }\r
        \r
        // create PD\r
-       ib_pd_p = ibv_alloc_pd(ib_dev, context_p, p_umv_buf);\r
+       ib_pd_p = ibv_alloc_pd(ib_dev, p_context, p_umv_buf);\r
        if (IS_ERR(ib_pd_p)) {\r
                err = PTR_ERR(ib_pd_p);\r
                HCA_PRINT(TRACE_LEVEL_ERROR  , HCA_DBG_SHIM,\r
@@ -558,7 +559,7 @@ mlnx_create_av (
        struct ib_device *ib_dev = ib_pd_p->device;\r
        struct ib_ah *ib_av_p;\r
        struct ib_ah_attr ah_attr;\r
-       struct ib_ucontext *context_p = NULL;\r
+       struct ib_ucontext *p_context = NULL;\r
 \r
        HCA_ENTER(HCA_DBG_QP);\r
 \r
@@ -570,16 +571,16 @@ mlnx_create_av (
                        status = IB_INVALID_PARAMETER;\r
                        goto err_inval_params;\r
                }\r
-               context_p = ib_pd_p->ucontext;\r
+               p_context = ib_pd_p->ucontext;\r
        }\r
        else \r
-               context_p = NULL;\r
+               p_context = NULL;\r
 \r
        // fill parameters \r
        RtlZeroMemory(&ah_attr, sizeof(ah_attr));\r
        mlnx_conv_ibal_av( ib_dev, p_addr_vector,  &ah_attr );\r
 \r
-       ib_av_p = ibv_create_ah(ib_pd_p, &ah_attr, context_p, p_umv_buf);\r
+       ib_av_p = ibv_create_ah(ib_pd_p, &ah_attr, p_context, p_umv_buf);\r
        if (IS_ERR(ib_pd_p)) {\r
                err = PTR_ERR(ib_pd_p);\r
                HCA_PRINT(TRACE_LEVEL_ERROR   ,HCA_DBG_QP,\r
@@ -591,7 +592,7 @@ mlnx_create_av (
        // return the result\r
        if (ph_av) *ph_av = (ib_av_handle_t)ib_av_p;\r
 \r
-       if( context_p )\r
+       if( p_context )\r
        {\r
                struct ibv_create_ah_resp *create_ah_resp = (struct ibv_create_ah_resp *)(void*)p_umv_buf->p_inout_buf;\r
                cl_memcpy( &create_ah_resp->av_attr, p_addr_vector, sizeof(create_ah_resp->av_attr) );\r
@@ -753,7 +754,7 @@ _create_qp (
                struct ib_qp * ib_qp_p;\r
                struct mthca_qp *qp_p;\r
                struct ib_qp_init_attr qp_init_attr;\r
-               struct ib_ucontext *context_p = NULL;\r
+               struct ib_ucontext *p_context = NULL;\r
                struct ib_pd *ib_pd_p = (struct ib_pd *)h_pd;\r
                struct ib_device *ib_dev = ib_pd_p->device;\r
                mlnx_hob_t       *hob_p = HOB_FROM_IBDEV(ib_dev);\r
@@ -769,10 +770,10 @@ _create_qp (
                                status = IB_INVALID_PARAMETER;\r
                                goto err_inval_params;\r
                        }\r
-                       context_p = ib_pd_p->ucontext;\r
+                       p_context = ib_pd_p->ucontext;\r
                }\r
                else \r
-                       context_p = NULL;\r
+                       p_context = NULL;\r
 \r
                // prepare the parameters\r
                RtlZeroMemory(&qp_init_attr, sizeof(qp_init_attr));\r
@@ -790,7 +791,7 @@ _create_qp (
 \r
 \r
                // create qp            \r
-               ib_qp_p = ibv_create_qp( ib_pd_p, &qp_init_attr, context_p, p_umv_buf );\r
+               ib_qp_p = ibv_create_qp( ib_pd_p, &qp_init_attr, p_context, p_umv_buf );\r
                if (IS_ERR(ib_qp_p)) {\r
                        err = PTR_ERR(ib_qp_p);\r
                        HCA_PRINT(TRACE_LEVEL_ERROR  , HCA_DBG_QP,\r
@@ -1064,15 +1065,15 @@ mlnx_create_cq (
        struct mthca_cq *cq_p;\r
        mlnx_hob_t                      *hob_p;\r
        struct ib_device *ib_dev;\r
-       struct ib_ucontext *context_p;\r
+       struct ib_ucontext *p_context;\r
        \r
        HCA_ENTER(HCA_DBG_CQ);\r
 \r
        if( p_umv_buf ) {\r
 \r
-               context_p = (struct ib_ucontext *)h_ca;\r
-               hob_p = HOB_FROM_IBDEV(context_p->device);\r
-               ib_dev = context_p->device;\r
+               p_context = (struct ib_ucontext *)h_ca;\r
+               hob_p = HOB_FROM_IBDEV(p_context->device);\r
+               ib_dev = p_context->device;\r
 \r
                // sanity checks \r
                if (p_umv_buf->input_size < sizeof(struct ibv_create_cq) ||\r
@@ -1084,14 +1085,14 @@ mlnx_create_cq (
        }\r
        else {\r
                hob_p = (mlnx_hob_t *)h_ca;\r
-               context_p = NULL;\r
+               p_context = NULL;\r
                ib_dev = IBDEV_FROM_HOB( hob_p );\r
        }\r
 \r
        // allocate cq  \r
        ib_cq_p = ibv_create_cq(ib_dev, \r
                cq_comp_handler, cq_event_handler,\r
-               hob_p, *p_size, context_p, p_umv_buf );\r
+               hob_p, *p_size, p_context, p_umv_buf );\r
        if (IS_ERR(ib_cq_p)) {\r
                err = PTR_ERR(ib_cq_p);\r
                HCA_PRINT (TRACE_LEVEL_ERROR ,HCA_DBG_CQ, ("ibv_create_cq failed (%d)\n", err));\r
index 7c7418c..24b093d 100644 (file)
@@ -531,9 +531,11 @@ struct ib_ucontext {
        struct ib_pd *pd;
        atomic_t                usecnt; /* count all resources */
        ULONG           is_removing;
-       // for CR space mapping
+       // for tools support
        KMUTEX  mutex;
-       struct list_head map_list;
+       PMDL    p_mdl;
+       PVOID   va;
+       int     fw_if_open;
 };
 
 struct ib_uobject {
index fb96c64..936d14b 100644 (file)
@@ -175,10 +175,10 @@ static int  mthca_dev_lim(struct mthca_dev *mdev, struct mthca_dev_lim *dev_lim)
                return -ENODEV;
        }
 
-       if (dev_lim->uar_size > pci_resource_len(mdev, 2)) {
+       if (dev_lim->uar_size > (int)pci_resource_len(mdev, 2)) {
                HCA_PRINT_EV(TRACE_LEVEL_ERROR ,HCA_DBG_LOW , ("HCA reported UAR size of 0x%x bigger than "
                          "PCI resource 2 size of 0x%lx, aborting.\n",
-                         dev_lim->uar_size, pci_resource_len(mdev, 2)));
+                         dev_lim->uar_size, (unsigned long)pci_resource_len(mdev, 2)));
                return -ENODEV;
        }
        
index 45c001e..9a75758 100644 (file)
@@ -39,12 +39,6 @@ struct _map_crspace {
        unsigned long           size;   /* size of CRSPACE, mapped to user space */
 } map_crspace;
 
-typedef
-struct _unmap_crspace {
-       void *          va;             /* address of CRSPACE, mapped to user space */
-} unmap_crspace;
-
-
 /* Definitions for hca_driver commands*/
 #define FW_READ                        0x00
 #define FW_WRITE               0x01