[IPoIB] Enable IBAT on a device only if its packet filter is non-zero.
authorftillier <ftillier@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Fri, 9 Dec 2005 19:59:19 +0000 (19:59 +0000)
committerftillier <ftillier@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Fri, 9 Dec 2005 19:59:19 +0000 (19:59 +0000)
git-svn-id: svn://openib.tc.cornell.edu/gen1/trunk@202 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_ibat.c

index 0fe0418..e2f4bc4 100644 (file)
@@ -126,7 +126,6 @@ ipoib_create_adapter(
        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
@@ -189,10 +188,6 @@ ipoib_create_adapter(
                return IB_ERROR;\r
        }\r
 \r
-       KeAcquireInStackQueuedSpinLock( &g_ipoib.lock, &hdl );\r
-       cl_qlist_insert_tail( &g_ipoib.adapter_list, &p_adapter->entry );\r
-       KeReleaseInStackQueuedSpinLock( &hdl );\r
-\r
        status = adapter_init( p_adapter );\r
        if( status != IB_SUCCESS )\r
        {\r
@@ -429,10 +424,19 @@ __adapter_destroying(
                p_adapter->h_pnp = NULL;\r
        }\r
 \r
-       KeAcquireInStackQueuedSpinLock( &g_ipoib.lock, &hdl );\r
-       ASSERT( cl_qlist_count( &g_ipoib.adapter_list ) );\r
-       cl_qlist_remove_item( &g_ipoib.adapter_list, &p_adapter->entry );\r
-       KeReleaseInStackQueuedSpinLock( &hdl );\r
+       if( p_adapter->packet_filter )\r
+       {\r
+               KeAcquireInStackQueuedSpinLock( &g_ipoib.lock, &hdl );\r
+               cl_obj_lock( &p_adapter->obj );\r
+\r
+               ASSERT( cl_qlist_count( &g_ipoib.adapter_list ) );\r
+               cl_qlist_remove_item( &g_ipoib.adapter_list, &p_adapter->entry );\r
+\r
+               p_adapter->packet_filter = 0;\r
+\r
+               cl_obj_unlock( &p_adapter->obj );\r
+               KeReleaseInStackQueuedSpinLock( &hdl );\r
+       }\r
 \r
        IPOIB_EXIT( IPOIB_DBG_INIT );\r
 }\r
index b2e7388..a913585 100644 (file)
@@ -183,6 +183,13 @@ typedef struct _ipoib_adapter
 *      guids\r
 *              CA and port GUIDs returned by the bus driver.\r
 *\r
+*      entry\r
+*              List item for storing all adapters in a list for address translation.\r
+*              We add adapters when their packet filter is set to a non-zero value,\r
+*              and remove them when their packet filter is cleared.  This is needed\r
+*              since user-mode removal events are generated after the packet filter\r
+*              is cleared, but before the adapter is destroyed.\r
+*\r
 *      h_al\r
 *              AL handle for all IB resources.\r
 *\r
index 8247b27..7283bbc 100644 (file)
@@ -1393,6 +1393,8 @@ ipoib_set_info(
 \r
        ULONG                           buf_len;\r
        uint8_t                         port_num;\r
+\r
+       KLOCK_QUEUE_HANDLE      hdl;\r
        \r
        IPOIB_ENTER( IPOIB_DBG_OID );\r
 \r
@@ -1425,6 +1427,7 @@ ipoib_set_info(
                }\r
                else\r
                {\r
+                       KeAcquireInStackQueuedSpinLock( &g_ipoib.lock, &hdl );\r
                        cl_obj_lock( &p_adapter->obj );\r
                        switch( p_adapter->state )\r
                        {\r
@@ -1445,6 +1448,9 @@ ipoib_set_info(
                        default:\r
                                if( !p_adapter->packet_filter && (*(uint32_t*)info_buf) )\r
                                {\r
+                                       cl_qlist_insert_tail(\r
+                                               &g_ipoib.adapter_list, &p_adapter->entry );\r
+\r
                                        /*\r
                                         * Filter was zero, now non-zero.  Register IP addresses\r
                                         * with SA.\r
@@ -1457,11 +1463,16 @@ ipoib_set_info(
                                         * Filter was non-zero, now zero.  Deregister IP addresses.\r
                                         */\r
                                        ipoib_dereg_addrs( p_adapter );\r
+\r
+                                       ASSERT( cl_qlist_count( &g_ipoib.adapter_list ) );\r
+                                       cl_qlist_remove_item(\r
+                                               &g_ipoib.adapter_list, &p_adapter->entry );\r
                                }\r
 \r
                                p_adapter->packet_filter = *(uint32_t*)info_buf;\r
                        }\r
                        cl_obj_unlock( &p_adapter->obj );\r
+                       KeReleaseInStackQueuedSpinLock( &hdl );\r
                }\r
                break;\r
 \r
@@ -1700,11 +1711,12 @@ void
 ipoib_resume_oids(\r
        IN                              ipoib_adapter_t* const          p_adapter )\r
 {\r
-       ULONG                   info;\r
-       NDIS_STATUS             status;\r
-       boolean_t               pending_query, pending_set;\r
-       pending_oid_t   query_oid = {0};\r
-       pending_oid_t   set_oid = {0};\r
+       ULONG                           info;\r
+       NDIS_STATUS                     status;\r
+       boolean_t                       pending_query, pending_set;\r
+       pending_oid_t           query_oid = {0};\r
+       pending_oid_t           set_oid = {0};\r
+       KLOCK_QUEUE_HANDLE      hdl;\r
 \r
        IPOIB_ENTER( IPOIB_DBG_INIT );\r
 \r
@@ -1775,25 +1787,32 @@ ipoib_resume_oids(
                case OID_GEN_CURRENT_PACKET_FILTER:\r
                        /* Validation already performed in the SetInformation path. */\r
 \r
+                       KeAcquireInStackQueuedSpinLock( &g_ipoib.lock, &hdl );\r
                        cl_obj_lock( &p_adapter->obj );\r
                        if( !p_adapter->packet_filter && (*(PULONG)set_oid.p_buf) )\r
                        {\r
+                               cl_qlist_insert_tail(\r
+                                       &g_ipoib.adapter_list, &p_adapter->entry );\r
                                /*\r
-                               * Filter was zero, now non-zero.  Register IP addresses\r
-                               * with SA.\r
-                               */\r
+                                * Filter was zero, now non-zero.  Register IP addresses\r
+                                * with SA.\r
+                                */\r
                                ipoib_reg_addrs( p_adapter );\r
                        }\r
                        else if( p_adapter->packet_filter && !(*(PULONG)set_oid.p_buf) )\r
                        {\r
-                               /*\r
-                               * Filter was non-zero, now zero.  Deregister IP addresses.\r
-                               */\r
+                               /* Filter was non-zero, now zero.  Deregister IP addresses. */\r
                                ipoib_dereg_addrs( p_adapter );\r
+\r
+                               ASSERT( cl_qlist_count( &g_ipoib.adapter_list ) );\r
+                               cl_qlist_remove_item(\r
+                                       &g_ipoib.adapter_list, &p_adapter->entry );\r
                        }\r
+                       p_adapter->packet_filter = *(PULONG)set_oid.p_buf;\r
+\r
                        cl_obj_unlock( &p_adapter->obj );\r
+                       KeReleaseInStackQueuedSpinLock( &hdl );\r
 \r
-                       p_adapter->packet_filter = *(PULONG)set_oid.p_buf;\r
                        NdisMSetInformationComplete( p_adapter->h_adapter, status );\r
                        break;\r
 \r
index f6a8b75..a49e0c5 100644 (file)
@@ -200,19 +200,6 @@ __ibat_get_ips(
                        continue;\r
 \r
                cl_obj_lock( &pAdapter->obj );\r
-\r
-               /*\r
-                * Only report IP addresses for adapters that have a non-zero\r
-                * packet filter since user-mode removal events are generated\r
-                * after the packet filter is cleared, but before the adapter\r
-                * is destroyed.\r
-                */\r
-               if( !pAdapter->packet_filter )\r
-               {\r
-                       cl_obj_unlock( &pAdapter->obj );\r
-                       continue;\r
-               }\r
-\r
                nIps += (LONG)cl_vector_get_size( &pAdapter->ip_vector );\r
 \r
                for( idx = 0;\r