session: cleanup event llist usage
[vpp.git] / src / vnet / session / session_cli.c
index 563ee83..24d8cfb 100644 (file)
@@ -14,7 +14,6 @@
  */
 #include <vnet/session/application.h>
 #include <vnet/session/session.h>
-#include <vnet/session/session_debug.h>
 
 u8 *
 format_session_fifos (u8 * s, va_list * args)
@@ -28,14 +27,14 @@ format_session_fifos (u8 * s, va_list * args)
     return s;
 
   s = format (s, " Rx fifo: %U", format_svm_fifo, ss->rx_fifo, verbose);
-  if (verbose > 2 && ss->rx_fifo->has_event)
+  if (verbose > 2 && ss->rx_fifo->shr->has_event)
     {
       found = session_node_lookup_fifo_event (ss->rx_fifo, e);
       s = format (s, " session node event: %s\n",
                  found ? "found" : "not found");
     }
   s = format (s, " Tx fifo: %U", format_svm_fifo, ss->tx_fifo, verbose);
-  if (verbose > 2 && ss->tx_fifo->has_event)
+  if (verbose > 2 && ss->tx_fifo->shr->has_event)
     {
       found = session_node_lookup_fifo_event (ss->tx_fifo, e);
       s = format (s, " session node event: %s\n",
@@ -145,8 +144,12 @@ format_session (u8 * s, va_list * args)
     }
   else if (ss->session_state == SESSION_STATE_CONNECTING)
     {
-      s = format (s, "%-40U%v", format_transport_half_open_connection,
-                 tp, ss->connection_index, ss->thread_index, str);
+      if (ss->flags & SESSION_F_HALF_OPEN)
+       s = format (s, "%U%v", format_transport_half_open_connection, tp,
+                   ss->connection_index, ss->thread_index, verbose, str);
+      else
+       s = format (s, "%U", format_transport_connection, tp,
+                   ss->connection_index, ss->thread_index, verbose);
     }
   else
     {
@@ -330,21 +333,22 @@ session_cli_show_all_sessions (vlib_main_t * vm, int verbose)
        }
 
       if (verbose == 1)
-       vlib_cli_output (vm, "%s%-50s%-15s%-10s%-10s",
+       vlib_cli_output (vm, "%s%-" SESSION_CLI_ID_LEN "s%-"
+                        SESSION_CLI_STATE_LEN "s%-10s%-10s",
                         thread_index ? "\n" : "",
                         "Connection", "State", "Rx-f", "Tx-f");
 
       n_closed = 0;
 
       /* *INDENT-OFF* */
-      pool_foreach(s, pool, ({
+      pool_foreach (s, pool)  {
         if (s->session_state >= SESSION_STATE_TRANSPORT_DELETED)
           {
             n_closed += 1;
             continue;
           }
         vlib_cli_output (vm, "%U", format_session, s, verbose);
-      }));
+      }
       /* *INDENT-ON* */
 
       if (!n_closed)
@@ -451,9 +455,9 @@ session_cli_show_events_thread (vlib_main_t * vm, u32 thread_index)
 
   vlib_cli_output (vm, "Thread %d:\n", thread_index);
   vlib_cli_output (vm, " evt elements alloc: %u",
-                  pool_elts (wrk->event_elts));
+                  clib_llist_elts (wrk->event_elts));
   vlib_cli_output (vm, " ctrl evt elt data alloc: %d",
-                  pool_elts (wrk->ctrl_evts_data));
+                  clib_llist_elts (wrk->ctrl_evts_data));
 }
 
 static void
