[ofw] [PATCH 7/9] mthca/pnp: respond to query interface

Sean Hefty sean.hefty at intel.com
Wed Jun 25 16:58:55 PDT 2008


Add infrastructure to respond to query calls for the
RDMA_INTERFACE_VERB interface.

Signed-off-by: Sean Hefty <sean.hefty at intel.com>
---
Hmmm... I just noticed that we'll need something similar for mlx4.  Without it,
winverbs would not work on mlx4 cards, but I don't think this affects stability
or other usage of mlx4.

diff -up -r -X trunk\docs\dontdiff.txt -I '\$Id:' trunk/hw/mthca/kernel/hca_data.h
branches\winverbs/hw/mthca/kernel/hca_data.h
--- trunk/hw/mthca/kernel/hca_data.h	2008-06-03 21:13:58.572875000 -0700
+++ branches\winverbs/hw/mthca/kernel/hca_data.h	2008-06-03 21:42:20.557250000 -0700
@@ -236,7 +236,6 @@ extern mlnx_hobul_t *mlnx_hobul_array[];
 void
 setup_ci_interface(
 	IN		const	ib_net64_t					ca_guid,
-	IN		const	int							is_livefish,
 		OUT			ci_interface_t				*p_interface );
 
 void
diff -up -r -X trunk\docs\dontdiff.txt -I '\$Id:' trunk/hw/mthca/kernel/hca_pnp.c
branches\winverbs/hw/mthca/kernel/hca_pnp.c
--- trunk/hw/mthca/kernel/hca_pnp.c	2008-04-30 12:42:35.088000000 -0700
+++ branches\winverbs/hw/mthca/kernel/hca_pnp.c	2008-06-03 21:42:20.572875000 -0700
@@ -12,6 +12,7 @@
 
 #include "hca_driver.h"
 #include "mthca_dev.h"
+#include <rdma\verbs.h>
 
 #if defined(EVENT_TRACING)
 #ifdef offsetof
@@ -23,6 +24,9 @@
 #include <initguid.h>
 #include <wdmguid.h>
 
+#define MTHCA_VERBS_MIN_VERSION		2
+#define MTHCA_VERBS_MAX_VERSION		2
+
 extern const char *mthca_version;
 
 static NTSTATUS
@@ -112,6 +116,12 @@ __alloc_hca_ifc(
 	IN				hca_dev_ext_t* const		p_ext );
 
 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
 __get_ci_interface(
 	IN				DEVICE_OBJECT* const		p_dev_obj );
 
@@ -145,6 +155,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)
@@ -185,7 +196,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;
@@ -441,9 +452,7 @@ __alloc_hca_ifc(
 		return NULL;
 	}
 
-	setup_ci_interface( p_ext->hca.guid,
-		!!mthca_is_livefish(p_ext->hca.mdev),
-		pIfc );
+	setup_ci_interface( p_ext->hca.guid, pIfc );
 
 	pIfc->p_hca_dev = p_ext->cl_ext.p_pdo;
 	pIfc->vend_id = (uint32_t)p_ext->hcaConfig.VendorID;
@@ -1272,6 +1281,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;
+	hca_dev_ext_t			*p_ext;
+	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 < MTHCA_VERBS_MIN_VERSION || version > MTHCA_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_ext = (hca_dev_ext_t*)p_dev_obj->DeviceExtension;
+	p_hca_ifc = __alloc_hca_ifc( p_ext );
+	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_ext->hca.hob;
+
+	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,
diff -up -r -X trunk\docs\dontdiff.txt -I '\$Id:' trunk/hw/mthca/kernel/hca_verbs.c
branches\winverbs/hw/mthca/kernel/hca_verbs.c
--- trunk/hw/mthca/kernel/hca_verbs.c	2008-06-03 21:13:58.588500000 -0700
+++ branches\winverbs/hw/mthca/kernel/hca_verbs.c	2008-06-03 21:42:20.588500000 -0700
@@ -1632,7 +1632,6 @@ err_port_num:	
 void
 setup_ci_interface(
 	IN		const	ib_net64_t					ca_guid,
-	IN		const	int							is_livefish,
 	IN	OUT			ci_interface_t				*p_interface )
 {
 	cl_memclr(p_interface, sizeof(*p_interface));
@@ -1659,43 +1658,35 @@ setup_ci_interface(
 	p_interface->deallocate_pd = mlnx_deallocate_pd;
 	p_interface->vendor_call = fw_access_ctrl;
 
-	if (is_livefish) {
-		mlnx_memory_if_livefish(p_interface);
-	}
-	else {	
-		p_interface->modify_ca = mlnx_modify_ca; 
-		
-		p_interface->create_av = mlnx_create_av;
-		p_interface->query_av = mlnx_query_av;
-		p_interface->modify_av = mlnx_modify_av;
-		p_interface->destroy_av = mlnx_destroy_av;
-
-		p_interface->create_srq = mlnx_create_srq;
-		p_interface->modify_srq = mlnx_modify_srq;
-		p_interface->query_srq = mlnx_query_srq;
-		p_interface->destroy_srq = mlnx_destroy_srq;
-
-		p_interface->create_qp = mlnx_create_qp;
-		p_interface->create_spl_qp = mlnx_create_spl_qp;
-		p_interface->modify_qp = mlnx_modify_qp;
-		p_interface->ndi_modify_qp = mlnx_ndi_modify_qp;
-		p_interface->query_qp = mlnx_query_qp;
-		p_interface->destroy_qp = mlnx_destroy_qp;
-
-		p_interface->create_cq = mlnx_create_cq;
-		p_interface->resize_cq = mlnx_resize_cq;
-		p_interface->query_cq = mlnx_query_cq;
-		p_interface->destroy_cq = mlnx_destroy_cq;
-
-		p_interface->local_mad = mlnx_local_mad;
-		
-
-		mlnx_memory_if(p_interface);
-		mlnx_direct_if(p_interface);
-		mlnx_mcast_if(p_interface);
-	}
-
-	return;
+	p_interface->modify_ca = mlnx_modify_ca; 
+	
+	p_interface->create_av = mlnx_create_av;
+	p_interface->query_av = mlnx_query_av;
+	p_interface->modify_av = mlnx_modify_av;
+	p_interface->destroy_av = mlnx_destroy_av;
+
+	p_interface->create_srq = mlnx_create_srq;
+	p_interface->modify_srq = mlnx_modify_srq;
+	p_interface->query_srq = mlnx_query_srq;
+	p_interface->destroy_srq = mlnx_destroy_srq;
+
+	p_interface->create_qp = mlnx_create_qp;
+	p_interface->create_spl_qp = mlnx_create_spl_qp;
+	p_interface->modify_qp = mlnx_modify_qp;
+	p_interface->ndi_modify_qp = mlnx_ndi_modify_qp;
+	p_interface->query_qp = mlnx_query_qp;
+	p_interface->destroy_qp = mlnx_destroy_qp;
+
+	p_interface->create_cq = mlnx_create_cq;
+	p_interface->resize_cq = mlnx_resize_cq;
+	p_interface->query_cq = mlnx_query_cq;
+	p_interface->destroy_cq = mlnx_destroy_cq;
+
+	p_interface->local_mad = mlnx_local_mad;
+
+	mlnx_memory_if(p_interface);
+	mlnx_direct_if(p_interface);
+	mlnx_mcast_if(p_interface);
 }
 
 





More information about the ofw mailing list