mlx4: add winverbs support
authorshefty <shefty@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Mon, 11 Aug 2008 16:17:04 +0000 (16:17 +0000)
committershefty <shefty@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Mon, 11 Aug 2008 16:17:04 +0000 (16:17 +0000)
Export the mlx4 channel interface via PnP query interface calls.  This allows the driver to export its channel interface to multiple drivers, such as WinVerbs.

Signed-off-by: Sean Hefty <sean.hefty@intel.com>
git-svn-id: svn://openib.tc.cornell.edu/gen1/trunk@1477 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86

hw/mlx4/kernel/hca/drv.c

index d8557a2..485576b 100644 (file)
@@ -33,6 +33,7 @@
 #include "precomp.h"\r
 #include <initguid.h>\r
 #include <wdmguid.h>\r
+#include <rdma\verbs.h>\r
 \r
 #if defined(EVENT_TRACING)\r
 #ifdef offsetof\r
@@ -44,6 +45,9 @@
 #define DRV_VERSION    "1.0"\r
 #define DRV_RELDATE    "02/01/2008"\r
 \r
+#define MLX_VERBS_MIN_VERSION          2\r
+#define MLX_VERBS_MAX_VERSION          2\r
+\r
 GLOBALS g;\r
 \r
 /*\r
@@ -1042,6 +1046,12 @@ hca_query_capabilities(
        IN                              IRP* const                                      p_irp, \r
                OUT                     cl_irp_action_t* const          p_action );\r
 \r
+static NTSTATUS\r
+hca_query_interface(\r
+       IN                              DEVICE_OBJECT* const            p_dev_obj,\r
+       IN                              IRP* const                                      p_irp, \r
+               OUT                     cl_irp_action_t* const          p_action );\r
+\r
 static NTSTATUS\r
 hca_query_pnp_state(\r
        IN                              DEVICE_OBJECT* const            p_dev_obj,\r
@@ -1114,6 +1124,7 @@ __pnp_notify_ifc(
 #pragma alloc_text (PAGE, hca_cancel_remove)\r
 #pragma alloc_text (PAGE, hca_surprise_remove)\r
 #pragma alloc_text (PAGE, hca_query_capabilities)\r
+#pragma alloc_text (PAGE, hca_query_interface)\r
 #pragma alloc_text (PAGE, hca_query_pnp_state)\r
 #pragma alloc_text (PAGE, hca_query_bus_relations)\r
 #pragma alloc_text (PAGE, hca_query_removal_relations)\r
@@ -1772,6 +1783,8 @@ hca_start(
        p_fdo->bus_ib_ifc_taken = TRUE;\r
        p_fdo->bus_ib_ifc.p_ibdev->x.p_fdo = p_fdo;\r
        \r
+       InitializeListHead(&p_fdo->hca.event_list);\r
+       KeInitializeSpinLock(&p_fdo->hca.event_list_lock);\r
 \r
        /* get node GUID */\r
        err = __get_dev_info( p_fdo, &p_fdo->hca.guid, &p_fdo->hca.hw_ver );\r
@@ -2048,6 +2061,101 @@ hca_query_capabilities(
 }\r
 \r
 \r
