From: shefty Date: Mon, 11 Aug 2008 16:17:04 +0000 (+0000) Subject: mlx4: add winverbs support X-Git-Url: https://openfabrics.org/gitweb/?a=commitdiff_plain;h=0ab321d46fc62a9c0e3ca795ccb215d0b5fdf3d0;p=~shefty%2Frdma-win.git mlx4: add winverbs support 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 git-svn-id: svn://openib.tc.cornell.edu/gen1@1477 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86 --- diff --git a/trunk/hw/mlx4/kernel/hca/drv.c b/trunk/hw/mlx4/kernel/hca/drv.c index d8557a25..485576ba 100644 --- a/trunk/hw/mlx4/kernel/hca/drv.c +++ b/trunk/hw/mlx4/kernel/hca/drv.c @@ -33,6 +33,7 @@ #include "precomp.h" #include #include +#include #if defined(EVENT_TRACING) #ifdef offsetof @@ -44,6 +45,9 @@ #define DRV_VERSION "1.0" #define DRV_RELDATE "02/01/2008" +#define MLX_VERBS_MIN_VERSION 2 +#define MLX_VERBS_MAX_VERSION 2 + GLOBALS g; /* @@ -1042,6 +1046,12 @@ hca_query_capabilities( IN IRP* const p_irp, OUT cl_irp_action_t* const p_action ); +static NTSTATUS +hca_query_interface( + IN DEVICE_OBJECT* const p_dev_obj, + IN IRP* const p_irp, + OUT cl_irp_action_t* const p_action ); + static NTSTATUS hca_query_pnp_state( IN DEVICE_OBJECT* const p_dev_obj, @@ -1114,6 +1124,7 @@ __pnp_notify_ifc( #pragma alloc_text (PAGE, hca_cancel_remove) #pragma alloc_text (PAGE, hca_surprise_remove) #pragma alloc_text (PAGE, hca_query_capabilities) +#pragma alloc_text (PAGE, hca_query_interface) #pragma alloc_text (PAGE, hca_query_pnp_state) #pragma alloc_text (PAGE, hca_query_bus_relations) #pragma alloc_text (PAGE, hca_query_removal_relations) @@ -1772,6 +1783,8 @@ hca_start( p_fdo->bus_ib_ifc_taken = TRUE; p_fdo->bus_ib_ifc.p_ibdev->x.p_fdo = p_fdo; + InitializeListHead(&p_fdo->hca.event_list); + KeInitializeSpinLock(&p_fdo->hca.event_list_lock); /* get node GUID */ err = __get_dev_info( p_fdo, &p_fdo->hca.guid, &p_fdo->hca.hw_ver ); @@ -2048,6 +2061,101 @@ hca_query_capabilities( } +static VOID +__hca_noop( VOID *context ) +{ + UNREFERENCED_PARAMETER(context); +} + + +static NTSTATUS +__query_ci_ifc( + IN DEVICE_OBJECT* const p_dev_obj, + IN IO_STACK_LOCATION* const p_io_stack ) +{ + RDMA_INTERFACE_VERBS *p_ifc; + PFDO_DEVICE_DATA p_fdo; + ci_interface_t *p_hca_ifc; + NTSTATUS status; + UINT8 version; + + HCA_ENTER( HCA_DBG_PNP ); + + version = VerbsVersionMajor(p_io_stack->Parameters.QueryInterface.Version); + if( version < MLX_VERBS_MIN_VERSION || version > MLX_VERBS_MAX_VERSION ) + { + status = STATUS_NOT_SUPPORTED; + goto exit; + } + + if( p_io_stack->Parameters.QueryInterface.Size < sizeof(RDMA_INTERFACE_VERBS) ) + { + status = STATUS_BUFFER_TOO_SMALL; + goto exit; + } + + p_fdo = (PFDO_DEVICE_DATA)p_dev_obj->DeviceExtension; + p_hca_ifc = __alloc_hca_ifc( p_fdo ); + if( !p_hca_ifc ) + { + status = STATUS_NO_MEMORY; + goto exit; + } + + p_ifc = (RDMA_INTERFACE_VERBS *) p_io_stack->Parameters.QueryInterface.Interface; + + p_ifc->InterfaceHeader.Size = sizeof(RDMA_INTERFACE_VERBS); + p_ifc->InterfaceHeader.Version = VerbsVersion(version, 0); + p_ifc->InterfaceHeader.Context = p_dev_obj; + p_ifc->InterfaceHeader.InterfaceReference = __hca_noop; + p_ifc->InterfaceHeader.InterfaceDereference = __hca_noop; + p_ifc->Verbs = *p_hca_ifc; + p_ifc->Verbs.p_hca_dev = &p_fdo->hca; + + ExFreePool( p_hca_ifc ); + status = STATUS_SUCCESS; + +exit: + HCA_EXIT( HCA_DBG_PNP ); + return status; +} + + +static NTSTATUS +hca_query_interface( + IN DEVICE_OBJECT* const p_dev_obj, + IN IRP* const p_irp, + OUT cl_irp_action_t* const p_action ) +{ + NTSTATUS status; + IO_STACK_LOCATION *p_io_stack; + + HCA_ENTER( HCA_DBG_PNP ); + +#pragma warning( push, 3 ) + PAGED_CODE(); +#pragma warning( pop ) + + p_io_stack = IoGetCurrentIrpStackLocation( p_irp ); + + /* Compare requested GUID with our supported interface GUIDs. */ + if( IsEqualGUID( p_io_stack->Parameters.QueryInterface.InterfaceType, + &GUID_RDMA_INTERFACE_VERBS ) ) + { + status = __query_ci_ifc( p_dev_obj, p_io_stack ); + *p_action = IrpComplete; + } + else + { + status = p_irp->IoStatus.Status; + *p_action = IrpSkip; + } + + HCA_EXIT( HCA_DBG_PNP ); + return status; +} + + static NTSTATUS hca_query_pnp_state( IN DEVICE_OBJECT* const p_dev_obj, @@ -2555,7 +2663,7 @@ hca_init_vfptr( void ) vfptrHcaPnp.pfn_query_resources = cl_irp_ignore; vfptrHcaPnp.pfn_query_res_req = cl_irp_ignore; vfptrHcaPnp.pfn_query_bus_info = cl_irp_ignore; - vfptrHcaPnp.pfn_query_interface = cl_irp_ignore; + vfptrHcaPnp.pfn_query_interface = hca_query_interface; vfptrHcaPnp.pfn_read_config = cl_irp_ignore; vfptrHcaPnp.pfn_write_config = cl_irp_ignore; vfptrHcaPnp.pfn_eject = cl_irp_ignore;