host stack: update stale copyright
[vpp.git] / src / vnet / session-apps / echo_client.c
index c39f787..fb7de48 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * echo_client.c - vpp built-in echo client code
  *
- * Copyright (c) 2017 by Cisco and/or its affiliates.
+ * Copyright (c) 2017-2019 by Cisco and/or its affiliates.
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at:
@@ -62,8 +62,9 @@ send_data_chunk (echo_client_main_t * ecm, eclient_session_t * s)
          svm_fifo_t *f = s->data.tx_fifo;
          rv = clib_min (svm_fifo_max_enqueue (f), bytes_this_chunk);
          svm_fifo_enqueue_nocopy (f, rv);
-         session_send_io_evt_to_thread_custom (f, s->thread_index,
-                                               FIFO_EVENT_APP_TX);
+         session_send_io_evt_to_thread_custom (&f->master_session_index,
+                                               s->thread_index,
+                                               SESSION_IO_EVT_TX);
        }
       else
        rv = app_send_stream (&s->data, test_data + test_buf_offset,
@@ -95,8 +96,9 @@ send_data_chunk (echo_client_main_t * ecm, eclient_session_t * s)
          hdr.lcl_port = at->lcl_port;
          svm_fifo_enqueue_nowait (f, sizeof (hdr), (u8 *) & hdr);
          svm_fifo_enqueue_nocopy (f, rv);
-         session_send_io_evt_to_thread_custom (f, s->thread_index,
-                                               FIFO_EVENT_APP_TX);
+         session_send_io_evt_to_thread_custom (&f->master_session_index,
+                                               s->thread_index,
+                                               SESSION_IO_EVT_TX);
        }
       else
        rv = app_send_dgram (&s->data, test_data + test_buf_offset,
@@ -380,7 +382,7 @@ echo_clients_session_connected_callback (u32 app_index, u32 api_context,
 
   if (!ecm->vpp_event_queue[thread_index])
     ecm->vpp_event_queue[thread_index] =
-      session_manager_get_vpp_event_queue (thread_index);
+      session_main_get_vpp_event_queue (thread_index);
 
   /*
    * Setup session
@@ -428,7 +430,7 @@ echo_clients_session_reset_callback (session_t * s)
   vnet_disconnect_args_t _a = { 0 }, *a = &_a;
 
   if (s->session_state == SESSION_STATE_READY)
-    clib_warning ("Reset active connection %U", format_stream_session, s, 2);
+    clib_warning ("Reset active connection %U", format_session, s, 2);
 
   a->handle = session_handle (s);
   a->app_index = ecm->app_index;
@@ -481,7 +483,7 @@ echo_clients_rx_callback (session_t * s)
   if (svm_fifo_max_dequeue (s->rx_fifo))
     {
       if (svm_fifo_set_event (s->rx_fifo))
-       session_send_io_evt_to_thread (s->rx_fifo, FIFO_EVENT_BUILTIN_RX);
+       session_send_io_evt_to_thread (s->rx_fifo, SESSION_IO_EVT_BUILTIN_RX);
     }
   return 0;
 }
@@ -511,7 +513,7 @@ echo_clients_attach (u8 * appns_id, u64 appns_flags, u64 appns_secret)
   echo_client_main_t *ecm = &echo_client_main;
   vnet_app_attach_args_t _a, *a = &_a;
   u64 options[16];
-  clib_error_t *error = 0;
+  int rv;
 
   clib_memset (a, 0, sizeof (*a));
   clib_memset (options, 0, sizeof (options));
@@ -541,8 +543,8 @@ echo_clients_attach (u8 * appns_id, u64 appns_flags, u64 appns_secret)
   a->options = options;
   a->namespace_id = appns_id;
 
-  if ((error = vnet_application_attach (a)))
-    return error;
+  if ((rv = vnet_application_attach (a)))
+    return clib_error_return (0, "attach returned %d", rv);
 
   ecm->app_index = a->app_index;
   return 0;
@@ -592,8 +594,7 @@ echo_clients_connect (vlib_main_t * vm, u32 n_clients)
 {
   echo_client_main_t *ecm = &echo_client_main;
   vnet_connect_args_t _a, *a = &_a;
-  clib_error_t *error = 0;
-  int i;
+  int i, rv;
 
   clib_memset (a, 0, sizeof (*a));
   for (i = 0; i < n_clients; i++)
@@ -602,17 +603,15 @@ echo_clients_connect (vlib_main_t * vm, u32 n_clients)
       a->api_context = i;
       a->app_index = ecm->app_index;
 
-      if ((error = vnet_connect_uri (a)))
-       return error;
+      if ((rv = vnet_connect_uri (a)))
+       return clib_error_return (0, "connect returned: %d", rv);
 
       /* Crude pacing for call setups  */
-      if ((i % 4) == 0)
-       vlib_process_suspend (vm, 10e-6);
+      if ((i % 16) == 0)
+       vlib_process_suspend (vm, 100e-6);
       ASSERT (i + 1 >= ecm->ready_connections);
-      while (i + 1 - ecm->ready_connections > 1000)
-       {
-         vlib_process_suspend (vm, 100e-6);
-       }
+      while (i + 1 - ecm->ready_connections > 128)
+       vlib_process_suspend (vm, 1e-3);
     }
   return 0;
 }