[ofw] [Patch 10/62] Reference implementation of NDv2

Fab Tillier ftillier at microsoft.com
Wed Feb 20 17:22:40 PST 2013


Take KPROCESSOR_MODE as input to um_open calls.  Stores the mode the HCA was opened under, to be used to affect how memory is registered as well as how I/O space is mapped.

Signed-off-by: Fab Tillier <ftillier at microsoft.com>

diff -dwup3 -x *svn* -r c:\dev\openib\ofw\gen1\branches\mlx4_30\trunk\core\al\al_ca.c .\core\al\al_ca.c
--- c:\dev\openib\ofw\gen1\branches\mlx4_30\trunk\core\al\al_ca.c	Thu May 31 11:22:16 2012
+++ .\core\al\al_ca.c	Wed May 23 18:26:47 2012
@@ -85,7 +85,11 @@ ib_open_ca(
 	}
 
 	AL_PRINT( TRACE_LEVEL_ERROR, AL_DBG_ERROR, ("ib_open_ca: open  CA\n"));
-	status = open_ca( h_al, ca_guid, pfn_ca_event_cb, ca_context, ph_ca, NULL );
+	status = open_ca( h_al, ca_guid, pfn_ca_event_cb, ca_context,
+#if defined(CL_KERNEL)
+					  KernelMode,
+#endif
+					  ph_ca, NULL );
 	
 	/* Release the reference taken in init_al_obj. */
 	if( status == IB_SUCCESS )
