[Openib-windows] [PATCH] Track IPoIB adapter instances in a list

Fab Tillier ftillier at silverstorm.com
Fri Sep 16 12:38:50 PDT 2005


This patch adds a list to track IPoIB adapters.  This is being put in place to
support IB address translation.

Committed in revision 70.

- Fab

Index: ulp/ipoib/kernel/ipoib_adapter.c
===================================================================
--- ulp/ipoib/kernel/ipoib_adapter.c	(revision 69)
+++ ulp/ipoib/kernel/ipoib_adapter.c	(working copy)
@@ -123,10 +123,11 @@
 	IN				void* const
h_adapter,
 		OUT			ipoib_adapter_t** const
pp_adapter )
 {
-	ipoib_adapter_t	*p_adapter;
-	ib_api_status_t	status;
-	cl_status_t		cl_status;
-	uint8_t			port_num;
+	ipoib_adapter_t		*p_adapter;
+	ib_api_status_t		status;
+	cl_status_t			cl_status;
+	uint8_t				port_num;
+	KLOCK_QUEUE_HANDLE	hdl;
 
 	IPOIB_ENTER( IPOIB_DBG_INIT );
 
@@ -197,6 +198,10 @@
 		return IB_ERROR;
 	}
 
+	KeAcquireInStackQueuedSpinLock( &g_ipoib.lock, &hdl );
+	InsertHeadList( &g_ipoib.adapter_list, &p_adapter->entry );
+	KeReleaseInStackQueuedSpinLock( &hdl );
+
 	status = adapter_init( p_adapter );
 	if( status != IB_SUCCESS )
 	{
@@ -414,7 +419,8 @@
 __adapter_destroying(
 	IN				cl_obj_t* const
p_obj )
 {
-	ipoib_adapter_t	*p_adapter;
+	ipoib_adapter_t		*p_adapter;
+	KLOCK_QUEUE_HANDLE	hdl;
 
 	IPOIB_ENTER( IPOIB_DBG_INIT );
 
@@ -431,6 +437,11 @@
 		p_adapter->h_pnp = NULL;
 	}
 
+	KeAcquireInStackQueuedSpinLock( &g_ipoib.lock, &hdl );
+	ASSERT( !IsListEmpty( &g_ipoib.adapter_list ) );
+	RemoveEntryList( &p_adapter->entry );
+	KeReleaseInStackQueuedSpinLock( &hdl );
+
 	IPOIB_EXIT( IPOIB_DBG_INIT );
 }
 
Index: ulp/ipoib/kernel/ipoib_driver.h
===================================================================
--- ulp/ipoib/kernel/ipoib_driver.h	(revision 64)
+++ ulp/ipoib/kernel/ipoib_driver.h	(working copy)
@@ -63,20 +63,31 @@
 
 typedef struct _ipoib_globals
 {
-	cl_spinlock_t	lock;
+	KSPIN_LOCK		lock;
+	LIST_ENTRY		adapter_list;
 	cl_qlist_t		bundle_list;
 
+	atomic32_t		laa_idx;
+
 }	ipoib_globals_t;
 /*
 * FIELDS
 *	lock
 *		Spinlock to protect list access.
 *
+*	adapter_list
+*		List of all adapter instances.  Used for address translation
support.
+*
 *	bundle_list
 *		List of all adapter bundles.
+*
+*	laa_idx
+*		Global counter for generating LAA MACs
 *********/
 
+extern ipoib_globals_t	g_ipoib;
 
+
 typedef struct _ipoib_bundle
 {
 	cl_list_item_t	list_item;
Index: ulp/ipoib/kernel/ipoib_adapter.h
===================================================================
--- ulp/ipoib/kernel/ipoib_adapter.h	(revision 64)
+++ ulp/ipoib/kernel/ipoib_adapter.h	(working copy)
@@ -130,6 +130,8 @@
 	NDIS_HANDLE				h_adapter;
 	ipoib_ifc_data_t		guids;
 
+	LIST_ENTRY				entry;
+
 	ib_al_handle_t			h_al;
 	ib_pnp_handle_t			h_pnp;
 
Index: ulp/ipoib/kernel/ipoib_xfr_mgr.h
===================================================================
--- ulp/ipoib/kernel/ipoib_xfr_mgr.h	(revision 64)
+++ ulp/ipoib/kernel/ipoib_xfr_mgr.h	(working copy)
@@ -88,10 +88,7 @@
 {
 #endif
 
-/* Global counter for generating LAA MACs */
-extern atomic32_t		g_laa_idx;
 
-
 /*
  * Address accessors
  */
@@ -221,7 +218,7 @@
 	}
 
 	/* Value of zero is reserved. */
-	laa = cl_atomic_inc( &g_laa_idx );
+	laa = cl_atomic_inc( &g_ipoib.laa_idx );
 
 	if( !laa )
 		return IB_INVALID_GUID;
Index: ulp/ipoib/kernel/ipoib_driver.c
===================================================================
--- ulp/ipoib/kernel/ipoib_driver.c	(revision 69)
+++ ulp/ipoib/kernel/ipoib_driver.c	(working copy)
@@ -119,8 +119,8 @@
 
 
 /* Global driver debug level */
-uint32_t	g_ipoib_dbg_lvl = IPOIB_DBG_ERROR;
-atomic32_t	g_laa_idx = 0;
+uint32_t		g_ipoib_dbg_lvl = IPOIB_DBG_ERROR;
+ipoib_globals_t	g_ipoib = {0};
 
 
 NTSTATUS
@@ -249,6 +249,9 @@
 	status		= NDIS_STATUS_SUCCESS;
 	ndis_handle	= NULL;
 
+	KeInitializeSpinLock( &g_ipoib.lock );
+	InitializeListHead( &g_ipoib.adapter_list );
+
 	NdisMInitializeWrapper( &ndis_handle, p_drv_obj, p_registry_path, NULL
);
 
 	memset(&characteristics, 0, sizeof(characteristics));




More information about the ofw mailing list