[IPoIB] Track adapters instances in a list.
authorftillier <ftillier@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Fri, 16 Sep 2005 19:36:20 +0000 (19:36 +0000)
committerftillier <ftillier@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Fri, 16 Sep 2005 19:36:20 +0000 (19:36 +0000)
git-svn-id: svn://openib.tc.cornell.edu/gen1/trunk@70 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86

ulp/ipoib/kernel/ipoib_adapter.c
ulp/ipoib/kernel/ipoib_adapter.h
ulp/ipoib/kernel/ipoib_driver.c
ulp/ipoib/kernel/ipoib_driver.h
ulp/ipoib/kernel/ipoib_xfr_mgr.h

index 56e048f..f999084 100644 (file)
@@ -123,10 +123,11 @@ ipoib_create_adapter(
        IN                              void* const                                     h_adapter,\r
                OUT                     ipoib_adapter_t** const         pp_adapter )\r
 {\r
-       ipoib_adapter_t *p_adapter;\r
-       ib_api_status_t status;\r
-       cl_status_t             cl_status;\r
-       uint8_t                 port_num;\r
+       ipoib_adapter_t         *p_adapter;\r
+       ib_api_status_t         status;\r
+       cl_status_t                     cl_status;\r
+       uint8_t                         port_num;\r
+       KLOCK_QUEUE_HANDLE      hdl;\r
 \r
        IPOIB_ENTER( IPOIB_DBG_INIT );\r
 \r
@@ -197,6 +198,10 @@ ipoib_create_adapter(
                return IB_ERROR;\r
        }\r
 \r
+       KeAcquireInStackQueuedSpinLock( &g_ipoib.lock, &hdl );\r
+       InsertHeadList( &g_ipoib.adapter_list, &p_adapter->entry );\r
+       KeReleaseInStackQueuedSpinLock( &hdl );\r
+\r
        status = adapter_init( p_adapter );\r
        if( status != IB_SUCCESS )\r
        {\r
@@ -414,7 +419,8 @@ static void
 __adapter_destroying(\r
        IN                              cl_obj_t* const                         p_obj )\r
 {\r
-       ipoib_adapter_t *p_adapter;\r
+       ipoib_adapter_t         *p_adapter;\r
+       KLOCK_QUEUE_HANDLE      hdl;\r
 \r
        IPOIB_ENTER( IPOIB_DBG_INIT );\r
 \r
@@ -431,6 +437,11 @@ __adapter_destroying(
                p_adapter->h_pnp = NULL;\r
        }\r
 \r
+       KeAcquireInStackQueuedSpinLock( &g_ipoib.lock, &hdl );\r
+       ASSERT( !IsListEmpty( &g_ipoib.adapter_list ) );\r
+       RemoveEntryList( &p_adapter->entry );\r
+       KeReleaseInStackQueuedSpinLock( &hdl );\r
+\r
        IPOIB_EXIT( IPOIB_DBG_INIT );\r
 }\r
 \r
index fd78643..ba67e24 100644 (file)
@@ -130,6 +130,8 @@ typedef struct _ipoib_adapter
        NDIS_HANDLE                             h_adapter;\r
        ipoib_ifc_data_t                guids;\r
 \r
+       LIST_ENTRY                              entry;\r
+\r
        ib_al_handle_t                  h_al;\r
        ib_pnp_handle_t                 h_pnp;\r
 \r
index af855db..f81da08 100644 (file)
@@ -119,8 +119,8 @@ static const unsigned char VENDOR_ID[] = {0x00, 0x06, 0x6A, 0x00};
 \r
 \r
 /* Global driver debug level */\r
-uint32_t       g_ipoib_dbg_lvl = IPOIB_DBG_ERROR;\r
-atomic32_t     g_laa_idx = 0;\r
+uint32_t               g_ipoib_dbg_lvl = IPOIB_DBG_ERROR;\r
+ipoib_globals_t        g_ipoib = {0};\r
 \r
 \r
 NTSTATUS\r
@@ -249,6 +249,9 @@ DriverEntry(
        status          = NDIS_STATUS_SUCCESS;\r
        ndis_handle     = NULL;\r
 \r
+       KeInitializeSpinLock( &g_ipoib.lock );\r
+       InitializeListHead( &g_ipoib.adapter_list );\r
+\r
        NdisMInitializeWrapper( &ndis_handle, p_drv_obj, p_registry_path, NULL );\r
 \r
        memset(&characteristics, 0, sizeof(characteristics));\r
index 34b7a14..94bea71 100644 (file)
 \r
 typedef struct _ipoib_globals\r
 {\r
-       cl_spinlock_t   lock;\r
+       KSPIN_LOCK              lock;\r
+       LIST_ENTRY              adapter_list;\r
        cl_qlist_t              bundle_list;\r
 \r
+       atomic32_t              laa_idx;\r
+\r
 }      ipoib_globals_t;\r
 /*\r
 * FIELDS\r
 *      lock\r
 *              Spinlock to protect list access.\r
 *\r
+*      adapter_list\r
+*              List of all adapter instances.  Used for address translation support.\r
+*\r
 *      bundle_list\r
 *              List of all adapter bundles.\r
+*\r
+*      laa_idx\r
+*              Global counter for generating LAA MACs\r
 *********/\r
 \r
+extern ipoib_globals_t g_ipoib;\r
+\r
 \r
 typedef struct _ipoib_bundle\r
 {\r
index b7e0fd8..2b5a3b8 100644 (file)
@@ -88,9 +88,6 @@ extern "C"
 {\r
 #endif\r
 \r
-/* Global counter for generating LAA MACs */\r
-extern atomic32_t              g_laa_idx;\r
-\r
 \r
 /*\r
  * Address accessors\r
@@ -221,7 +218,7 @@ ipoib_mac_from_guid(
        }\r
 \r
        /* Value of zero is reserved. */\r
-       laa = cl_atomic_inc( &g_laa_idx );\r
+       laa = cl_atomic_inc( &g_ipoib.laa_idx );\r
 \r
        if( !laa )\r
                return IB_INVALID_GUID;\r