]> git.openfabrics.org - ~shefty/rdma-win.git/commitdiff
[IPoIB] Prevent reposting receives when QP may be in reset state.
authorftillier <ftillier@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Thu, 11 May 2006 06:31:56 +0000 (06:31 +0000)
committerftillier <ftillier@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Thu, 11 May 2006 06:31:56 +0000 (06:31 +0000)
git-svn-id: svn://openib.tc.cornell.edu/gen1@338 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86

trunk/ulp/ipoib/kernel/ipoib_port.c

index 79d5d03801c2f7b70f735e6c86e8c5b1bee94d68..0bb9cd5a09fcec18bf671b4beedeac7ebbcb9407 100644 (file)
@@ -203,8 +203,7 @@ __recv_mgr_destroy(
 /* Posts receive buffers to the receive queue. */\r
 static ib_api_status_t\r
 __recv_mgr_repost(\r
-       IN                              ipoib_port_t* const                     p_port,\r
-       IN                              uint32_t                                        num_wrs );\r
+       IN                              ipoib_port_t* const                     p_port );\r
 \r
 static void\r
 __recv_cb(\r
@@ -1303,8 +1302,7 @@ __recv_mgr_destroy(
 /* Posts receive buffers to the receive queue. */\r
 static ib_api_status_t\r
 __recv_mgr_repost(\r
-       IN                              ipoib_port_t* const                     p_port,\r
-       IN                              uint32_t                                        num_wrs )\r
+       IN                              ipoib_port_t* const                     p_port )\r
 {\r
        ipoib_recv_desc_t       *p_head = NULL, *p_tail = NULL, *p_next;\r
        ib_api_status_t         status;\r
@@ -1315,9 +1313,8 @@ __recv_mgr_repost(
        IPOIB_ENTER( IPOIB_DBG_RECV );\r
 \r
        CL_ASSERT( p_port );\r
-       CL_ASSERT( num_wrs );\r
        cl_obj_lock( &p_port->obj );\r
-       if( p_port->state == IB_QPS_ERROR )\r
+       if( p_port->state != IB_QPS_RTS )\r
        {\r
                cl_obj_unlock( &p_port->obj );\r
                IPOIB_PRINT_EXIT( TRACE_LEVEL_INFORMATION, IPOIB_DBG_RECV,\r
@@ -1327,15 +1324,8 @@ __recv_mgr_repost(
        cl_obj_ref( &p_port->obj );\r
        cl_obj_unlock( &p_port->obj );\r
 \r
-       while( num_wrs-- )\r
+       while( p_port->recv_mgr.depth < p_port->p_adapter->params.rq_depth )\r
        {\r
-               if( p_port->recv_mgr.depth == p_port->p_adapter->params.rq_depth )\r
-               {\r
-                       IPOIB_PRINT(TRACE_LEVEL_INFORMATION, IPOIB_DBG_RECV,\r
-                               ("Receive queue already full\n") );\r
-                       break;\r
-               }\r
-\r
                /* Pull receives out of the pool and chain them up. */\r
                cl_perf_start( GetRecv );\r
                p_next = __buf_mgr_get_recv( p_port );\r
@@ -1434,7 +1424,7 @@ ipoib_return_packet(
 \r
        /* Repost buffers. */\r
        cl_perf_start( ReturnRepostRecv );\r
-       __recv_mgr_repost( p_port, 0xFFFF );\r
+       __recv_mgr_repost( p_port );\r
        cl_perf_stop( &p_port->p_adapter->perf, ReturnRepostRecv );\r
 \r
        /* Complete any additional receives waiting for a packet. */\r
@@ -1576,7 +1566,7 @@ __recv_cb(
 \r
        /* Repost receives. */\r
        cl_perf_start( RepostRecv );\r
-       __recv_mgr_repost( p_port, recv_cnt );\r
+       __recv_mgr_repost( p_port );\r
        cl_perf_stop( &p_port->p_adapter->perf, RepostRecv );\r
 \r
        cl_spinlock_release( &p_port->recv_lock );\r
@@ -4880,7 +4870,13 @@ ipoib_port_down(
 \r
        IPOIB_ENTER( IPOIB_DBG_INIT );\r
 \r
-       /* Mark our state.  This causes all callbacks to abort. */\r
+       /*\r
+        * Mark our state.  This causes all callbacks to abort.\r
+        * Note that we hold the receive lock so that we synchronize\r
+        * with reposting.  We must take the receive lock before the\r
+        * object lock since that is the order taken when reposting.\r
+        */\r
+       cl_spinlock_acquire( &p_port->recv_lock );\r
        cl_obj_lock( &p_port->obj );\r
        p_port->state = IB_QPS_ERROR;\r
 \r
@@ -4894,6 +4890,7 @@ ipoib_port_down(
                p_port->ib_mgr.h_query = NULL;\r
        }\r
        cl_obj_unlock( &p_port->obj );\r
+       cl_spinlock_release( &p_port->recv_lock );\r
 \r
        KeWaitForSingleObject(\r
                &p_port->sa_event, Executive, KernelMode, FALSE, NULL );\r
@@ -5026,6 +5023,11 @@ err:
                p_port->state = IB_QPS_RTS;\r
        cl_obj_unlock( &p_port->obj );\r
 \r
+       /* Prepost receives. */\r
+       cl_spinlock_acquire( &p_port->recv_lock );\r
+       __recv_mgr_repost( p_port );\r
+       cl_spinlock_release( &p_port->recv_lock );\r
+\r
        /* Notify the adapter that we now have an active connection. */\r
        ipoib_set_active( p_port->p_adapter );\r
 \r
@@ -5110,11 +5112,6 @@ __ib_mgr_activate(
                return status;\r
        }\r
 \r
-       /* Prepost receives. */\r
-       cl_spinlock_acquire( &p_port->recv_lock );\r
-       __recv_mgr_repost( p_port, p_port->p_adapter->params.rq_depth );\r
-       cl_spinlock_release( &p_port->recv_lock );\r
-\r
        IPOIB_EXIT( IPOIB_DBG_INIT );\r
        return IB_SUCCESS;\r
 }\r