+static VOID\r
+__hca_noop( VOID *context )\r
+{\r
+       UNREFERENCED_PARAMETER(context);\r
+}\r
+\r
+\r
+static NTSTATUS\r
+__query_ci_ifc(\r
+       IN                                      DEVICE_OBJECT* const            p_dev_obj,\r
+       IN                                      IO_STACK_LOCATION* const        p_io_stack )\r
+{\r
+       RDMA_INTERFACE_VERBS    *p_ifc;\r
+       PFDO_DEVICE_DATA                p_fdo;\r
+       ci_interface_t                  *p_hca_ifc;\r
+       NTSTATUS                                status;\r
+       UINT8                                   version;\r
+\r
+       HCA_ENTER( HCA_DBG_PNP );\r
+\r
+       version = VerbsVersionMajor(p_io_stack->Parameters.QueryInterface.Version);\r
+       if( version < MLX_VERBS_MIN_VERSION || version > MLX_VERBS_MAX_VERSION )\r
+       {\r
+               status = STATUS_NOT_SUPPORTED;\r
+               goto exit;\r
+       }\r
+\r
+       if( p_io_stack->Parameters.QueryInterface.Size < sizeof(RDMA_INTERFACE_VERBS) )\r
+       {\r
+               status = STATUS_BUFFER_TOO_SMALL;\r
+               goto exit;\r
+       }\r
+\r
+       p_fdo = (PFDO_DEVICE_DATA)p_dev_obj->DeviceExtension;\r
+       p_hca_ifc = __alloc_hca_ifc( p_fdo );\r
+       if( !p_hca_ifc )\r
+       {\r
+               status = STATUS_NO_MEMORY;\r
+               goto exit;\r
+       }\r
+\r
+       p_ifc = (RDMA_INTERFACE_VERBS *) p_io_stack->Parameters.QueryInterface.Interface;\r
+\r
+       p_ifc->InterfaceHeader.Size = sizeof(RDMA_INTERFACE_VERBS);\r
+       p_ifc->InterfaceHeader.Version = VerbsVersion(version, 0);\r
+       p_ifc->InterfaceHeader.Context = p_dev_obj;\r
+       p_ifc->InterfaceHeader.InterfaceReference = __hca_noop;\r
+       p_ifc->InterfaceHeader.InterfaceDereference = __hca_noop;\r
+       p_ifc->Verbs = *p_hca_ifc;\r
+       p_ifc->Verbs.p_hca_dev = &p_fdo->hca;\r
+\r
+       ExFreePool( p_hca_ifc );\r
+       status = STATUS_SUCCESS;\r
+\r
+exit:\r
+       HCA_EXIT( HCA_DBG_PNP );\r
+       return status;\r
+}\r
+\r
+\r
+static NTSTATUS\r
+hca_query_interface(\r
+       IN                              DEVICE_OBJECT* const            p_dev_obj,\r
+       IN                              IRP* const                                      p_irp, \r
+               OUT                     cl_irp_action_t* const          p_action )\r
+{\r
+       NTSTATUS                        status;\r
+       IO_STACK_LOCATION       *p_io_stack;\r
+\r
+       HCA_ENTER( HCA_DBG_PNP );\r
+\r
+#pragma warning( push, 3 )\r
+       PAGED_CODE();\r
+#pragma warning( pop )\r
+\r
+       p_io_stack = IoGetCurrentIrpStackLocation( p_irp );\r
+       \r
+       /* Compare requested GUID with our supported interface GUIDs. */\r
+       if( IsEqualGUID( p_io_stack->Parameters.QueryInterface.InterfaceType,\r
+               &GUID_RDMA_INTERFACE_VERBS ) )\r
+       {\r
+               status = __query_ci_ifc( p_dev_obj, p_io_stack );\r
+               *p_action = IrpComplete;\r
+       }\r
+       else\r
+       {\r
+               status = p_irp->IoStatus.Status;\r
+               *p_action = IrpSkip;\r
+       }\r
+\r
+       HCA_EXIT( HCA_DBG_PNP );\r
+       return status;\r
+}\r
+\r
+\r
 static NTSTATUS\r
 hca_query_pnp_state(\r
        IN                              DEVICE_OBJECT* const            p_dev_obj,\r
@@ -2555,7 +2663,7 @@ hca_init_vfptr( void )
        vfptrHcaPnp.pfn_query_resources = cl_irp_ignore;\r
        vfptrHcaPnp.pfn_query_res_req = cl_irp_ignore;\r
        vfptrHcaPnp.pfn_query_bus_info = cl_irp_ignore;\r
-       vfptrHcaPnp.pfn_query_interface = cl_irp_ignore;\r
+       vfptrHcaPnp.pfn_query_interface = hca_query_interface;\r
        vfptrHcaPnp.pfn_read_config = cl_irp_ignore;\r
        vfptrHcaPnp.pfn_write_config = cl_irp_ignore;\r
        vfptrHcaPnp.pfn_eject = cl_irp_ignore;\r