@@ -598,7 +602,7 @@ show_session_command_fn (vlib_main_t * vm, unformat_input_t * input,
       u8 *str = format (0, "%U", format_session, s, 3);
       if (do_elog && s->session_state != SESSION_STATE_LISTENING)
        {
-         elog_main_t *em = &vm->elog_main;
+         elog_main_t *em = &vlib_global_main.elog_main;
          transport_connection_t *tc;
          f64 dt;
 
@@ -618,9 +622,11 @@ show_session_command_fn (vlib_main_t * vm, unformat_input_t * input,
   if (do_listeners)
     {
       sst = session_type_from_proto_and_ip (transport_proto, 1);
-      vlib_cli_output (vm, "%-50s%-24s", "Listener", "App");
+      vlib_cli_output (vm, "%-" SESSION_CLI_ID_LEN "s%-24s", "Listener",
+                      "App");
+
       /* *INDENT-OFF* */
-      pool_foreach (s, smm->wrk[0].sessions, ({
+      pool_foreach (s, smm->wrk[0].sessions)  {
        if (s->session_state != SESSION_STATE_LISTENING
            || s->session_type != sst)
          continue;
@@ -628,7 +634,7 @@ show_session_command_fn (vlib_main_t * vm, unformat_input_t * input,
        app_name = application_name_from_index (app_wrk->app_index);
        vlib_cli_output (vm, "%U%-25v%", format_session, s, 0,
                         app_name);
-      }));
+      }
       /* *INDENT-ON* */
       goto done;
     }
@@ -725,9 +731,9 @@ clear_session_command_fn (vlib_main_t * vm, unformat_input_t * input,
       /* *INDENT-OFF* */
       vec_foreach (wrk, smm->wrk)
        {
-         pool_foreach(session, wrk->sessions, ({
+         pool_foreach (session, wrk->sessions)  {
            clear_session (session);
-         }));
+         }
        };
       /* *INDENT-ON* */
     }
@@ -880,84 +886,6 @@ VLIB_CLI_COMMAND (session_enable_disable_command, static) =
 };
 /* *INDENT-ON* */
 
-#if SESSION_DEBUG
-
-static clib_error_t *
-show_session_dbg_clock_cycles_fn (vlib_main_t * vm, unformat_input_t * input,
-                                 vlib_cli_command_t * cmd)
-{
-  u32 thread;
-
-  if (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
-    return clib_error_return (0, "unknown input `%U'", format_unformat_error,
-                             input);
-
-  for (thread = 0; thread < vec_len (session_dbg_main.wrk); thread++)
-    {
-      vlib_cli_output (vm, "Threads %u:\n", thread);
-      session_dbg_evts_t *sdm = &session_dbg_main.wrk[thread];
-
-#define _(sym, disp, type, str)                                                                         \
-  if(disp)                                                             \
-    {                                                                  \
-      if (!type)                                                       \
-       vlib_cli_output (vm, "\t %25s : %12lu ",                        \
-                        str, sdm->sess_dbg_evt_type[SESS_Q_##sym].u64);\
-      else                                                             \
-       vlib_cli_output (vm, "\t %25s : %12.3f ",                       \
-                        str, sdm->sess_dbg_evt_type[SESS_Q_##sym].f64);\
-    }
-
-      foreach_session_events
-#undef _
-    }
-  return 0;
-}
-
-
-/* *INDENT-OFF* */
-VLIB_CLI_COMMAND (show_session_dbg_clock_cycles_command, static) =
-{
-  .path = "show session dbg clock_cycles",
-  .short_help = "show session dbg clock_cycles",
-  .function = show_session_dbg_clock_cycles_fn,
-};
-/* *INDENT-ON* */
-
-
-static clib_error_t *
-clear_session_dbg_clock_cycles_fn (vlib_main_t * vm, unformat_input_t * input,
-                                  vlib_cli_command_t * cmd)
-{
-  session_dbg_evts_t *sdb;
-  u32 thread;
-
-  if (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
-    return clib_error_return (0, "unknown input `%U'", format_unformat_error,
-                             input);
-
-  for (thread = 0; thread < vec_len (session_dbg_main.wrk); thread++)
-    {
-      sdb = &session_dbg_main.wrk[thread];
-      clib_memset (sdb, 0, sizeof (session_dbg_evts_t));
-      sdb->last_time = vlib_time_now (vlib_mains[thread]);
-    }
-
-  return 0;
-}
-
-
-/* *INDENT-OFF* */
-VLIB_CLI_COMMAND (clear_session_clock_cycles_command, static) =
-{
-  .path = "clear session dbg clock_cycles",
-  .short_help = "clear session dbg clock_cycles",
-  .function = clear_session_dbg_clock_cycles_fn,
-};
-#endif /* #if SESSION_DEBUG */
-
-/* *INDENT-ON* */
-
 /*
  * fd.io coding-style-patch-verification: ON
  *