[ofw] [Patch 2/3 ][ALL] Moving "shutter.h" under different location

Alex Naslednikov xalex at mellanox.co.il
Mon Jan 25 10:49:27 PST 2010


This patches introduces SHUTTER Data Structure to avoid stop
receiving packets during IPoIB shutdown.
The problem was discovered by WHQL NDIS 6.5 MPE test

Signed-off by: Alexander Naslednikov (xalex at mellanox.com),
      Tzachi Dar (tzachid at mellanox.com)
Index: ipoib_adapter.cpp
===================================================================
--- ipoib_adapter.cpp (revision 5452)
+++ ipoib_adapter.cpp (working copy)
@@ -393,6 +393,8 @@
   return status;
  }

+ shutter_init(&p_adapter->recv_shutter);
+
  IPOIB_EXIT( IPOIB_DBG_INIT );
  return status;
 }
Index: ipoib_adapter.h
===================================================================
--- ipoib_adapter.h (revision 5452)
+++ ipoib_adapter.h (working copy)
@@ -47,8 +47,10 @@
 #include <ip_packet.h>
 #include "ip_stats.h"
 #include "ipoib_stat.h"
+#include "shutter.h"


+
 /*
  * Definitions
  */
@@ -238,6 +240,9 @@
  ULONG     n_send_NBL;   // number of send NBLs, gotten from NDIS
  ULONG     n_send_NBL_done; // number of send NBLs, completed

+ //
+ shutter_t               recv_shutter;
+
 } ipoib_adapter_t;
 /*
 * FIELDS
Index: ipoib_driver.cpp
===================================================================
--- ipoib_driver.cpp (revision 5452)
+++ ipoib_driver.cpp (working copy)
@@ -3111,7 +3111,6 @@

  CL_ASSERT( adapter_context );
  p_adapter = (ipoib_adapter_t*)adapter_context;
- p_port = p_adapter->p_port;

  cl_obj_lock( &p_adapter->obj );
  if( p_adapter->ipoib_state == IPOIB_PAUSING ||
@@ -3239,9 +3238,17 @@
  IN NDIS_HANDLE  adapter_context,
  IN NDIS_SHUTDOWN_ACTION  shutdown_action)
 {
- IPOIB_ENTER( IPOIB_DBG_INIT );
- UNUSED_PARAM( adapter_context );
+ IPOIB_ENTER( IPOIB_DBG_INIT ) ;
  UNUSED_PARAM( shutdown_action );
+
+ ipoib_adapter_t *p_adapter = (ipoib_adapter_t *) adapter_context;
+
+ if (shutdown_action == NdisShutdownPowerOff ) {
+  ASSERT(KeGetCurrentIrql() == PASSIVE_LEVEL);
+  // We need to wait only if this is not a blue screen any way
+  shutter_shut ( &p_adapter->recv_shutter );
+ }
+
  IPOIB_EXIT( IPOIB_DBG_INIT );
 }

@@ -3940,9 +3947,9 @@
  p_adapter->ipoib_state = IPOIB_PAUSING;
  KeReleaseInStackQueuedSpinLock( &hdl );

+ shutter_shut ( &p_adapter->recv_shutter );
+
  if (p_adapter->p_port) {
-  //TODO improve this flow !
-  //TODO Be sure we stopped all sends and receives
   cl_spinlock_acquire( &p_adapter->p_port->send_lock );
   ipoib_port_resume(p_adapter->p_port,FALSE);
   cl_spinlock_release( &p_adapter->p_port->send_lock );
@@ -3978,6 +3985,10 @@
         //
         // Check to see if we need to change any attributes
     }
+
+ if (p_adapter->ipoib_state == IPOIB_PAUSED) {
+  shutter_alive( &p_adapter->recv_shutter );
+ }

  KeAcquireInStackQueuedSpinLock( &g_ipoib.lock, &hdl );
  p_adapter->ipoib_state = IPOIB_RUNNING;
Index: ipoib_port.cpp
===================================================================
--- ipoib_port.cpp (revision 5452)
+++ ipoib_port.cpp (working copy)
@@ -824,7 +824,12 @@
  IPOIB_PRINT( TRACE_LEVEL_ERROR, IPOIB_DBG_OBJ,
   ("ref type %d ref_cnt %d\n", ref_init, p_port->obj.ref_cnt) );
 #endif
-
+    // The port is started as paused and NDIS calls latter to ipoib_restart. We
+    // shut the recv_shuter for now and alive it on ipoib_restart. We did
+    // it in this way since MpInitializeInternal also calls in reset and than
+    // we need to set the rec ref count to 1 //TODO !!!!!!!!!!1
+    //
+ shutter_shut (&p_adapter->recv_shutter);
  IPOIB_EXIT( IPOIB_DBG_INIT );
  return IB_SUCCESS;
 }
@@ -1843,45 +1848,28 @@
  return p_port->p_adapter->params.rq_low_watermark - p_port->recv_mgr.depth;
 }

-void
-ipoib_return_net_buffer_list(
- IN    NDIS_HANDLE     adapter_context,
- IN    NET_BUFFER_LIST    *p_net_buffer_lists,
- IN    ULONG      return_flags)
+inline ULONG __free_received_NBL (
+ IN ipoib_port_t  *p_port,
+ IN NET_BUFFER_LIST  *p_net_buffer_lists
+ )
 {
- ipoib_port_t  *p_port;
+
  ipoib_recv_desc_t *p_desc;
- NET_BUFFER_LIST  *cur_net_buffer_list,*next_net_buffer_list;
- int32_t    shortage;
+ NET_BUFFER_LIST  *cur_net_buffer_list, *next_net_buffer_list;
+ LONG    NBL_cnt = 0;
+

- PERF_DECLARE( ReturnPacket );
- PERF_DECLARE( ReturnPutRecv );
- PERF_DECLARE( ReturnRepostRecv );
- PERF_DECLARE( ReturnPreparePkt );
- PERF_DECLARE( ReturnNdisIndicate );
-
- IPOIB_ENTER( IPOIB_DBG_RECV );
-
- UNUSED_PARAM( return_flags );
-
- p_port = ((ipoib_adapter_t*)adapter_context)->p_port;
- CL_ASSERT( p_net_buffer_lists );
-
- cl_perf_start( ReturnPacket );
- cl_spinlock_acquire( &p_port->recv_lock );
  for (cur_net_buffer_list = p_net_buffer_lists;
    cur_net_buffer_list != NULL;
    cur_net_buffer_list = next_net_buffer_list)
  {
+  ++NBL_cnt;
   next_net_buffer_list = NET_BUFFER_LIST_NEXT_NBL(cur_net_buffer_list);

   /* Get the port and descriptor from the NET_BUFFER_LIST. */
   CL_ASSERT(p_port == IPOIB_PORT_FROM_NBL( cur_net_buffer_list ));
   p_desc = IPOIB_RECV_FROM_NBL( cur_net_buffer_list );
