X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvnet%2Ftcp%2Ftcp_debug.h;h=e37b3cd9a9b18113d1053f69d2e293c62eb6ae17;hb=8e1039a8231cd1d817a24256c421b9fc512f45fa;hp=eb318cde4b9688d6ec97e58ca1404103c89955e8;hpb=f1762d6fa8cbc1a8fae691e568e73e94d5dcbc93;p=vpp.git diff --git a/src/vnet/tcp/tcp_debug.h b/src/vnet/tcp/tcp_debug.h index eb318cde4b9..e37b3cd9a9b 100755 --- a/src/vnet/tcp/tcp_debug.h +++ b/src/vnet/tcp/tcp_debug.h @@ -22,6 +22,7 @@ #define TCP_DEBUG_SM (0) #define TCP_DEBUG_CC (0) #define TCP_DEBUG_CC_STAT (1) +#define TCP_DEBUG_BUFFER_ALLOCATION (0) #define foreach_tcp_dbg_evt \ _(INIT, "") \ @@ -327,15 +328,18 @@ typedef enum _tcp_dbg_evt #define TCP_EVT_RST_SENT_HANDLER(_tc, ...) \ { \ - ELOG_TYPE_DECLARE (_e) = \ +if (_tc) \ { \ - .format = "rst-tx: snd_nxt %d rcv_nxt %d", \ - .format_args = "i4i4", \ - }; \ - DECLARE_ETD(_tc, _e, 2); \ - ed->data[0] = _tc->snd_nxt - _tc->iss; \ - ed->data[1] = _tc->rcv_nxt - _tc->irs; \ - TCP_EVT_STATE_CHANGE_HANDLER(_tc); \ + ELOG_TYPE_DECLARE (_e) = \ + { \ + .format = "rst-tx: snd_nxt %d rcv_nxt %d", \ + .format_args = "i4i4", \ + }; \ + DECLARE_ETD(_tc, _e, 2); \ + ed->data[0] = _tc->snd_nxt - _tc->iss; \ + ed->data[1] = _tc->rcv_nxt - _tc->irs; \ + TCP_EVT_STATE_CHANGE_HANDLER(_tc); \ + } \ } #define TCP_EVT_FIN_RCVD_HANDLER(_tc, ...) \ @@ -747,6 +751,39 @@ 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_DBG_BUFFER_ALLOC_MAYBE_FAIL(thread_index) +#endif + #else #define TCP_EVT_CC_STAT_HANDLER(_tc, ...) #endif