@@ -101,6 +105,9 @@ open_ca(
 	IN		const	ib_net64_t					ca_guid,
 	IN		const	ib_pfn_event_cb_t			pfn_ca_event_cb OPTIONAL,
 	IN		const	void* const					ca_context,
+#if defined(CL_KERNEL)
+	IN				KPROCESSOR_MODE				mode,
+#endif
 		OUT			ib_ca_handle_t* const		ph_ca,
 	IN	OUT			ci_umv_buf_t* const			p_umv_buf OPTIONAL )
 {
@@ -161,7 +168,7 @@ open_ca(
 	if( p_umv_buf )
 	{
 		status = h_ca->obj.p_ci_ca->verbs.um_open_ca(
-			h_ca->obj.p_ci_ca->h_ci_ca, p_umv_buf, &h_ca->h_um_ca );
+			h_ca->obj.p_ci_ca->h_ci_ca, mode, p_umv_buf, &h_ca->h_um_ca );
 		if( status != IB_SUCCESS )
 		{
 			h_ca->obj.pfn_destroy( &h_ca->obj, NULL );
diff -dwup3 -x *svn* -r c:\dev\openib\ofw\gen1\branches\mlx4_30\trunk\core\al\al_ca.h .\core\al\al_ca.h
--- c:\dev\openib\ofw\gen1\branches\mlx4_30\trunk\core\al\al_ca.h	Thu May 31 11:22:16 2012
+++ .\core\al\al_ca.h	Wed May 23 18:26:47 2012
@@ -61,6 +61,9 @@ open_ca(
 	IN		const	ib_net64_t					ca_guid,
 	IN		const	ib_pfn_event_cb_t			pfn_ca_event_cb OPTIONAL,
 	IN		const	void* const					ca_context,
+#if defined(CL_KERNEL)
+	IN				KPROCESSOR_MODE				mode,
+#endif
 		OUT			ib_ca_handle_t* const		ph_ca,
 	IN	OUT			ci_umv_buf_t* const			p_umv_buf OPTIONAL );
 
diff -dwup3 -x *svn* -r c:\dev\openib\ofw\gen1\branches\mlx4_30\trunk\core\al\kernel\al_proxy_verbs.c .\core\al\kernel\al_proxy_verbs.c
--- c:\dev\openib\ofw\gen1\branches\mlx4_30\trunk\core\al\kernel\al_proxy_verbs.c	Thu May 31 11:22:15 2012
+++ .\core\al\kernel\al_proxy_verbs.c	Wed May 23 18:26:47 2012
@@ -393,7 +393,8 @@ proxy_open_ca(
 
 	AL_PRINT( TRACE_LEVEL_ERROR, AL_DBG_ERROR, ("proxy_open_ca: open  CA\n"));
 	status = open_ca( p_context->h_al, p_ioctl->in.guid, proxy_ca_err_cb,
-		(void*)(ULONG_PTR)p_ioctl->in.context, &h_ca, p_umv_buf );
+		(void*)(ULONG_PTR)p_ioctl->in.context, UserMode, &h_ca,
+		p_umv_buf );
 	if( status != IB_SUCCESS )
 		goto proxy_open_ca_err;
 
diff -dwup3 -x *svn* -r c:\dev\openib\ofw\gen1\branches\mlx4_30\trunk\core\winverbs\kernel\wv_device.c .\core\winverbs\kernel\wv_device.c
--- c:\dev\openib\ofw\gen1\branches\mlx4_30\trunk\core\winverbs\kernel\wv_device.c	Thu Mar 29 00:15:18 2012
+++ .\core\winverbs\kernel\wv_device.c	Thu Jul 26 15:31:14 2012
@@ -135,6 +135,7 @@ static void WvDeviceEventHandler(ib_even
 			WvDeviceCompleteRequests(&dev->pPorts[i], STATUS_SUCCESS, event);
 		}
 	} else {
+		ASSERT(pEvent->port_number <= dev->PortCount);
 		if(pEvent->port_number <= dev->PortCount) {
 			WvDeviceCompleteRequests(&dev->pPorts[pEvent->port_number - 1],
 									 STATUS_SUCCESS, event);
@@ -255,7 +256,7 @@ static NTSTATUS WvDeviceInit(WV_DEVICE *
 	pDevice->pDevice = dev;
 	pDevice->pVerbs = &dev->Interface.Verbs;
 
-	ib_status = pDevice->pVerbs->um_open_ca(dev->hDevice, pVerbsData,
+	ib_status = pDevice->pVerbs->um_open_ca(dev->hDevice, UserMode, pVerbsData,
 											&pDevice->hVerbsDevice);
 	if (ib_status != IB_SUCCESS) {
 		goto err1;
diff -dwup3 -x *svn* -r c:\dev\openib\ofw\gen1\branches\mlx4_30\trunk\hw\mlx4\kernel\bus\inc\ib_verbs_ex.h .\hw\mlx4\kernel\bus\inc\ib_verbs_ex.h
--- c:\dev\openib\ofw\gen1\branches\mlx4_30\trunk\hw\mlx4\kernel\bus\inc\ib_verbs_ex.h	Thu May 31 11:22:18 2012
+++ .\hw\mlx4\kernel\bus\inc\ib_verbs_ex.h	Thu Jul 26 15:31:14 2012
@@ -97,6 +97,7 @@ struct ib_ucontext_ex 
 	PMDL				p_mdl;
 	PVOID				va;
 	int 				fw_if_open;
+	KPROCESSOR_MODE		mode;
 };
 
 /* extension for ib_event */
diff -dwup3 -x *svn* -r c:\dev\openib\ofw\gen1\branches\mlx4_30\trunk\hw\mlx4\kernel\hca\hverbs.c .\hw\mlx4\kernel\hca\hverbs.c
--- c:\dev\openib\ofw\gen1\branches\mlx4_30\trunk\hw\mlx4\kernel\hca\hverbs.c	Thu May 31 11:22:19 2012
+++ .\hw\mlx4\kernel\hca\hverbs.c	Thu Jul 26 15:31:14 2012
@@ -621,6 +621,7 @@ ib_api_status_t ibv_um_open(	
 
 ib_api_status_t ibv_um_open(	
 	IN 			struct ib_device 		*	p_ibdev,
+	IN			KPROCESSOR_MODE				mode,
 	IN	OUT		ci_umv_buf_t* const			p_umv_buf,
 	OUT			struct ib_ucontext 		**	pp_uctx )
 {
@@ -652,6 +653,7 @@ ib_api_status_t ibv_um_open(	
 	// fill the rest of ib_ucontext fields 
 	p_uctx->device = p_ibdev;
 	p_uctx->closing = 0;
+	p_uctx->x.mode = mode;
 
 	// map uar to user space
 	status = __map_memory_for_user( 
diff -dwup3 -x *svn* -r c:\dev\openib\ofw\gen1\branches\mlx4_30\trunk\hw\mlx4\kernel\hca\hverbs.h .\hw\mlx4\kernel\hca\hverbs.h
--- c:\dev\openib\ofw\gen1\branches\mlx4_30\trunk\hw\mlx4\kernel\hca\hverbs.h	Thu May 31 11:22:19 2012
+++ .\hw\mlx4\kernel\hca\hverbs.h	Wed May 23 18:26:47 2012
@@ -72,6 +72,7 @@ struct ib_srq *ibv_create_srq(struct ib_
 
 ib_api_status_t ibv_um_open(	
 	IN 			struct ib_device 		*	p_ibdev,
+	IN			KPROCESSOR_MODE				mode,
 	IN	OUT		ci_umv_buf_t* const			p_umv_buf,
 	OUT			struct ib_ucontext 		**	pp_uctx );
 
diff -dwup3 -x *svn* -r c:\dev\openib\ofw\gen1\branches\mlx4_30\trunk\hw\mlx4\kernel\hca\vp.c .\hw\mlx4\kernel\hca\vp.c
--- c:\dev\openib\ofw\gen1\branches\mlx4_30\trunk\hw\mlx4\kernel\hca\vp.c	Thu May 31 11:22:19 2012
+++ .\hw\mlx4\kernel\hca\vp.c	Thu Jul 26 15:31:14 2012
@@ -41,6 +41,7 @@
 static ib_api_status_t
 mlnx_um_open(
 	IN		const	ib_ca_handle_t				h_ca,
+	IN				KPROCESSOR_MODE				mode,
 	IN	OUT			ci_umv_buf_t* const			p_umv_buf,
 		OUT			ib_ca_handle_t* const		ph_um_ca )
 {
@@ -65,19 +66,20 @@ mlnx_um_open(
 		}
 		/* Copy the dev info. */
 		p_uctx->device = p_ibdev;
+		p_uctx->x.mode = mode;
 		p_umv_buf->output_size = 0;
 		status = IB_SUCCESS;
-		goto done;
 	}
-
+	else
+	{
 	// sanity check
 	if ( p_umv_buf->output_size < sizeof(struct ibv_get_context_resp) ||
 		!p_umv_buf->p_inout_buf) {
 		status = IB_INVALID_PARAMETER;
 		goto err_inval_params;
 	}
 
-	status = ibv_um_open( p_ibdev, p_umv_buf, &p_uctx );
+		status = ibv_um_open( p_ibdev, mode, p_umv_buf, &p_uctx );
 	if (status != IB_SUCCESS) {
 		goto end;
 	}
@@ -90,8 +92,8 @@ mlnx_um_open(
 	p_uresp->max_cqe		 = hca2mdev(p_hca)->caps.max_cqes;
 	p_uresp->max_sge		 = min( hca2mdev(p_hca)->caps.max_sq_sg,
 		hca2mdev(p_hca)->caps.max_rq_sg );
+	}
 
-done:
 	// fill the rest of ib_ucontext_ex fields 
 	atomic_set(&p_uctx->x.usecnt, 0);
 	p_uctx->x.va = p_uctx->x.p_mdl = NULL;
diff -dwup3 -x *svn* -r c:\dev\openib\ofw\gen1\branches\mlx4_30\trunk\hw\mthca\kernel\hca_verbs.c .\hw\mthca\kernel\hca_verbs.c
--- c:\dev\openib\ofw\gen1\branches\mlx4_30\trunk\hw\mthca\kernel\hca_verbs.c	Thu May 31 11:22:19 2012
+++ .\hw\mthca\kernel\hca_verbs.c	Wed May 23 18:26:48 2012
@@ -421,6 +421,7 @@ mlnx_close_ca (
 static ib_api_status_t
 mlnx_um_open(
 	IN		const	ib_ca_handle_t				h_ca,
+	IN				KPROCESSOR_MODE				mode,
 	IN	OUT			ci_umv_buf_t* const			p_umv_buf,
 		OUT			ib_ca_handle_t* const		ph_um_ca )
 {
@@ -436,6 +437,8 @@ mlnx_um_open(
 
 	HCA_ENTER(HCA_DBG_SHIM);
 
+	UNREFERENCED_PARAMETER( mode );
+
 	// sanity check
 	ASSERT( p_umv_buf );
 	if( !p_umv_buf->command )
@@ -1640,7 +1643,7 @@ mlnx_port_get_transport (
 	return RDMA_TRANSPORT_IB;
 }
 
-enum uint8_t
+uint8_t
 mlnx_get_sl_for_ip_port (
 	IN		const	ib_ca_handle_t	h_ca,
 	IN	const uint8_t				ca_port_num,
@@ -1649,7 +1652,7 @@ mlnx_get_sl_for_ip_port (
 	UNREFERENCED_PARAMETER(h_ca);
 	UNREFERENCED_PARAMETER(ca_port_num);
 	UNREFERENCED_PARAMETER(ip_port_num);
-	return -1;
+	return 0xff;
 }
 
 void
diff -dwup3 -x *svn* -r c:\dev\openib\ofw\gen1\branches\mlx4_30\trunk\inc\iba\ib_ci.h .\inc\iba\ib_ci.h
--- c:\dev\openib\ofw\gen1\branches\mlx4_30\trunk\inc\iba\ib_ci.h	Thu May 31 11:22:18 2012
+++ .\inc\iba\ib_ci.h	Thu Jul 26 15:31:14 2012
@@ -285,6 +285,7 @@ typedef void
 typedef ib_api_status_t
 (*ci_um_open_ca_t) (
 	IN		const	ib_ca_handle_t				h_ca,
+	IN				KPROCESSOR_MODE				mode,
 	IN	OUT			ci_umv_buf_t* const			p_umv_buf,
 		OUT			ib_ca_handle_t* const		ph_um_ca );
 /*
@@ -295,6 +296,8 @@ typedef ib_api_status_t
 * PARAMETERS
 *	h_ca
 *		[in] Handle returned by an earlier call to ci_open_ca()
+*	mode
+*		[in] Processor mode of the caller, either UserMode or KernelMode.
 *	p_umv_buf
 *		[in/out] Vendor specific parameter to support user mode IO.
 *	ph_um_ca
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ndv2.10.patch
Type: application/octet-stream
Size: 8803 bytes
Desc: ndv2.10.patch
URL: <http://lists.openfabrics.org/pipermail/ofw/attachments/20130221/1d852c3b/attachment.obj>


More information about the ofw mailing list