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