[IPoIB NDIS 6.0 CM] Fixing a possible race when we get PORT_REMOVE before PORT_DOWN...
authortzachid <tzachid@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Mon, 30 Nov 2009 15:36:34 +0000 (15:36 +0000)
committertzachid <tzachid@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Mon, 30 Nov 2009 15:36:34 +0000 (15:36 +0000)
git-svn-id: svn://openib.tc.cornell.edu/gen1/trunk@2602 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86

ulp/ipoib_NDIS6_CM/kernel/ipoib_adapter.cpp
ulp/ipoib_NDIS6_CM/kernel/ipoib_port.cpp

index 97e859d..e9283cf 100644 (file)
@@ -561,6 +561,35 @@ pkey_end:
        return status;\r
 }\r
 \r
+static inline void __ipoib_get_down(\r
+       IN ipoib_adapter_t              *p_adapter) \r
+{\r
+\r
+       NDIS_LINK_STATE         link_state;\r
+       NDIS_STATUS_INDICATION  status_indication;\r
+       \r
+       link_state.Header.Revision = NDIS_LINK_STATE_REVISION_1;\r
+       link_state.Header.Type = NDIS_OBJECT_TYPE_DEFAULT;\r
+       link_state.Header.Size = sizeof(NDIS_LINK_STATE);\r
+       link_state.MediaConnectState = MediaConnectStateDisconnected;\r
+       link_state.MediaDuplexState = MediaDuplexStateFull;\r
+       link_state.XmitLinkSpeed = \r
+       link_state.RcvLinkSpeed = IPOIB_MEDIA_MAX_SPEED;\r
+       link_state.PauseFunctions = NdisPauseFunctionsSendAndReceive;\r
+\r
+       IPOIB_INIT_NDIS_STATUS_INDICATION(&status_indication,\r
+                           p_adapter->h_adapter,\r
+                           NDIS_STATUS_LINK_STATE,\r
+                           (PVOID)&link_state,\r
+                           sizeof(link_state));\r
+\r
+       NdisMIndicateStatusEx(p_adapter->h_adapter,&status_indication);\r
+       IPOIB_PRINT( TRACE_LEVEL_INFORMATION, IPOIB_DBG_INIT,\r
+               ("Link DOWN!\n") );\r
+\r
+       ipoib_port_down( p_adapter->p_port );\r
+}\r
+\r
 static ib_api_status_t\r
 __ipoib_pnp_cb(\r
        IN                              ib_pnp_rec_t                            *p_pnp_rec )\r
@@ -642,6 +671,13 @@ __ipoib_pnp_cb(
                break;\r
 \r
        case IB_PNP_PORT_REMOVE:\r
+\r
+               if (p_adapter->state != IB_PNP_PORT_DOWN) {\r
+                       IPOIB_PRINT( TRACE_LEVEL_WARNING, IPOIB_DBG_ALL, \r
+                               (" Port got IB_PNP_PORT_REMOVE before IB_PNP_PORT_DOWN\n"));\r
+                       __ipoib_get_down( p_adapter);\r
+               }\r
+\r
                /* Release all IB resources. */\r
                CL_ASSERT( p_pnp_rec->context );\r
 \r
@@ -687,26 +723,7 @@ __ipoib_pnp_cb(
 \r
                if( !p_adapter->registering && old_state != IB_PNP_PORT_DOWN )\r
                {\r
-                       link_state.Header.Revision = NDIS_LINK_STATE_REVISION_1;\r
-                       link_state.Header.Type = NDIS_OBJECT_TYPE_DEFAULT;\r
-                       link_state.Header.Size = sizeof(NDIS_LINK_STATE);\r
-                       link_state.MediaConnectState = MediaConnectStateDisconnected;\r
-                       link_state.MediaDuplexState = MediaDuplexStateFull;\r
-                       link_state.XmitLinkSpeed = \r
-                       link_state.RcvLinkSpeed = IPOIB_MEDIA_MAX_SPEED;\r
-                       link_state.PauseFunctions = NdisPauseFunctionsSendAndReceive;\r
-\r
-                       IPOIB_INIT_NDIS_STATUS_INDICATION(&status_indication,\r
-                                   p_adapter->h_adapter,\r
-                                   NDIS_STATUS_LINK_STATE,\r
-                                   (PVOID)&link_state,\r
-                                   sizeof(link_state));\r
-\r
-                       NdisMIndicateStatusEx(p_adapter->h_adapter,&status_indication);\r
-                       IPOIB_PRINT( TRACE_LEVEL_INFORMATION, IPOIB_DBG_INIT,\r
-                               ("Link DOWN!\n") );\r
-\r
-                       ipoib_port_down( p_adapter->p_port );\r
+                       __ipoib_get_down( p_adapter );\r
                }\r
                break;\r
 \r
index cfb8e73..dec7dce 100644 (file)
@@ -793,7 +793,7 @@ __port_init(
        cl_status = cl_obj_init( &p_port->obj, CL_DESTROY_SYNC,\r
                __port_destroying, __port_cleanup, __port_free );\r
 \r
-#if DBG\r
+#if 0\r
        cl_atomic_inc( &p_port->ref[ref_init] );\r
        IPOIB_PRINT( TRACE_LEVEL_INFORMATION, IPOIB_DBG_OBJ,\r
                ("ref type %d ref_cnt %d\n", ref_init, p_port->obj.ref_cnt) );\r
@@ -815,7 +815,7 @@ __port_init(
                return IB_ERROR;\r
        }\r
 \r
-#if DBG\r
+#if 0\r
        cl_atomic_inc( &p_port->ref[ref_init] );\r
        IPOIB_PRINT( TRACE_LEVEL_ERROR, IPOIB_DBG_OBJ,\r
                ("ref type %d ref_cnt %d\n", ref_init, p_port->obj.ref_cnt) );\r
@@ -6508,7 +6508,7 @@ __endpt_mgr_insert(
                return IB_INVALID_STATE;\r
        }\r
 \r
-#if DBG\r
+#if 0\r
        cl_atomic_inc( &p_port->ref[ref_endpt_track] );\r
        IPOIB_PRINT( TRACE_LEVEL_INFORMATION, IPOIB_DBG_OBJ,\r
                ("ref  type %d ref_cnt %d\n", ref_endpt_track, p_port->obj.ref_cnt) );\r
@@ -6646,7 +6646,7 @@ ipoib_port_remove_endpt(
                //TODO CM\r
                //endpt_cm_destroy_conn( p_port, p_endpt );\r
 \r
-#if DBG\r
+#if 0\r
                cl_atomic_dec( &p_port->ref[ref_endpt_track] );\r
                IPOIB_PRINT( TRACE_LEVEL_INFORMATION, IPOIB_DBG_ENDPT,\r
                        ("ref type %d ref_cnt %d\n", ref_endpt_track, p_port->obj.ref_cnt) );\r