22 #define _(sym, str) str, 36 u8 *
a = va_arg (*args,
u8 *);
37 return format (s,
"%d.%d.%d.%d", a[0], a[1], a[2], a[3]);
44 u32 i, i_max_n_zero, max_n_zeros, i_first_zero, n_zeros, last_double_colon;
48 i_first_zero = i_max_n_zero;
53 if (is_zero && i_first_zero >= ARRAY_LEN (a->
as_u16))
59 if ((!is_zero && n_zeros > max_n_zeros)
62 i_max_n_zero = i_first_zero;
63 max_n_zeros = n_zeros;
69 last_double_colon = 0;
72 if (i == i_max_n_zero && max_n_zeros > 1)
76 last_double_colon = 1;
81 (last_double_colon || i == 0) ?
"" :
":",
82 clib_net_to_host_u16 (a->
as_u16[i]));
83 last_double_colon = 0;
94 ip46_address_t *ip46 = va_arg (*args, ip46_address_t *);
120 u64 *
a = va_arg (*args,
u64 *);
121 if (
unformat (input,
"%lluGb", &_a))
123 else if (
unformat (input,
"%lluG", &_a))
125 else if (
unformat (input,
"%lluMb", &_a))
127 else if (
unformat (input,
"%lluM", &_a))
129 else if (
unformat (input,
"%lluKb", &_a))
131 else if (
unformat (input,
"%lluK", &_a))
133 else if (
unformat (input,
"%llu", a))
144 i32 error = va_arg (*args,
u32);
150 s =
format (s,
"%s", p[0]);
152 s =
format (s,
"%d", error);
162 #define _(n,v,s) hash_set (em->error_string_by_error_number, -v, s); 174 return format (s,
"STATE_START");
176 return format (s,
"STATE_ATTACHED");
178 return format (s,
"STATE_LISTEN");
180 return format (s,
"STATE_READY");
182 return format (s,
"STATE_DATA_DONE");
184 return format (s,
"STATE_DISCONNECTED");
186 return format (s,
"STATE_DETACHED");
188 return format (s,
"unknown state");
194 u8 *
a = va_arg (*args,
u8 *);
209 u8 *
a = va_arg (*args,
u8 *);
212 else if (
unformat (input,
"qconnected"))
214 else if (
unformat (input,
"qconnect"))
216 else if (
unformat (input,
"sconnected"))
218 else if (
unformat (input,
"sconnect"))
220 else if (
unformat (input,
"lastbyte"))
232 u32 timing_event = va_arg (*args,
u32);
234 return format (s,
"start");
236 return format (s,
"qconnect");
238 return format (s,
"qconnected");
240 return format (s,
"sconnect");
242 return format (s,
"sconnected");
244 return format (s,
"lastbyte");
246 return format (s,
"exit");
248 return format (s,
"unknown timing event");
256 *proto = TRANSPORT_PROTO_TCP;
258 *proto = TRANSPORT_PROTO_TCP;
260 *proto = TRANSPORT_PROTO_UDPC;
262 *proto = TRANSPORT_PROTO_UDPC;
264 *proto = TRANSPORT_PROTO_UDP;
266 *proto = TRANSPORT_PROTO_UDP;
268 *proto = TRANSPORT_PROTO_SCTP;
270 *proto = TRANSPORT_PROTO_SCTP;
272 *proto = TRANSPORT_PROTO_TLS;
274 *proto = TRANSPORT_PROTO_TLS;
276 *proto = TRANSPORT_PROTO_QUIC;
278 *proto = TRANSPORT_PROTO_QUIC;
287 u32 transport_proto = va_arg (*args,
u32);
288 switch (transport_proto)
290 case TRANSPORT_PROTO_TCP:
293 case TRANSPORT_PROTO_UDP:
296 case TRANSPORT_PROTO_SCTP:
299 case TRANSPORT_PROTO_NONE:
302 case TRANSPORT_PROTO_TLS:
305 case TRANSPORT_PROTO_UDPC:
308 case TRANSPORT_PROTO_QUIC:
312 s =
format (s,
"UNKNOWN");
321 u8 *result = va_arg (*args,
u8 *);
324 if (!
unformat (input,
"%d.%d.%d.%d", &a[0], &a[1], &a[2], &a[3]))
327 if (a[0] >= 256 || a[1] >= 256 || a[2] >= 256 || a[3] >= 256)
343 uword hex_quad, n_hex_quads, hex_digit, n_hex_digits;
344 uword c, n_colon, double_colon_index;
346 n_hex_quads = hex_quad = n_hex_digits = n_colon = 0;
347 double_colon_index =
ARRAY_LEN (hex_quads);
351 if (c >=
'0' && c <=
'9')
353 else if (c >=
'a' && c <=
'f')
354 hex_digit = c + 10 -
'a';
355 else if (c >=
'A' && c <=
'F')
356 hex_digit = c + 10 -
'A';
357 else if (c ==
':' && n_colon < 2)
366 if (n_hex_quads >=
ARRAY_LEN (hex_quads))
371 hex_quad = (hex_quad << 4) | hex_digit;
374 if (n_hex_digits >= 4)
385 if (double_colon_index <
ARRAY_LEN (hex_quads))
387 double_colon_index = n_hex_quads;
390 if (n_colon > 0 && n_hex_digits > 0)
392 hex_quads[n_hex_quads++] = hex_quad;
398 if (n_hex_digits > 0)
399 hex_quads[n_hex_quads++] = hex_quad;
405 if (double_colon_index <
ARRAY_LEN (hex_quads))
409 for (i = n_hex_quads - 1; i >= (signed) double_colon_index; i--)
410 hex_quads[n_zero + i] = hex_quads[i];
412 for (i = 0; i < n_zero; i++)
413 hex_quads[double_colon_index + i] = 0;
422 for (i = 0; i <
ARRAY_LEN (hex_quads); i++)
423 result->
as_u16[i] = clib_host_to_net_u16 (hex_quads[i]);
490 ECHO_FAIL (ECHO_FAIL_GET_SESSION_FROM_HANDLE,
491 "unknown handle 0x%lx", handle);
503 uword *segment_present;
504 ECHO_LOG (1,
"Waiting for segment 0x%lx...", segment_handle);
510 if (segment_present != 0)
515 ECHO_LOG (1,
"timeout wait_for_segment_allocation (0x%lx)", segment_handle);
526 if (em->
state == state)
551 ECHO_LOG (0,
"Session 0x%x done in %.6fs RX[%.4f] TX[%.4f] Gbit/s\n",
uword unformat_data(unformat_input_t *input, va_list *args)
#define hash_set(h, key, value)
void * svm_msg_q_msg_data(svm_msg_q_t *mq, svm_msg_q_msg_t *msg)
Get data for message in queue.
static u8 svm_msg_q_ring_is_full(svm_msg_q_t *mq, u32 ring_index)
static_always_inline void clib_spinlock_unlock(clib_spinlock_t *p)
static_always_inline void clib_spinlock_lock(clib_spinlock_t *p)
u8 * echo_format_timing_event(u8 *s, va_list *args)
#define hash_unset(h, key)
uword unformat_ip6_address(unformat_input_t *input, va_list *args)
echo_session_t * sessions
u8 * format_ip6_address(u8 *s, va_list *args)
clib_spinlock_t sid_vpp_handles_lock
static f64 clib_time_now(clib_time_t *c)
uword echo_unformat_timing_event(unformat_input_t *input, va_list *args)
uword unformat_ip4_address(unformat_input_t *input, va_list *args)
volatile connection_state_t state
char * echo_fail_code_str[]
int wait_for_state_change(echo_main_t *em, connection_state_t state, f64 timeout)
foreach_app_session_field u64 vpp_session_handle
echo_session_t * echo_session_new(echo_main_t *em)
volatile u64 bytes_received
void echo_session_handle_add_del(echo_main_t *em, u64 handle, u32 sid)
clib_spinlock_t segment_handles_lock
vhost_vring_state_t state
#define ECHO_FAIL(fail, _fmt, _args...)
vl_api_fib_path_type_t type
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
void init_error_string_table()
u8 * echo_format_app_state(u8 *s, va_list *args)
uword * error_string_by_error_number
#define SESSION_INVALID_INDEX
#define ip46_address_is_ip4(ip46)
u8 * format_ip46_address(u8 *s, va_list *args)
enum echo_test_evt_ echo_test_evt_t
static void svm_msg_q_unlock(svm_msg_q_t *mq)
Unlock message queue.
u8 * format_ip4_address(u8 *s, va_list *args)
uword * shared_segment_handles
#define ECHO_LOG(lvl, _fmt, _args...)
void echo_notify_event(echo_main_t *em, echo_test_evt_t e)
uword unformat_transport_proto(unformat_input_t *input, va_list *args)
#define foreach_vnet_api_error
struct echo_main_t::@482 timing
#define hash_create(elts, value_bytes)
void svm_msg_q_add_and_unlock(svm_msg_q_t *mq, svm_msg_q_msg_t *msg)
Producer enqueue one message to queue with mutex held.
volatile u32 nxt_available_sidx
echo_session_t * echo_get_session_from_handle(echo_main_t *em, u64 handle)
#define clib_atomic_fetch_add(a, b)
u8 * format_api_error(u8 *s, va_list *args)
uword * session_index_by_vpp_handles
int wait_for_segment_allocation(u64 segment_handle)
svm_msg_q_t * rpc_msq_queue
int echo_send_rpc(echo_main_t *em, void *fp, void *arg, u32 opaque)
static int svm_msg_q_lock(svm_msg_q_t *mq)
Lock, or block trying, the message queue.
void echo_session_print_stats(echo_main_t *em, echo_session_t *session)
svm_msg_q_msg_t svm_msg_q_alloc_msg_w_ring(svm_msg_q_t *mq, u32 ring_index)
Allocate message buffer on ring.
vl_api_fib_path_nh_proto_t proto
uword echo_unformat_close(unformat_input_t *input, va_list *args)
u8 * format_transport_proto(u8 *s, va_list *args)