[Openib-windows] [PATCH] Add unload handler to IPoIB and relocate CL_INIT/CL_DEINIT calls
Fab Tillier
ftillier at silverstorm.com
Mon Sep 19 00:00:16 PDT 2005
This patch adds an unload handler to IPoIB and moves calls to CL_INIT to
DriverEntry and CL_DEINIT to the unload handler. This removes repeated calls to
CL_INIT and CL_DEINIT, and eliminates any potential races in case of parallel
initialization/tear down.
This is committed in revision 71.
- Fab
Signed-off-by: Fab Tillier (ftillier at silverstorm.com)
Index: ulp/ipoib/kernel/ipoib_adapter.c
===================================================================
--- ulp/ipoib/kernel/ipoib_adapter.c (revision 70)
+++ ulp/ipoib/kernel/ipoib_adapter.c (working copy)
@@ -35,7 +35,6 @@
#include "ipoib_port.h"
#include "ipoib_driver.h"
#include "ipoib_debug.h"
-#include <complib/cl_init.h>
#define ITEM_POOL_START 16
@@ -131,17 +130,9 @@
IPOIB_ENTER( IPOIB_DBG_INIT );
- if( !NT_SUCCESS( CL_INIT ) )
- {
- IPOIB_TRACE_EXIT( IPOIB_DBG_ERROR,
- ("cl_init failed.\n") );
- return IB_ERROR;
- }
-
p_adapter = cl_zalloc( sizeof(ipoib_adapter_t) );
if( !p_adapter )
{
- CL_DEINIT;
IPOIB_TRACE_EXIT( IPOIB_DBG_ERROR,
("Failed to allocate ipoib_adapter_t (%d bytes)",
sizeof(ipoib_adapter_t)) );
@@ -475,8 +466,6 @@
cl_free( p_adapter );
- CL_DEINIT;
-
IPOIB_EXIT( IPOIB_DBG_INIT );
}
Index: ulp/ipoib/kernel/ipoib_driver.c
===================================================================
--- ulp/ipoib/kernel/ipoib_driver.c (revision 70)
+++ ulp/ipoib/kernel/ipoib_driver.c (working copy)
@@ -34,6 +34,7 @@
#include "ipoib_debug.h"
#include "ipoib_port.h"
#include <complib/cl_bus_ifc.h>
+#include <complib/cl_init.h>
#include <initguid.h>
#include <iba/ipoib_ifc.h>
@@ -128,6 +129,10 @@
IN PDRIVER_OBJECT
p_drv_obj,
IN PUNICODE_STRING
p_reg_path );
+VOID
+ipoib_unload(
+ IN PDRIVER_OBJECT
p_drv_obj );
+
NDIS_STATUS
ipoib_initialize(
OUT PNDIS_STATUS
p_open_err_status,
@@ -246,6 +251,14 @@
PAGED_CODE();
#endif
+ status = CL_INIT;
+ if( !NT_SUCCESS( status ) )
+ {
+ IPOIB_TRACE_EXIT( IPOIB_DBG_ERROR,
+ ("cl_init failed.\n") );
+ return status;
+ }
+
status = NDIS_STATUS_SUCCESS;
ndis_handle = NULL;
@@ -277,15 +290,31 @@
if( status != NDIS_STATUS_SUCCESS )
{
IPOIB_TRACE( IPOIB_DBG_ERROR,
- ("NdisMRegisterMiniport failed with status of %s",
status) );
+ ("NdisMRegisterMiniport failed with status of %d\n",
status) );
NdisTerminateWrapper( ndis_handle, NULL );
+ CL_DEINIT;
}
+ else
+ {
+ NdisMRegisterUnloadHandler( ndis_handle, ipoib_unload );
+ }
IPOIB_EXIT( IPOIB_DBG_INIT );
return status;
}
+VOID
+ipoib_unload(
+ IN PDRIVER_OBJECT
p_drv_obj )
+{
+ IPOIB_ENTER( IPOIB_DBG_INIT );
+ UNREFERENCED_PARAMETER( p_drv_obj );
+ CL_DEINIT;
+ IPOIB_EXIT( IPOIB_DBG_INIT );
+}
+
+
NDIS_STATUS
ipoib_get_adapter_params(
IN NDIS_HANDLE* const
wrapper_config_context,
More information about the ofw
mailing list