16 #ifndef SRC_VNET_TCP_TCP_DEBUG_H_ 17 #define SRC_VNET_TCP_TCP_DEBUG_H_ 26 #define TCP_DEBUG_ALWAYS (0) 31 #define TCP_DEBUG_ENABLE (0) 33 #define TCP_DEBUG_SM (0) 34 #define TCP_DEBUG_CC (0) 35 #define TCP_DEBUG_CS (0) 36 #define TCP_DEBUG_LC (0 || TCP_DEBUG_SM || TCP_DEBUG_CC || TCP_DEBUG_CS) 38 #define TCP_DEBUG (TCP_DEBUG_ALWAYS || TCP_DEBUG_ENABLE) 39 #define TCP_DEBUG_BUF_ALLOC (0) 42 #define TRANSPORT_DEBUG (1) 45 #define TCP_CONCAT_HELPER(_a, _b) _a##_b 46 #define TCP_CC(_a, _b) TCP_CONCAT_HELPER(_a, _b) 48 #define tcp_evt_lvl(_evt) TCP_CC(_evt, _LVL) 49 #define tcp_evt_grp(_evt) TCP_CC(_evt, _GRP) 50 #define tcp_evt_handler(_evt, _args...) TCP_CC(_evt, _HANDLER) (_args) 51 #define tcp_evt_grp_dbg_lvl(_evt) tcp_dbg_main.grp_dbg_lvl[tcp_evt_grp (_evt)] 53 #define foreach_tcp_evt_grp \ 55 _(SM, "state machine") \ 56 _(CC, "congestion control") \ 61 #define _(sym, str) TCP_EVT_GRP_ ## sym, 75 #define foreach_tcp_dbg_evt \ 76 _(INIT, LC, 1, "init") \ 77 _(DEALLOC, LC, 1, "dealloc") \ 78 _(OPEN, LC, 1, "open") \ 79 _(CLOSE, LC, 1, "close") \ 80 _(BIND, LC, 1, "bind") \ 81 _(UNBIND, LC, 1, "unbind") \ 82 _(DELETE, LC, 1, "delete") \ 83 _(SYN_RCVD, LC, 1, "SYN rcvd") \ 84 _(STATE_CHANGE, LC, 1, "state change") \ 85 _(SYN_SENT, SM, 1, "SYN sent") \ 86 _(SYN_RXT, SM, 1, "SYN retransmit") \ 87 _(SYNACK_SENT, SM, 1, "SYNACK sent") \ 88 _(SYNACK_RCVD, SM, 1, "SYNACK rcvd") \ 89 _(FIN_SENT, SM, 1, "FIN sent") \ 90 _(FIN_RCVD, SM, 1, "FIN rcvd") \ 91 _(RST_SENT, SM, 1, "RST sent") \ 92 _(RST_RCVD, SM, 1, "RST rcvd") \ 93 _(TIMER_POP, SM, 1, "timer pop") \ 94 _(SEG_INVALID, SM, 2, "invalid segment") \ 95 _(PAWS_FAIL, SM, 2, "failed paws check") \ 96 _(ACK_RCV_ERR, SM, 2, "invalid ack") \ 97 _(RCV_WND_SHRUNK, SM, 2, "shrunk rcv_wnd") \ 98 _(ACK_SENT, SM, 3, "ACK sent") \ 99 _(ACK_RCVD, SM, 3, "ACK rcvd") \ 100 _(PKTIZE, SM, 3, "packetize") \ 101 _(INPUT, SM, 3, "in") \ 102 _(OUTPUT, SM, 4, "output") \ 103 _(SND_WND, SM, 4, "snd_wnd update") \ 104 _(CC_EVT, CC, 1, "cc event") \ 105 _(CC_RTX, CC, 2, "retransmit") \ 106 _(CC_PACK, CC, 2, "cc partial ack") \ 107 _(DUPACK_SENT, CC, 2, "DUPACK sent") \ 108 _(DUPACK_RCVD, CC, 2, "DUPACK rcvd") \ 109 _(CC_SCOREBOARD, CC, 2, "scoreboard stats") \ 110 _(CC_SACKS, CC, 2, "snd sacks stats") \ 111 _(CC_INPUT, CC, 2, "ooo data delivered") \ 112 _(CC_STAT, CS, 1, "cc stats") \ 113 _(CC_RTO_STAT, CS, 1, "cc rto stats") \ 117 #define _(sym, grp, lvl, str) TCP_EVT_##sym, 124 #define _(sym, grp, lvl, str) TCP_EVT_## sym ## _LVL = lvl, 131 #define _(sym, grp, lvl, str) TCP_EVT_ ## sym ## _GRP = TCP_EVT_GRP_ ## grp, 136 #if TCP_DEBUG_ALWAYS > 0 137 #define TCP_EVT(_evt, _args...) \ 138 if (PREDICT_FALSE (tcp_evt_grp_dbg_lvl (_evt) >= tcp_evt_lvl (_evt))) \ 139 tcp_evt_handler (_evt, _args) 140 #define TCP_DBG(_fmt, _args...) clib_warning (_fmt, ##_args) 141 #elif TCP_DEBUG_ENABLE > 0 142 #define TCP_EVT(_evt, _args...) tcp_evt_handler(_evt, _args) 143 #define TCP_DBG(_fmt, _args...) clib_warning (_fmt, ##_args) 145 #define TCP_EVT(_evt, _args...) 146 #define TCP_DBG(_fmt, _args...) 152 #define TCP_DECLARE_ETD(_tc, _e, _size) \ 157 ed = ELOG_TRACK_DATA (&vlib_global_main.elog_main, _e, \ 164 #if TCP_DEBUG_LC || TCP_DEBUG_ALWAYS 170 #define TCP_DBG_IP_TAG_LCL(_tc) \ 174 ELOG_TYPE_DECLARE (_e) = \ 176 .format = "lcl: %d.%d.%d.%d:%d", \ 177 .format_args = "i4i4i4i4i4", \ 179 TCP_DECLARE_ETD(_tc, _e, 5); \ 180 ed->data[0] = _tc->c_lcl_ip.ip4.as_u8[0]; \ 181 ed->data[1] = _tc->c_lcl_ip.ip4.as_u8[1]; \ 182 ed->data[2] = _tc->c_lcl_ip.ip4.as_u8[2]; \ 183 ed->data[3] = _tc->c_lcl_ip.ip4.as_u8[3]; \ 184 ed->data[4] = clib_net_to_host_u16(_tc->c_lcl_port); \ 188 #define TCP_DBG_IP_TAG_RMT(_tc) \ 192 ELOG_TYPE_DECLARE (_e) = \ 194 .format = "rmt: %d.%d.%d.%d:%d", \ 195 .format_args = "i4i4i4i4i4", \ 197 TCP_DECLARE_ETD(_tc, _e, 5); \ 198 ed->data[0] = _tc->c_rmt_ip.ip4.as_u8[0]; \ 199 ed->data[1] = _tc->c_rmt_ip.ip4.as_u8[1]; \ 200 ed->data[2] = _tc->c_rmt_ip.ip4.as_u8[2]; \ 201 ed->data[3] = _tc->c_rmt_ip.ip4.as_u8[3]; \ 202 ed->data[4] = clib_net_to_host_u16(_tc->c_rmt_port); \ 206 #define TCP_EVT_INIT_HANDLER(_tc, _is_l, ...) \ 208 char *_fmt = _is_l ? "l[%d].%d:%d%c" : "[%d].%d:%d->.%d:%d%c"; \ 211 _tc->c_elog_track.name = \ 212 (char *) format (0, _fmt, _tc->c_thread_index, \ 213 _tc->c_lcl_ip.ip4.as_u8[3], \ 214 clib_net_to_host_u16(_tc->c_lcl_port), \ 215 _tc->c_rmt_ip.ip4.as_u8[3], \ 216 clib_net_to_host_u16(_tc->c_rmt_port), 0); \ 219 _tc->c_elog_track.name = \ 220 (char *) format (0, _fmt, _tc->c_thread_index, \ 221 _tc->c_lcl_ip.ip6.as_u8[15], \ 222 clib_net_to_host_u16(_tc->c_lcl_port), \ 223 _tc->c_rmt_ip.ip6.as_u8[15], \ 224 clib_net_to_host_u16(_tc->c_rmt_port), 0); \ 225 tcp_evt_track_register (&_tc->c_elog_track); \ 226 TCP_DBG_IP_TAG_LCL(_tc); \ 227 TCP_DBG_IP_TAG_RMT(_tc); \ 230 #define TCP_EVT_DEALLOC_HANDLER(_tc, ...) \ 232 vec_free (_tc->c_elog_track.name); \ 233 vec_add1 (tcp_dbg_main.free_track_indices, \ 234 _tc->c_elog_track.track_index_plus_one - 1); \ 237 #define TCP_EVT_OPEN_HANDLER(_tc, ...) \ 239 TCP_EVT_INIT_HANDLER(_tc, 0); \ 240 ELOG_TYPE_DECLARE (_e) = \ 242 .format = "open: index %d", \ 243 .format_args = "i4", \ 245 TCP_DECLARE_ETD(_tc, _e, 1); \ 246 ed->data[0] = _tc->c_c_index; \ 249 #define TCP_EVT_CLOSE_HANDLER(_tc, ...) \ 251 ELOG_TYPE_DECLARE (_e) = \ 253 .format = "close: cidx %d", \ 254 .format_args = "i4", \ 256 TCP_DECLARE_ETD(_tc, _e, 1); \ 257 ed->data[0] = _tc->c_c_index; \ 260 #define TCP_EVT_BIND_HANDLER(_tc, ...) \ 262 TCP_EVT_INIT_HANDLER(_tc, 1); \ 263 ELOG_TYPE_DECLARE (_e) = \ 265 .format = "bind: listener %d", \ 267 TCP_DECLARE_ETD(_tc, _e, 1); \ 268 ed->data[0] = _tc->c_c_index; \ 271 #define TCP_EVT_SYN_RCVD_HANDLER(_tc,_init, ...) \ 274 TCP_EVT_INIT_HANDLER(_tc, 0); \ 275 ELOG_TYPE_DECLARE (_e) = \ 277 .format = "syn-rx: cidx %u sidx %u irs %u", \ 278 .format_args = "i4i4i4", \ 280 TCP_DECLARE_ETD(_tc, _e, 3); \ 281 ed->data[0] = _tc->c_c_index; \ 282 ed->data[1] = _tc->c_s_index; \ 283 ed->data[2] = _tc->irs; \ 284 TCP_EVT_STATE_CHANGE_HANDLER(_tc); \ 287 #define TCP_EVT_UNBIND_HANDLER(_tc, ...) \ 289 TCP_EVT_DEALLOC_HANDLER(_tc); \ 290 ELOG_TYPE_DECLARE (_e) = \ 292 .format = "unbind: listener %d", \ 294 TCP_DECLARE_ETD(_tc, _e, 1); \ 295 ed->data[0] = _tc->c_c_index; \ 296 TCP_EVT_DEALLOC_HANDLER(_tc); \ 299 #define TCP_EVT_DELETE_HANDLER(_tc, ...) \ 301 ELOG_TYPE_DECLARE (_e) = \ 303 .format = "delete: cidx %d sidx %d", \ 304 .format_args = "i4i4", \ 306 TCP_DECLARE_ETD(_tc, _e, 2); \ 307 ed->data[0] = _tc->c_c_index; \ 308 ed->data[1] = _tc->c_s_index; \ 309 TCP_EVT_DEALLOC_HANDLER(_tc); \ 317 #if TCP_DEBUG_SM > 0 || TCP_DEBUG_ALWAYS 319 #define TCP_EVT_STATE_CHANGE_HANDLER(_tc, ...) \ 321 ELOG_TYPE_DECLARE (_e) = \ 323 .format = "state: %s", \ 324 .format_args = "t4", \ 325 .n_enum_strings = 11, \ 340 TCP_DECLARE_ETD(_tc, _e, 1); \ 341 ed->data[0] = _tc->state; \ 344 #define TCP_EVT_SYN_SENT_HANDLER(_tc, ...) \ 346 ELOG_TYPE_DECLARE (_e) = \ 348 .format = "syn-tx: iss %u snd_una %u snd_una_max %u snd_nxt %u", \ 349 .format_args = "i4i4i4i4", \ 351 TCP_DECLARE_ETD(_tc, _e, 4); \ 352 ed->data[0] = _tc->iss; \ 353 ed->data[1] = _tc->snd_una - _tc->iss; \ 354 ed->data[2] = _tc->snd_una_max - _tc->iss; \ 355 ed->data[3] = _tc->snd_nxt - _tc->iss; \ 356 TCP_EVT_STATE_CHANGE_HANDLER(_tc); \ 359 #define TCP_EVT_SYNACK_SENT_HANDLER(_tc, ...) \ 361 ELOG_TYPE_DECLARE (_e) = \ 363 .format = "synack-tx: iss %u irs %u snd_una %u snd_nxt %u rcv_nxt %u",\ 364 .format_args = "i4i4i4i4i4", \ 366 TCP_DECLARE_ETD(_tc, _e, 5); \ 367 ed->data[0] = _tc->iss; \ 368 ed->data[1] = _tc->irs; \ 369 ed->data[2] = _tc->snd_una - _tc->iss; \ 370 ed->data[3] = _tc->snd_nxt - _tc->iss; \ 371 ed->data[4] = _tc->rcv_nxt - _tc->irs; \ 374 #define TCP_EVT_SYNACK_RCVD_HANDLER(_tc, ...) \ 376 ELOG_TYPE_DECLARE (_e) = \ 378 .format = "synack-rx: iss %u irs %u snd_una %u snd_nxt %u rcv_nxt %u",\ 379 .format_args = "i4i4i4i4i4", \ 381 TCP_DECLARE_ETD(_tc, _e, 5); \ 382 ed->data[0] = _tc->iss; \ 383 ed->data[1] = _tc->irs; \ 384 ed->data[2] = _tc->snd_una - _tc->iss; \ 385 ed->data[3] = _tc->snd_nxt - _tc->iss; \ 386 ed->data[4] = _tc->rcv_nxt - _tc->irs; \ 387 TCP_EVT_STATE_CHANGE_HANDLER(_tc); \ 390 #define TCP_EVT_FIN_SENT_HANDLER(_tc, ...) \ 392 ELOG_TYPE_DECLARE (_e) = \ 394 .format = "fin-tx: snd_nxt %d rcv_nxt %d", \ 395 .format_args = "i4i4", \ 397 TCP_DECLARE_ETD(_tc, _e, 2); \ 398 ed->data[0] = _tc->snd_nxt - _tc->iss; \ 399 ed->data[1] = _tc->rcv_nxt - _tc->irs; \ 402 #define TCP_EVT_RST_SENT_HANDLER(_tc, ...) \ 406 ELOG_TYPE_DECLARE (_e) = \ 408 .format = "rst-tx: snd_nxt %d rcv_nxt %d", \ 409 .format_args = "i4i4", \ 411 TCP_DECLARE_ETD(_tc, _e, 2); \ 412 ed->data[0] = _tc->snd_nxt - _tc->iss; \ 413 ed->data[1] = _tc->rcv_nxt - _tc->irs; \ 414 TCP_EVT_STATE_CHANGE_HANDLER(_tc); \ 418 #define TCP_EVT_FIN_RCVD_HANDLER(_tc, ...) \ 420 ELOG_TYPE_DECLARE (_e) = \ 422 .format = "fin-rx: snd_nxt %d rcv_nxt %d", \ 423 .format_args = "i4i4", \ 425 TCP_DECLARE_ETD(_tc, _e, 2); \ 426 ed->data[0] = _tc->snd_nxt - _tc->iss; \ 427 ed->data[1] = _tc->rcv_nxt - _tc->irs; \ 430 #define TCP_EVT_RST_RCVD_HANDLER(_tc, ...) \ 432 ELOG_TYPE_DECLARE (_e) = \ 434 .format = "rst-rx: snd_nxt %d rcv_nxt %d", \ 435 .format_args = "i4i4", \ 437 TCP_DECLARE_ETD(_tc, _e, 2); \ 438 ed->data[0] = _tc->snd_nxt - _tc->iss; \ 439 ed->data[1] = _tc->rcv_nxt - _tc->irs; \ 442 #define TCP_EVT_SYN_RXT_HANDLER(_tc, _type, ...) \ 444 ELOG_TYPE_DECLARE (_e) = \ 446 .format = "%s-rxt: iss %u irs %u snd_nxt %u rcv_nxt %u", \ 447 .format_args = "t4i4i4i4i4", \ 448 .n_enum_strings = 2, \ 454 TCP_DECLARE_ETD(_tc, _e, 5); \ 455 ed->data[0] = _type; \ 456 ed->data[1] = _tc->iss; \ 457 ed->data[2] = _tc->irs; \ 458 ed->data[3] = _tc->snd_nxt - _tc->iss; \ 459 ed->data[4] = _tc->rcv_nxt - _tc->irs; \ 462 #define TCP_EVT_TIMER_POP_HANDLER(_tc_index, _timer_id, ...) \ 464 tcp_connection_t *_tc; \ 465 if (_timer_id == TCP_TIMER_RETRANSMIT_SYN) \ 467 _tc = tcp_half_open_connection_get (_tc_index); \ 471 u32 _thread_index = vlib_get_thread_index (); \ 472 _tc = tcp_connection_get (_tc_index, _thread_index); \ 474 ELOG_TYPE_DECLARE (_e) = \ 476 .format = "timer-pop: %s cidx %u sidx %u", \ 477 .format_args = "t4i4i4", \ 478 .n_enum_strings = 8, \ 492 TCP_DECLARE_ETD(_tc, _e, 3); \ 493 ed->data[0] = _timer_id; \ 494 ed->data[1] = _tc->c_c_index; \ 495 ed->data[2] = _tc->c_s_index; \ 499 clib_warning ("pop %d for unexisting connection %d", _timer_id, \ 505 #define TCP_EVT_SYN_SENT_HANDLER(_tc, ...) 506 #define TCP_EVT_SYNACK_SENT_HANDLER(_tc, ...) 507 #define TCP_EVT_SYNACK_RCVD_HANDLER(_tc, ...) 508 #define TCP_EVT_SYN_RXT_HANDLER(_tc, ...) 509 #define TCP_EVT_FIN_SENT_HANDLER(_tc, ...) 510 #define TCP_EVT_RST_SENT_HANDLER(_tc, ...) 511 #define TCP_EVT_FIN_RCVD_HANDLER(_tc, ...) 512 #define TCP_EVT_RST_RCVD_HANDLER(_tc, ...) 513 #define TCP_EVT_STATE_CHANGE_HANDLER(_tc, ...) 514 #define TCP_EVT_TIMER_POP_HANDLER(_tc_index, _timer_id, ...) 517 #if TCP_DEBUG_SM > 1 || TCP_DEBUG_ALWAYS 518 #define TCP_EVT_SEG_INVALID_HANDLER(_tc, _btcp, ...) \ 520 ELOG_TYPE_DECLARE (_e) = \ 522 .format = "seg-inv: seq %u end %u rcv_las %u rcv_nxt %u rcv_wnd %u",\ 523 .format_args = "i4i4i4i4i4", \ 525 TCP_DECLARE_ETD(_tc, _e, 5); \ 526 ed->data[0] = _btcp.seq_number - _tc->irs; \ 527 ed->data[1] = _btcp.seq_end - _tc->irs; \ 528 ed->data[2] = _tc->rcv_las - _tc->irs; \ 529 ed->data[3] = _tc->rcv_nxt - _tc->irs; \ 530 ed->data[4] = _tc->rcv_wnd; \ 533 #define TCP_EVT_PAWS_FAIL_HANDLER(_tc, _seq, _end, ...) \ 535 ELOG_TYPE_DECLARE (_e) = \ 537 .format = "paws-err: seq %u end %u tsval %u tsval_recent %u", \ 538 .format_args = "i4i4i4i4", \ 540 TCP_DECLARE_ETD(_tc, _e, 4); \ 541 ed->data[0] = _seq - _tc->irs; \ 542 ed->data[1] = _end - _tc->irs; \ 543 ed->data[2] = _tc->rcv_opts.tsval; \ 544 ed->data[3] = _tc->tsval_recent; \ 547 #define TCP_EVT_ACK_RCV_ERR_HANDLER(_tc, _type, _ack, ...) \ 549 ELOG_TYPE_DECLARE (_e) = \ 551 .format = "ack-err: %s ack %u snd_una %u snd_nxt %u una_max %u", \ 552 .format_args = "t4i4i4i4i4", \ 553 .n_enum_strings = 3, \ 560 TCP_DECLARE_ETD(_tc, _e, 5); \ 561 ed->data[0] = _type; \ 562 ed->data[1] = _ack - _tc->iss; \ 563 ed->data[2] = _tc->snd_una - _tc->iss; \ 564 ed->data[3] = _tc->snd_nxt - _tc->iss; \ 565 ed->data[4] = _tc->snd_una_max - _tc->iss; \ 568 #define TCP_EVT_RCV_WND_SHRUNK_HANDLER(_tc, _obs, _av, ...) \ 572 ELOG_TYPE_DECLARE (_e) = \ 574 .format = "huh?: rcv_wnd %u obsd %u av %u rcv_nxt %u rcv_las %u", \ 575 .format_args = "i4i4i4i4i4", \ 577 TCP_DECLARE_ETD(_tc, _e, 5); \ 578 ed->data[0] = _tc->rcv_wnd; \ 579 ed->data[1] = _obs; \ 581 ed->data[3] = _tc->rcv_nxt - _tc->irs; \ 582 ed->data[4] = _tc->rcv_las - _tc->irs; \ 586 #define TCP_EVT_SEG_INVALID_HANDLER(_tc, _btcp, ...) 587 #define TCP_EVT_PAWS_FAIL_HANDLER(_tc, _seq, _end, ...) 588 #define TCP_EVT_ACK_RCV_ERR_HANDLER(_tc, _type, _ack, ...) 589 #define TCP_EVT_RCV_WND_SHRUNK_HANDLER(_tc, _obs, _av, ...) 592 #if TCP_DEBUG_SM > 2 || TCP_DEBUG_ALWAYS 594 #define TCP_EVT_ACK_SENT_HANDLER(_tc, ...) \ 596 ELOG_TYPE_DECLARE (_e) = \ 598 .format = "ack-tx: acked %u rcv_nxt %u rcv_wnd %u snd_nxt %u snd_wnd %u",\ 599 .format_args = "i4i4i4i4i4", \ 601 TCP_DECLARE_ETD(_tc, _e, 5); \ 602 ed->data[0] = _tc->rcv_nxt - _tc->rcv_las; \ 603 ed->data[1] = _tc->rcv_nxt - _tc->irs; \ 604 ed->data[2] = _tc->rcv_wnd; \ 605 ed->data[3] = _tc->snd_nxt - _tc->iss; \ 606 ed->data[4] = _tc->snd_wnd; \ 609 #define TCP_EVT_ACK_RCVD_HANDLER(_tc, ...) \ 611 ELOG_TYPE_DECLARE (_e) = \ 613 .format = "ack-rx: %u snd_una %u snd_wnd %u cwnd %u inflight %u", \ 614 .format_args = "i4i4i4i4i4", \ 616 TCP_DECLARE_ETD(_tc, _e, 5); \ 617 ed->data[0] = _tc->bytes_acked; \ 618 ed->data[1] = _tc->snd_una - _tc->iss; \ 619 ed->data[2] = _tc->snd_wnd; \ 620 ed->data[3] = _tc->cwnd; \ 621 ed->data[4] = tcp_flight_size(_tc); \ 624 #define TCP_EVT_PKTIZE_HANDLER(_tc, ...) \ 626 ELOG_TYPE_DECLARE (_e) = \ 628 .format = "tx: una %u snd_nxt %u space %u flight %u rcv_wnd %u",\ 629 .format_args = "i4i4i4i4i4", \ 631 TCP_DECLARE_ETD(_tc, _e, 5); \ 632 ed->data[0] = _tc->snd_una - _tc->iss; \ 633 ed->data[1] = _tc->snd_nxt - _tc->iss; \ 634 ed->data[2] = tcp_available_output_snd_space (_tc); \ 635 ed->data[3] = tcp_flight_size (_tc); \ 636 ed->data[4] = _tc->rcv_wnd; \ 639 #define TCP_EVT_INPUT_HANDLER(_tc, _type, _len, _written, ...) \ 641 ELOG_TYPE_DECLARE (_e) = \ 643 .format = "in: %s len %u written %d rcv_nxt %u rcv_wnd(o) %d", \ 644 .format_args = "t4i4i4i4i4", \ 645 .n_enum_strings = 2, \ 651 TCP_DECLARE_ETD(_tc, _e, 5); \ 652 ed->data[0] = _type; \ 653 ed->data[1] = _len; \ 654 ed->data[2] = _written; \ 655 ed->data[3] = (_tc->rcv_nxt - _tc->irs) + _written; \ 656 ed->data[4] = _tc->rcv_wnd - (_tc->rcv_nxt - _tc->rcv_las); \ 660 #define TCP_EVT_ACK_SENT_HANDLER(_tc, ...) 661 #define TCP_EVT_ACK_RCVD_HANDLER(_tc, ...) 662 #define TCP_EVT_PKTIZE_HANDLER(_tc, ...) 663 #define TCP_EVT_INPUT_HANDLER(_tc, _type, _len, _written, ...) 669 #if TCP_DEBUG_SM > 3 || TCP_DEBUG_ALWAYS 670 #define TCP_EVT_SND_WND_HANDLER(_tc, ...) \ 672 ELOG_TYPE_DECLARE (_e) = \ 674 .format = "snd-wnd update: %u ", \ 675 .format_args = "i4", \ 677 TCP_DECLARE_ETD(_tc, _e, 1); \ 678 ed->data[0] = _tc->snd_wnd; \ 681 #define TCP_EVT_OUTPUT_HANDLER(_tc, flags, n_bytes,...) \ 683 ELOG_TYPE_DECLARE (_e) = \ 685 .format = "out: flags %x, bytes %u", \ 686 .format_args = "i4i4", \ 688 TCP_DECLARE_ETD(_tc, _e, 2); \ 689 ed->data[0] = flags; \ 690 ed->data[1] = n_bytes; \ 693 #define TCP_EVT_SND_WND_HANDLER(_tc, ...) 694 #define TCP_EVT_OUTPUT_HANDLER(_tc, flags, n_bytes,...) 701 #if TCP_DEBUG_CC || TCP_DEBUG_ALWAYS 703 #define TCP_EVT_CC_EVT_PRINT(_tc, _sub_evt) \ 705 ELOG_TYPE_DECLARE (_e) = \ 707 .format = "cc: %s snd_space %u snd_una %u out %u flight %u", \ 708 .format_args = "t4i4i4i4i4", \ 709 .n_enum_strings = 7, \ 720 TCP_DECLARE_ETD(_tc, _e, 5); \ 721 ed->data[0] = _sub_evt; \ 722 ed->data[1] = tcp_available_cc_snd_space (_tc); \ 723 ed->data[2] = _tc->snd_una - _tc->iss; \ 724 ed->data[3] = tcp_bytes_out(_tc); \ 725 ed->data[4] = tcp_flight_size (_tc); \ 728 #define TCP_EVT_CC_EVT_HANDLER(_tc, _sub_evt, ...) \ 730 if (_tc->snd_una != _tc->iss) \ 731 TCP_EVT_CC_STAT_PRINT (_tc); \ 732 if ((_sub_evt <= 1 && TCP_DEBUG_CC > 1) \ 733 || (_sub_evt > 1 && TCP_DEBUG_CC > 0)) \ 734 TCP_EVT_CC_EVT_PRINT (_tc, _sub_evt); \ 737 #define TCP_EVT_CC_EVT_HANDLER(_tc, _sub_evt, ...) \ 741 #if TCP_DEBUG_CC > 1 || TCP_DEBUG_ALWAYS 742 #define TCP_EVT_CC_RTX_HANDLER(_tc, offset, n_bytes, ...) \ 744 ELOG_TYPE_DECLARE (_e) = \ 746 .format = "rxt: snd_nxt %u offset %u snd %u rxt %u", \ 747 .format_args = "i4i4i4i4", \ 749 TCP_DECLARE_ETD(_tc, _e, 4); \ 750 ed->data[0] = _tc->snd_nxt - _tc->iss; \ 751 ed->data[1] = offset; \ 752 ed->data[2] = n_bytes; \ 753 ed->data[3] = _tc->snd_rxt_bytes; \ 756 #define TCP_EVT_DUPACK_SENT_HANDLER(_tc, _btcp, ...) \ 758 ELOG_TYPE_DECLARE (_e) = \ 760 .format = "dack-tx: rcv_nxt %u seq %u rcv_wnd %u snd_nxt %u av_wnd %u",\ 761 .format_args = "i4i4i4i4i4", \ 763 TCP_DECLARE_ETD(_tc, _e, 5); \ 764 ed->data[0] = _tc->rcv_nxt - _tc->irs; \ 765 ed->data[1] = _btcp.seq_number - _tc->irs; \ 766 ed->data[2] = _tc->rcv_wnd; \ 767 ed->data[3] = _tc->snd_nxt - _tc->iss; \ 768 ed->data[4] = tcp_available_snd_wnd(_tc); \ 771 #define TCP_EVT_DUPACK_RCVD_HANDLER(_tc, ...) \ 773 ELOG_TYPE_DECLARE (_e) = \ 775 .format = "dack-rx: snd_una %u cwnd %u snd_wnd %u flight %u rcv_wnd %u",\ 776 .format_args = "i4i4i4i4i4", \ 778 TCP_DECLARE_ETD(_tc, _e, 5); \ 779 ed->data[0] = _tc->snd_una - _tc->iss; \ 780 ed->data[1] = _tc->cwnd; \ 781 ed->data[2] = _tc->snd_wnd; \ 782 ed->data[3] = tcp_flight_size(_tc); \ 783 ed->data[4] = _tc->rcv_wnd; \ 786 #define TCP_EVT_CC_PACK_HANDLER(_tc, ...) \ 788 ELOG_TYPE_DECLARE (_e) = \ 790 .format = "pack: snd_una %u snd_una_max %u", \ 791 .format_args = "i4i4", \ 793 TCP_DECLARE_ETD(_tc, _e, 2); \ 794 ed->data[0] = _tc->snd_una - _tc->iss; \ 795 ed->data[1] = _tc->snd_una_max - _tc->iss; \ 797 #define TCP_EVT_CC_SCOREBOARD_HANDLER(_tc, ...) \ 799 if (TCP_DEBUG_CC > 1 && _tc->sack_sb.last_sacked_bytes) \ 801 ELOG_TYPE_DECLARE (_e) = \ 803 .format = "sb1: holes %u lost %u sacked %u high %u highrxt %u", \ 804 .format_args = "i4i4i4i4i4", \ 806 TCP_DECLARE_ETD(_tc, _e, 5); \ 807 ed->data[0] = pool_elts(_tc->sack_sb.holes); \ 808 ed->data[1] = _tc->sack_sb.lost_bytes; \ 809 ed->data[2] = _tc->sack_sb.sacked_bytes; \ 810 ed->data[3] = _tc->sack_sb.high_sacked - _tc->iss; \ 811 ed->data[4] = _tc->sack_sb.high_rxt - _tc->iss; \ 813 if (TCP_DEBUG_CC > 1 && _tc->sack_sb.last_sacked_bytes) \ 815 sack_scoreboard_hole_t *hole; \ 816 hole = scoreboard_first_hole (&_tc->sack_sb); \ 817 ELOG_TYPE_DECLARE (_e) = \ 819 .format = "sb2: first start: %u end %u last start %u end %u", \ 820 .format_args = "i4i4i4i4", \ 822 TCP_DECLARE_ETD(_tc, _e, 4); \ 823 ed->data[0] = hole ? hole->start - _tc->iss : 0; \ 824 ed->data[1] = hole ? hole->end - _tc->iss : 0; \ 825 hole = scoreboard_last_hole (&_tc->sack_sb); \ 826 ed->data[2] = hole ? hole->start - _tc->iss : 0; \ 827 ed->data[3] = hole ? hole->end - _tc->iss : 0; \ 830 #define TCP_EVT_CC_SACKS_HANDLER(_tc, ...) \ 832 if (TCP_DEBUG_CC > 1) \ 834 ELOG_TYPE_DECLARE (_e) = \ 836 .format = "sacks: blocks %u bytes %u", \ 837 .format_args = "i4i4", \ 839 TCP_DECLARE_ETD(_tc, _e, 2); \ 840 ed->data[0] = vec_len (_tc->snd_sacks); \ 841 ed->data[1] = tcp_sack_list_bytes (_tc); \ 844 #define TCP_EVT_CC_INPUT_HANDLER(_tc, _len, _written, ...) \ 846 ELOG_TYPE_DECLARE (_e) = \ 848 .format = "cc input: len %u written %d rcv_nxt %u rcv_wnd(o) %d", \ 849 .format_args = "i4i4i4i4", \ 851 TCP_DECLARE_ETD(_tc, _e, 4); \ 852 ed->data[0] = _len; \ 853 ed->data[1] = _written; \ 854 ed->data[2] = _tc->rcv_nxt - _tc->irs; \ 855 ed->data[3] = _tc->rcv_wnd - (_tc->rcv_nxt - _tc->rcv_las); \ 858 #define TCP_EVT_CC_RTX_HANDLER(_tc, offset, n_bytes, ...) 859 #define TCP_EVT_DUPACK_SENT_HANDLER(_tc, _btcp, ...) 860 #define TCP_EVT_DUPACK_RCVD_HANDLER(_tc, ...) 861 #define TCP_EVT_CC_PACK_HANDLER(_tc, ...) 862 #define TCP_EVT_CC_SCOREBOARD_HANDLER(_tc, ...) 863 #define TCP_EVT_CC_SACKS_HANDLER(_tc, ...) 864 #define TCP_EVT_CC_INPUT_HANDLER(_tc, _len, _written, ...) 870 #if TCP_DEBUG_CS || TCP_DEBUG_ALWAYS 872 #define STATS_INTERVAL 1 874 #define tcp_cc_time_to_print_stats(_tc) \ 875 _tc->c_cc_stat_tstamp + STATS_INTERVAL < tcp_time_now() \ 876 || tcp_in_fastrecovery (_tc) \ 878 #define TCP_EVT_CC_RTO_STAT_PRINT(_tc) \ 880 ELOG_TYPE_DECLARE (_e) = \ 882 .format = "rcv_stat: rto %u srtt %u mrtt-us %u rttvar %u", \ 883 .format_args = "i4i4i4i4", \ 885 TCP_DECLARE_ETD(_tc, _e, 4); \ 886 ed->data[0] = _tc->rto; \ 887 ed->data[1] = _tc->srtt; \ 888 ed->data[2] = (u32) (_tc->mrtt_us * 1e6); \ 889 ed->data[3] = _tc->rttvar; \ 892 #define TCP_EVT_CC_RTO_STAT_HANDLER(_tc, ...) \ 894 if (tcp_cc_time_to_print_stats (_tc)) \ 896 TCP_EVT_CC_RTO_STAT_PRINT (_tc); \ 897 _tc->c_cc_stat_tstamp = tcp_time_now (); \ 901 #define TCP_EVT_CC_SND_STAT_PRINT(_tc) \ 903 ELOG_TYPE_DECLARE (_e) = \ 905 .format = "snd_stat: cc_space %u sacked %u lost %u out %u rxt %u", \ 906 .format_args = "i4i4i4i4i4", \ 908 TCP_DECLARE_ETD(_tc, _e, 5); \ 909 ed->data[0] = tcp_available_cc_snd_space (_tc); \ 910 ed->data[1] = _tc->sack_sb.sacked_bytes; \ 911 ed->data[2] = _tc->sack_sb.lost_bytes; \ 912 ed->data[3] = tcp_bytes_out (_tc); \ 913 ed->data[3] = _tc->snd_rxt_bytes; \ 916 #define TCP_EVT_CC_SND_STAT_HANDLER(_tc, ...) \ 918 if (tcp_cc_time_to_print_stats (_tc)) \ 920 TCP_EVT_CC_SND_STAT_PRINT(_tc); \ 921 _tc->c_cc_stat_tstamp = tcp_time_now (); \ 925 #define TCP_EVT_CC_STAT_PRINT(_tc) \ 927 ELOG_TYPE_DECLARE (_e) = \ 929 .format = "cc_stat: cwnd %u flight %u space %u ssthresh %u snd_wnd %u",\ 930 .format_args = "i4i4i4i4i4", \ 932 TCP_DECLARE_ETD(_tc, _e, 5); \ 933 ed->data[0] = _tc->cwnd; \ 934 ed->data[1] = tcp_flight_size (_tc); \ 935 ed->data[2] = tcp_snd_space (_tc); \ 936 ed->data[3] = _tc->ssthresh; \ 937 ed->data[4] = _tc->snd_wnd; \ 938 TCP_EVT_CC_RTO_STAT_PRINT (_tc); \ 939 TCP_EVT_CC_SND_STAT_PRINT (_tc); \ 942 #define TCP_EVT_CC_STAT_HANDLER(_tc, ...) \ 944 if (tcp_cc_time_to_print_stats (_tc)) \ 946 TCP_EVT_CC_STAT_PRINT (_tc); \ 947 _tc->c_cc_stat_tstamp = tcp_time_now(); \ 951 #define TCP_EVT_CC_STAT_HANDLER(_tc, ...) 952 #define TCP_EVT_CC_STAT_PRINT(_tc) 958 #if TCP_DEBUG_BUF_ALLOC 960 #define TCP_DBG_BUFFER_ALLOC_MAYBE_FAIL(thread_index) \ 962 static u32 *buffer_fail_counters; \ 963 if (PREDICT_FALSE (buffer_fail_counters == 0)) \ 966 vlib_thread_main_t *vtm = vlib_get_thread_main (); \ 967 num_threads = 1 + vtm->n_threads; \ 968 vec_validate (buffer_fail_counters, num_threads - 1); \ 970 if (PREDICT_FALSE (tcp_cfg.buffer_fail_fraction != 0.0)) \ 972 if (PREDICT_TRUE (buffer_fail_counters[thread_index] > 0)) \ 974 if ((1.0 / (f32) (buffer_fail_counters[thread_index])) \ 975 < tcp_cfg.buffer_fail_fraction) \ 977 buffer_fail_counters[thread_index] = 0.0000001; \ 981 buffer_fail_counters[thread_index] ++; \ 985 #define TCP_DBG_BUFFER_ALLOC_MAYBE_FAIL(thread_index)
enum tcp_evt_lvl_ tcp_evt_lvl_e
#define foreach_tcp_evt_grp
u8 grp_dbg_lvl[TCP_EVT_N_GRP]
void tcp_evt_track_register(elog_track_t *et)
tcp_dbg_main_t tcp_dbg_main
enum tcp_evt_to_grp_ tcp_evt_to_grp_e
void tcp_debug_init(void)
struct tcp_dbg_main_ tcp_dbg_main_t
enum tcp_evt_types_ tcp_evt_types_e
#define foreach_tcp_dbg_evt
enum tcp_evt_grp_ tcp_evt_grp_e