X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvnet%2Ftcp%2Ftcp_debug.h;h=e0db7f4f0fa606ad4626ba68af8230680c9c0c92;hb=b384b543313b6b47a277c903e9d4fcd4343054fa;hp=4bc6b42e297197a3caa82ec2f2f4f97e27ef6aec;hpb=9d063047eb1a3738cb0fc9ebebb55793d155bb20;p=vpp.git diff --git a/src/vnet/tcp/tcp_debug.h b/src/vnet/tcp/tcp_debug.h index 4bc6b42e297..e0db7f4f0fa 100755 --- a/src/vnet/tcp/tcp_debug.h +++ b/src/vnet/tcp/tcp_debug.h @@ -19,9 +19,10 @@ #include #define TCP_DEBUG (1) -#define TCP_DEBUG_SM (0) -#define TCP_DEBUG_CC (1) +#define TCP_DEBUG_SM (1) +#define TCP_DEBUG_CC (0) #define TCP_DEBUG_CC_STAT (1) +#define TCP_DEBUG_BUFFER_ALLOCATION (0) #define foreach_tcp_dbg_evt \ _(INIT, "") \ @@ -411,21 +412,6 @@ typedef enum _tcp_dbg_evt ed->data[4] = _tc->snd_wnd; \ } -#define TCP_EVT_DUPACK_SENT_HANDLER(_tc, ...) \ -{ \ - ELOG_TYPE_DECLARE (_e) = \ - { \ - .format = "dack-tx: rcv_nxt %u rcv_wnd %u snd_nxt %u av_wnd %u snd_wnd %u",\ - .format_args = "i4i4i4i4i4", \ - }; \ - DECLARE_ETD(_tc, _e, 5); \ - ed->data[0] = _tc->rcv_nxt - _tc->irs; \ - ed->data[1] = _tc->rcv_wnd; \ - ed->data[2] = _tc->snd_nxt - _tc->iss; \ - ed->data[3] = tcp_available_snd_wnd(_tc); \ - ed->data[4] = _tc->snd_wnd; \ -} - #define TCP_EVT_ACK_RCVD_HANDLER(_tc, ...) \ { \ ELOG_TYPE_DECLARE (_e) = \ @@ -441,21 +427,6 @@ typedef enum _tcp_dbg_evt ed->data[4] = tcp_flight_size(_tc); \ } -#define TCP_EVT_DUPACK_RCVD_HANDLER(_tc, ...) \ -{ \ - ELOG_TYPE_DECLARE (_e) = \ - { \ - .format = "dack-rx: snd_una %u cwnd %u snd_wnd %u flight %u rcv_wnd %u",\ - .format_args = "i4i4i4i4i4", \ - }; \ - DECLARE_ETD(_tc, _e, 5); \ - ed->data[0] = _tc->snd_una - _tc->iss; \ - ed->data[1] = _tc->cwnd; \ - ed->data[2] = _tc->snd_wnd; \ - ed->data[3] = tcp_flight_size(_tc); \ - ed->data[4] = _tc->rcv_wnd; \ -} - #define TCP_EVT_PKTIZE_HANDLER(_tc, ...) \ { \ ELOG_TYPE_DECLARE (_e) = \ @@ -601,9 +572,7 @@ if (_av > 0) \ } #else #define TCP_EVT_ACK_SENT_HANDLER(_tc, ...) -#define TCP_EVT_DUPACK_SENT_HANDLER(_tc, ...) #define TCP_EVT_ACK_RCVD_HANDLER(_tc, ...) -#define TCP_EVT_DUPACK_RCVD_HANDLER(_tc, ...) #define TCP_EVT_PKTIZE_HANDLER(_tc, ...) #define TCP_EVT_INPUT_HANDLER(_tc, _type, _len, _written, ...) #define TCP_EVT_TIMER_POP_HANDLER(_tc_index, _timer_id, ...) @@ -649,19 +618,6 @@ if (_av > 0) \ */ #if TCP_DEBUG_CC -#define TCP_EVT_CC_RTX_HANDLER(_tc, offset, n_bytes, ...) \ -{ \ - ELOG_TYPE_DECLARE (_e) = \ - { \ - .format = "rxt: snd_nxt %u offset %u snd %u rxt %u", \ - .format_args = "i4i4i4i4", \ - }; \ - DECLARE_ETD(_tc, _e, 4); \ - ed->data[0] = _tc->snd_nxt - _tc->iss; \ - ed->data[1] = offset; \ - ed->data[2] = n_bytes; \ - ed->data[3] = _tc->snd_rxt_bytes; \ -} #define TCP_EVT_CC_EVT_HANDLER(_tc, _sub_evt, ...) \ { \ @@ -669,13 +625,14 @@ if (_av > 0) \ { \ .format = "cc: %s wnd %u snd_cong %u rxt_bytes %u", \ .format_args = "t4i4i4i4", \ - .n_enum_strings = 5, \ + .n_enum_strings = 6, \ .enum_strings = { \ "fast-rxt", \ "rxt-timeout", \ "first-rxt", \ "recovered", \ "congestion", \ + "undo", \ }, \ }; \ DECLARE_ETD(_tc, _e, 4); \ @@ -685,6 +642,50 @@ if (_av > 0) \ ed->data[3] = _tc->snd_rxt_bytes; \ } +#define TCP_EVT_CC_RTX_HANDLER(_tc, offset, n_bytes, ...) \ +{ \ + ELOG_TYPE_DECLARE (_e) = \ + { \ + .format = "rxt: snd_nxt %u offset %u snd %u rxt %u", \ + .format_args = "i4i4i4i4", \ + }; \ + DECLARE_ETD(_tc, _e, 4); \ + ed->data[0] = _tc->snd_nxt - _tc->iss; \ + ed->data[1] = offset; \ + ed->data[2] = n_bytes; \ + ed->data[3] = _tc->snd_rxt_bytes; \ +} + +#define TCP_EVT_DUPACK_SENT_HANDLER(_tc, ...) \ +{ \ + ELOG_TYPE_DECLARE (_e) = \ + { \ + .format = "dack-tx: rcv_nxt %u rcv_wnd %u snd_nxt %u av_wnd %u snd_wnd %u",\ + .format_args = "i4i4i4i4i4", \ + }; \ + DECLARE_ETD(_tc, _e, 5); \ + ed->data[0] = _tc->rcv_nxt - _tc->irs; \ + ed->data[1] = _tc->rcv_wnd; \ + ed->data[2] = _tc->snd_nxt - _tc->iss; \ + ed->data[3] = tcp_available_snd_wnd(_tc); \ + ed->data[4] = _tc->snd_wnd; \ +} + +#define TCP_EVT_DUPACK_RCVD_HANDLER(_tc, ...) \ +{ \ + ELOG_TYPE_DECLARE (_e) = \ + { \ + .format = "dack-rx: snd_una %u cwnd %u snd_wnd %u flight %u rcv_wnd %u",\ + .format_args = "i4i4i4i4i4", \ + }; \ + DECLARE_ETD(_tc, _e, 5); \ + ed->data[0] = _tc->snd_una - _tc->iss; \ + ed->data[1] = _tc->cwnd; \ + ed->data[2] = _tc->snd_wnd; \ + ed->data[3] = tcp_flight_size(_tc); \ + ed->data[4] = _tc->rcv_wnd; \ +} + #define TCP_EVT_CC_PACK_HANDLER(_tc, ...) \ { \ ELOG_TYPE_DECLARE (_e) = \ @@ -696,6 +697,13 @@ if (_av > 0) \ ed->data[0] = _tc->snd_una - _tc->iss; \ ed->data[1] = _tc->snd_una_max - _tc->iss; \ } +#else +#define TCP_EVT_CC_RTX_HANDLER(_tc, offset, n_bytes, ...) +#define TCP_EVT_DUPACK_SENT_HANDLER(_tc, ...) +#define TCP_EVT_DUPACK_RCVD_HANDLER(_tc, ...) +#define TCP_EVT_CC_PACK_HANDLER(_tc, ...) +#define TCP_EVT_CC_EVT_HANDLER(_tc, _sub_evt, ...) +#endif /* * Congestion control stats @@ -740,14 +748,40 @@ if (_tc->c_cc_stat_tstamp + STATS_INTERVAL < tcp_time_now()) \ } \ } +/* + * Buffer allocation + */ +#if TCP_DEBUG_BUFFER_ALLOCATION + +#define TCP_DBG_BUFFER_ALLOC_MAYBE_FAIL(thread_index) \ +{ \ + static u32 *buffer_fail_counters; \ + if (PREDICT_FALSE (buffer_fail_counters == 0)) \ + { \ + u32 num_threads; \ + vlib_thread_main_t *vtm = vlib_get_thread_main (); \ + num_threads = 1 /* main thread */ + vtm->n_threads; \ + vec_validate (buffer_fail_counters, num_threads - 1); \ + } \ + if (PREDICT_FALSE (tcp_main.buffer_fail_fraction != 0.0)) \ + { \ + if (PREDICT_TRUE (buffer_fail_counters[thread_index] > 0)) \ + { \ + if ((1.0 / (f32) (buffer_fail_counters[thread_index])) \ + < tcp_main.buffer_fail_fraction) \ + { \ + buffer_fail_counters[thread_index] = 0.0000001; \ + return -1; \ + } \ + } \ + buffer_fail_counters[thread_index] ++; \ + } \ +} #else -#define TCP_EVT_CC_STAT_HANDLER(_tc, ...) +#define TCP_DBG_BUFFER_ALLOC_MAYBE_FAIL(thread_index) #endif #else -#define TCP_EVT_CC_RTX_HANDLER(_tc, offset, n_bytes, ...) -#define TCP_EVT_CC_EVT_HANDLER(_tc, _sub_evt, ...) -#define TCP_EVT_CC_PACK_HANDLER(_tc, ...) #define TCP_EVT_CC_STAT_HANDLER(_tc, ...) #endif