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)
{
*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"))
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;
}
}
+uword
+unformat_ip46_address (unformat_input_t * input, va_list * args)
+{
+ ip46_address_t *ip = va_arg (*args, ip46_address_t *);
+
+ if (unformat (input, "%U", unformat_ip4_address, &ip->ip4))
+ ;
+ else if (unformat (input, "%U", unformat_ip6_address, &ip->ip6))
+ ;
+ else
+ return 0;
+ return 1;
+}
+
u8 *
echo_format_crypto_engine (u8 * s, va_list * args)
{
clib_spinlock_lock (&em->sid_vpp_handles_lock);
if (sid == SESSION_INVALID_INDEX)
{
- ECHO_LOG (2, "hash_unset(0x%lx)", handle);
+ ECHO_LOG (3, "hash_unset(0x%lx)", handle);
hash_unset (em->session_index_by_vpp_handles, handle);
}
else
{
- ECHO_LOG (2, "hash_set(0x%lx) S[%d]", handle, sid);
+ ECHO_LOG (3, "hash_set(0x%lx) S[%d]", handle, sid);
hash_set (em->session_index_by_vpp_handles, handle, sid);
}
clib_spinlock_unlock (&em->sid_vpp_handles_lock);
echo_session_t *
echo_session_new (echo_main_t * em)
{
- /* thread safe new prealloced session */
+ /* thread safe new prealloced session
+ * see echo_session_prealloc */
return pool_elt_at_index (em->sessions,
clib_atomic_fetch_add (&em->nxt_available_sidx,
1));
}
int
-echo_send_rpc (echo_main_t * em, void *fp, void *arg, u32 opaque)
+echo_send_rpc (echo_main_t * em, void *fp, echo_rpc_args_t * args)
{
svm_msg_q_msg_t msg;
echo_rpc_msg_t *evt;
}
msg = svm_msg_q_alloc_msg_w_ring (em->rpc_msq_queue, 0);
evt = (echo_rpc_msg_t *) svm_msg_q_msg_data (em->rpc_msq_queue, &msg);
- evt->arg = arg;
- evt->opaque = opaque;
evt->fp = fp;
+ clib_memcpy (&evt->args, args, sizeof (evt->args));
svm_msg_q_add_and_unlock (em->rpc_msq_queue, &msg);
return 0;
clib_spinlock_unlock (&em->sid_vpp_handles_lock);
if (!p)
{
- ECHO_LOG (1, "unknown handle 0x%lx", handle);
+ ECHO_LOG (2, "unknown handle 0x%lx", handle);
return 0;
}
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 (1, "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 (1, "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)
if (em->time_to_stop)
return 1;
}
- ECHO_LOG (1, "timeout waiting for %U", echo_format_app_state, state);
+ ECHO_LOG (2, "timeout waiting for %U", echo_format_app_state, state);
return -1;
}
echo_session_print_stats (echo_main_t * em, echo_session_t * session)
{
f64 deltat = clib_time_now (&em->clib_time) - session->start;
- ECHO_LOG (0, "Session 0x%x done in %.6fs RX[%.4f] TX[%.4f] Gbit/s\n",
+ ECHO_LOG (1, "Session 0x%x done in %.6fs RX[%.4f] TX[%.4f] Gbit/s\n",
session->vpp_session_handle, deltat,
(session->bytes_received * 8.0) / deltat / 1e9,
(session->bytes_sent * 8.0) / deltat / 1e9);