[IPOIB] bug fix: free pending list in ipoib_port_down
authorsleybo <sleybo@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Mon, 19 Feb 2007 15:41:15 +0000 (15:41 +0000)
committersleybo <sleybo@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Mon, 19 Feb 2007 15:41:15 +0000 (15:41 +0000)
check the port state in port_send and port_resume

git-svn-id: svn://openib.tc.cornell.edu/gen1/trunk@596 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86

ulp/ipoib/kernel/ipoib_port.c

index 29b299a..25a3701 100644 (file)
@@ -2625,15 +2625,14 @@ __send_mgr_construct(
 }\r
 \r
 \r
-static void\r
-__send_mgr_destroy(\r
+static void \r
+__pending_list_destroy(\r
        IN                              ipoib_port_t* const                     p_port )\r
 {\r
        cl_list_item_t  *p_item;\r
        NDIS_PACKET             *p_packet;\r
-\r
-       IPOIB_ENTER( IPOIB_DBG_SEND );\r
-\r
+       \r
+       cl_spinlock_acquire( &p_port->send_lock );\r
        /* Complete any pending packets. */\r
        for( p_item = cl_qlist_remove_head( &p_port->send_mgr.pending_list );\r
                p_item != cl_qlist_end( &p_port->send_mgr.pending_list );\r
@@ -2643,6 +2642,15 @@ __send_mgr_destroy(
                NdisMSendComplete( p_port->p_adapter->h_adapter, p_packet,\r
                        NDIS_STATUS_RESET_IN_PROGRESS );\r
        }\r
+       cl_spinlock_release( &p_port->send_lock );\r
+}\r
+\r
+static void\r
+__send_mgr_destroy(\r
+       IN                              ipoib_port_t* const                     p_port )\r
+{\r
+       IPOIB_ENTER( IPOIB_DBG_SEND );\r
+       __pending_list_destroy(p_port);\r
 \r
        IPOIB_EXIT( IPOIB_DBG_SEND );\r
 }\r
@@ -3633,6 +3641,27 @@ ipoib_port_send(
 \r
        IPOIB_ENTER( IPOIB_DBG_SEND );\r
 \r
+\r
+       cl_obj_lock( &p_port->obj );\r
+       if( p_port->state != IB_QPS_RTS )\r
+       {\r
+               cl_obj_unlock( &p_port->obj );\r
+               for( i = 0; i < num_packets; ++i )\r
+               {\r
+                       ipoib_inc_send_stat( p_port->p_adapter, IP_STAT_DROPPED, 0 );\r
+                       /* Complete the packet. */\r
+                       NdisMSendComplete( p_port->p_adapter->h_adapter,\r
+                               p_packet_array[i], NDIS_STATUS_ADAPTER_NOT_READY );\r
+                       \r
+               }\r
+\r
+               IPOIB_PRINT_EXIT( TRACE_LEVEL_INFORMATION, IPOIB_DBG_SEND,\r
+                       ("Invalid state - Aborting.\n") );\r
+               return;\r
+       }\r
+       cl_obj_unlock( &p_port->obj );\r
+\r
+       \r
        cl_spinlock_acquire( &p_port->send_lock );\r
        for( i = 0; i < num_packets; i++ )\r
        {\r
@@ -3736,6 +3765,17 @@ ipoib_port_resume(
 \r
        IPOIB_ENTER( IPOIB_DBG_SEND );\r
 \r
+\r
+       cl_obj_lock( &p_port->obj );\r
+       if( p_port->state != IB_QPS_RTS )\r
+       {\r
+               IPOIB_PRINT_EXIT( TRACE_LEVEL_WARNING, IPOIB_DBG_SEND,\r
+                       ("Invalid state - Aborting.\n") );\r
+               cl_obj_unlock( &p_port->obj );\r
+               return;\r
+       }\r
+       cl_obj_unlock( &p_port->obj );\r
+\r
        cl_spinlock_acquire( &p_port->send_lock );\r
 \r
        for( p_item = cl_qlist_head( &p_port->send_mgr.pending_list );\r
@@ -3745,7 +3785,7 @@ ipoib_port_resume(
                /* Check the send queue and pend the request if not empty. */\r
                if( p_port->send_mgr.depth == p_port->p_adapter->params.sq_depth )\r
                {\r
-                       IPOIB_PRINT_EXIT( TRACE_LEVEL_WARNING, IPOIB_DBG_SEND,\r
+                       IPOIB_PRINT( TRACE_LEVEL_WARNING, IPOIB_DBG_SEND,\r
                                ("No available WQEs.\n") );\r
                        break;\r
                }\r
@@ -4130,7 +4170,7 @@ __endpt_mgr_reset_all(
                KeSetEvent( &p_port->leave_mcast_event, EVENT_INCREMENT, FALSE );\r
        }       \r
 \r
-       IPOIB_PRINT( TRACE_LEVEL_ERROR, IPOIB_DBG_ERROR,("p_port->mcast_cnt = %d\n", p_port->mcast_cnt - local_exist));\r
+       IPOIB_PRINT( TRACE_LEVEL_INFORMATION, IPOIB_DBG_ENDPT,("p_port->mcast_cnt = %d\n", p_port->mcast_cnt - local_exist));\r
 \r
        /* Destroy all multicast endpoints now that we have released the lock. */\r
        while( cl_qlist_count( &mc_list ) )\r
@@ -5138,6 +5178,8 @@ ipoib_port_down(
 \r
        KeWaitForSingleObject(\r
                &p_port->leave_mcast_event, Executive, KernelMode, FALSE, NULL );\r
+\r
+       __pending_list_destroy(p_port);\r
        \r
        cl_obj_lock( &p_port->p_adapter->obj );\r
        ipoib_dereg_addrs( p_port->p_adapter );\r
@@ -5579,7 +5621,7 @@ ipoib_leave_mcast_cb(
 \r
        p_port = (ipoib_port_t* __ptr64)context;\r
 \r
-       IPOIB_PRINT( TRACE_LEVEL_ERROR, IPOIB_DBG_ERROR,("p_port->mcast_cnt = %d\n", p_port->mcast_cnt));\r
+       IPOIB_PRINT( TRACE_LEVEL_VERBOSE, IPOIB_DBG_MCAST,("p_port->mcast_cnt = %d\n", p_port->mcast_cnt));\r
        \r
        ipoib_port_deref( p_port, ref_leave_mcast);\r
        cl_atomic_dec( &p_port->mcast_cnt);\r
@@ -5590,7 +5632,7 @@ ipoib_leave_mcast_cb(
        }\r
        \r
        IPOIB_PRINT_EXIT( TRACE_LEVEL_INFORMATION, IPOIB_DBG_MCAST,\r
-                       ("Leav mcast callback deref ipoib_port \n") );\r
+                       ("Leave mcast callback deref ipoib_port \n") );\r
        \r
        IPOIB_EXIT( IPOIB_DBG_MCAST );\r
 }\r
@@ -5609,7 +5651,7 @@ __leave_error_mcast_cb(
 \r
        ipoib_port_deref( p_port, ref_leave_mcast);\r
        IPOIB_PRINT_EXIT( TRACE_LEVEL_INFORMATION, IPOIB_DBG_MCAST,\r
-                       ("Leav mcast callback deref ipoib_port \n") );\r
+                       ("Leave mcast callback deref ipoib_port \n") );\r
        \r
        IPOIB_EXIT( IPOIB_DBG_MCAST );\r
 }\r