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

Fab Tillier ftillier at microsoft.com
Wed Feb 20 17:59:42 PST 2013


Add driver GUID to interfaces

The driver GUID provides versioning between user-mode and kernel-mode drivers, to ensure they are compatible.  This prevents using an out dated user-mode DLL with an updated kernel mode driver, and any potential subtle side effects that could have.

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

diff -dwup3 -X excl.txt -r c:\dev\openib\ofw\gen1\branches\mlx4_30\trunk\hw\mlx4\inc\mx_abi.h .\hw\mlx4\inc\mx_abi.h
--- c:\dev\openib\ofw\gen1\branches\mlx4_30\trunk\hw\mlx4\inc\mx_abi.h	Thu May 31 11:22:19 2012
+++ .\hw\mlx4\inc\mx_abi.h	Thu May 31 12:35:10 2012
@@ -38,6 +38,10 @@
 #include <complib/cl_types_osd.h>
 #include "user.h"
 
+// {697925A7-84F0-4ED9-A9E8-76A941E72EB1}
+DEFINE_GUID(GUID_MLX4_DRIVER, 
+0x697925a7, 0x84f0, 0x4ed9, 0xa9, 0xe8, 0x76, 0xa9, 0x41, 0xe7, 0x2e, 0xb1);
+
 #pragma warning( disable : 4201)
 
 /*
diff -dwup3 -X excl.txt -r c:\dev\openib\ofw\gen1\branches\mlx4_30\trunk\hw\mlx4\kernel\hca\data.c .\hw\mlx4\kernel\hca\data.c
--- c:\dev\openib\ofw\gen1\branches\mlx4_30\trunk\hw\mlx4\kernel\hca\data.c	Fri Aug 03 12:58:34 2012
+++ .\hw\mlx4\kernel\hca\data.c	Thu Jul 26 15:31:14 2012
@@ -430,7 +430,6 @@ to_av(
 		err = p_ib_dev->x.find_cached_gid((struct ib_device *)p_ib_dev, 
 			(union ib_gid	*)p_ib_av_attr->grh.src_gid.raw, &port_num, &gid_index);
 		if (err) {
-
 			HCA_PRINT(TRACE_LEVEL_ERROR ,HCA_DBG_SHIM ,
 			("ib_find_cached_gid failed %d (%#x). Using default:  sgid_index = 0\n", err, err));
 			gid_index = 0;
@@ -482,7 +481,6 @@ int from_av(
 			p_ib_ah_attr->port_num, p_ib_ah_attr->grh.sgid_index,
 			(union ib_gid*)p_ib_av_attr->grh.src_gid.raw );
 		if (err) {
-
 			HCA_PRINT(TRACE_LEVEL_ERROR ,HCA_DBG_SHIM ,
 			("ib_get_cached_gid failed %d (%#x). Using default:  sgid_index = 0\n", err, err));
 		}
diff -dwup3 -X excl.txt -r c:\dev\openib\ofw\gen1\branches\mlx4_30\trunk\hw\mlx4\kernel\hca\drv.c .\hw\mlx4\kernel\hca\drv.c
--- c:\dev\openib\ofw\gen1\branches\mlx4_30\trunk\hw\mlx4\kernel\hca\drv.c	Thu May 31 11:22:19 2012
+++ .\hw\mlx4\kernel\hca\drv.c	Fri Aug 03 14:39:19 2012
@@ -57,7 +57,7 @@ __unmap_fdo_memory(
 
 	HCA_ENTER( HCA_DBG_PNP );
 
-	if (p_fdo->p_bus_ib_ifc) {
+    if (p_fdo->p_bus_ib_ifc != NULL) {
 		pdev = p_fdo->p_bus_ib_ifc->pdev;
 
 		for( i = 0; i < HCA_BAR_TYPE_MAX; i++ ) {
@@ -89,6 +89,7 @@ static int __get_dev_info(PHCA_FDO_DEVIC
 	return 0;
 }
 
+
 /* release the resources, allocated in hca_start */
 static void
 __hca_release_resources(
@@ -110,33 +111,22 @@ __hca_release_resources(
 	HCA_EXIT( HCA_DBG_PNP );
 }
 
-ci_interface_t*
-mlx4_hca_alloc_ifc(
-	IN				PHCA_FDO_DEVICE_DATA const		p_fdo )
+void
+mlx4_setup_hca_ifc(
+    IN              PHCA_FDO_DEVICE_DATA const  p_fdo,
+    OUT             ci_interface_t*             pIfc )
 {
-	ci_interface_t	*pIfc;
-
 	HCA_ENTER( HCA_DBG_PNP );
 
-	pIfc =
-		(ci_interface_t*)ExAllocatePoolWithTag( NonPagedPool, sizeof(ci_interface_t), MT_TAG_KERNEL );
-	if( !pIfc )
-	{
-		HCA_PRINT( TRACE_LEVEL_ERROR,HCA_DBG_PNP, 
-			("Failed to allocate ci_interface_t (%d bytes).\n",
-			sizeof(ci_interface_t)));
-		return NULL;
-	}
-
 	setup_ci_interface( p_fdo->hca.guid, pIfc );
 
+    pIfc->driver_id =       GUID_MLX4_DRIVER;
 	pIfc->p_hca_obj = &p_fdo->hca;
 	pIfc->vend_id = (uint32_t)p_fdo->p_bus_ib_ifc->pdev->ven_id;
 	pIfc->dev_id = (uint16_t)p_fdo->p_bus_ib_ifc->pdev->dev_id;
 	pIfc->dev_revision = (uint16_t)p_fdo->hca.hw_ver;
 
 	HCA_EXIT( HCA_DBG_PNP );
-	return pIfc;
 }
 
 NTSTATUS mlx4_hca_driver_entry()
@@ -226,5 +216,3 @@ int mlx4_hca_get_usecnt(PHCA_FDO_DEVICE_
 {
 	return atomic_read(&p_fdo->usecnt);
 }
-
-
diff -dwup3 -X excl.txt -r c:\dev\openib\ofw\gen1\branches\mlx4_30\trunk\hw\mlx4\kernel\hca\mr.c .\hw\mlx4\kernel\hca\mr.c
--- c:\dev\openib\ofw\gen1\branches\mlx4_30\trunk\hw\mlx4\kernel\hca\mr.c	Fri Aug 03 15:05:27 2012
+++ .\hw\mlx4\kernel\hca\mr.c	Tue Aug 07 09:45:21 2012
@@ -123,6 +123,7 @@ err_unsupported:
 	HCA_EXIT(HCA_DBG_MEMORY);
 	return status;
 }
+
 
 ib_api_status_t
 mlnx_register_mr (
diff -dwup3 -X excl.txt -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	Fri Aug 03 15:05:27 2012
+++ .\inc\iba\ib_ci.h	Tue Aug 07 09:44:14 2012
@@ -1623,9 +1623,10 @@ typedef ib_api_status_t
 */
 
 
-/****f* Verbs/ci_register_mr
+
+/****f* Verbs/ci_register_mr_remap
 * NAME
-*	ci_register_mr -- Register a memory region with the HCA.
+*	ci_register_mr_remap -- Register a memory region with the HCA.
 * SYNOPSIS
 */
 typedef ib_api_status_t
@@ -3193,6 +3194,12 @@ typedef struct _ci_interface
 	 * It has ib_ca_handle_t type
 	 */
 	void				*p_hca_obj;
+
+    /*
+     * The Driver ID identifies a unique driver, even if that driver can handle
+     * multiple device types.
+     */
+    GUID                driver_id;
 
 	/*
 	 * Vendor ID, Device ID, Device Revision of the HCA
diff -dwup3 -X excl.txt -r c:\dev\openib\ofw\gen1\branches\mlx4_30\trunk\inc\kernel\iba\ipoib_ifc.h .\inc\kernel\iba\ipoib_ifc.h
--- c:\dev\openib\ofw\gen1\branches\mlx4_30\trunk\inc\kernel\iba\ipoib_ifc.h	Thu May 31 11:22:17 2012
+++ .\inc\kernel\iba\ipoib_ifc.h	Thu Jul 26 16:41:39 2012
@@ -29,9 +29,9 @@
  */
 
 
-
 #include "iba/ib_al_ifc.h"
 
+
 #if !defined _IPOIB_IFC_H_
 #define _IPOIB_IFC_H_
 
@@ -171,6 +171,7 @@ typedef struct _port_guid_pkey
 	char		name[MAX_USER_NAME_SIZE];
 } port_guid_pkey_t;
 
+
 /*
 *	The ipoib_ifc_data_t structure 
 *
@@ -178,15 +179,18 @@ typedef struct _port_guid_pkey
 */
 typedef struct _ipoib_ifc_data
 {
+    GUID                        driver_id;
 	net64_t						ca_guid;
 	port_guid_pkey_t			port_guid;
-	
 	uint8_t						port_num;
 	ipoib_ifc_func				ibal_ipoib_ifc;
 
 }	ipoib_ifc_data_t;
 /*
 * FIELDS
+*   driver_id
+*       GUID identifying the HCA driver, used to perform per-driver IBAT filtering.
+*
 *	ca_guid
 *		HCA GUID for this IPoIB interface
 *
diff -dwup3 -X excl.txt -r c:\dev\openib\ofw\gen1\branches\mlx4_30\trunk\hw\mlx4\kernel\bus\drv\drv.c .\hw\mlx4\kernel\bus\drv\drv.c
--- c:\dev\openib\ofw\gen1\branches\mlx4_30\trunk\hw\mlx4\kernel\bus\drv\drv.c	Wed Jul 25 13:28:06 2012
+++ .\hw\mlx4\kernel\bus\drv\drv.c	Mon Jul 30 22:41:41 2012
@@ -886,17 +886,10 @@ __start_card(
 	}
 
 	if ( number_of_ib_ports ) {
-		ci_interface_t *p_fdo_ifc;
 		RDMA_INTERFACE_VERBS rdma_ifc, *p_ifc = &rdma_ifc;
 		WDF_QUERY_INTERFACE_CONFIG qiConfig;
 
 		/* Allocate and populate our HCA interface structure. */
-		p_fdo_ifc = mlx4_hca_alloc_ifc( &p_fdo->mlx4_hca_data );
-		if( !p_fdo_ifc ) {
-			MLX4_PRINT( TRACE_LEVEL_ERROR  ,MLX4_DBG_DEV  ,("mlx4_hca_alloc_ifc failed.\n"));
-			status = STATUS_NO_MEMORY;
-			goto err;
-		}
 
 		/* fill interface fields */
 		p_ifc->InterfaceHeader.Size = sizeof(RDMA_INTERFACE_VERBS);
@@ -904,9 +897,8 @@ __start_card(
 		p_ifc->InterfaceHeader.Context = p_fdo;
 		p_ifc->InterfaceHeader.InterfaceReference = __ref_hca_ifc;
 		p_ifc->InterfaceHeader.InterfaceDereference = __deref_hca_ifc;
-		p_ifc->Verbs = *p_fdo_ifc;
+        mlx4_setup_hca_ifc(&p_fdo->mlx4_hca_data, &p_ifc->Verbs);
 		p_ifc->post_event = st_et_event_func;
-		ExFreePool( p_fdo_ifc );
 
 		/* create an upper interface */
 		WDF_QUERY_INTERFACE_CONFIG_INIT( &qiConfig, (PINTERFACE)p_ifc,
diff -dwup3 -X excl.txt -r c:\dev\openib\ofw\gen1\branches\mlx4_30\trunk\hw\mlx4\kernel\bus\drv\drv.h .\hw\mlx4\kernel\bus\drv\drv.h
--- c:\dev\openib\ofw\gen1\branches\mlx4_30\trunk\hw\mlx4\kernel\bus\drv\drv.h	Thu Mar 29 00:15:28 2012
+++ .\hw\mlx4\kernel\bus\drv\drv.h	Thu Jul 26 18:25:36 2012
@@ -344,8 +344,10 @@ extern "C"
 		IN		PHCA_FDO_DEVICE_DATA			p_fdo
 		);
 
-	ci_interface_t* mlx4_hca_alloc_ifc(
-		IN		PHCA_FDO_DEVICE_DATA const		p_fdo 
+    void
+    mlx4_setup_hca_ifc(
+        IN      PHCA_FDO_DEVICE_DATA const      p_fdo,
+        OUT     ci_interface_t*                 pIfc
 		);
 
 #ifdef __cplusplus
diff -dwup3 -X excl.txt -r c:\dev\openib\ofw\gen1\branches\mlx4_30\trunk\core\bus\kernel\bus_port_mgr.c .\core\bus\kernel\bus_port_mgr.c
--- c:\dev\openib\ofw\gen1\branches\mlx4_30\trunk\core\bus\kernel\bus_port_mgr.c	Tue Aug 07 11:28:12 2012
+++ .\core\bus\kernel\bus_port_mgr.c	Thu Jul 26 16:38:31 2012
@@ -2081,6 +2081,7 @@ port_query_ipoib_ifc(
 	/* Set the interface data. */
 	p_ipoib_data = (ipoib_ifc_data_t*)p_ifc_data->p_data;
 
+    p_ipoib_data->driver_id = p_ext->pdo.h_ca->obj.p_ci_ca->verbs.driver_id;
 	p_ipoib_data->ca_guid = p_ext->pdo.h_ca->obj.p_ci_ca->verbs.guid;
 	p_ipoib_data->port_guid = p_ext->port_guid;
 	p_ipoib_data->port_num = (uint8_t)p_ext->n_port;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ndv2.29.patch
Type: application/octet-stream
Size: 8451 bytes
Desc: ndv2.29.patch
URL: <http://lists.openfabrics.org/pipermail/ofw/attachments/20130221/3be26149/attachment.obj>


More information about the ofw mailing list