Florin Coras | e69f495 | 2017-03-07 10:06:24 -0800 | [diff] [blame] | 1 | /* |
Florin Coras | 6416e62 | 2019-04-03 17:52:43 -0700 | [diff] [blame] | 2 | * Copyright (c) 2017-2019 Cisco and/or its affiliates. |
Florin Coras | e69f495 | 2017-03-07 10:06:24 -0800 | [diff] [blame] | 3 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | * you may not use this file except in compliance with the License. |
| 5 | * You may obtain a copy of the License at: |
| 6 | * |
| 7 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | * |
| 9 | * Unless required by applicable law or agreed to in writing, software |
| 10 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | * See the License for the specific language governing permissions and |
| 13 | * limitations under the License. |
| 14 | */ |
| 15 | |
| 16 | #ifndef SRC_VNET_TCP_TCP_DEBUG_H_ |
| 17 | #define SRC_VNET_TCP_TCP_DEBUG_H_ |
| 18 | |
| 19 | #include <vlib/vlib.h> |
Steven Luong | 23b33ec | 2022-10-07 13:53:20 -0700 | [diff] [blame] | 20 | #include <vpp/vnet/config.h> |
Florin Coras | e69f495 | 2017-03-07 10:06:24 -0800 | [diff] [blame] | 21 | |
Florin Coras | a436a42 | 2019-08-20 07:09:31 -0700 | [diff] [blame] | 22 | /** |
| 23 | * Build debugging infra unconditionally. Debug components controlled via |
| 24 | * debug configuration. Comes with some overhead so it's not recommended for |
| 25 | * production/performance scenarios. Takes priority over TCP_DEBUG_ENABLE. |
| 26 | */ |
Steven Luong | 8d97a5c | 2022-10-06 16:48:24 -0700 | [diff] [blame] | 27 | #ifdef VPP_TCP_DEBUG_ALWAYS |
| 28 | #define TCP_DEBUG_ALWAYS (1) |
| 29 | #else |
Florin Coras | a436a42 | 2019-08-20 07:09:31 -0700 | [diff] [blame] | 30 | #define TCP_DEBUG_ALWAYS (0) |
Steven Luong | 8d97a5c | 2022-10-06 16:48:24 -0700 | [diff] [blame] | 31 | #endif |
Florin Coras | a436a42 | 2019-08-20 07:09:31 -0700 | [diff] [blame] | 32 | /** |
| 33 | * Build debugging infra only if enabled. Debug components controlled via |
| 34 | * macros that follow. |
| 35 | */ |
| 36 | #define TCP_DEBUG_ENABLE (0) |
| 37 | |
Florin Coras | 2f8d8fa | 2018-01-26 06:36:04 -0800 | [diff] [blame] | 38 | #define TCP_DEBUG_SM (0) |
Florin Coras | e5c57d7 | 2019-03-19 19:36:07 -0700 | [diff] [blame] | 39 | #define TCP_DEBUG_CC (0) |
Florin Coras | a436a42 | 2019-08-20 07:09:31 -0700 | [diff] [blame] | 40 | #define TCP_DEBUG_CS (0) |
| 41 | #define TCP_DEBUG_LC (0 || TCP_DEBUG_SM || TCP_DEBUG_CC || TCP_DEBUG_CS) |
Florin Coras | e69f495 | 2017-03-07 10:06:24 -0800 | [diff] [blame] | 42 | |
Florin Coras | a436a42 | 2019-08-20 07:09:31 -0700 | [diff] [blame] | 43 | #define TCP_DEBUG (TCP_DEBUG_ALWAYS || TCP_DEBUG_ENABLE) |
| 44 | #define TCP_DEBUG_BUF_ALLOC (0) |
Florin Coras | e69f495 | 2017-03-07 10:06:24 -0800 | [diff] [blame] | 45 | |
Florin Coras | a436a42 | 2019-08-20 07:09:31 -0700 | [diff] [blame] | 46 | #if TCP_DEBUG > 0 |
Florin Coras | e69f495 | 2017-03-07 10:06:24 -0800 | [diff] [blame] | 47 | #define TRANSPORT_DEBUG (1) |
Florin Coras | a436a42 | 2019-08-20 07:09:31 -0700 | [diff] [blame] | 48 | #endif |
| 49 | |
| 50 | #define TCP_CONCAT_HELPER(_a, _b) _a##_b |
| 51 | #define TCP_CC(_a, _b) TCP_CONCAT_HELPER(_a, _b) |
| 52 | |
| 53 | #define tcp_evt_lvl(_evt) TCP_CC(_evt, _LVL) |
| 54 | #define tcp_evt_grp(_evt) TCP_CC(_evt, _GRP) |
| 55 | #define tcp_evt_handler(_evt, _args...) TCP_CC(_evt, _HANDLER) (_args) |
| 56 | #define tcp_evt_grp_dbg_lvl(_evt) tcp_dbg_main.grp_dbg_lvl[tcp_evt_grp (_evt)] |
| 57 | |
| 58 | #define foreach_tcp_evt_grp \ |
| 59 | _(LC, "life cycle") \ |
| 60 | _(SM, "state machine") \ |
| 61 | _(CC, "congestion control") \ |
| 62 | _(CS, "cc stats") \ |
| 63 | |
| 64 | typedef enum tcp_evt_grp_ |
| 65 | { |
| 66 | #define _(sym, str) TCP_EVT_GRP_ ## sym, |
| 67 | foreach_tcp_evt_grp |
| 68 | #undef _ |
| 69 | TCP_EVT_N_GRP |
| 70 | } tcp_evt_grp_e; |
| 71 | |
| 72 | typedef struct tcp_dbg_main_ |
| 73 | { |
| 74 | u8 grp_dbg_lvl[TCP_EVT_N_GRP]; |
| 75 | u32 *free_track_indices; |
| 76 | } tcp_dbg_main_t; |
| 77 | |
| 78 | extern tcp_dbg_main_t tcp_dbg_main; |
| 79 | |
| 80 | #define foreach_tcp_dbg_evt \ |
| 81 | _(INIT, LC, 1, "init") \ |
| 82 | _(DEALLOC, LC, 1, "dealloc") \ |
| 83 | _(OPEN, LC, 1, "open") \ |
| 84 | _(CLOSE, LC, 1, "close") \ |
| 85 | _(BIND, LC, 1, "bind") \ |
| 86 | _(UNBIND, LC, 1, "unbind") \ |
| 87 | _(DELETE, LC, 1, "delete") \ |
| 88 | _(SYN_RCVD, LC, 1, "SYN rcvd") \ |
| 89 | _(STATE_CHANGE, LC, 1, "state change") \ |
| 90 | _(SYN_SENT, SM, 1, "SYN sent") \ |
| 91 | _(SYN_RXT, SM, 1, "SYN retransmit") \ |
| 92 | _(SYNACK_SENT, SM, 1, "SYNACK sent") \ |
| 93 | _(SYNACK_RCVD, SM, 1, "SYNACK rcvd") \ |
| 94 | _(FIN_SENT, SM, 1, "FIN sent") \ |
| 95 | _(FIN_RCVD, SM, 1, "FIN rcvd") \ |
| 96 | _(RST_SENT, SM, 1, "RST sent") \ |
| 97 | _(RST_RCVD, SM, 1, "RST rcvd") \ |
| 98 | _(TIMER_POP, SM, 1, "timer pop") \ |
| 99 | _(SEG_INVALID, SM, 2, "invalid segment") \ |
| 100 | _(PAWS_FAIL, SM, 2, "failed paws check") \ |
| 101 | _(ACK_RCV_ERR, SM, 2, "invalid ack") \ |
| 102 | _(RCV_WND_SHRUNK, SM, 2, "shrunk rcv_wnd") \ |
| 103 | _(ACK_SENT, SM, 3, "ACK sent") \ |
| 104 | _(ACK_RCVD, SM, 3, "ACK rcvd") \ |
| 105 | _(PKTIZE, SM, 3, "packetize") \ |
| 106 | _(INPUT, SM, 3, "in") \ |
| 107 | _(OUTPUT, SM, 4, "output") \ |
| 108 | _(SND_WND, SM, 4, "snd_wnd update") \ |
| 109 | _(CC_EVT, CC, 1, "cc event") \ |
| 110 | _(CC_RTX, CC, 2, "retransmit") \ |
| 111 | _(CC_PACK, CC, 2, "cc partial ack") \ |
| 112 | _(DUPACK_SENT, CC, 2, "DUPACK sent") \ |
| 113 | _(DUPACK_RCVD, CC, 2, "DUPACK rcvd") \ |
| 114 | _(CC_SCOREBOARD, CC, 2, "scoreboard stats") \ |
| 115 | _(CC_SACKS, CC, 2, "snd sacks stats") \ |
| 116 | _(CC_INPUT, CC, 2, "ooo data delivered") \ |
| 117 | _(CC_STAT, CS, 1, "cc stats") \ |
| 118 | _(CC_RTO_STAT, CS, 1, "cc rto stats") \ |
| 119 | |
| 120 | typedef enum tcp_evt_types_ |
| 121 | { |
| 122 | #define _(sym, grp, lvl, str) TCP_EVT_##sym, |
| 123 | foreach_tcp_dbg_evt |
| 124 | #undef _ |
| 125 | } tcp_evt_types_e; |
| 126 | |
| 127 | typedef enum tcp_evt_lvl_ |
| 128 | { |
| 129 | #define _(sym, grp, lvl, str) TCP_EVT_## sym ## _LVL = lvl, |
| 130 | foreach_tcp_dbg_evt |
| 131 | #undef _ |
| 132 | } tcp_evt_lvl_e; |
| 133 | |
| 134 | typedef enum tcp_evt_to_grp_ |
| 135 | { |
| 136 | #define _(sym, grp, lvl, str) TCP_EVT_ ## sym ## _GRP = TCP_EVT_GRP_ ## grp, |
| 137 | foreach_tcp_dbg_evt |
| 138 | #undef _ |
| 139 | } tcp_evt_to_grp_e; |
| 140 | |
| 141 | #if TCP_DEBUG_ALWAYS > 0 |
| 142 | #define TCP_EVT(_evt, _args...) \ |
| 143 | if (PREDICT_FALSE (tcp_evt_grp_dbg_lvl (_evt) >= tcp_evt_lvl (_evt))) \ |
| 144 | tcp_evt_handler (_evt, _args) |
| 145 | #define TCP_DBG(_fmt, _args...) clib_warning (_fmt, ##_args) |
| 146 | #elif TCP_DEBUG_ENABLE > 0 |
| 147 | #define TCP_EVT(_evt, _args...) tcp_evt_handler(_evt, _args) |
| 148 | #define TCP_DBG(_fmt, _args...) clib_warning (_fmt, ##_args) |
| 149 | #else |
| 150 | #define TCP_EVT(_evt, _args...) |
| 151 | #define TCP_DBG(_fmt, _args...) |
| 152 | #endif |
| 153 | |
| 154 | void tcp_evt_track_register (elog_track_t * et); |
| 155 | void tcp_debug_init (void); |
| 156 | |
| 157 | #define TCP_DECLARE_ETD(_tc, _e, _size) \ |
| 158 | struct \ |
| 159 | { \ |
| 160 | u32 data[_size]; \ |
| 161 | } * ed; \ |
| 162 | ed = ELOG_TRACK_DATA (&vlib_global_main.elog_main, _e, \ |
| 163 | _tc->c_elog_track) \ |
| 164 | |
| 165 | /* |
| 166 | * Event handlers definitions |
| 167 | */ |
| 168 | |
| 169 | #if TCP_DEBUG_LC || TCP_DEBUG_ALWAYS |
Florin Coras | e69f495 | 2017-03-07 10:06:24 -0800 | [diff] [blame] | 170 | |
Florin Coras | f03a59a | 2017-06-09 21:07:32 -0700 | [diff] [blame] | 171 | /* |
| 172 | * Infra and evt track setup |
| 173 | */ |
| 174 | |
Florin Coras | 6534b7a | 2017-07-18 05:38:03 -0400 | [diff] [blame] | 175 | #define TCP_DBG_IP_TAG_LCL(_tc) \ |
Florin Coras | e69f495 | 2017-03-07 10:06:24 -0800 | [diff] [blame] | 176 | { \ |
Florin Coras | 6534b7a | 2017-07-18 05:38:03 -0400 | [diff] [blame] | 177 | if (_tc->c_is_ip4) \ |
| 178 | { \ |
| 179 | ELOG_TYPE_DECLARE (_e) = \ |
| 180 | { \ |
| 181 | .format = "lcl: %d.%d.%d.%d:%d", \ |
| 182 | .format_args = "i4i4i4i4i4", \ |
| 183 | }; \ |
Florin Coras | a436a42 | 2019-08-20 07:09:31 -0700 | [diff] [blame] | 184 | TCP_DECLARE_ETD(_tc, _e, 5); \ |
Florin Coras | 6534b7a | 2017-07-18 05:38:03 -0400 | [diff] [blame] | 185 | ed->data[0] = _tc->c_lcl_ip.ip4.as_u8[0]; \ |
| 186 | ed->data[1] = _tc->c_lcl_ip.ip4.as_u8[1]; \ |
| 187 | ed->data[2] = _tc->c_lcl_ip.ip4.as_u8[2]; \ |
| 188 | ed->data[3] = _tc->c_lcl_ip.ip4.as_u8[3]; \ |
| 189 | ed->data[4] = clib_net_to_host_u16(_tc->c_lcl_port); \ |
| 190 | } \ |
| 191 | } |
| 192 | |
| 193 | #define TCP_DBG_IP_TAG_RMT(_tc) \ |
| 194 | { \ |
| 195 | if (_tc->c_is_ip4) \ |
| 196 | { \ |
| 197 | ELOG_TYPE_DECLARE (_e) = \ |
| 198 | { \ |
| 199 | .format = "rmt: %d.%d.%d.%d:%d", \ |
| 200 | .format_args = "i4i4i4i4i4", \ |
| 201 | }; \ |
Florin Coras | a436a42 | 2019-08-20 07:09:31 -0700 | [diff] [blame] | 202 | TCP_DECLARE_ETD(_tc, _e, 5); \ |
Florin Coras | 6534b7a | 2017-07-18 05:38:03 -0400 | [diff] [blame] | 203 | ed->data[0] = _tc->c_rmt_ip.ip4.as_u8[0]; \ |
| 204 | ed->data[1] = _tc->c_rmt_ip.ip4.as_u8[1]; \ |
| 205 | ed->data[2] = _tc->c_rmt_ip.ip4.as_u8[2]; \ |
| 206 | ed->data[3] = _tc->c_rmt_ip.ip4.as_u8[3]; \ |
| 207 | ed->data[4] = clib_net_to_host_u16(_tc->c_rmt_port); \ |
| 208 | } \ |
| 209 | } |
| 210 | |
| 211 | #define TCP_EVT_INIT_HANDLER(_tc, _is_l, ...) \ |
| 212 | { \ |
| 213 | char *_fmt = _is_l ? "l[%d].%d:%d%c" : "[%d].%d:%d->.%d:%d%c"; \ |
| 214 | if (_tc->c_is_ip4) \ |
| 215 | { \ |
| 216 | _tc->c_elog_track.name = \ |
| 217 | (char *) format (0, _fmt, _tc->c_thread_index, \ |
| 218 | _tc->c_lcl_ip.ip4.as_u8[3], \ |
| 219 | clib_net_to_host_u16(_tc->c_lcl_port), \ |
| 220 | _tc->c_rmt_ip.ip4.as_u8[3], \ |
| 221 | clib_net_to_host_u16(_tc->c_rmt_port), 0); \ |
| 222 | } \ |
| 223 | else \ |
| 224 | _tc->c_elog_track.name = \ |
| 225 | (char *) format (0, _fmt, _tc->c_thread_index, \ |
| 226 | _tc->c_lcl_ip.ip6.as_u8[15], \ |
| 227 | clib_net_to_host_u16(_tc->c_lcl_port), \ |
| 228 | _tc->c_rmt_ip.ip6.as_u8[15], \ |
| 229 | clib_net_to_host_u16(_tc->c_rmt_port), 0); \ |
Florin Coras | a436a42 | 2019-08-20 07:09:31 -0700 | [diff] [blame] | 230 | tcp_evt_track_register (&_tc->c_elog_track); \ |
Florin Coras | 6534b7a | 2017-07-18 05:38:03 -0400 | [diff] [blame] | 231 | TCP_DBG_IP_TAG_LCL(_tc); \ |
| 232 | TCP_DBG_IP_TAG_RMT(_tc); \ |
Florin Coras | e69f495 | 2017-03-07 10:06:24 -0800 | [diff] [blame] | 233 | } |
| 234 | |
| 235 | #define TCP_EVT_DEALLOC_HANDLER(_tc, ...) \ |
| 236 | { \ |
| 237 | vec_free (_tc->c_elog_track.name); \ |
Florin Coras | a436a42 | 2019-08-20 07:09:31 -0700 | [diff] [blame] | 238 | vec_add1 (tcp_dbg_main.free_track_indices, \ |
| 239 | _tc->c_elog_track.track_index_plus_one - 1); \ |
Florin Coras | e69f495 | 2017-03-07 10:06:24 -0800 | [diff] [blame] | 240 | } |
| 241 | |
| 242 | #define TCP_EVT_OPEN_HANDLER(_tc, ...) \ |
| 243 | { \ |
Florin Coras | 6534b7a | 2017-07-18 05:38:03 -0400 | [diff] [blame] | 244 | TCP_EVT_INIT_HANDLER(_tc, 0); \ |
Florin Coras | e69f495 | 2017-03-07 10:06:24 -0800 | [diff] [blame] | 245 | ELOG_TYPE_DECLARE (_e) = \ |
| 246 | { \ |
| 247 | .format = "open: index %d", \ |
| 248 | .format_args = "i4", \ |
| 249 | }; \ |
Florin Coras | a436a42 | 2019-08-20 07:09:31 -0700 | [diff] [blame] | 250 | TCP_DECLARE_ETD(_tc, _e, 1); \ |
Florin Coras | e69f495 | 2017-03-07 10:06:24 -0800 | [diff] [blame] | 251 | ed->data[0] = _tc->c_c_index; \ |
| 252 | } |
| 253 | |
| 254 | #define TCP_EVT_CLOSE_HANDLER(_tc, ...) \ |
| 255 | { \ |
| 256 | ELOG_TYPE_DECLARE (_e) = \ |
| 257 | { \ |
Florin Coras | 6416e62 | 2019-04-03 17:52:43 -0700 | [diff] [blame] | 258 | .format = "close: cidx %d", \ |
Florin Coras | e69f495 | 2017-03-07 10:06:24 -0800 | [diff] [blame] | 259 | .format_args = "i4", \ |
| 260 | }; \ |
Florin Coras | a436a42 | 2019-08-20 07:09:31 -0700 | [diff] [blame] | 261 | TCP_DECLARE_ETD(_tc, _e, 1); \ |
Florin Coras | e69f495 | 2017-03-07 10:06:24 -0800 | [diff] [blame] | 262 | ed->data[0] = _tc->c_c_index; \ |
| 263 | } |
| 264 | |
| 265 | #define TCP_EVT_BIND_HANDLER(_tc, ...) \ |
| 266 | { \ |
Florin Coras | 6534b7a | 2017-07-18 05:38:03 -0400 | [diff] [blame] | 267 | TCP_EVT_INIT_HANDLER(_tc, 1); \ |
Florin Coras | e69f495 | 2017-03-07 10:06:24 -0800 | [diff] [blame] | 268 | ELOG_TYPE_DECLARE (_e) = \ |
| 269 | { \ |
| 270 | .format = "bind: listener %d", \ |
| 271 | }; \ |
Florin Coras | a436a42 | 2019-08-20 07:09:31 -0700 | [diff] [blame] | 272 | TCP_DECLARE_ETD(_tc, _e, 1); \ |
Florin Coras | e69f495 | 2017-03-07 10:06:24 -0800 | [diff] [blame] | 273 | ed->data[0] = _tc->c_c_index; \ |
| 274 | } |
| 275 | |
Florin Coras | ca1c8f3 | 2018-05-23 21:01:30 -0700 | [diff] [blame] | 276 | #define TCP_EVT_SYN_RCVD_HANDLER(_tc,_init, ...) \ |
Florin Coras | 6881062 | 2017-07-24 17:40:28 -0700 | [diff] [blame] | 277 | { \ |
Florin Coras | 4eeeaaf | 2017-09-05 14:03:37 -0400 | [diff] [blame] | 278 | if (_init) \ |
| 279 | TCP_EVT_INIT_HANDLER(_tc, 0); \ |
Florin Coras | 6881062 | 2017-07-24 17:40:28 -0700 | [diff] [blame] | 280 | ELOG_TYPE_DECLARE (_e) = \ |
| 281 | { \ |
Florin Coras | 6416e62 | 2019-04-03 17:52:43 -0700 | [diff] [blame] | 282 | .format = "syn-rx: cidx %u sidx %u irs %u", \ |
| 283 | .format_args = "i4i4i4", \ |
Florin Coras | 6881062 | 2017-07-24 17:40:28 -0700 | [diff] [blame] | 284 | }; \ |
Florin Coras | a436a42 | 2019-08-20 07:09:31 -0700 | [diff] [blame] | 285 | TCP_DECLARE_ETD(_tc, _e, 3); \ |
Florin Coras | 070fd4b | 2019-04-02 19:03:23 -0700 | [diff] [blame] | 286 | ed->data[0] = _tc->c_c_index; \ |
Florin Coras | 6416e62 | 2019-04-03 17:52:43 -0700 | [diff] [blame] | 287 | ed->data[1] = _tc->c_s_index; \ |
| 288 | ed->data[2] = _tc->irs; \ |
Florin Coras | 6881062 | 2017-07-24 17:40:28 -0700 | [diff] [blame] | 289 | TCP_EVT_STATE_CHANGE_HANDLER(_tc); \ |
| 290 | } |
| 291 | |
Florin Coras | e69f495 | 2017-03-07 10:06:24 -0800 | [diff] [blame] | 292 | #define TCP_EVT_UNBIND_HANDLER(_tc, ...) \ |
| 293 | { \ |
| 294 | TCP_EVT_DEALLOC_HANDLER(_tc); \ |
| 295 | ELOG_TYPE_DECLARE (_e) = \ |
| 296 | { \ |
| 297 | .format = "unbind: listener %d", \ |
| 298 | }; \ |
Florin Coras | a436a42 | 2019-08-20 07:09:31 -0700 | [diff] [blame] | 299 | TCP_DECLARE_ETD(_tc, _e, 1); \ |
Florin Coras | e69f495 | 2017-03-07 10:06:24 -0800 | [diff] [blame] | 300 | ed->data[0] = _tc->c_c_index; \ |
| 301 | TCP_EVT_DEALLOC_HANDLER(_tc); \ |
| 302 | } |
| 303 | |
| 304 | #define TCP_EVT_DELETE_HANDLER(_tc, ...) \ |
| 305 | { \ |
| 306 | ELOG_TYPE_DECLARE (_e) = \ |
| 307 | { \ |
Florin Coras | 6416e62 | 2019-04-03 17:52:43 -0700 | [diff] [blame] | 308 | .format = "delete: cidx %d sidx %d", \ |
| 309 | .format_args = "i4i4", \ |
Florin Coras | e69f495 | 2017-03-07 10:06:24 -0800 | [diff] [blame] | 310 | }; \ |
Florin Coras | a436a42 | 2019-08-20 07:09:31 -0700 | [diff] [blame] | 311 | TCP_DECLARE_ETD(_tc, _e, 2); \ |
Florin Coras | e69f495 | 2017-03-07 10:06:24 -0800 | [diff] [blame] | 312 | ed->data[0] = _tc->c_c_index; \ |
Florin Coras | 6416e62 | 2019-04-03 17:52:43 -0700 | [diff] [blame] | 313 | ed->data[1] = _tc->c_s_index; \ |
Florin Coras | e69f495 | 2017-03-07 10:06:24 -0800 | [diff] [blame] | 314 | TCP_EVT_DEALLOC_HANDLER(_tc); \ |
| 315 | } |
| 316 | |
Florin Coras | f03a59a | 2017-06-09 21:07:32 -0700 | [diff] [blame] | 317 | #endif |
| 318 | |
| 319 | /* |
| 320 | * State machine |
| 321 | */ |
Florin Coras | a436a42 | 2019-08-20 07:09:31 -0700 | [diff] [blame] | 322 | #if TCP_DEBUG_SM > 0 || TCP_DEBUG_ALWAYS |
Florin Coras | f03a59a | 2017-06-09 21:07:32 -0700 | [diff] [blame] | 323 | |
Florin Coras | 6534b7a | 2017-07-18 05:38:03 -0400 | [diff] [blame] | 324 | #define TCP_EVT_STATE_CHANGE_HANDLER(_tc, ...) \ |
| 325 | { \ |
| 326 | ELOG_TYPE_DECLARE (_e) = \ |
| 327 | { \ |
| 328 | .format = "state: %s", \ |
| 329 | .format_args = "t4", \ |
| 330 | .n_enum_strings = 11, \ |
| 331 | .enum_strings = { \ |
| 332 | "closed", \ |
| 333 | "listen", \ |
| 334 | "syn-sent", \ |
| 335 | "syn-rcvd", \ |
| 336 | "established", \ |
| 337 | "close_wait", \ |
| 338 | "fin-wait-1", \ |
| 339 | "last-ack", \ |
| 340 | "closing", \ |
| 341 | "fin-wait-2", \ |
| 342 | "time-wait", \ |
| 343 | }, \ |
| 344 | }; \ |
Florin Coras | a436a42 | 2019-08-20 07:09:31 -0700 | [diff] [blame] | 345 | TCP_DECLARE_ETD(_tc, _e, 1); \ |
Florin Coras | 6534b7a | 2017-07-18 05:38:03 -0400 | [diff] [blame] | 346 | ed->data[0] = _tc->state; \ |
| 347 | } |
| 348 | |
Florin Coras | 6534b7a | 2017-07-18 05:38:03 -0400 | [diff] [blame] | 349 | #define TCP_EVT_SYN_SENT_HANDLER(_tc, ...) \ |
| 350 | { \ |
| 351 | ELOG_TYPE_DECLARE (_e) = \ |
| 352 | { \ |
Florin Coras | 9404a07 | 2020-11-24 17:29:17 -0800 | [diff] [blame] | 353 | .format = "syn-tx: iss %u snd_una %u snd_nxt %u", \ |
| 354 | .format_args = "i4i4i4", \ |
Florin Coras | 6534b7a | 2017-07-18 05:38:03 -0400 | [diff] [blame] | 355 | }; \ |
Florin Coras | 9404a07 | 2020-11-24 17:29:17 -0800 | [diff] [blame] | 356 | TCP_DECLARE_ETD(_tc, _e, 3); \ |
Florin Coras | 6534b7a | 2017-07-18 05:38:03 -0400 | [diff] [blame] | 357 | ed->data[0] = _tc->iss; \ |
Florin Coras | ca1c8f3 | 2018-05-23 21:01:30 -0700 | [diff] [blame] | 358 | ed->data[1] = _tc->snd_una - _tc->iss; \ |
Florin Coras | 9404a07 | 2020-11-24 17:29:17 -0800 | [diff] [blame] | 359 | ed->data[2] = _tc->snd_nxt - _tc->iss; \ |
Florin Coras | 6534b7a | 2017-07-18 05:38:03 -0400 | [diff] [blame] | 360 | TCP_EVT_STATE_CHANGE_HANDLER(_tc); \ |
| 361 | } |
| 362 | |
| 363 | #define TCP_EVT_SYNACK_SENT_HANDLER(_tc, ...) \ |
| 364 | { \ |
| 365 | ELOG_TYPE_DECLARE (_e) = \ |
| 366 | { \ |
Florin Coras | 4eeeaaf | 2017-09-05 14:03:37 -0400 | [diff] [blame] | 367 | .format = "synack-tx: iss %u irs %u snd_una %u snd_nxt %u rcv_nxt %u",\ |
Florin Coras | ca1c8f3 | 2018-05-23 21:01:30 -0700 | [diff] [blame] | 368 | .format_args = "i4i4i4i4i4", \ |
Florin Coras | 6534b7a | 2017-07-18 05:38:03 -0400 | [diff] [blame] | 369 | }; \ |
Florin Coras | a436a42 | 2019-08-20 07:09:31 -0700 | [diff] [blame] | 370 | TCP_DECLARE_ETD(_tc, _e, 5); \ |
Florin Coras | 6534b7a | 2017-07-18 05:38:03 -0400 | [diff] [blame] | 371 | ed->data[0] = _tc->iss; \ |
| 372 | ed->data[1] = _tc->irs; \ |
Florin Coras | ca1c8f3 | 2018-05-23 21:01:30 -0700 | [diff] [blame] | 373 | ed->data[2] = _tc->snd_una - _tc->iss; \ |
| 374 | ed->data[3] = _tc->snd_nxt - _tc->iss; \ |
| 375 | ed->data[4] = _tc->rcv_nxt - _tc->irs; \ |
Florin Coras | 6534b7a | 2017-07-18 05:38:03 -0400 | [diff] [blame] | 376 | } |
| 377 | |
| 378 | #define TCP_EVT_SYNACK_RCVD_HANDLER(_tc, ...) \ |
| 379 | { \ |
| 380 | ELOG_TYPE_DECLARE (_e) = \ |
| 381 | { \ |
Florin Coras | 4eeeaaf | 2017-09-05 14:03:37 -0400 | [diff] [blame] | 382 | .format = "synack-rx: iss %u irs %u snd_una %u snd_nxt %u rcv_nxt %u",\ |
Florin Coras | ca1c8f3 | 2018-05-23 21:01:30 -0700 | [diff] [blame] | 383 | .format_args = "i4i4i4i4i4", \ |
Florin Coras | 6534b7a | 2017-07-18 05:38:03 -0400 | [diff] [blame] | 384 | }; \ |
Florin Coras | a436a42 | 2019-08-20 07:09:31 -0700 | [diff] [blame] | 385 | TCP_DECLARE_ETD(_tc, _e, 5); \ |
Florin Coras | 6534b7a | 2017-07-18 05:38:03 -0400 | [diff] [blame] | 386 | ed->data[0] = _tc->iss; \ |
| 387 | ed->data[1] = _tc->irs; \ |
Florin Coras | ca1c8f3 | 2018-05-23 21:01:30 -0700 | [diff] [blame] | 388 | ed->data[2] = _tc->snd_una - _tc->iss; \ |
| 389 | ed->data[3] = _tc->snd_nxt - _tc->iss; \ |
| 390 | ed->data[4] = _tc->rcv_nxt - _tc->irs; \ |
Florin Coras | 6534b7a | 2017-07-18 05:38:03 -0400 | [diff] [blame] | 391 | TCP_EVT_STATE_CHANGE_HANDLER(_tc); \ |
| 392 | } |
| 393 | |
| 394 | #define TCP_EVT_FIN_SENT_HANDLER(_tc, ...) \ |
| 395 | { \ |
| 396 | ELOG_TYPE_DECLARE (_e) = \ |
| 397 | { \ |
| 398 | .format = "fin-tx: snd_nxt %d rcv_nxt %d", \ |
| 399 | .format_args = "i4i4", \ |
| 400 | }; \ |
Florin Coras | a436a42 | 2019-08-20 07:09:31 -0700 | [diff] [blame] | 401 | TCP_DECLARE_ETD(_tc, _e, 2); \ |
Florin Coras | 6534b7a | 2017-07-18 05:38:03 -0400 | [diff] [blame] | 402 | ed->data[0] = _tc->snd_nxt - _tc->iss; \ |
| 403 | ed->data[1] = _tc->rcv_nxt - _tc->irs; \ |
| 404 | } |
| 405 | |
| 406 | #define TCP_EVT_RST_SENT_HANDLER(_tc, ...) \ |
| 407 | { \ |
Florin Coras | fc804d9 | 2018-01-26 01:27:01 -0800 | [diff] [blame] | 408 | if (_tc) \ |
Florin Coras | 6534b7a | 2017-07-18 05:38:03 -0400 | [diff] [blame] | 409 | { \ |
Florin Coras | fc804d9 | 2018-01-26 01:27:01 -0800 | [diff] [blame] | 410 | ELOG_TYPE_DECLARE (_e) = \ |
| 411 | { \ |
| 412 | .format = "rst-tx: snd_nxt %d rcv_nxt %d", \ |
| 413 | .format_args = "i4i4", \ |
| 414 | }; \ |
Florin Coras | a436a42 | 2019-08-20 07:09:31 -0700 | [diff] [blame] | 415 | TCP_DECLARE_ETD(_tc, _e, 2); \ |
Florin Coras | fc804d9 | 2018-01-26 01:27:01 -0800 | [diff] [blame] | 416 | ed->data[0] = _tc->snd_nxt - _tc->iss; \ |
| 417 | ed->data[1] = _tc->rcv_nxt - _tc->irs; \ |
| 418 | TCP_EVT_STATE_CHANGE_HANDLER(_tc); \ |
| 419 | } \ |
Florin Coras | 6534b7a | 2017-07-18 05:38:03 -0400 | [diff] [blame] | 420 | } |
| 421 | |
| 422 | #define TCP_EVT_FIN_RCVD_HANDLER(_tc, ...) \ |
| 423 | { \ |
| 424 | ELOG_TYPE_DECLARE (_e) = \ |
| 425 | { \ |
| 426 | .format = "fin-rx: snd_nxt %d rcv_nxt %d", \ |
| 427 | .format_args = "i4i4", \ |
| 428 | }; \ |
Florin Coras | a436a42 | 2019-08-20 07:09:31 -0700 | [diff] [blame] | 429 | TCP_DECLARE_ETD(_tc, _e, 2); \ |
Florin Coras | 6534b7a | 2017-07-18 05:38:03 -0400 | [diff] [blame] | 430 | ed->data[0] = _tc->snd_nxt - _tc->iss; \ |
| 431 | ed->data[1] = _tc->rcv_nxt - _tc->irs; \ |
| 432 | } |
| 433 | |
| 434 | #define TCP_EVT_RST_RCVD_HANDLER(_tc, ...) \ |
| 435 | { \ |
| 436 | ELOG_TYPE_DECLARE (_e) = \ |
| 437 | { \ |
| 438 | .format = "rst-rx: snd_nxt %d rcv_nxt %d", \ |
| 439 | .format_args = "i4i4", \ |
| 440 | }; \ |
Florin Coras | a436a42 | 2019-08-20 07:09:31 -0700 | [diff] [blame] | 441 | TCP_DECLARE_ETD(_tc, _e, 2); \ |
Florin Coras | 6534b7a | 2017-07-18 05:38:03 -0400 | [diff] [blame] | 442 | ed->data[0] = _tc->snd_nxt - _tc->iss; \ |
| 443 | ed->data[1] = _tc->rcv_nxt - _tc->irs; \ |
| 444 | } |
| 445 | |
| 446 | #define TCP_EVT_SYN_RXT_HANDLER(_tc, _type, ...) \ |
| 447 | { \ |
| 448 | ELOG_TYPE_DECLARE (_e) = \ |
| 449 | { \ |
Florin Coras | 4eeeaaf | 2017-09-05 14:03:37 -0400 | [diff] [blame] | 450 | .format = "%s-rxt: iss %u irs %u snd_nxt %u rcv_nxt %u", \ |
Florin Coras | ca1c8f3 | 2018-05-23 21:01:30 -0700 | [diff] [blame] | 451 | .format_args = "t4i4i4i4i4", \ |
Florin Coras | 6534b7a | 2017-07-18 05:38:03 -0400 | [diff] [blame] | 452 | .n_enum_strings = 2, \ |
| 453 | .enum_strings = { \ |
| 454 | "syn", \ |
Florin Coras | 6416e62 | 2019-04-03 17:52:43 -0700 | [diff] [blame] | 455 | "synack", \ |
Florin Coras | 6534b7a | 2017-07-18 05:38:03 -0400 | [diff] [blame] | 456 | }, \ |
| 457 | }; \ |
Florin Coras | a436a42 | 2019-08-20 07:09:31 -0700 | [diff] [blame] | 458 | TCP_DECLARE_ETD(_tc, _e, 5); \ |
Florin Coras | 6534b7a | 2017-07-18 05:38:03 -0400 | [diff] [blame] | 459 | ed->data[0] = _type; \ |
| 460 | ed->data[1] = _tc->iss; \ |
Florin Coras | 4eeeaaf | 2017-09-05 14:03:37 -0400 | [diff] [blame] | 461 | ed->data[2] = _tc->irs; \ |
Florin Coras | ca1c8f3 | 2018-05-23 21:01:30 -0700 | [diff] [blame] | 462 | ed->data[3] = _tc->snd_nxt - _tc->iss; \ |
| 463 | ed->data[4] = _tc->rcv_nxt - _tc->irs; \ |
Florin Coras | 6534b7a | 2017-07-18 05:38:03 -0400 | [diff] [blame] | 464 | } |
Florin Coras | 85a3ddd | 2018-12-24 16:54:34 -0800 | [diff] [blame] | 465 | |
| 466 | #define TCP_EVT_TIMER_POP_HANDLER(_tc_index, _timer_id, ...) \ |
| 467 | { \ |
| 468 | tcp_connection_t *_tc; \ |
Florin Coras | a436a42 | 2019-08-20 07:09:31 -0700 | [diff] [blame] | 469 | if (_timer_id == TCP_TIMER_RETRANSMIT_SYN) \ |
Florin Coras | 85a3ddd | 2018-12-24 16:54:34 -0800 | [diff] [blame] | 470 | { \ |
| 471 | _tc = tcp_half_open_connection_get (_tc_index); \ |
| 472 | } \ |
| 473 | else \ |
| 474 | { \ |
| 475 | u32 _thread_index = vlib_get_thread_index (); \ |
| 476 | _tc = tcp_connection_get (_tc_index, _thread_index); \ |
| 477 | } \ |
| 478 | ELOG_TYPE_DECLARE (_e) = \ |
| 479 | { \ |
Florin Coras | 6416e62 | 2019-04-03 17:52:43 -0700 | [diff] [blame] | 480 | .format = "timer-pop: %s cidx %u sidx %u", \ |
| 481 | .format_args = "t4i4i4", \ |
Florin Coras | 85a3ddd | 2018-12-24 16:54:34 -0800 | [diff] [blame] | 482 | .n_enum_strings = 8, \ |
| 483 | .enum_strings = { \ |
| 484 | "retransmit", \ |
| 485 | "delack", \ |
| 486 | "persist", \ |
| 487 | "keep", \ |
| 488 | "waitclose", \ |
| 489 | "retransmit syn", \ |
| 490 | "establish", \ |
| 491 | "establish-ao", \ |
| 492 | }, \ |
| 493 | }; \ |
| 494 | if (_tc) \ |
| 495 | { \ |
Florin Coras | a436a42 | 2019-08-20 07:09:31 -0700 | [diff] [blame] | 496 | TCP_DECLARE_ETD(_tc, _e, 3); \ |
Florin Coras | 85a3ddd | 2018-12-24 16:54:34 -0800 | [diff] [blame] | 497 | ed->data[0] = _timer_id; \ |
Florin Coras | 6416e62 | 2019-04-03 17:52:43 -0700 | [diff] [blame] | 498 | ed->data[1] = _tc->c_c_index; \ |
| 499 | ed->data[2] = _tc->c_s_index; \ |
Florin Coras | 85a3ddd | 2018-12-24 16:54:34 -0800 | [diff] [blame] | 500 | } \ |
| 501 | else \ |
| 502 | { \ |
| 503 | clib_warning ("pop %d for unexisting connection %d", _timer_id, \ |
| 504 | _tc_index); \ |
| 505 | } \ |
| 506 | } |
| 507 | |
Florin Coras | 6534b7a | 2017-07-18 05:38:03 -0400 | [diff] [blame] | 508 | #else |
| 509 | #define TCP_EVT_SYN_SENT_HANDLER(_tc, ...) |
| 510 | #define TCP_EVT_SYNACK_SENT_HANDLER(_tc, ...) |
| 511 | #define TCP_EVT_SYNACK_RCVD_HANDLER(_tc, ...) |
| 512 | #define TCP_EVT_SYN_RXT_HANDLER(_tc, ...) |
| 513 | #define TCP_EVT_FIN_SENT_HANDLER(_tc, ...) |
| 514 | #define TCP_EVT_RST_SENT_HANDLER(_tc, ...) |
| 515 | #define TCP_EVT_FIN_RCVD_HANDLER(_tc, ...) |
| 516 | #define TCP_EVT_RST_RCVD_HANDLER(_tc, ...) |
| 517 | #define TCP_EVT_STATE_CHANGE_HANDLER(_tc, ...) |
Florin Coras | 85a3ddd | 2018-12-24 16:54:34 -0800 | [diff] [blame] | 518 | #define TCP_EVT_TIMER_POP_HANDLER(_tc_index, _timer_id, ...) |
Florin Coras | 6534b7a | 2017-07-18 05:38:03 -0400 | [diff] [blame] | 519 | #endif |
| 520 | |
Florin Coras | a436a42 | 2019-08-20 07:09:31 -0700 | [diff] [blame] | 521 | #if TCP_DEBUG_SM > 1 || TCP_DEBUG_ALWAYS |
Florin Coras | ca1c8f3 | 2018-05-23 21:01:30 -0700 | [diff] [blame] | 522 | #define TCP_EVT_SEG_INVALID_HANDLER(_tc, _btcp, ...) \ |
| 523 | { \ |
| 524 | ELOG_TYPE_DECLARE (_e) = \ |
| 525 | { \ |
| 526 | .format = "seg-inv: seq %u end %u rcv_las %u rcv_nxt %u rcv_wnd %u",\ |
| 527 | .format_args = "i4i4i4i4i4", \ |
| 528 | }; \ |
Florin Coras | a436a42 | 2019-08-20 07:09:31 -0700 | [diff] [blame] | 529 | TCP_DECLARE_ETD(_tc, _e, 5); \ |
Florin Coras | ca1c8f3 | 2018-05-23 21:01:30 -0700 | [diff] [blame] | 530 | ed->data[0] = _btcp.seq_number - _tc->irs; \ |
| 531 | ed->data[1] = _btcp.seq_end - _tc->irs; \ |
| 532 | ed->data[2] = _tc->rcv_las - _tc->irs; \ |
| 533 | ed->data[3] = _tc->rcv_nxt - _tc->irs; \ |
| 534 | ed->data[4] = _tc->rcv_wnd; \ |
| 535 | } |
| 536 | |
| 537 | #define TCP_EVT_PAWS_FAIL_HANDLER(_tc, _seq, _end, ...) \ |
| 538 | { \ |
| 539 | ELOG_TYPE_DECLARE (_e) = \ |
| 540 | { \ |
| 541 | .format = "paws-err: seq %u end %u tsval %u tsval_recent %u", \ |
| 542 | .format_args = "i4i4i4i4", \ |
| 543 | }; \ |
Florin Coras | a436a42 | 2019-08-20 07:09:31 -0700 | [diff] [blame] | 544 | TCP_DECLARE_ETD(_tc, _e, 4); \ |
Florin Coras | ca1c8f3 | 2018-05-23 21:01:30 -0700 | [diff] [blame] | 545 | ed->data[0] = _seq - _tc->irs; \ |
| 546 | ed->data[1] = _end - _tc->irs; \ |
| 547 | ed->data[2] = _tc->rcv_opts.tsval; \ |
| 548 | ed->data[3] = _tc->tsval_recent; \ |
| 549 | } |
| 550 | |
| 551 | #define TCP_EVT_ACK_RCV_ERR_HANDLER(_tc, _type, _ack, ...) \ |
| 552 | { \ |
| 553 | ELOG_TYPE_DECLARE (_e) = \ |
| 554 | { \ |
Florin Coras | 9404a07 | 2020-11-24 17:29:17 -0800 | [diff] [blame] | 555 | .format = "ack-err: %s ack %u snd_una %u snd_nxt %u", \ |
| 556 | .format_args = "t4i4i4i4", \ |
Florin Coras | ca1c8f3 | 2018-05-23 21:01:30 -0700 | [diff] [blame] | 557 | .n_enum_strings = 3, \ |
| 558 | .enum_strings = { \ |
| 559 | "invalid", \ |
| 560 | "old", \ |
| 561 | "future", \ |
| 562 | }, \ |
| 563 | }; \ |
Florin Coras | 9404a07 | 2020-11-24 17:29:17 -0800 | [diff] [blame] | 564 | TCP_DECLARE_ETD(_tc, _e, 4); \ |
Florin Coras | ca1c8f3 | 2018-05-23 21:01:30 -0700 | [diff] [blame] | 565 | ed->data[0] = _type; \ |
| 566 | ed->data[1] = _ack - _tc->iss; \ |
| 567 | ed->data[2] = _tc->snd_una - _tc->iss; \ |
| 568 | ed->data[3] = _tc->snd_nxt - _tc->iss; \ |
Florin Coras | ca1c8f3 | 2018-05-23 21:01:30 -0700 | [diff] [blame] | 569 | } |
| 570 | |
| 571 | #define TCP_EVT_RCV_WND_SHRUNK_HANDLER(_tc, _obs, _av, ...) \ |
| 572 | { \ |
| 573 | if (_av > 0) \ |
| 574 | { \ |
| 575 | ELOG_TYPE_DECLARE (_e) = \ |
| 576 | { \ |
| 577 | .format = "huh?: rcv_wnd %u obsd %u av %u rcv_nxt %u rcv_las %u", \ |
| 578 | .format_args = "i4i4i4i4i4", \ |
| 579 | }; \ |
Florin Coras | a436a42 | 2019-08-20 07:09:31 -0700 | [diff] [blame] | 580 | TCP_DECLARE_ETD(_tc, _e, 5); \ |
Florin Coras | ca1c8f3 | 2018-05-23 21:01:30 -0700 | [diff] [blame] | 581 | ed->data[0] = _tc->rcv_wnd; \ |
| 582 | ed->data[1] = _obs; \ |
| 583 | ed->data[2] = _av; \ |
| 584 | ed->data[3] = _tc->rcv_nxt - _tc->irs; \ |
| 585 | ed->data[4] = _tc->rcv_las - _tc->irs; \ |
| 586 | } \ |
| 587 | } |
| 588 | #else |
| 589 | #define TCP_EVT_SEG_INVALID_HANDLER(_tc, _btcp, ...) |
| 590 | #define TCP_EVT_PAWS_FAIL_HANDLER(_tc, _seq, _end, ...) |
| 591 | #define TCP_EVT_ACK_RCV_ERR_HANDLER(_tc, _type, _ack, ...) |
| 592 | #define TCP_EVT_RCV_WND_SHRUNK_HANDLER(_tc, _obs, _av, ...) |
| 593 | #endif |
| 594 | |
Florin Coras | a436a42 | 2019-08-20 07:09:31 -0700 | [diff] [blame] | 595 | #if TCP_DEBUG_SM > 2 || TCP_DEBUG_ALWAYS |
Florin Coras | 6534b7a | 2017-07-18 05:38:03 -0400 | [diff] [blame] | 596 | |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 597 | #define TCP_EVT_ACK_SENT_HANDLER(_tc, ...) \ |
| 598 | { \ |
| 599 | ELOG_TYPE_DECLARE (_e) = \ |
| 600 | { \ |
Florin Coras | 6534b7a | 2017-07-18 05:38:03 -0400 | [diff] [blame] | 601 | .format = "ack-tx: acked %u rcv_nxt %u rcv_wnd %u snd_nxt %u snd_wnd %u",\ |
Florin Coras | 3e350af | 2017-03-30 02:54:28 -0700 | [diff] [blame] | 602 | .format_args = "i4i4i4i4i4", \ |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 603 | }; \ |
Florin Coras | a436a42 | 2019-08-20 07:09:31 -0700 | [diff] [blame] | 604 | TCP_DECLARE_ETD(_tc, _e, 5); \ |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 605 | ed->data[0] = _tc->rcv_nxt - _tc->rcv_las; \ |
| 606 | ed->data[1] = _tc->rcv_nxt - _tc->irs; \ |
| 607 | ed->data[2] = _tc->rcv_wnd; \ |
| 608 | ed->data[3] = _tc->snd_nxt - _tc->iss; \ |
Florin Coras | 3e350af | 2017-03-30 02:54:28 -0700 | [diff] [blame] | 609 | ed->data[4] = _tc->snd_wnd; \ |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 610 | } |
| 611 | |
Florin Coras | 3e350af | 2017-03-30 02:54:28 -0700 | [diff] [blame] | 612 | #define TCP_EVT_ACK_RCVD_HANDLER(_tc, ...) \ |
Florin Coras | e69f495 | 2017-03-07 10:06:24 -0800 | [diff] [blame] | 613 | { \ |
| 614 | ELOG_TYPE_DECLARE (_e) = \ |
| 615 | { \ |
Florin Coras | 4eeeaaf | 2017-09-05 14:03:37 -0400 | [diff] [blame] | 616 | .format = "ack-rx: %u snd_una %u snd_wnd %u cwnd %u inflight %u", \ |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 617 | .format_args = "i4i4i4i4i4", \ |
Florin Coras | e69f495 | 2017-03-07 10:06:24 -0800 | [diff] [blame] | 618 | }; \ |
Florin Coras | a436a42 | 2019-08-20 07:09:31 -0700 | [diff] [blame] | 619 | TCP_DECLARE_ETD(_tc, _e, 5); \ |
Florin Coras | e69f495 | 2017-03-07 10:06:24 -0800 | [diff] [blame] | 620 | ed->data[0] = _tc->bytes_acked; \ |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 621 | ed->data[1] = _tc->snd_una - _tc->iss; \ |
Florin Coras | 3e350af | 2017-03-30 02:54:28 -0700 | [diff] [blame] | 622 | ed->data[2] = _tc->snd_wnd; \ |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 623 | ed->data[3] = _tc->cwnd; \ |
| 624 | ed->data[4] = tcp_flight_size(_tc); \ |
| 625 | } |
| 626 | |
Florin Coras | e69f495 | 2017-03-07 10:06:24 -0800 | [diff] [blame] | 627 | #define TCP_EVT_PKTIZE_HANDLER(_tc, ...) \ |
| 628 | { \ |
| 629 | ELOG_TYPE_DECLARE (_e) = \ |
| 630 | { \ |
Florin Coras | 4eeeaaf | 2017-09-05 14:03:37 -0400 | [diff] [blame] | 631 | .format = "tx: una %u snd_nxt %u space %u flight %u rcv_wnd %u",\ |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 632 | .format_args = "i4i4i4i4i4", \ |
Florin Coras | e69f495 | 2017-03-07 10:06:24 -0800 | [diff] [blame] | 633 | }; \ |
Florin Coras | a436a42 | 2019-08-20 07:09:31 -0700 | [diff] [blame] | 634 | TCP_DECLARE_ETD(_tc, _e, 5); \ |
Florin Coras | e69f495 | 2017-03-07 10:06:24 -0800 | [diff] [blame] | 635 | ed->data[0] = _tc->snd_una - _tc->iss; \ |
| 636 | ed->data[1] = _tc->snd_nxt - _tc->iss; \ |
Florin Coras | 4eeeaaf | 2017-09-05 14:03:37 -0400 | [diff] [blame] | 637 | ed->data[2] = tcp_available_output_snd_space (_tc); \ |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 638 | ed->data[3] = tcp_flight_size (_tc); \ |
| 639 | ed->data[4] = _tc->rcv_wnd; \ |
Florin Coras | e69f495 | 2017-03-07 10:06:24 -0800 | [diff] [blame] | 640 | } |
| 641 | |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 642 | #define TCP_EVT_INPUT_HANDLER(_tc, _type, _len, _written, ...) \ |
Florin Coras | e69f495 | 2017-03-07 10:06:24 -0800 | [diff] [blame] | 643 | { \ |
| 644 | ELOG_TYPE_DECLARE (_e) = \ |
| 645 | { \ |
Florin Coras | 3e350af | 2017-03-30 02:54:28 -0700 | [diff] [blame] | 646 | .format = "in: %s len %u written %d rcv_nxt %u rcv_wnd(o) %d", \ |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 647 | .format_args = "t4i4i4i4i4", \ |
| 648 | .n_enum_strings = 2, \ |
| 649 | .enum_strings = { \ |
| 650 | "order", \ |
| 651 | "ooo", \ |
| 652 | }, \ |
Florin Coras | e69f495 | 2017-03-07 10:06:24 -0800 | [diff] [blame] | 653 | }; \ |
Florin Coras | a436a42 | 2019-08-20 07:09:31 -0700 | [diff] [blame] | 654 | TCP_DECLARE_ETD(_tc, _e, 5); \ |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 655 | ed->data[0] = _type; \ |
| 656 | ed->data[1] = _len; \ |
| 657 | ed->data[2] = _written; \ |
| 658 | ed->data[3] = (_tc->rcv_nxt - _tc->irs) + _written; \ |
| 659 | ed->data[4] = _tc->rcv_wnd - (_tc->rcv_nxt - _tc->rcv_las); \ |
Florin Coras | e69f495 | 2017-03-07 10:06:24 -0800 | [diff] [blame] | 660 | } |
| 661 | |
Florin Coras | f03a59a | 2017-06-09 21:07:32 -0700 | [diff] [blame] | 662 | #else |
| 663 | #define TCP_EVT_ACK_SENT_HANDLER(_tc, ...) |
Florin Coras | f03a59a | 2017-06-09 21:07:32 -0700 | [diff] [blame] | 664 | #define TCP_EVT_ACK_RCVD_HANDLER(_tc, ...) |
Florin Coras | f03a59a | 2017-06-09 21:07:32 -0700 | [diff] [blame] | 665 | #define TCP_EVT_PKTIZE_HANDLER(_tc, ...) |
| 666 | #define TCP_EVT_INPUT_HANDLER(_tc, _type, _len, _written, ...) |
Florin Coras | f03a59a | 2017-06-09 21:07:32 -0700 | [diff] [blame] | 667 | #endif |
| 668 | |
| 669 | /* |
| 670 | * State machine verbose |
| 671 | */ |
Florin Coras | a436a42 | 2019-08-20 07:09:31 -0700 | [diff] [blame] | 672 | #if TCP_DEBUG_SM > 3 || TCP_DEBUG_ALWAYS |
Florin Coras | f03a59a | 2017-06-09 21:07:32 -0700 | [diff] [blame] | 673 | #define TCP_EVT_SND_WND_HANDLER(_tc, ...) \ |
| 674 | { \ |
| 675 | ELOG_TYPE_DECLARE (_e) = \ |
| 676 | { \ |
Florin Coras | 6534b7a | 2017-07-18 05:38:03 -0400 | [diff] [blame] | 677 | .format = "snd-wnd update: %u ", \ |
Florin Coras | f03a59a | 2017-06-09 21:07:32 -0700 | [diff] [blame] | 678 | .format_args = "i4", \ |
| 679 | }; \ |
Florin Coras | a436a42 | 2019-08-20 07:09:31 -0700 | [diff] [blame] | 680 | TCP_DECLARE_ETD(_tc, _e, 1); \ |
Florin Coras | f03a59a | 2017-06-09 21:07:32 -0700 | [diff] [blame] | 681 | ed->data[0] = _tc->snd_wnd; \ |
| 682 | } |
| 683 | |
| 684 | #define TCP_EVT_OUTPUT_HANDLER(_tc, flags, n_bytes,...) \ |
| 685 | { \ |
| 686 | ELOG_TYPE_DECLARE (_e) = \ |
| 687 | { \ |
| 688 | .format = "out: flags %x, bytes %u", \ |
| 689 | .format_args = "i4i4", \ |
| 690 | }; \ |
Florin Coras | a436a42 | 2019-08-20 07:09:31 -0700 | [diff] [blame] | 691 | TCP_DECLARE_ETD(_tc, _e, 2); \ |
Florin Coras | f03a59a | 2017-06-09 21:07:32 -0700 | [diff] [blame] | 692 | ed->data[0] = flags; \ |
| 693 | ed->data[1] = n_bytes; \ |
| 694 | } |
| 695 | #else |
| 696 | #define TCP_EVT_SND_WND_HANDLER(_tc, ...) |
| 697 | #define TCP_EVT_OUTPUT_HANDLER(_tc, flags, n_bytes,...) |
| 698 | #endif |
| 699 | |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 700 | /* |
| 701 | * Congestion Control |
| 702 | */ |
| 703 | |
Florin Coras | a436a42 | 2019-08-20 07:09:31 -0700 | [diff] [blame] | 704 | #if TCP_DEBUG_CC || TCP_DEBUG_ALWAYS |
Florin Coras | f1762d6 | 2017-09-24 19:43:08 -0400 | [diff] [blame] | 705 | |
Florin Coras | e55a6d7 | 2018-10-31 23:09:22 -0700 | [diff] [blame] | 706 | #define TCP_EVT_CC_EVT_PRINT(_tc, _sub_evt) \ |
Florin Coras | f1762d6 | 2017-09-24 19:43:08 -0400 | [diff] [blame] | 707 | { \ |
| 708 | ELOG_TYPE_DECLARE (_e) = \ |
| 709 | { \ |
Florin Coras | ca1c8f3 | 2018-05-23 21:01:30 -0700 | [diff] [blame] | 710 | .format = "cc: %s snd_space %u snd_una %u out %u flight %u", \ |
| 711 | .format_args = "t4i4i4i4i4", \ |
| 712 | .n_enum_strings = 7, \ |
Florin Coras | f1762d6 | 2017-09-24 19:43:08 -0400 | [diff] [blame] | 713 | .enum_strings = { \ |
| 714 | "fast-rxt", \ |
Florin Coras | f1762d6 | 2017-09-24 19:43:08 -0400 | [diff] [blame] | 715 | "first-rxt", \ |
Florin Coras | e55a6d7 | 2018-10-31 23:09:22 -0700 | [diff] [blame] | 716 | "rxt-timeout", \ |
Florin Coras | f1762d6 | 2017-09-24 19:43:08 -0400 | [diff] [blame] | 717 | "recovered", \ |
| 718 | "congestion", \ |
| 719 | "undo", \ |
Florin Coras | ca1c8f3 | 2018-05-23 21:01:30 -0700 | [diff] [blame] | 720 | "recovery", \ |
Florin Coras | f1762d6 | 2017-09-24 19:43:08 -0400 | [diff] [blame] | 721 | }, \ |
| 722 | }; \ |
Florin Coras | a436a42 | 2019-08-20 07:09:31 -0700 | [diff] [blame] | 723 | TCP_DECLARE_ETD(_tc, _e, 5); \ |
Florin Coras | f1762d6 | 2017-09-24 19:43:08 -0400 | [diff] [blame] | 724 | ed->data[0] = _sub_evt; \ |
Florin Coras | ca1c8f3 | 2018-05-23 21:01:30 -0700 | [diff] [blame] | 725 | ed->data[1] = tcp_available_cc_snd_space (_tc); \ |
| 726 | ed->data[2] = _tc->snd_una - _tc->iss; \ |
| 727 | ed->data[3] = tcp_bytes_out(_tc); \ |
| 728 | ed->data[4] = tcp_flight_size (_tc); \ |
Florin Coras | f1762d6 | 2017-09-24 19:43:08 -0400 | [diff] [blame] | 729 | } |
Florin Coras | e55a6d7 | 2018-10-31 23:09:22 -0700 | [diff] [blame] | 730 | |
| 731 | #define TCP_EVT_CC_EVT_HANDLER(_tc, _sub_evt, ...) \ |
| 732 | { \ |
| 733 | if (_tc->snd_una != _tc->iss) \ |
| 734 | TCP_EVT_CC_STAT_PRINT (_tc); \ |
| 735 | if ((_sub_evt <= 1 && TCP_DEBUG_CC > 1) \ |
| 736 | || (_sub_evt > 1 && TCP_DEBUG_CC > 0)) \ |
| 737 | TCP_EVT_CC_EVT_PRINT (_tc, _sub_evt); \ |
| 738 | } |
Florin Coras | 537b17e | 2018-09-28 10:35:45 -0700 | [diff] [blame] | 739 | #else |
Florin Coras | e55a6d7 | 2018-10-31 23:09:22 -0700 | [diff] [blame] | 740 | #define TCP_EVT_CC_EVT_HANDLER(_tc, _sub_evt, ...) \ |
| 741 | |
Florin Coras | 537b17e | 2018-09-28 10:35:45 -0700 | [diff] [blame] | 742 | #endif |
Florin Coras | f1762d6 | 2017-09-24 19:43:08 -0400 | [diff] [blame] | 743 | |
Florin Coras | a436a42 | 2019-08-20 07:09:31 -0700 | [diff] [blame] | 744 | #if TCP_DEBUG_CC > 1 || TCP_DEBUG_ALWAYS |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 745 | #define TCP_EVT_CC_RTX_HANDLER(_tc, offset, n_bytes, ...) \ |
| 746 | { \ |
| 747 | ELOG_TYPE_DECLARE (_e) = \ |
| 748 | { \ |
Florin Coras | 93992a9 | 2017-05-24 18:03:56 -0700 | [diff] [blame] | 749 | .format = "rxt: snd_nxt %u offset %u snd %u rxt %u", \ |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 750 | .format_args = "i4i4i4i4", \ |
| 751 | }; \ |
Florin Coras | a436a42 | 2019-08-20 07:09:31 -0700 | [diff] [blame] | 752 | TCP_DECLARE_ETD(_tc, _e, 4); \ |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 753 | ed->data[0] = _tc->snd_nxt - _tc->iss; \ |
| 754 | ed->data[1] = offset; \ |
| 755 | ed->data[2] = n_bytes; \ |
Florin Coras | 93992a9 | 2017-05-24 18:03:56 -0700 | [diff] [blame] | 756 | ed->data[3] = _tc->snd_rxt_bytes; \ |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 757 | } |
| 758 | |
Florin Coras | ca1c8f3 | 2018-05-23 21:01:30 -0700 | [diff] [blame] | 759 | #define TCP_EVT_DUPACK_SENT_HANDLER(_tc, _btcp, ...) \ |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 760 | { \ |
| 761 | ELOG_TYPE_DECLARE (_e) = \ |
| 762 | { \ |
Florin Coras | ca1c8f3 | 2018-05-23 21:01:30 -0700 | [diff] [blame] | 763 | .format = "dack-tx: rcv_nxt %u seq %u rcv_wnd %u snd_nxt %u av_wnd %u",\ |
Florin Coras | f1762d6 | 2017-09-24 19:43:08 -0400 | [diff] [blame] | 764 | .format_args = "i4i4i4i4i4", \ |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 765 | }; \ |
Florin Coras | a436a42 | 2019-08-20 07:09:31 -0700 | [diff] [blame] | 766 | TCP_DECLARE_ETD(_tc, _e, 5); \ |
Florin Coras | f1762d6 | 2017-09-24 19:43:08 -0400 | [diff] [blame] | 767 | ed->data[0] = _tc->rcv_nxt - _tc->irs; \ |
Florin Coras | ca1c8f3 | 2018-05-23 21:01:30 -0700 | [diff] [blame] | 768 | ed->data[1] = _btcp.seq_number - _tc->irs; \ |
| 769 | ed->data[2] = _tc->rcv_wnd; \ |
| 770 | ed->data[3] = _tc->snd_nxt - _tc->iss; \ |
| 771 | ed->data[4] = tcp_available_snd_wnd(_tc); \ |
Florin Coras | f1762d6 | 2017-09-24 19:43:08 -0400 | [diff] [blame] | 772 | } |
| 773 | |
| 774 | #define TCP_EVT_DUPACK_RCVD_HANDLER(_tc, ...) \ |
| 775 | { \ |
| 776 | ELOG_TYPE_DECLARE (_e) = \ |
| 777 | { \ |
| 778 | .format = "dack-rx: snd_una %u cwnd %u snd_wnd %u flight %u rcv_wnd %u",\ |
| 779 | .format_args = "i4i4i4i4i4", \ |
| 780 | }; \ |
Florin Coras | a436a42 | 2019-08-20 07:09:31 -0700 | [diff] [blame] | 781 | TCP_DECLARE_ETD(_tc, _e, 5); \ |
Florin Coras | f1762d6 | 2017-09-24 19:43:08 -0400 | [diff] [blame] | 782 | ed->data[0] = _tc->snd_una - _tc->iss; \ |
| 783 | ed->data[1] = _tc->cwnd; \ |
| 784 | ed->data[2] = _tc->snd_wnd; \ |
| 785 | ed->data[3] = tcp_flight_size(_tc); \ |
| 786 | ed->data[4] = _tc->rcv_wnd; \ |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 787 | } |
| 788 | |
| 789 | #define TCP_EVT_CC_PACK_HANDLER(_tc, ...) \ |
| 790 | { \ |
| 791 | ELOG_TYPE_DECLARE (_e) = \ |
| 792 | { \ |
Florin Coras | 9404a07 | 2020-11-24 17:29:17 -0800 | [diff] [blame] | 793 | .format = "pack: snd_una %u snd_nxt %u", \ |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 794 | .format_args = "i4i4", \ |
| 795 | }; \ |
Florin Coras | a436a42 | 2019-08-20 07:09:31 -0700 | [diff] [blame] | 796 | TCP_DECLARE_ETD(_tc, _e, 2); \ |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 797 | ed->data[0] = _tc->snd_una - _tc->iss; \ |
Florin Coras | 9404a07 | 2020-11-24 17:29:17 -0800 | [diff] [blame] | 798 | ed->data[1] = _tc->snd_nxt - _tc->iss; \ |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 799 | } |
Florin Coras | ca1c8f3 | 2018-05-23 21:01:30 -0700 | [diff] [blame] | 800 | #define TCP_EVT_CC_SCOREBOARD_HANDLER(_tc, ...) \ |
| 801 | { \ |
| 802 | if (TCP_DEBUG_CC > 1 && _tc->sack_sb.last_sacked_bytes) \ |
| 803 | { \ |
| 804 | ELOG_TYPE_DECLARE (_e) = \ |
| 805 | { \ |
| 806 | .format = "sb1: holes %u lost %u sacked %u high %u highrxt %u", \ |
| 807 | .format_args = "i4i4i4i4i4", \ |
| 808 | }; \ |
Florin Coras | a436a42 | 2019-08-20 07:09:31 -0700 | [diff] [blame] | 809 | TCP_DECLARE_ETD(_tc, _e, 5); \ |
Florin Coras | ca1c8f3 | 2018-05-23 21:01:30 -0700 | [diff] [blame] | 810 | ed->data[0] = pool_elts(_tc->sack_sb.holes); \ |
| 811 | ed->data[1] = _tc->sack_sb.lost_bytes; \ |
| 812 | ed->data[2] = _tc->sack_sb.sacked_bytes; \ |
| 813 | ed->data[3] = _tc->sack_sb.high_sacked - _tc->iss; \ |
| 814 | ed->data[4] = _tc->sack_sb.high_rxt - _tc->iss; \ |
| 815 | } \ |
| 816 | if (TCP_DEBUG_CC > 1 && _tc->sack_sb.last_sacked_bytes) \ |
| 817 | { \ |
| 818 | sack_scoreboard_hole_t *hole; \ |
| 819 | hole = scoreboard_first_hole (&_tc->sack_sb); \ |
| 820 | ELOG_TYPE_DECLARE (_e) = \ |
| 821 | { \ |
| 822 | .format = "sb2: first start: %u end %u last start %u end %u", \ |
| 823 | .format_args = "i4i4i4i4", \ |
| 824 | }; \ |
Florin Coras | a436a42 | 2019-08-20 07:09:31 -0700 | [diff] [blame] | 825 | TCP_DECLARE_ETD(_tc, _e, 4); \ |
Florin Coras | ca1c8f3 | 2018-05-23 21:01:30 -0700 | [diff] [blame] | 826 | ed->data[0] = hole ? hole->start - _tc->iss : 0; \ |
| 827 | ed->data[1] = hole ? hole->end - _tc->iss : 0; \ |
| 828 | hole = scoreboard_last_hole (&_tc->sack_sb); \ |
| 829 | ed->data[2] = hole ? hole->start - _tc->iss : 0; \ |
| 830 | ed->data[3] = hole ? hole->end - _tc->iss : 0; \ |
| 831 | } \ |
| 832 | } |
| 833 | #define TCP_EVT_CC_SACKS_HANDLER(_tc, ...) \ |
| 834 | { \ |
| 835 | if (TCP_DEBUG_CC > 1) \ |
| 836 | { \ |
| 837 | ELOG_TYPE_DECLARE (_e) = \ |
| 838 | { \ |
| 839 | .format = "sacks: blocks %u bytes %u", \ |
| 840 | .format_args = "i4i4", \ |
| 841 | }; \ |
Florin Coras | a436a42 | 2019-08-20 07:09:31 -0700 | [diff] [blame] | 842 | TCP_DECLARE_ETD(_tc, _e, 2); \ |
Florin Coras | ca1c8f3 | 2018-05-23 21:01:30 -0700 | [diff] [blame] | 843 | ed->data[0] = vec_len (_tc->snd_sacks); \ |
| 844 | ed->data[1] = tcp_sack_list_bytes (_tc); \ |
| 845 | } \ |
| 846 | } |
| 847 | #define TCP_EVT_CC_INPUT_HANDLER(_tc, _len, _written, ...) \ |
| 848 | { \ |
| 849 | ELOG_TYPE_DECLARE (_e) = \ |
| 850 | { \ |
| 851 | .format = "cc input: len %u written %d rcv_nxt %u rcv_wnd(o) %d", \ |
| 852 | .format_args = "i4i4i4i4", \ |
| 853 | }; \ |
Florin Coras | a436a42 | 2019-08-20 07:09:31 -0700 | [diff] [blame] | 854 | TCP_DECLARE_ETD(_tc, _e, 4); \ |
Florin Coras | ca1c8f3 | 2018-05-23 21:01:30 -0700 | [diff] [blame] | 855 | ed->data[0] = _len; \ |
| 856 | ed->data[1] = _written; \ |
| 857 | ed->data[2] = _tc->rcv_nxt - _tc->irs; \ |
| 858 | ed->data[3] = _tc->rcv_wnd - (_tc->rcv_nxt - _tc->rcv_las); \ |
| 859 | } |
Florin Coras | f1762d6 | 2017-09-24 19:43:08 -0400 | [diff] [blame] | 860 | #else |
| 861 | #define TCP_EVT_CC_RTX_HANDLER(_tc, offset, n_bytes, ...) |
Florin Coras | ca1c8f3 | 2018-05-23 21:01:30 -0700 | [diff] [blame] | 862 | #define TCP_EVT_DUPACK_SENT_HANDLER(_tc, _btcp, ...) |
Florin Coras | f1762d6 | 2017-09-24 19:43:08 -0400 | [diff] [blame] | 863 | #define TCP_EVT_DUPACK_RCVD_HANDLER(_tc, ...) |
| 864 | #define TCP_EVT_CC_PACK_HANDLER(_tc, ...) |
Florin Coras | ca1c8f3 | 2018-05-23 21:01:30 -0700 | [diff] [blame] | 865 | #define TCP_EVT_CC_SCOREBOARD_HANDLER(_tc, ...) |
| 866 | #define TCP_EVT_CC_SACKS_HANDLER(_tc, ...) |
| 867 | #define TCP_EVT_CC_INPUT_HANDLER(_tc, _len, _written, ...) |
Florin Coras | f1762d6 | 2017-09-24 19:43:08 -0400 | [diff] [blame] | 868 | #endif |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 869 | |
Florin Coras | f03a59a | 2017-06-09 21:07:32 -0700 | [diff] [blame] | 870 | /* |
| 871 | * Congestion control stats |
| 872 | */ |
Florin Coras | a436a42 | 2019-08-20 07:09:31 -0700 | [diff] [blame] | 873 | #if TCP_DEBUG_CS || TCP_DEBUG_ALWAYS |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 874 | |
Steven Luong | 6161bba | 2022-09-29 16:45:23 -0700 | [diff] [blame] | 875 | #define STATS_INTERVAL 0.001 |
Florin Coras | f03a59a | 2017-06-09 21:07:32 -0700 | [diff] [blame] | 876 | |
Steven Luong | 6161bba | 2022-09-29 16:45:23 -0700 | [diff] [blame] | 877 | #define tcp_cc_time_to_print_stats(_tc) \ |
| 878 | _tc->c_cc_stat_tstamp + STATS_INTERVAL < \ |
| 879 | tcp_time_now_us (_tc->c_thread_index) || \ |
| 880 | tcp_in_fastrecovery (_tc) |
Florin Coras | bf4d5ce | 2018-10-19 16:26:24 -0700 | [diff] [blame] | 881 | |
| 882 | #define TCP_EVT_CC_RTO_STAT_PRINT(_tc) \ |
Florin Coras | 3e350af | 2017-03-30 02:54:28 -0700 | [diff] [blame] | 883 | { \ |
| 884 | ELOG_TYPE_DECLARE (_e) = \ |
| 885 | { \ |
Florin Coras | efefc6b | 2018-11-07 12:49:19 -0800 | [diff] [blame] | 886 | .format = "rcv_stat: rto %u srtt %u mrtt-us %u rttvar %u", \ |
| 887 | .format_args = "i4i4i4i4", \ |
Florin Coras | 3e350af | 2017-03-30 02:54:28 -0700 | [diff] [blame] | 888 | }; \ |
Florin Coras | a436a42 | 2019-08-20 07:09:31 -0700 | [diff] [blame] | 889 | TCP_DECLARE_ETD(_tc, _e, 4); \ |
Florin Coras | f03a59a | 2017-06-09 21:07:32 -0700 | [diff] [blame] | 890 | ed->data[0] = _tc->rto; \ |
| 891 | ed->data[1] = _tc->srtt; \ |
Florin Coras | efefc6b | 2018-11-07 12:49:19 -0800 | [diff] [blame] | 892 | ed->data[2] = (u32) (_tc->mrtt_us * 1e6); \ |
| 893 | ed->data[3] = _tc->rttvar; \ |
Florin Coras | bf4d5ce | 2018-10-19 16:26:24 -0700 | [diff] [blame] | 894 | } |
| 895 | |
Steven Luong | 6161bba | 2022-09-29 16:45:23 -0700 | [diff] [blame] | 896 | #define TCP_EVT_CC_RTO_STAT_HANDLER(_tc, ...) \ |
| 897 | { \ |
| 898 | if (tcp_cc_time_to_print_stats (_tc)) \ |
| 899 | { \ |
| 900 | TCP_EVT_CC_RTO_STAT_PRINT (_tc); \ |
| 901 | _tc->c_cc_stat_tstamp = tcp_time_now_us (_tc->c_thread_index); \ |
| 902 | } \ |
| 903 | } |
Florin Coras | bf4d5ce | 2018-10-19 16:26:24 -0700 | [diff] [blame] | 904 | |
| 905 | #define TCP_EVT_CC_SND_STAT_PRINT(_tc) \ |
Florin Coras | 6216600 | 2018-04-18 16:40:55 -0700 | [diff] [blame] | 906 | { \ |
| 907 | ELOG_TYPE_DECLARE (_e) = \ |
| 908 | { \ |
Florin Coras | bf4d5ce | 2018-10-19 16:26:24 -0700 | [diff] [blame] | 909 | .format = "snd_stat: cc_space %u sacked %u lost %u out %u rxt %u", \ |
Florin Coras | 6216600 | 2018-04-18 16:40:55 -0700 | [diff] [blame] | 910 | .format_args = "i4i4i4i4i4", \ |
| 911 | }; \ |
Florin Coras | a436a42 | 2019-08-20 07:09:31 -0700 | [diff] [blame] | 912 | TCP_DECLARE_ETD(_tc, _e, 5); \ |
Florin Coras | bf4d5ce | 2018-10-19 16:26:24 -0700 | [diff] [blame] | 913 | ed->data[0] = tcp_available_cc_snd_space (_tc); \ |
Florin Coras | 6216600 | 2018-04-18 16:40:55 -0700 | [diff] [blame] | 914 | ed->data[1] = _tc->sack_sb.sacked_bytes; \ |
| 915 | ed->data[2] = _tc->sack_sb.lost_bytes; \ |
| 916 | ed->data[3] = tcp_bytes_out (_tc); \ |
| 917 | ed->data[3] = _tc->snd_rxt_bytes; \ |
Florin Coras | bf4d5ce | 2018-10-19 16:26:24 -0700 | [diff] [blame] | 918 | } |
| 919 | |
Steven Luong | 6161bba | 2022-09-29 16:45:23 -0700 | [diff] [blame] | 920 | #define TCP_EVT_CC_SND_STAT_HANDLER(_tc, ...) \ |
| 921 | { \ |
| 922 | if (tcp_cc_time_to_print_stats (_tc)) \ |
| 923 | { \ |
| 924 | TCP_EVT_CC_SND_STAT_PRINT (_tc); \ |
| 925 | _tc->c_cc_stat_tstamp = tcp_time_now_us (_tc->c_thread_index); \ |
| 926 | } \ |
| 927 | } |
Florin Coras | 3e350af | 2017-03-30 02:54:28 -0700 | [diff] [blame] | 928 | |
Florin Coras | bf4d5ce | 2018-10-19 16:26:24 -0700 | [diff] [blame] | 929 | #define TCP_EVT_CC_STAT_PRINT(_tc) \ |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 930 | { \ |
| 931 | ELOG_TYPE_DECLARE (_e) = \ |
| 932 | { \ |
Florin Coras | f03a59a | 2017-06-09 21:07:32 -0700 | [diff] [blame] | 933 | .format = "cc_stat: cwnd %u flight %u space %u ssthresh %u snd_wnd %u",\ |
| 934 | .format_args = "i4i4i4i4i4", \ |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 935 | }; \ |
Florin Coras | a436a42 | 2019-08-20 07:09:31 -0700 | [diff] [blame] | 936 | TCP_DECLARE_ETD(_tc, _e, 5); \ |
Florin Coras | f03a59a | 2017-06-09 21:07:32 -0700 | [diff] [blame] | 937 | ed->data[0] = _tc->cwnd; \ |
| 938 | ed->data[1] = tcp_flight_size (_tc); \ |
| 939 | ed->data[2] = tcp_snd_space (_tc); \ |
| 940 | ed->data[3] = _tc->ssthresh; \ |
| 941 | ed->data[4] = _tc->snd_wnd; \ |
Florin Coras | bf4d5ce | 2018-10-19 16:26:24 -0700 | [diff] [blame] | 942 | TCP_EVT_CC_RTO_STAT_PRINT (_tc); \ |
| 943 | TCP_EVT_CC_SND_STAT_PRINT (_tc); \ |
| 944 | } |
| 945 | |
Steven Luong | 6161bba | 2022-09-29 16:45:23 -0700 | [diff] [blame] | 946 | #define TCP_EVT_CC_STAT_HANDLER(_tc, ...) \ |
| 947 | { \ |
| 948 | if (tcp_cc_time_to_print_stats (_tc)) \ |
| 949 | { \ |
| 950 | TCP_EVT_CC_STAT_PRINT (_tc); \ |
| 951 | _tc->c_cc_stat_tstamp = tcp_time_now_us (_tc->c_thread_index); \ |
| 952 | } \ |
| 953 | } |
Florin Coras | c1a448b | 2018-04-20 10:51:49 -0700 | [diff] [blame] | 954 | #else |
| 955 | #define TCP_EVT_CC_STAT_HANDLER(_tc, ...) |
Florin Coras | 0702554 | 2019-01-19 16:45:13 -0800 | [diff] [blame] | 956 | #define TCP_EVT_CC_STAT_PRINT(_tc) |
Florin Coras | c1a448b | 2018-04-20 10:51:49 -0700 | [diff] [blame] | 957 | #endif |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 958 | |
Florin Coras | f988e69 | 2017-11-27 04:34:14 -0500 | [diff] [blame] | 959 | /* |
| 960 | * Buffer allocation |
| 961 | */ |
Florin Coras | a436a42 | 2019-08-20 07:09:31 -0700 | [diff] [blame] | 962 | #if TCP_DEBUG_BUF_ALLOC |
Florin Coras | f988e69 | 2017-11-27 04:34:14 -0500 | [diff] [blame] | 963 | |
| 964 | #define TCP_DBG_BUFFER_ALLOC_MAYBE_FAIL(thread_index) \ |
| 965 | { \ |
| 966 | static u32 *buffer_fail_counters; \ |
Florin Coras | c1a448b | 2018-04-20 10:51:49 -0700 | [diff] [blame] | 967 | if (PREDICT_FALSE (buffer_fail_counters == 0)) \ |
Florin Coras | f988e69 | 2017-11-27 04:34:14 -0500 | [diff] [blame] | 968 | { \ |
| 969 | u32 num_threads; \ |
Florin Coras | c1a448b | 2018-04-20 10:51:49 -0700 | [diff] [blame] | 970 | vlib_thread_main_t *vtm = vlib_get_thread_main (); \ |
Florin Coras | f988e69 | 2017-11-27 04:34:14 -0500 | [diff] [blame] | 971 | num_threads = 1 /* main thread */ + vtm->n_threads; \ |
| 972 | vec_validate (buffer_fail_counters, num_threads - 1); \ |
| 973 | } \ |
Florin Coras | 9094b5c | 2019-08-12 14:17:47 -0700 | [diff] [blame] | 974 | if (PREDICT_FALSE (tcp_cfg.buffer_fail_fraction != 0.0)) \ |
Florin Coras | f988e69 | 2017-11-27 04:34:14 -0500 | [diff] [blame] | 975 | { \ |
Florin Coras | c1a448b | 2018-04-20 10:51:49 -0700 | [diff] [blame] | 976 | if (PREDICT_TRUE (buffer_fail_counters[thread_index] > 0)) \ |
Florin Coras | f988e69 | 2017-11-27 04:34:14 -0500 | [diff] [blame] | 977 | { \ |
Florin Coras | c1a448b | 2018-04-20 10:51:49 -0700 | [diff] [blame] | 978 | if ((1.0 / (f32) (buffer_fail_counters[thread_index])) \ |
Florin Coras | 9094b5c | 2019-08-12 14:17:47 -0700 | [diff] [blame] | 979 | < tcp_cfg.buffer_fail_fraction) \ |
Florin Coras | f988e69 | 2017-11-27 04:34:14 -0500 | [diff] [blame] | 980 | { \ |
| 981 | buffer_fail_counters[thread_index] = 0.0000001; \ |
Florin Coras | c1a448b | 2018-04-20 10:51:49 -0700 | [diff] [blame] | 982 | return -1; \ |
Florin Coras | f988e69 | 2017-11-27 04:34:14 -0500 | [diff] [blame] | 983 | } \ |
| 984 | } \ |
| 985 | buffer_fail_counters[thread_index] ++; \ |
| 986 | } \ |
| 987 | } |
| 988 | #else |
| 989 | #define TCP_DBG_BUFFER_ALLOC_MAYBE_FAIL(thread_index) |
| 990 | #endif |
| 991 | |
Florin Coras | e69f495 | 2017-03-07 10:06:24 -0800 | [diff] [blame] | 992 | #endif /* SRC_VNET_TCP_TCP_DEBUG_H_ */ |
| 993 | /* |
| 994 | * fd.io coding-style-patch-verification: ON |
| 995 | * |
| 996 | * Local Variables: |
| 997 | * eval: (c-set-style "gnu") |
| 998 | * End: |
| 999 | */ |