X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fplugins%2Fhs_apps%2Fsapi%2Fvpp_echo_common.c;h=02ce1686ea293f668ecf985d61cbc515cb6d3754;hb=4b47ee26c;hp=be847b57acea6303566752535480a4431f378356;hpb=4d62365ad69bd4c9e763712f89593e5c725a1ab7;p=vpp.git diff --git a/src/plugins/hs_apps/sapi/vpp_echo_common.c b/src/plugins/hs_apps/sapi/vpp_echo_common.c index be847b57ace..02ce1686ea2 100644 --- a/src/plugins/hs_apps/sapi/vpp_echo_common.c +++ b/src/plugins/hs_apps/sapi/vpp_echo_common.c @@ -205,8 +205,6 @@ echo_format_app_state (u8 * s, va_list * args) return format (s, "STATE_ATTACHED (%u)", state); if (state == STATE_ATTACHED_NO_CERT) return format (s, "STATE_ATTACHED_NO_CERT (%u)", state); - if (state == STATE_ATTACHED_ONE_CERT) - return format (s, "STATE_ATTACHED_ONE_CERT (%u)", state); if (state == STATE_LISTEN) return format (s, "STATE_LISTEN (%u)", state); if (state == STATE_READY) @@ -259,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) { @@ -289,18 +301,10 @@ unformat_transport_proto (unformat_input_t * input, va_list * args) *proto = TRANSPORT_PROTO_TCP; else if (unformat (input, "TCP")) *proto = TRANSPORT_PROTO_TCP; - else if (unformat (input, "udpc")) - *proto = TRANSPORT_PROTO_UDPC; - else if (unformat (input, "UDPC")) - *proto = TRANSPORT_PROTO_UDPC; else if (unformat (input, "udp")) *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")) @@ -326,21 +330,18 @@ 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; case TRANSPORT_PROTO_TLS: s = format (s, "TLS"); break; - case TRANSPORT_PROTO_UDPC: - s = format (s, "UDPC"); - break; case TRANSPORT_PROTO_QUIC: s = format (s, "QUIC"); break; + case TRANSPORT_PROTO_DTLS: + s = format (s, "DTLS"); + break; default: s = format (s, "UNKNOWN"); break; @@ -459,6 +460,20 @@ unformat_ip6_address (unformat_input_t * input, va_list * args) } } +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) { @@ -505,12 +520,12 @@ echo_session_handle_add_del (echo_main_t * em, u64 handle, u32 sid) 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); @@ -519,35 +534,35 @@ echo_session_handle_add_del (echo_main_t * em, u64 handle, u32 sid) 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; - if (PREDICT_FALSE (svm_msg_q_lock (em->rpc_msq_queue))) + if (PREDICT_FALSE (svm_msg_q_lock (&em->rpc_msq_queue))) { - ECHO_LOG (1, "RPC lock failed"); + ECHO_FAIL (ECHO_FAIL_RPC_SIZE, "RPC lock failed"); return -1; } - if (PREDICT_FALSE (svm_msg_q_ring_is_full (em->rpc_msq_queue, 0))) + if (PREDICT_FALSE (svm_msg_q_ring_is_full (&em->rpc_msq_queue, 0))) { - svm_msg_q_unlock (em->rpc_msq_queue); - ECHO_LOG (1, "RPC ring is full"); + svm_msg_q_unlock (&em->rpc_msq_queue); + ECHO_FAIL (ECHO_FAIL_RPC_SIZE, "RPC ring is full"); return -2; } - 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; + 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->fp = fp; + clib_memcpy (&evt->args, args, sizeof (evt->args)); - svm_msg_q_add_and_unlock (em->rpc_msq_queue, &msg); + svm_msg_q_add_and_unlock (&em->rpc_msq_queue, &msg); return 0; } @@ -560,34 +575,12 @@ echo_get_session_from_handle (echo_main_t * em, u64 handle) 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) @@ -600,7 +593,7 @@ wait_for_state_change (echo_main_t * em, connection_state_t state, 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; } @@ -620,7 +613,7 @@ void 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);