-

-  //TODO: NDIS60, rewrite this block
-
 #if 0 //TODO CM flow
   if( p_desc->type == PKT_TYPE_CM_UCAST )
   {
@@ -1916,9 +1904,44 @@
   __buf_mgr_put_recv( p_port, p_desc, cur_net_buffer_list );
   cl_perf_stop( &p_port->p_adapter->perf, ReturnPutRecv );
  }
+ return NBL_cnt;
+}

+void
+ipoib_return_net_buffer_list(
+ IN    NDIS_HANDLE     adapter_context,
+ IN    NET_BUFFER_LIST    *p_net_buffer_lists,
+ IN    ULONG      return_flags)
+{
+ ipoib_port_t  *p_port;
+ int32_t    shortage;
+ LONG    NBL_cnt = 0;
+
+ PERF_DECLARE( ReturnPacket );
+ PERF_DECLARE( ReturnPutRecv );
+ PERF_DECLARE( ReturnRepostRecv );
+ PERF_DECLARE( ReturnPreparePkt );
+ PERF_DECLARE( ReturnNdisIndicate );

+ IPOIB_ENTER( IPOIB_DBG_RECV );

+ UNUSED_PARAM( return_flags );
+
+ p_port = ((ipoib_adapter_t*)adapter_context)->p_port;
+ CL_ASSERT( p_net_buffer_lists );
+ if ( !p_port ) {
+  ASSERT(p_port);
+  IPOIB_PRINT_EXIT( TRACE_LEVEL_ERROR, IPOIB_DBG_ERROR,
+   ("return_NBL callback called when port pointer was already cleared\n") );
+  return;
+ }
+
+ cl_perf_start( ReturnPacket );
+ cl_spinlock_acquire( &p_port->recv_lock );
+ NBL_cnt = __free_received_NBL( p_port, p_net_buffer_lists );
+
+ shutter_sub( &p_port->p_adapter->recv_shutter, -NBL_cnt );
+
  /* Repost buffers to HW */
  cl_perf_start( ReturnRepostRecv );
  shortage = __recv_mgr_repost( p_port );
@@ -1958,6 +1981,7 @@
  cl_qlist_t   done_list, bad_list;
  size_t    i;
  ULONG    recv_complete_flags = 0;
+ BOOLEAN    res;

  PERF_DECLARE( RecvCompBundle );
  PERF_DECLARE( RecvCb );
@@ -2069,13 +2093,40 @@

   cl_perf_start( RecvNdisIndicate );

-  NdisMIndicateReceiveNetBufferLists(
-   p_port->p_adapter->h_adapter,
-   p_port->recv_mgr.recv_NBL_array[0],
-   NDIS_DEFAULT_PORT_NUMBER,
-   NBL_cnt,
-   recv_complete_flags);
+  if (shortage <= 0) {

+   res = shutter_add( &p_port->p_adapter->recv_shutter, NBL_cnt );
+   if (res) {
+    NdisMIndicateReceiveNetBufferLists(
+     p_port->p_adapter->h_adapter,
+     p_port->recv_mgr.recv_NBL_array[0],
+     NDIS_DEFAULT_PORT_NUMBER,
+     NBL_cnt,
+     recv_complete_flags);
+   }
+   else {
+    __free_received_NBL (p_port, p_port->recv_mgr.recv_NBL_array[0]);
+   }
+
+  } else {
+
+   // If shortage >0, we already set the status to NDIS_RECEIVE_FLAGS_RESOURCES
+   // That is, IPoIB driver regain ownership of the NET_BUFFER_LIST structures immediately
+   res = shutter_add( &p_port->p_adapter->recv_shutter, 1 );
+   if (res) {
+    NdisMIndicateReceiveNetBufferLists(
+     p_port->p_adapter->h_adapter,
+     p_port->recv_mgr.recv_NBL_array[0],
+     NDIS_DEFAULT_PORT_NUMBER,
+     NBL_cnt,
+     recv_complete_flags);
+    shutter_sub( &p_port->p_adapter->recv_shutter, -1 );
+   }
+
+  }
+
+
+
   cl_perf_stop( &p_port->p_adapter->perf, RecvNdisIndicate );

   /*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openfabrics.org/pipermail/ofw/attachments/20100125/05e82727/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: shutter_MPE_patch_2_of_3.patch
Type: application/octet-stream
Size: 8041 bytes
Desc: shutter_MPE_patch_2_of_3.patch
URL: <http://lists.openfabrics.org/pipermail/ofw/attachments/20100125/05e82727/attachment.obj>


More information about the ofw mailing list