[ofw] [Patch][IPoIB_NDIS6_CM] __recv_cb_internal() revisited

Alex Naslednikov xalex at mellanox.co.il
Wed Dec 22 02:27:15 PST 2010


__recv_cb_internal revisited
Code clean-up and rearrange
Update shortage counter when reposting recv descriptors again
Signed-off by: Alexander Naslednikov (xalex at mellanox.co.il)

Index: ulp/ipoib_NDIS6_CM/kernel/ipoib_port.cpp
===================================================================
--- ulp/ipoib_NDIS6_CM/kernel/ipoib_port.cpp	(revision 3033)
+++ ulp/ipoib_NDIS6_CM/kernel/ipoib_port.cpp	(working copy)
@@ -2143,12 +2143,6 @@
 		cl_perf_start( RepostRecv );
 		shortage = __recv_mgr_repost( p_port );
 		
-		if( shortage > 0 )
-		{				
-			recv_complete_flags |= NDIS_RECEIVE_FLAGS_RESOURCES;
-			cl_dbg_out("Got SHORTAGE=%d\n",shortage);
-		}
-		
 		cl_perf_stop( &p_port->p_adapter->perf, RepostRecv );
 
 		cl_perf_start( BuildNBLArray );
@@ -2161,12 +2155,13 @@
 		{
 			/* We may have thrown away packets, and have a shortage */
 			cl_perf_start( RepostRecv );
-			__recv_mgr_repost( p_port );
+			IPOIB_PRINT_EXIT( TRACE_LEVEL_WARNING, IPOIB_DBG_ALL,
+					("Out of recv descriptors, reposting again\n") )
+			shortage = __recv_mgr_repost( p_port );
 			cl_perf_stop( &p_port->p_adapter->perf, RepostRecv );
 		}
 
 		if( !NBL_cnt ) {
-			//cl_dbg_out("NBL cnt == 0 :-(\n");
 			break;
 		}
 
@@ -2174,7 +2169,8 @@
 
 		cl_perf_start( RecvNdisIndicate );
 		
-		if (shortage <= 0) {
+		if (shortage <= 0) 
+		{
 
 			res = shutter_add( &p_port->p_adapter->recv_shutter, NBL_cnt );
 			if (res)
@@ -2191,14 +2187,16 @@
 				__free_received_NBL( p_port, p_port->recv_mgr.recv_NBL_array[0] );
 				cl_spinlock_release( &p_port->recv_lock );
 			}
-				
-		} else {
-			/* If shortage >0, we already set the status to
-			   NDIS_RECEIVE_FLAGS_RESOURCES.  That is, IPoIB driver regain
+			cl_perf_stop( &p_port->p_adapter->perf, RecvNdisIndicate );
+		} 
+		else 
+		{
+			/* If shortage >0,  IPoIB driver should regain
 			   ownership of the NET_BUFFER_LIST structures immediately.
 			 */
 			res = shutter_add( &p_port->p_adapter->recv_shutter, 1 );
 			if (res) {
+				recv_complete_flags |= NDIS_RECEIVE_FLAGS_RESOURCES;
 				NdisMIndicateReceiveNetBufferLists(
 												p_port->p_adapter->h_adapter,
 												p_port->recv_mgr.recv_NBL_array[0],
@@ -2207,20 +2205,18 @@
 												recv_complete_flags );
 				shutter_sub( &p_port->p_adapter->recv_shutter, -1 );
 			}
-		}
+			cl_perf_stop( &p_port->p_adapter->perf, RecvNdisIndicate );
 
-		cl_perf_stop( &p_port->p_adapter->perf, RecvNdisIndicate );
-
-		/*
-		 * Cap the number of receives to put back to what we just indicated
-		 * with NDIS_STATUS_RESOURCES.
-		 */
-		if( shortage > 0 )
-		{
-			cl_dbg_out("GOT SHORTAGE <===============\n");
+			/*
+			 * Cap the number of receives to put back to what we just indicated
+			 * with NDIS_STATUS_RESOURCES.
+			 */
+			
+			IPOIB_PRINT_EXIT( TRACE_LEVEL_WARNING, IPOIB_DBG_ALL,
+					("Out of recv descriptors, SHORTAGE=%d\n",shortage) );
+			
 			/* Return all but the last packet to the pool. */
 			cl_spinlock_acquire( &p_port->recv_lock );
-			//while( shortage-- > 1 )
 			while ( NBL_cnt-- > 0)
 			{
 				__buf_mgr_put_recv(
@@ -2232,12 +2228,8 @@
 			__recv_mgr_repost( p_port );
 			cl_spinlock_release( &p_port->recv_lock );
 
-			/*
-			 * Return the last packet as if NDIS returned it, so that we repost
-			 * and report any other pending receives.
-			 */
-			//ipoib_return_net_buffer_list( p_port, p_port->recv_mgr.recv_NBL_array[0],recv_complete_flags );
 		}
+
 		cl_spinlock_acquire( &p_port->recv_lock );
 
 	} while( NBL_cnt );
-------------- next part --------------
A non-text attachment was scrubbed...
Name: recv_cb_revisited_ofw.patch
Type: application/octet-stream
Size: 3418 bytes
Desc: recv_cb_revisited_ofw.patch
URL: <http://lists.openfabrics.org/pipermail/ofw/attachments/20101222/f989459b/attachment.obj>


More information about the ofw mailing list