session: api to add new transport types
[vpp.git] / src / plugins / hs_apps / sapi / vpp_echo_common.c
index e7829f3..60ea5a1 100644 (file)
@@ -257,6 +257,20 @@ echo_unformat_timing_event (unformat_input_t * input, va_list * args)
   return 1;
 }
 
+u8 *
+echo_format_bytes_per_sec (u8 * s, va_list * args)
+{
+  f64 bps = va_arg (*args, f64) * 8;
+  if (bps > 1e9)
+    return format (s, "%.3f Gb/s", bps / 1e9);
+  else if (bps > 1e6)
+    return format (s, "%.3f Mb/s", bps / 1e6);
+  else if (bps > 1e3)
+    return format (s, "%.3f Kb/s", bps / 1e3);
+  else
+    return format (s, "%.3f b/s", bps);
+}
+
 u8 *
 echo_format_timing_event (u8 * s, va_list * args)
 {
@@ -295,10 +309,6 @@ unformat_transport_proto (unformat_input_t * input, va_list * args)
     *proto = TRANSPORT_PROTO_UDP;
   else if (unformat (input, "UDP"))
     *proto = TRANSPORT_PROTO_UDP;
-  else if (unformat (input, "sctp"))
-    *proto = TRANSPORT_PROTO_SCTP;
-  else if (unformat (input, "SCTP"))
-    *proto = TRANSPORT_PROTO_SCTP;
   else if (unformat (input, "tls"))
     *proto = TRANSPORT_PROTO_TLS;
   else if (unformat (input, "TLS"))
@@ -324,9 +334,6 @@ format_transport_proto (u8 * s, va_list * args)
     case TRANSPORT_PROTO_UDP:
       s = format (s, "UDP");
       break;
-    case TRANSPORT_PROTO_SCTP:
-      s = format (s, "SCTP");
-      break;
     case TRANSPORT_PROTO_NONE:
       s = format (s, "NONE");
       break;
@@ -578,28 +585,6 @@ echo_get_session_from_handle (echo_main_t * em, u64 handle)
   return pool_elt_at_index (em->sessions, p[0]);
 }
 
-int
-wait_for_segment_allocation (u64 segment_handle)
-{
-  echo_main_t *em = &echo_main;
-  f64 timeout;
-  timeout = clib_time_now (&em->clib_time) + TIMEOUT;
-  uword *segment_present;
-  ECHO_LOG (3, "Waiting for segment 0x%lx...", segment_handle);
-  while (clib_time_now (&em->clib_time) < timeout)
-    {
-      clib_spinlock_lock (&em->segment_handles_lock);
-      segment_present = hash_get (em->shared_segment_handles, segment_handle);
-      clib_spinlock_unlock (&em->segment_handles_lock);
-      if (segment_present != 0)
-       return 0;
-      if (em->time_to_stop == 1)
-       return 0;
-    }
-  ECHO_LOG (2, "timeout wait_for_segment_allocation (0x%lx)", segment_handle);
-  return -1;
-}
-
 int
 wait_for_state_change (echo_main_t * em, connection_state_t state,
                       f64 timeout)