|
FD.io VPP
v21.06-3-gbb25fbf28
Vector Packet Processing
|
Go to the documentation of this file.
25 #define ECHO_CLIENT_DBG (0)
26 #define DBG(_fmt, _args...) \
27 if (ECHO_CLIENT_DBG) \
28 clib_warning (_fmt, ##_args)
52 int test_buf_len, test_buf_offset,
rv;
55 test_buf_len =
vec_len (test_data);
57 test_buf_offset = s->
bytes_sent % test_buf_len;
58 bytes_this_chunk =
clib_min (test_buf_len - test_buf_offset,
95 sizeof (ip46_address_t));
99 sizeof (ip46_address_t));
108 bytes_this_chunk =
clib_min (bytes_this_chunk, max_enqueue);
110 bytes_this_chunk, 0);
126 .format =
"tx-enq: xfer %d bytes, sent %u remain %u",
127 .format_args =
"i4i4i4",
171 .format =
"rx-deq: %d bytes",
180 ed->data[0] = n_read;
185 for (
i = 0;
i < n_read;
i++)
190 clib_warning (
"read %d error at byte %lld, 0x%x not 0x%x",
198 ASSERT (n_read <= s->bytes_to_receive);
213 u32 *connection_indices;
214 u32 *connections_this_batch;
215 u32 nconnections_this_batch;
218 connections_this_batch =
222 ((
vec_len (connection_indices) == 0)
223 &&
vec_len (connections_this_batch) == 0))
229 nconnections_this_batch =
232 ASSERT (nconnections_this_batch > 0);
233 vec_validate (connections_this_batch, nconnections_this_batch - 1);
235 connection_indices +
vec_len (connection_indices)
236 - nconnections_this_batch,
237 nconnections_this_batch *
sizeof (
u32));
238 _vec_len (connection_indices) -= nconnections_this_batch;
257 for (
i = 0;
i <
vec_len (connections_this_batch);
i++)
307 connections_this_batch;
315 .name =
"echo-clients",
317 .state = VLIB_NODE_STATE_DISABLED,
337 for (
i = 0;
i < num_threads;
i++)
371 for (stream_n = 0; stream_n < ecm->
quic_streams; stream_n++)
375 a->api_context = -1 - api_context;
378 DBG (
"QUIC opening stream %d", stream_n);
381 clib_error (
"Stream session %d opening failed: %d", stream_n,
rv);
384 DBG (
"QUIC stream %d connected", stream_n);
420 DBG (
"STREAM Connection callback %d", api_context);
438 session_index = session - ecm->
sessions;
442 session->
data.rx_fifo->shr->client_session_index = session_index;
444 session->
data.tx_fifo->shr->client_session_index = session_index;
453 sizeof (session->
data.transport));
454 session->
data.is_dgram = 1;
505 session_index = session - ecm->
sessions;
509 session->
data.rx_fifo->shr->client_session_index = session_index;
511 session->
data.tx_fifo->shr->client_session_index = session_index;
520 sizeof (session->
data.transport));
521 session->
data.is_dgram = 1;
624 u32 prealloc_fifos, segment_size = 256 << 20;
633 a->api_client_index = ~0;
634 a->name =
format (0,
"echo_client");
661 a->namespace_id = appns_id;
688 da->api_client_index = ~0;
724 return proto == TRANSPORT_PROTO_TLS ||
proto == TRANSPORT_PROTO_DTLS ||
725 proto == TRANSPORT_PROTO_QUIC;
741 for (
i = 0;
i < n_clients;
i++)
755 if (
a->sep_ext.ext_cfg)
774 #define ec_cli_output(_fmt, _args...) \
775 if (!ecm->no_output) \
776 vlib_cli_output(vm, _fmt, ##_args)
784 u64 tmp, total_bytes, appns_flags = 0, appns_secret = 0;
786 f64 test_timeout = 20.0, syn_timeout = 20.0, delta;
787 char *default_uri =
"tcp://6.0.1.1/1234";
788 u8 *appns_id = 0, barrier_acq_needed = 0;
789 int preallocate_sessions = 0,
i,
rv;
790 uword *event_data = 0, event_type;
791 f64 time_before_connects;
819 barrier_acq_needed = 1;
828 VLIB_NODE_STATE_POLLING);
839 else if (
unformat (input,
"nclients %d", &n_clients))
849 else if (
unformat (input,
"test-timeout %f", &test_timeout))
851 else if (
unformat (input,
"syn-timeout %f", &syn_timeout))
853 else if (
unformat (input,
"no-return"))
857 else if (
unformat (input,
"private-segment-count %d",
860 else if (
unformat (input,
"private-segment-size %U",
863 if (
tmp >= 0x100000000ULL)
866 0,
"private segment size %lld (%llu) too large",
tmp,
tmp);
871 else if (
unformat (input,
"preallocate-fifos"))
873 else if (
unformat (input,
"preallocate-sessions"))
874 preallocate_sessions = 1;
878 else if (
unformat (input,
"appns %_%v%_", &appns_id))
880 else if (
unformat (input,
"all-scope"))
881 appns_flags |= (APP_OPTIONS_FLAGS_USE_GLOBAL_SCOPE
882 | APP_OPTIONS_FLAGS_USE_LOCAL_SCOPE);
883 else if (
unformat (input,
"local-scope"))
884 appns_flags = APP_OPTIONS_FLAGS_USE_LOCAL_SCOPE;
885 else if (
unformat (input,
"global-scope"))
886 appns_flags = APP_OPTIONS_FLAGS_USE_GLOBAL_SCOPE;
887 else if (
unformat (input,
"secret %lu", &appns_secret))
889 else if (
unformat (input,
"no-output"))
924 clib_warning (
"No uri provided. Using default: %s", default_uri);
934 ecm->
is_dgram = (sep.transport_proto == TRANSPORT_PROTO_UDP);
936 #if ECHO_CLIENT_PTHREAD
959 VLIB_NODE_STATE_POLLING);
961 if (preallocate_sessions)
986 ec_cli_output (
"%d three-way handshakes in %.2f seconds %.2f/s",
987 n_clients, delta, ((
f64) n_clients) / delta);
1028 transfer_type = ecm->
no_return ?
"half-duplex" :
"full-duplex";
1029 ec_cli_output (
"%lld bytes (%lld mbytes, %lld gbytes) in %.2f seconds",
1030 total_bytes, total_bytes / (1ULL << 20),
1031 total_bytes / (1ULL << 30), delta);
1035 (((
f64) total_bytes * 8.0) / delta / 1e9),
1074 if (barrier_acq_needed)
1083 .path =
"test echo clients",
1084 .short_help =
"test echo clients [nclients %d][[m|g]bytes <bytes>]"
1085 "[test-timeout <time>][syn-timeout <time>][no-return][fifo-size <size>]"
1086 "[private-segment-count <count>][private-segment-size <bytes>[m|g]]"
1087 "[preallocate-fifos][preallocate-sessions][client-batch <batch-size>]"
1088 "[uri <tcp://ip/port>][test-bytes][no-output]",
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
static void clib_spinlock_init(clib_spinlock_t *p)
static u8 svm_fifo_set_event(svm_fifo_t *f)
Set fifo event flag.
static void echo_clients_session_disconnect_callback(session_t *s)
static u32 vlib_num_workers()
u32 ** connection_index_by_thread
void vlib_worker_thread_barrier_release(vlib_main_t *vm)
u32 private_segment_count
Number of private fifo segs.
enum session_error_ session_error_t
int vnet_connect(vnet_connect_args_t *a)
int echo_clients_start_tx_pthread(echo_client_main_t *ecm)
Start a transmit thread.
vlib_main_t vlib_node_runtime_t vlib_frame_t * frame
#define ec_cli_output(_fmt, _args...)
@ APP_OPTIONS_RX_FIFO_SIZE
u32 private_segment_size
size of private fifo segs
static void * echo_client_thread_fn(void *arg)
#define clib_memcpy(d, s, n)
u32 no_copy
Don't memcpy data to tx fifo.
u32 connections_per_batch
Connections to rx/tx at once.
static_always_inline void clib_spinlock_lock_if_init(clib_spinlock_t *p)
static void vlib_node_set_state(vlib_main_t *vm, u32 node_index, vlib_node_state_t new_state)
Set node dispatch state.
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
static int app_recv_dgram(app_session_t *s, u8 *buf, u32 len)
struct session_dgram_header_ session_dgram_hdr_t
static int echo_clients_session_connected_callback(u32 app_index, u32 api_context, session_t *s, session_error_t err)
static int app_send_stream(app_session_t *s, u8 *data, u32 len, u8 noblock)
static void clib_mem_free(void *p)
vlib_main_t vlib_node_runtime_t * node
#define clib_error_return(e, args...)
struct _session_endpoint_cfg session_endpoint_cfg_t
ip46_address_t rmt_ip
remote ip
static vlib_cli_command_t echo_clients_command
(constructor) VLIB_CLI_COMMAND (echo_clients_command)
static clib_error_t * echo_clients_attach(u8 *appns_id, u64 appns_flags, u64 appns_secret)
int vnet_application_detach(vnet_app_detach_args_t *a)
Detach application from vpp.
u8 thread_index
Index of the thread that allocated the session.
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
static void signal_evt_to_cli_i(int *code)
u32 cli_node_index
cli process node index
#define vec_delete(V, N, M)
Delete N elements starting at element M.
u32 ** quic_session_index_by_thread
vlib_node_runtime_t node_runtime
static int echo_clients_init(vlib_main_t *vm)
@ APP_OPTIONS_SEGMENT_SIZE
static int quic_echo_clients_qsession_connected_callback(u32 app_index, u32 api_context, session_t *s, session_error_t err)
struct _vnet_app_detach_args_t vnet_app_detach_args_t
#define clib_error_report(e)
struct _transport_connection transport_connection_t
static void vlib_process_signal_event(vlib_main_t *vm, uword node_index, uword type_opaque, uword data)
static_always_inline void * clib_memcpy_fast(void *restrict dst, const void *restrict src, size_t n)
@ APP_OPTIONS_NAMESPACE_SECRET
u8 ** rx_buf
intermediate rx buffers
u16 lcl_port
local port (network order)
u8 prealloc_fifos
Request fifo preallocation.
struct _svm_fifo svm_fifo_t
vlib_node_registration_t echo_clients_node
(constructor) VLIB_REGISTER_NODE (echo_clients_node)
#define SESSION_ENDPOINT_CFG_NULL
static uword vlib_process_get_events(vlib_main_t *vm, uword **data_vector)
Return the first event type which has occurred and a vector of per-event data of that type,...
#define pool_init_fixed(pool, max_elts)
initialize a fixed-size, preallocated pool
u8 * connect_uri
URI for slave's connect.
svm_fifo_t * rx_fifo
Pointers to rx/tx buffers.
clib_spinlock_t sessions_lock
@ SESSION_IO_EVT_BUILTIN_RX
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
static void session_endpoint_alloc_ext_cfg(session_endpoint_cfg_t *sep_ext, transport_endpt_ext_cfg_type_t type)
#define ELOG_TYPE_DECLARE(f)
u32 ckpair_index
Cert key pair for tls/quic.
struct _vnet_disconnect_args_t vnet_disconnect_args_t
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
transport_connection_t * session_get_transport(session_t *s)
static uword echo_client_node_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
void svm_fifo_enqueue_nocopy(svm_fifo_t *f, u32 len)
Advance tail.
static const char test_srv_key_rsa[]
static svm_msg_q_t * session_main_get_vpp_event_queue(u32 thread_index)
int vnet_app_del_cert_key_pair(u32 index)
#define vlib_worker_thread_barrier_sync(X)
static_always_inline uword vlib_get_thread_index(void)
int session_send_io_evt_to_thread_custom(void *data, u32 thread_index, session_evt_type_t evt_type)
vlib_global_main_t vlib_global_main
static void receive_data_chunk(echo_client_main_t *ecm, eclient_session_t *s)
ip46_address_t lcl_ip
local ip
if(node->flags &VLIB_NODE_FLAG_TRACE) vnet_interface_output_trace(vm
static int app_recv_stream(app_session_t *s, u8 *buf, u32 len)
static u8 vlib_thread_is_main_w_barrier(void)
pthread_t client_thread_handle
sll srl srl sll sra u16x4 i
int svm_fifo_dequeue_drop(svm_fifo_t *f, u32 len)
Dequeue and drop bytes from fifo.
static void clib_spinlock_free(clib_spinlock_t *p)
static int quic_echo_clients_session_connected_callback(u32 app_index, u32 api_context, session_t *s, session_error_t err)
static session_handle_t session_handle(session_t *s)
int svm_fifo_enqueue(svm_fifo_t *f, u32 len, const u8 *src)
Enqueue data to fifo.
#define pool_get(P, E)
Allocate an object E from a pool P (unspecified alignment).
static session_t * session_get_from_handle_if_valid(session_handle_t handle)
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment)
#define VLIB_CLI_COMMAND(x,...)
void(* session_reset_callback)(session_t *s)
Notify app that session was reset.
@ APP_OPTIONS_ACCEPT_COOKIE
clib_error_t * echo_clients_main_init(vlib_main_t *vm)
int vnet_app_add_cert_key_pair(vnet_app_add_cert_key_pair_args_t *a)
static int app_send_dgram(app_session_t *s, u8 *data, u32 len, u8 noblock)
struct _vlib_node_registration vlib_node_registration_t
int vnet_disconnect_session(vnet_disconnect_args_t *a)
u32 tls_engine
TLS engine mbedtls/openssl.
u8 * format_session(u8 *s, va_list *args)
Format stream session as per the following format.
void echo_clients_session_disconnect(session_t *s)
struct _vnet_app_add_cert_key_pair_args_ vnet_app_add_cert_key_pair_args_t
u32 expected_connections
Number of clients/connections.
@ APP_OPTIONS_PREALLOC_FIFO_PAIRS
session_handle_t listener_handle
Parent listener session index if the result of an accept.
#define clib_atomic_fetch_add(a, b)
int vnet_application_attach(vnet_app_attach_args_t *a)
Attach application to vpp.
eclient_session_t * sessions
Session pool, shared.
u64 bytes_to_send
Bytes to send.
#define vec_free(V)
Free vector's memory (no header).
u32 node_index
Node index.
@ APP_OPTIONS_TX_FIFO_SIZE
static int echo_client_transport_needs_crypto(transport_proto_t proto)
u32 quic_streams
QUIC streams per connection.
int echo_client_add_segment_callback(u32 client_index, u64 segment_handle)
static u32 svm_fifo_max_enqueue_prod(svm_fifo_t *f)
Maximum number of bytes that can be enqueued into fifo.
static const char test_srv_crt_rsa[]
@ APP_OPTIONS_ADD_SEGMENT_SIZE
static f64 vlib_process_wait_for_event_or_clock(vlib_main_t *vm, f64 dt)
Suspend a cooperative multi-tasking thread Waits for an event, or for the indicated number of seconds...
description fragment has unexpected format
clib_error_t * echo_clients_connect(vlib_main_t *vm, u32 n_clients)
static uword vlib_process_suspend(vlib_main_t *vm, f64 dt)
Suspend a vlib cooperative multi-tasking thread for a period of time.
static int echo_clients_session_create_callback(session_t *s)
#define VLIB_INIT_FUNCTION(x)
static struct option options[]
enum _transport_proto transport_proto_t
static vlib_process_t * vlib_get_current_process(vlib_main_t *vm)
void vl_api_rpc_call_main_thread(void *fp, u8 *data, u32 data_length)
volatile int run_test
Signal start of test.
static const u32 test_srv_crt_rsa_len
static vlib_main_t * vlib_get_main_by_index(u32 thread_index)
struct _vnet_connect_args vnet_connect_args_t
static session_cb_vft_t echo_clients
int parse_uri(char *uri, session_endpoint_cfg_t *sep)
#define SESSION_INVALID_HANDLE
int(* session_connected_callback)(u32 app_wrk_index, u32 opaque, session_t *s, session_error_t code)
Connection request callback.
static int echo_clients_detach()
static void signal_evt_to_cli(int code)
static clib_error_t * echo_clients_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
@ TRANSPORT_SERVICE_CL
connectionless service
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
u32 app_index
app index after attach
u8 * connect_test_data
Pre-computed test data.
static transport_service_type_t session_transport_service_type(session_t *s)
clib_error_t *() vlib_init_function_t(struct vlib_main_t *vm)
#define clib_error(format, args...)
#define pool_free(p)
Free a pool.
#define clib_warning(format, args...)
static void cleanup(void)
u16 rmt_port
remote port (network order)
volatile u32 ready_connections
static f64 vlib_time_now(vlib_main_t *vm)
struct _vnet_app_attach_args_t vnet_app_attach_args_t
@ APP_OPTIONS_PCT_FIRST_ALLOC
static void echo_clients_session_reset_callback(session_t *s)
static_always_inline void clib_spinlock_unlock_if_init(clib_spinlock_t *p)
svm_msg_q_t ** vpp_event_queue
vlib_node_registration_t session_queue_node
(constructor) VLIB_REGISTER_NODE (session_queue_node)
static int echo_clients_rx_callback(session_t *s)
static void send_data_chunk(echo_client_main_t *ecm, eclient_session_t *s)
static vlib_thread_main_t * vlib_get_thread_main()
static u32 svm_fifo_max_dequeue_cons(svm_fifo_t *f)
Fifo max bytes to dequeue optimized for consumer.
int session_send_io_evt_to_thread(svm_fifo_t *f, session_evt_type_t evt_type)
volatile u8 session_state
State in session layer state machine.
@ TRANSPORT_ENDPT_EXT_CFG_CRYPTO
u32 ** connections_this_batch_by_thread
active connection batch
echo_client_main_t echo_client_main
@ APP_OPTIONS_PRIVATE_SEGMENT_COUNT
clib_error_t * vnet_session_enable_disable(vlib_main_t *vm, u8 is_en)
u8 is_ip4
set if uses ip4 networking
#define DBG(_fmt, _args...)
static const u32 test_srv_key_rsa_len
#define VLIB_REGISTER_NODE(x,...)