Florin Coras | e69f495 | 2017-03-07 10:06:24 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2017 Cisco and/or its affiliates. |
| 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 | |
| 21 | #define TCP_DEBUG (1) |
Florin Coras | 6881062 | 2017-07-24 17:40:28 -0700 | [diff] [blame] | 22 | #define TCP_DEBUG_SM (0) |
| 23 | #define TCP_DEBUG_CC (1) |
| 24 | #define TCP_DEBUG_CC_STAT (1) |
Florin Coras | e69f495 | 2017-03-07 10:06:24 -0800 | [diff] [blame] | 25 | |
| 26 | #define foreach_tcp_dbg_evt \ |
| 27 | _(INIT, "") \ |
| 28 | _(DEALLOC, "") \ |
| 29 | _(OPEN, "open") \ |
| 30 | _(CLOSE, "close") \ |
| 31 | _(BIND, "bind") \ |
| 32 | _(UNBIND, "unbind") \ |
| 33 | _(DELETE, "delete") \ |
| 34 | _(SYN_SENT, "SYN sent") \ |
Florin Coras | 6534b7a | 2017-07-18 05:38:03 -0400 | [diff] [blame] | 35 | _(SYNACK_SENT, "SYNACK sent") \ |
| 36 | _(SYNACK_RCVD, "SYNACK rcvd") \ |
| 37 | _(SYN_RXT, "SYN retransmit") \ |
Florin Coras | e69f495 | 2017-03-07 10:06:24 -0800 | [diff] [blame] | 38 | _(FIN_SENT, "FIN sent") \ |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 39 | _(ACK_SENT, "ACK sent") \ |
| 40 | _(DUPACK_SENT, "DUPACK sent") \ |
Florin Coras | e69f495 | 2017-03-07 10:06:24 -0800 | [diff] [blame] | 41 | _(RST_SENT, "RST sent") \ |
| 42 | _(SYN_RCVD, "SYN rcvd") \ |
| 43 | _(ACK_RCVD, "ACK rcvd") \ |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 44 | _(DUPACK_RCVD, "DUPACK rcvd") \ |
Florin Coras | e69f495 | 2017-03-07 10:06:24 -0800 | [diff] [blame] | 45 | _(FIN_RCVD, "FIN rcvd") \ |
| 46 | _(RST_RCVD, "RST rcvd") \ |
Florin Coras | 6534b7a | 2017-07-18 05:38:03 -0400 | [diff] [blame] | 47 | _(STATE_CHANGE, "state change") \ |
Florin Coras | e69f495 | 2017-03-07 10:06:24 -0800 | [diff] [blame] | 48 | _(PKTIZE, "packetize") \ |
| 49 | _(INPUT, "in") \ |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 50 | _(SND_WND, "snd_wnd update") \ |
| 51 | _(OUTPUT, "output") \ |
| 52 | _(TIMER_POP, "timer pop") \ |
| 53 | _(CC_RTX, "retransmit") \ |
| 54 | _(CC_EVT, "cc event") \ |
| 55 | _(CC_PACK, "cc partial ack") \ |
Florin Coras | f03a59a | 2017-06-09 21:07:32 -0700 | [diff] [blame] | 56 | _(CC_STAT, "cc stats") \ |
| 57 | _(CC_RTO_STAT, "cc rto stats") \ |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 58 | _(SEG_INVALID, "invalid segment") \ |
Florin Coras | c28764f | 2017-04-26 00:08:42 -0700 | [diff] [blame] | 59 | _(PAWS_FAIL, "failed paws check") \ |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 60 | _(ACK_RCV_ERR, "invalid ack") \ |
Florin Coras | 3e350af | 2017-03-30 02:54:28 -0700 | [diff] [blame] | 61 | _(RCV_WND_SHRUNK, "shrunk rcv_wnd") \ |
Florin Coras | e69f495 | 2017-03-07 10:06:24 -0800 | [diff] [blame] | 62 | |
| 63 | typedef enum _tcp_dbg |
| 64 | { |
| 65 | #define _(sym, str) TCP_DBG_##sym, |
| 66 | foreach_tcp_dbg_evt |
| 67 | #undef _ |
| 68 | } tcp_dbg_e; |
| 69 | |
| 70 | typedef enum _tcp_dbg_evt |
| 71 | { |
| 72 | #define _(sym, str) TCP_EVT_##sym, |
| 73 | foreach_tcp_dbg_evt |
| 74 | #undef _ |
| 75 | } tcp_dbg_evt_e; |
| 76 | |
| 77 | #if TCP_DEBUG |
| 78 | |
| 79 | #define TRANSPORT_DEBUG (1) |
| 80 | |
Florin Coras | f03a59a | 2017-06-09 21:07:32 -0700 | [diff] [blame] | 81 | /* |
| 82 | * Infra and evt track setup |
| 83 | */ |
| 84 | |
Florin Coras | e69f495 | 2017-03-07 10:06:24 -0800 | [diff] [blame] | 85 | #define TCP_DBG(_tc, _evt, _args...) \ |
| 86 | { \ |
| 87 | u8 *_tmp = 0; \ |
| 88 | _tmp = format(_tmp, "%U", format_tcp_connection_verbose, _tc); \ |
| 89 | clib_warning("%s", _tmp); \ |
| 90 | vec_free(_tmp); \ |
| 91 | } |
| 92 | |
| 93 | #define DECLARE_ETD(_tc, _e, _size) \ |
| 94 | struct \ |
| 95 | { \ |
| 96 | u32 data[_size]; \ |
| 97 | } * ed; \ |
| 98 | ed = ELOG_TRACK_DATA (&vlib_global_main.elog_main, \ |
| 99 | _e, _tc->c_elog_track) |
| 100 | |
Florin Coras | 6534b7a | 2017-07-18 05:38:03 -0400 | [diff] [blame] | 101 | #define TCP_DBG_IP_TAG_LCL(_tc) \ |
Florin Coras | e69f495 | 2017-03-07 10:06:24 -0800 | [diff] [blame] | 102 | { \ |
Florin Coras | 6534b7a | 2017-07-18 05:38:03 -0400 | [diff] [blame] | 103 | if (_tc->c_is_ip4) \ |
| 104 | { \ |
| 105 | ELOG_TYPE_DECLARE (_e) = \ |
| 106 | { \ |
| 107 | .format = "lcl: %d.%d.%d.%d:%d", \ |
| 108 | .format_args = "i4i4i4i4i4", \ |
| 109 | }; \ |
| 110 | DECLARE_ETD(_tc, _e, 5); \ |
| 111 | ed->data[0] = _tc->c_lcl_ip.ip4.as_u8[0]; \ |
| 112 | ed->data[1] = _tc->c_lcl_ip.ip4.as_u8[1]; \ |
| 113 | ed->data[2] = _tc->c_lcl_ip.ip4.as_u8[2]; \ |
| 114 | ed->data[3] = _tc->c_lcl_ip.ip4.as_u8[3]; \ |
| 115 | ed->data[4] = clib_net_to_host_u16(_tc->c_lcl_port); \ |
| 116 | } \ |
| 117 | } |
| 118 | |
| 119 | #define TCP_DBG_IP_TAG_RMT(_tc) \ |
| 120 | { \ |
| 121 | if (_tc->c_is_ip4) \ |
| 122 | { \ |
| 123 | ELOG_TYPE_DECLARE (_e) = \ |
| 124 | { \ |
| 125 | .format = "rmt: %d.%d.%d.%d:%d", \ |
| 126 | .format_args = "i4i4i4i4i4", \ |
| 127 | }; \ |
| 128 | DECLARE_ETD(_tc, _e, 5); \ |
| 129 | ed->data[0] = _tc->c_rmt_ip.ip4.as_u8[0]; \ |
| 130 | ed->data[1] = _tc->c_rmt_ip.ip4.as_u8[1]; \ |
| 131 | ed->data[2] = _tc->c_rmt_ip.ip4.as_u8[2]; \ |
| 132 | ed->data[3] = _tc->c_rmt_ip.ip4.as_u8[3]; \ |
| 133 | ed->data[4] = clib_net_to_host_u16(_tc->c_rmt_port); \ |
| 134 | } \ |
| 135 | } |
| 136 | |
| 137 | #define TCP_EVT_INIT_HANDLER(_tc, _is_l, ...) \ |
| 138 | { \ |
| 139 | char *_fmt = _is_l ? "l[%d].%d:%d%c" : "[%d].%d:%d->.%d:%d%c"; \ |
| 140 | if (_tc->c_is_ip4) \ |
| 141 | { \ |
| 142 | _tc->c_elog_track.name = \ |
| 143 | (char *) format (0, _fmt, _tc->c_thread_index, \ |
| 144 | _tc->c_lcl_ip.ip4.as_u8[3], \ |
| 145 | clib_net_to_host_u16(_tc->c_lcl_port), \ |
| 146 | _tc->c_rmt_ip.ip4.as_u8[3], \ |
| 147 | clib_net_to_host_u16(_tc->c_rmt_port), 0); \ |
| 148 | } \ |
| 149 | else \ |
| 150 | _tc->c_elog_track.name = \ |
| 151 | (char *) format (0, _fmt, _tc->c_thread_index, \ |
| 152 | _tc->c_lcl_ip.ip6.as_u8[15], \ |
| 153 | clib_net_to_host_u16(_tc->c_lcl_port), \ |
| 154 | _tc->c_rmt_ip.ip6.as_u8[15], \ |
| 155 | clib_net_to_host_u16(_tc->c_rmt_port), 0); \ |
Florin Coras | e69f495 | 2017-03-07 10:06:24 -0800 | [diff] [blame] | 156 | elog_track_register (&vlib_global_main.elog_main, &_tc->c_elog_track);\ |
Florin Coras | 6534b7a | 2017-07-18 05:38:03 -0400 | [diff] [blame] | 157 | TCP_DBG_IP_TAG_LCL(_tc); \ |
| 158 | TCP_DBG_IP_TAG_RMT(_tc); \ |
Florin Coras | e69f495 | 2017-03-07 10:06:24 -0800 | [diff] [blame] | 159 | } |
| 160 | |
| 161 | #define TCP_EVT_DEALLOC_HANDLER(_tc, ...) \ |
| 162 | { \ |
| 163 | vec_free (_tc->c_elog_track.name); \ |
| 164 | } |
| 165 | |
| 166 | #define TCP_EVT_OPEN_HANDLER(_tc, ...) \ |
| 167 | { \ |
Florin Coras | 6534b7a | 2017-07-18 05:38:03 -0400 | [diff] [blame] | 168 | TCP_EVT_INIT_HANDLER(_tc, 0); \ |
Florin Coras | e69f495 | 2017-03-07 10:06:24 -0800 | [diff] [blame] | 169 | ELOG_TYPE_DECLARE (_e) = \ |
| 170 | { \ |
| 171 | .format = "open: index %d", \ |
| 172 | .format_args = "i4", \ |
| 173 | }; \ |
| 174 | DECLARE_ETD(_tc, _e, 1); \ |
| 175 | ed->data[0] = _tc->c_c_index; \ |
| 176 | } |
| 177 | |
| 178 | #define TCP_EVT_CLOSE_HANDLER(_tc, ...) \ |
| 179 | { \ |
| 180 | ELOG_TYPE_DECLARE (_e) = \ |
| 181 | { \ |
| 182 | .format = "close: %d", \ |
| 183 | .format_args = "i4", \ |
| 184 | }; \ |
| 185 | DECLARE_ETD(_tc, _e, 1); \ |
| 186 | ed->data[0] = _tc->c_c_index; \ |
| 187 | } |
| 188 | |
| 189 | #define TCP_EVT_BIND_HANDLER(_tc, ...) \ |
| 190 | { \ |
Florin Coras | 6534b7a | 2017-07-18 05:38:03 -0400 | [diff] [blame] | 191 | TCP_EVT_INIT_HANDLER(_tc, 1); \ |
Florin Coras | e69f495 | 2017-03-07 10:06:24 -0800 | [diff] [blame] | 192 | ELOG_TYPE_DECLARE (_e) = \ |
| 193 | { \ |
| 194 | .format = "bind: listener %d", \ |
| 195 | }; \ |
| 196 | DECLARE_ETD(_tc, _e, 1); \ |
| 197 | ed->data[0] = _tc->c_c_index; \ |
| 198 | } |
| 199 | |
Florin Coras | 6881062 | 2017-07-24 17:40:28 -0700 | [diff] [blame] | 200 | #define TCP_EVT_SYN_RCVD_HANDLER(_tc, ...) \ |
| 201 | { \ |
| 202 | TCP_EVT_INIT_HANDLER(_tc, 0); \ |
| 203 | ELOG_TYPE_DECLARE (_e) = \ |
| 204 | { \ |
| 205 | .format = "syn-rx: irs %u", \ |
| 206 | .format_args = "i4", \ |
| 207 | }; \ |
| 208 | DECLARE_ETD(_tc, _e, 1); \ |
| 209 | ed->data[0] = _tc->irs; \ |
| 210 | TCP_EVT_STATE_CHANGE_HANDLER(_tc); \ |
| 211 | } |
| 212 | |
Florin Coras | e69f495 | 2017-03-07 10:06:24 -0800 | [diff] [blame] | 213 | #define TCP_EVT_UNBIND_HANDLER(_tc, ...) \ |
| 214 | { \ |
| 215 | TCP_EVT_DEALLOC_HANDLER(_tc); \ |
| 216 | ELOG_TYPE_DECLARE (_e) = \ |
| 217 | { \ |
| 218 | .format = "unbind: listener %d", \ |
| 219 | }; \ |
| 220 | DECLARE_ETD(_tc, _e, 1); \ |
| 221 | ed->data[0] = _tc->c_c_index; \ |
| 222 | TCP_EVT_DEALLOC_HANDLER(_tc); \ |
| 223 | } |
| 224 | |
| 225 | #define TCP_EVT_DELETE_HANDLER(_tc, ...) \ |
| 226 | { \ |
| 227 | ELOG_TYPE_DECLARE (_e) = \ |
| 228 | { \ |
| 229 | .format = "delete: %d", \ |
| 230 | .format_args = "i4", \ |
| 231 | }; \ |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 232 | DECLARE_ETD(_tc, _e, 1); \ |
Florin Coras | e69f495 | 2017-03-07 10:06:24 -0800 | [diff] [blame] | 233 | ed->data[0] = _tc->c_c_index; \ |
| 234 | TCP_EVT_DEALLOC_HANDLER(_tc); \ |
| 235 | } |
| 236 | |
Florin Coras | f03a59a | 2017-06-09 21:07:32 -0700 | [diff] [blame] | 237 | #define CONCAT_HELPER(_a, _b) _a##_b |
| 238 | #define CC(_a, _b) CONCAT_HELPER(_a, _b) |
| 239 | #define TCP_EVT_DBG(_evt, _args...) CC(_evt, _HANDLER)(_args) |
| 240 | #else |
| 241 | #define TCP_EVT_DBG(_evt, _args...) |
| 242 | #endif |
| 243 | |
| 244 | /* |
| 245 | * State machine |
| 246 | */ |
| 247 | #if TCP_DEBUG_SM |
| 248 | |
Florin Coras | 6534b7a | 2017-07-18 05:38:03 -0400 | [diff] [blame] | 249 | #define TCP_EVT_STATE_CHANGE_HANDLER(_tc, ...) \ |
| 250 | { \ |
| 251 | ELOG_TYPE_DECLARE (_e) = \ |
| 252 | { \ |
| 253 | .format = "state: %s", \ |
| 254 | .format_args = "t4", \ |
| 255 | .n_enum_strings = 11, \ |
| 256 | .enum_strings = { \ |
| 257 | "closed", \ |
| 258 | "listen", \ |
| 259 | "syn-sent", \ |
| 260 | "syn-rcvd", \ |
| 261 | "established", \ |
| 262 | "close_wait", \ |
| 263 | "fin-wait-1", \ |
| 264 | "last-ack", \ |
| 265 | "closing", \ |
| 266 | "fin-wait-2", \ |
| 267 | "time-wait", \ |
| 268 | }, \ |
| 269 | }; \ |
| 270 | DECLARE_ETD(_tc, _e, 1); \ |
| 271 | ed->data[0] = _tc->state; \ |
| 272 | } |
| 273 | |
Florin Coras | 6534b7a | 2017-07-18 05:38:03 -0400 | [diff] [blame] | 274 | #define TCP_EVT_SYN_SENT_HANDLER(_tc, ...) \ |
| 275 | { \ |
| 276 | ELOG_TYPE_DECLARE (_e) = \ |
| 277 | { \ |
| 278 | .format = "syn-tx: iss %u", \ |
| 279 | .format_args = "i4", \ |
| 280 | }; \ |
| 281 | DECLARE_ETD(_tc, _e, 1); \ |
| 282 | ed->data[0] = _tc->iss; \ |
| 283 | TCP_EVT_STATE_CHANGE_HANDLER(_tc); \ |
| 284 | } |
| 285 | |
| 286 | #define TCP_EVT_SYNACK_SENT_HANDLER(_tc, ...) \ |
| 287 | { \ |
| 288 | ELOG_TYPE_DECLARE (_e) = \ |
| 289 | { \ |
| 290 | .format = "synack-tx: iss %u irs %u", \ |
| 291 | .format_args = "i4i4", \ |
| 292 | }; \ |
| 293 | DECLARE_ETD(_tc, _e, 2); \ |
| 294 | ed->data[0] = _tc->iss; \ |
| 295 | ed->data[1] = _tc->irs; \ |
| 296 | } |
| 297 | |
| 298 | #define TCP_EVT_SYNACK_RCVD_HANDLER(_tc, ...) \ |
| 299 | { \ |
| 300 | ELOG_TYPE_DECLARE (_e) = \ |
| 301 | { \ |
| 302 | .format = "synack-rx: iss %u irs %u", \ |
| 303 | .format_args = "i4i4", \ |
| 304 | }; \ |
| 305 | DECLARE_ETD(_tc, _e, 2); \ |
| 306 | ed->data[0] = _tc->iss; \ |
| 307 | ed->data[1] = _tc->irs; \ |
| 308 | TCP_EVT_STATE_CHANGE_HANDLER(_tc); \ |
| 309 | } |
| 310 | |
| 311 | #define TCP_EVT_FIN_SENT_HANDLER(_tc, ...) \ |
| 312 | { \ |
| 313 | ELOG_TYPE_DECLARE (_e) = \ |
| 314 | { \ |
| 315 | .format = "fin-tx: snd_nxt %d rcv_nxt %d", \ |
| 316 | .format_args = "i4i4", \ |
| 317 | }; \ |
| 318 | DECLARE_ETD(_tc, _e, 2); \ |
| 319 | ed->data[0] = _tc->snd_nxt - _tc->iss; \ |
| 320 | ed->data[1] = _tc->rcv_nxt - _tc->irs; \ |
| 321 | } |
| 322 | |
| 323 | #define TCP_EVT_RST_SENT_HANDLER(_tc, ...) \ |
| 324 | { \ |
| 325 | ELOG_TYPE_DECLARE (_e) = \ |
| 326 | { \ |
| 327 | .format = "rst-tx: snd_nxt %d rcv_nxt %d", \ |
| 328 | .format_args = "i4i4", \ |
| 329 | }; \ |
| 330 | DECLARE_ETD(_tc, _e, 2); \ |
| 331 | ed->data[0] = _tc->snd_nxt - _tc->iss; \ |
| 332 | ed->data[1] = _tc->rcv_nxt - _tc->irs; \ |
| 333 | TCP_EVT_STATE_CHANGE_HANDLER(_tc); \ |
| 334 | } |
| 335 | |
| 336 | #define TCP_EVT_FIN_RCVD_HANDLER(_tc, ...) \ |
| 337 | { \ |
| 338 | ELOG_TYPE_DECLARE (_e) = \ |
| 339 | { \ |
| 340 | .format = "fin-rx: snd_nxt %d rcv_nxt %d", \ |
| 341 | .format_args = "i4i4", \ |
| 342 | }; \ |
| 343 | DECLARE_ETD(_tc, _e, 2); \ |
| 344 | ed->data[0] = _tc->snd_nxt - _tc->iss; \ |
| 345 | ed->data[1] = _tc->rcv_nxt - _tc->irs; \ |
| 346 | } |
| 347 | |
| 348 | #define TCP_EVT_RST_RCVD_HANDLER(_tc, ...) \ |
| 349 | { \ |
| 350 | ELOG_TYPE_DECLARE (_e) = \ |
| 351 | { \ |
| 352 | .format = "rst-rx: snd_nxt %d rcv_nxt %d", \ |
| 353 | .format_args = "i4i4", \ |
| 354 | }; \ |
| 355 | DECLARE_ETD(_tc, _e, 2); \ |
| 356 | ed->data[0] = _tc->snd_nxt - _tc->iss; \ |
| 357 | ed->data[1] = _tc->rcv_nxt - _tc->irs; \ |
| 358 | } |
| 359 | |
| 360 | #define TCP_EVT_SYN_RXT_HANDLER(_tc, _type, ...) \ |
| 361 | { \ |
| 362 | ELOG_TYPE_DECLARE (_e) = \ |
| 363 | { \ |
| 364 | .format = "%s-rxt: iss %u", \ |
| 365 | .format_args = "t4i4", \ |
| 366 | .n_enum_strings = 2, \ |
| 367 | .enum_strings = { \ |
| 368 | "syn", \ |
| 369 | "syn-ack", \ |
| 370 | }, \ |
| 371 | }; \ |
| 372 | DECLARE_ETD(_tc, _e, 2); \ |
| 373 | ed->data[0] = _type; \ |
| 374 | ed->data[1] = _tc->iss; \ |
| 375 | } |
| 376 | |
| 377 | #else |
| 378 | #define TCP_EVT_SYN_SENT_HANDLER(_tc, ...) |
| 379 | #define TCP_EVT_SYNACK_SENT_HANDLER(_tc, ...) |
| 380 | #define TCP_EVT_SYNACK_RCVD_HANDLER(_tc, ...) |
| 381 | #define TCP_EVT_SYN_RXT_HANDLER(_tc, ...) |
| 382 | #define TCP_EVT_FIN_SENT_HANDLER(_tc, ...) |
| 383 | #define TCP_EVT_RST_SENT_HANDLER(_tc, ...) |
| 384 | #define TCP_EVT_FIN_RCVD_HANDLER(_tc, ...) |
| 385 | #define TCP_EVT_RST_RCVD_HANDLER(_tc, ...) |
| 386 | #define TCP_EVT_STATE_CHANGE_HANDLER(_tc, ...) |
| 387 | #endif |
| 388 | |
| 389 | #if TCP_DEBUG_SM > 1 |
| 390 | |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 391 | #define TCP_EVT_ACK_SENT_HANDLER(_tc, ...) \ |
| 392 | { \ |
| 393 | ELOG_TYPE_DECLARE (_e) = \ |
| 394 | { \ |
Florin Coras | 6534b7a | 2017-07-18 05:38:03 -0400 | [diff] [blame] | 395 | .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] | 396 | .format_args = "i4i4i4i4i4", \ |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 397 | }; \ |
Florin Coras | 3e350af | 2017-03-30 02:54:28 -0700 | [diff] [blame] | 398 | DECLARE_ETD(_tc, _e, 5); \ |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 399 | ed->data[0] = _tc->rcv_nxt - _tc->rcv_las; \ |
| 400 | ed->data[1] = _tc->rcv_nxt - _tc->irs; \ |
| 401 | ed->data[2] = _tc->rcv_wnd; \ |
| 402 | ed->data[3] = _tc->snd_nxt - _tc->iss; \ |
Florin Coras | 3e350af | 2017-03-30 02:54:28 -0700 | [diff] [blame] | 403 | ed->data[4] = _tc->snd_wnd; \ |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 404 | } |
| 405 | |
| 406 | #define TCP_EVT_DUPACK_SENT_HANDLER(_tc, ...) \ |
| 407 | { \ |
| 408 | ELOG_TYPE_DECLARE (_e) = \ |
| 409 | { \ |
Florin Coras | 6534b7a | 2017-07-18 05:38:03 -0400 | [diff] [blame] | 410 | .format = "dack-tx: rcv_nxt %u rcv_wnd %u snd_nxt %u av_wnd %u snd_wnd %u",\ |
Florin Coras | 3e350af | 2017-03-30 02:54:28 -0700 | [diff] [blame] | 411 | .format_args = "i4i4i4i4i4", \ |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 412 | }; \ |
Florin Coras | 3e350af | 2017-03-30 02:54:28 -0700 | [diff] [blame] | 413 | DECLARE_ETD(_tc, _e, 5); \ |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 414 | ed->data[0] = _tc->rcv_nxt - _tc->irs; \ |
| 415 | ed->data[1] = _tc->rcv_wnd; \ |
| 416 | ed->data[2] = _tc->snd_nxt - _tc->iss; \ |
| 417 | ed->data[3] = tcp_available_wnd(_tc); \ |
Florin Coras | 3e350af | 2017-03-30 02:54:28 -0700 | [diff] [blame] | 418 | ed->data[4] = _tc->snd_wnd; \ |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 419 | } |
| 420 | |
Florin Coras | 3e350af | 2017-03-30 02:54:28 -0700 | [diff] [blame] | 421 | #define TCP_EVT_ACK_RCVD_HANDLER(_tc, ...) \ |
Florin Coras | e69f495 | 2017-03-07 10:06:24 -0800 | [diff] [blame] | 422 | { \ |
| 423 | ELOG_TYPE_DECLARE (_e) = \ |
| 424 | { \ |
Florin Coras | 3e350af | 2017-03-30 02:54:28 -0700 | [diff] [blame] | 425 | .format = "acked: %u snd_una %u snd_wnd %u cwnd %u inflight %u", \ |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 426 | .format_args = "i4i4i4i4i4", \ |
Florin Coras | e69f495 | 2017-03-07 10:06:24 -0800 | [diff] [blame] | 427 | }; \ |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 428 | DECLARE_ETD(_tc, _e, 5); \ |
Florin Coras | e69f495 | 2017-03-07 10:06:24 -0800 | [diff] [blame] | 429 | ed->data[0] = _tc->bytes_acked; \ |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 430 | ed->data[1] = _tc->snd_una - _tc->iss; \ |
Florin Coras | 3e350af | 2017-03-30 02:54:28 -0700 | [diff] [blame] | 431 | ed->data[2] = _tc->snd_wnd; \ |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 432 | ed->data[3] = _tc->cwnd; \ |
| 433 | ed->data[4] = tcp_flight_size(_tc); \ |
| 434 | } |
| 435 | |
| 436 | #define TCP_EVT_DUPACK_RCVD_HANDLER(_tc, ...) \ |
| 437 | { \ |
| 438 | ELOG_TYPE_DECLARE (_e) = \ |
| 439 | { \ |
Florin Coras | 6534b7a | 2017-07-18 05:38:03 -0400 | [diff] [blame] | 440 | .format = "dack-rx: snd_una %u cwnd %u snd_wnd %u flight %u rcv_wnd %u",\ |
Florin Coras | 3e350af | 2017-03-30 02:54:28 -0700 | [diff] [blame] | 441 | .format_args = "i4i4i4i4i4", \ |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 442 | }; \ |
Florin Coras | 3e350af | 2017-03-30 02:54:28 -0700 | [diff] [blame] | 443 | DECLARE_ETD(_tc, _e, 5); \ |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 444 | ed->data[0] = _tc->snd_una - _tc->iss; \ |
Florin Coras | e69f495 | 2017-03-07 10:06:24 -0800 | [diff] [blame] | 445 | ed->data[1] = _tc->cwnd; \ |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 446 | ed->data[2] = _tc->snd_wnd; \ |
| 447 | ed->data[3] = tcp_flight_size(_tc); \ |
Florin Coras | 3e350af | 2017-03-30 02:54:28 -0700 | [diff] [blame] | 448 | ed->data[4] = _tc->rcv_wnd; \ |
Florin Coras | e69f495 | 2017-03-07 10:06:24 -0800 | [diff] [blame] | 449 | } |
| 450 | |
| 451 | #define TCP_EVT_PKTIZE_HANDLER(_tc, ...) \ |
| 452 | { \ |
| 453 | ELOG_TYPE_DECLARE (_e) = \ |
| 454 | { \ |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 455 | .format = "pktize: una %u snd_nxt %u space %u flight %u rcv_wnd %u",\ |
| 456 | .format_args = "i4i4i4i4i4", \ |
Florin Coras | e69f495 | 2017-03-07 10:06:24 -0800 | [diff] [blame] | 457 | }; \ |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 458 | DECLARE_ETD(_tc, _e, 5); \ |
Florin Coras | e69f495 | 2017-03-07 10:06:24 -0800 | [diff] [blame] | 459 | ed->data[0] = _tc->snd_una - _tc->iss; \ |
| 460 | ed->data[1] = _tc->snd_nxt - _tc->iss; \ |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 461 | ed->data[2] = tcp_available_snd_space (_tc); \ |
| 462 | ed->data[3] = tcp_flight_size (_tc); \ |
| 463 | ed->data[4] = _tc->rcv_wnd; \ |
Florin Coras | e69f495 | 2017-03-07 10:06:24 -0800 | [diff] [blame] | 464 | } |
| 465 | |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 466 | #define TCP_EVT_INPUT_HANDLER(_tc, _type, _len, _written, ...) \ |
Florin Coras | e69f495 | 2017-03-07 10:06:24 -0800 | [diff] [blame] | 467 | { \ |
| 468 | ELOG_TYPE_DECLARE (_e) = \ |
| 469 | { \ |
Florin Coras | 3e350af | 2017-03-30 02:54:28 -0700 | [diff] [blame] | 470 | .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] | 471 | .format_args = "t4i4i4i4i4", \ |
| 472 | .n_enum_strings = 2, \ |
| 473 | .enum_strings = { \ |
| 474 | "order", \ |
| 475 | "ooo", \ |
| 476 | }, \ |
Florin Coras | e69f495 | 2017-03-07 10:06:24 -0800 | [diff] [blame] | 477 | }; \ |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 478 | DECLARE_ETD(_tc, _e, 5); \ |
| 479 | ed->data[0] = _type; \ |
| 480 | ed->data[1] = _len; \ |
| 481 | ed->data[2] = _written; \ |
| 482 | ed->data[3] = (_tc->rcv_nxt - _tc->irs) + _written; \ |
| 483 | ed->data[4] = _tc->rcv_wnd - (_tc->rcv_nxt - _tc->rcv_las); \ |
Florin Coras | e69f495 | 2017-03-07 10:06:24 -0800 | [diff] [blame] | 484 | } |
| 485 | |
| 486 | #define TCP_EVT_TIMER_POP_HANDLER(_tc_index, _timer_id, ...) \ |
| 487 | { \ |
| 488 | tcp_connection_t *_tc; \ |
flyingeagle23 | e8146b0 | 2017-04-26 20:06:52 +0800 | [diff] [blame] | 489 | if (_timer_id == TCP_TIMER_RETRANSMIT_SYN \ |
| 490 | || _timer_id == TCP_TIMER_ESTABLISH) \ |
Florin Coras | e69f495 | 2017-03-07 10:06:24 -0800 | [diff] [blame] | 491 | { \ |
| 492 | _tc = tcp_half_open_connection_get (_tc_index); \ |
| 493 | } \ |
| 494 | else \ |
| 495 | { \ |
Damjan Marion | 586afd7 | 2017-04-05 19:18:20 +0200 | [diff] [blame] | 496 | u32 _thread_index = vlib_get_thread_index (); \ |
Florin Coras | e69f495 | 2017-03-07 10:06:24 -0800 | [diff] [blame] | 497 | _tc = tcp_connection_get (_tc_index, _thread_index); \ |
| 498 | } \ |
| 499 | ELOG_TYPE_DECLARE (_e) = \ |
| 500 | { \ |
Florin Coras | 6534b7a | 2017-07-18 05:38:03 -0400 | [diff] [blame] | 501 | .format = "timer-pop: %s (%d)", \ |
Florin Coras | e69f495 | 2017-03-07 10:06:24 -0800 | [diff] [blame] | 502 | .format_args = "t4i4", \ |
| 503 | .n_enum_strings = 7, \ |
| 504 | .enum_strings = { \ |
| 505 | "retransmit", \ |
| 506 | "delack", \ |
Florin Coras | 3e350af | 2017-03-30 02:54:28 -0700 | [diff] [blame] | 507 | "persist", \ |
Florin Coras | e69f495 | 2017-03-07 10:06:24 -0800 | [diff] [blame] | 508 | "keep", \ |
| 509 | "waitclose", \ |
| 510 | "retransmit syn", \ |
| 511 | "establish", \ |
| 512 | }, \ |
| 513 | }; \ |
Dave Barach | 2c25a62 | 2017-06-26 11:35:07 -0400 | [diff] [blame] | 514 | if (_tc) \ |
| 515 | { \ |
| 516 | DECLARE_ETD(_tc, _e, 2); \ |
| 517 | ed->data[0] = _timer_id; \ |
| 518 | ed->data[1] = _timer_id; \ |
| 519 | } \ |
| 520 | else \ |
| 521 | { \ |
Florin Coras | 6534b7a | 2017-07-18 05:38:03 -0400 | [diff] [blame] | 522 | clib_warning ("pop %d for unexisting connection %d", _timer_id, \ |
| 523 | _tc_index); \ |
Dave Barach | 2c25a62 | 2017-06-26 11:35:07 -0400 | [diff] [blame] | 524 | } \ |
Florin Coras | e69f495 | 2017-03-07 10:06:24 -0800 | [diff] [blame] | 525 | } |
| 526 | |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 527 | #define TCP_EVT_SEG_INVALID_HANDLER(_tc, _seq, _end, ...) \ |
| 528 | { \ |
| 529 | ELOG_TYPE_DECLARE (_e) = \ |
| 530 | { \ |
Florin Coras | 3e350af | 2017-03-30 02:54:28 -0700 | [diff] [blame] | 531 | .format = "seg-inv: seq %u end %u rcv_las %u rcv_nxt %u rcv_wnd %u",\ |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 532 | .format_args = "i4i4i4i4i4", \ |
| 533 | }; \ |
| 534 | DECLARE_ETD(_tc, _e, 5); \ |
| 535 | ed->data[0] = _seq - _tc->irs; \ |
| 536 | ed->data[1] = _end - _tc->irs; \ |
| 537 | ed->data[2] = _tc->rcv_las - _tc->irs; \ |
| 538 | ed->data[3] = _tc->rcv_nxt - _tc->irs; \ |
| 539 | ed->data[4] = _tc->rcv_wnd; \ |
| 540 | } |
| 541 | |
Florin Coras | c28764f | 2017-04-26 00:08:42 -0700 | [diff] [blame] | 542 | #define TCP_EVT_PAWS_FAIL_HANDLER(_tc, _seq, _end, ...) \ |
| 543 | { \ |
| 544 | ELOG_TYPE_DECLARE (_e) = \ |
| 545 | { \ |
Florin Coras | 6534b7a | 2017-07-18 05:38:03 -0400 | [diff] [blame] | 546 | .format = "paws-err: seq %u end %u tsval %u tsval_recent %u", \ |
Florin Coras | c28764f | 2017-04-26 00:08:42 -0700 | [diff] [blame] | 547 | .format_args = "i4i4i4i4", \ |
| 548 | }; \ |
| 549 | DECLARE_ETD(_tc, _e, 4); \ |
| 550 | ed->data[0] = _seq - _tc->irs; \ |
| 551 | ed->data[1] = _end - _tc->irs; \ |
Florin Coras | 93992a9 | 2017-05-24 18:03:56 -0700 | [diff] [blame] | 552 | ed->data[2] = _tc->rcv_opts.tsval; \ |
Florin Coras | c28764f | 2017-04-26 00:08:42 -0700 | [diff] [blame] | 553 | ed->data[3] = _tc->tsval_recent; \ |
| 554 | } |
| 555 | |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 556 | #define TCP_EVT_ACK_RCV_ERR_HANDLER(_tc, _type, _ack, ...) \ |
| 557 | { \ |
| 558 | ELOG_TYPE_DECLARE (_e) = \ |
| 559 | { \ |
| 560 | .format = "ack-err: %s ack %u snd_una %u snd_nxt %u una_max %u", \ |
| 561 | .format_args = "t4i4i4i4i4", \ |
| 562 | .n_enum_strings = 3, \ |
| 563 | .enum_strings = { \ |
| 564 | "invalid", \ |
| 565 | "old", \ |
| 566 | "future", \ |
| 567 | }, \ |
| 568 | }; \ |
| 569 | DECLARE_ETD(_tc, _e, 5); \ |
| 570 | ed->data[0] = _type; \ |
| 571 | ed->data[1] = _ack - _tc->iss; \ |
| 572 | ed->data[2] = _tc->snd_una - _tc->iss; \ |
| 573 | ed->data[3] = _tc->snd_nxt - _tc->iss; \ |
| 574 | ed->data[4] = _tc->snd_una_max - _tc->iss; \ |
| 575 | } |
| 576 | |
Florin Coras | f03a59a | 2017-06-09 21:07:32 -0700 | [diff] [blame] | 577 | #define TCP_EVT_RCV_WND_SHRUNK_HANDLER(_tc, _obs, _av, ...) \ |
| 578 | { \ |
| 579 | if (_av > 0) \ |
| 580 | { \ |
| 581 | ELOG_TYPE_DECLARE (_e) = \ |
| 582 | { \ |
| 583 | .format = "huh?: rcv_wnd %u obsd %u av %u rcv_nxt %u rcv_las %u", \ |
| 584 | .format_args = "i4i4i4i4i4", \ |
| 585 | }; \ |
| 586 | DECLARE_ETD(_tc, _e, 5); \ |
| 587 | ed->data[0] = _tc->rcv_wnd; \ |
| 588 | ed->data[1] = _obs; \ |
| 589 | ed->data[2] = _av; \ |
| 590 | ed->data[3] = _tc->rcv_nxt - _tc->irs; \ |
| 591 | ed->data[4] = _tc->rcv_las - _tc->irs; \ |
| 592 | } \ |
| 593 | } |
| 594 | #else |
| 595 | #define TCP_EVT_ACK_SENT_HANDLER(_tc, ...) |
| 596 | #define TCP_EVT_DUPACK_SENT_HANDLER(_tc, ...) |
Florin Coras | f03a59a | 2017-06-09 21:07:32 -0700 | [diff] [blame] | 597 | #define TCP_EVT_ACK_RCVD_HANDLER(_tc, ...) |
| 598 | #define TCP_EVT_DUPACK_RCVD_HANDLER(_tc, ...) |
| 599 | #define TCP_EVT_PKTIZE_HANDLER(_tc, ...) |
| 600 | #define TCP_EVT_INPUT_HANDLER(_tc, _type, _len, _written, ...) |
| 601 | #define TCP_EVT_TIMER_POP_HANDLER(_tc_index, _timer_id, ...) |
| 602 | #define TCP_EVT_SEG_INVALID_HANDLER(_tc, _seq, _end, ...) |
| 603 | #define TCP_EVT_PAWS_FAIL_HANDLER(_tc, _seq, _end, ...) |
| 604 | #define TCP_EVT_ACK_RCV_ERR_HANDLER(_tc, _type, _ack, ...) |
| 605 | #define TCP_EVT_RCV_WND_SHRUNK_HANDLER(_tc, _obs, _av, ...) |
| 606 | #endif |
| 607 | |
| 608 | /* |
| 609 | * State machine verbose |
| 610 | */ |
Florin Coras | 6534b7a | 2017-07-18 05:38:03 -0400 | [diff] [blame] | 611 | #if TCP_DEBUG_SM > 2 |
Florin Coras | f03a59a | 2017-06-09 21:07:32 -0700 | [diff] [blame] | 612 | #define TCP_EVT_SND_WND_HANDLER(_tc, ...) \ |
| 613 | { \ |
| 614 | ELOG_TYPE_DECLARE (_e) = \ |
| 615 | { \ |
Florin Coras | 6534b7a | 2017-07-18 05:38:03 -0400 | [diff] [blame] | 616 | .format = "snd-wnd update: %u ", \ |
Florin Coras | f03a59a | 2017-06-09 21:07:32 -0700 | [diff] [blame] | 617 | .format_args = "i4", \ |
| 618 | }; \ |
| 619 | DECLARE_ETD(_tc, _e, 1); \ |
| 620 | ed->data[0] = _tc->snd_wnd; \ |
| 621 | } |
| 622 | |
| 623 | #define TCP_EVT_OUTPUT_HANDLER(_tc, flags, n_bytes,...) \ |
| 624 | { \ |
| 625 | ELOG_TYPE_DECLARE (_e) = \ |
| 626 | { \ |
| 627 | .format = "out: flags %x, bytes %u", \ |
| 628 | .format_args = "i4i4", \ |
| 629 | }; \ |
| 630 | DECLARE_ETD(_tc, _e, 2); \ |
| 631 | ed->data[0] = flags; \ |
| 632 | ed->data[1] = n_bytes; \ |
| 633 | } |
| 634 | #else |
| 635 | #define TCP_EVT_SND_WND_HANDLER(_tc, ...) |
| 636 | #define TCP_EVT_OUTPUT_HANDLER(_tc, flags, n_bytes,...) |
| 637 | #endif |
| 638 | |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 639 | /* |
| 640 | * Congestion Control |
| 641 | */ |
| 642 | |
| 643 | #if TCP_DEBUG_CC |
| 644 | #define TCP_EVT_CC_RTX_HANDLER(_tc, offset, n_bytes, ...) \ |
| 645 | { \ |
| 646 | ELOG_TYPE_DECLARE (_e) = \ |
| 647 | { \ |
Florin Coras | 93992a9 | 2017-05-24 18:03:56 -0700 | [diff] [blame] | 648 | .format = "rxt: snd_nxt %u offset %u snd %u rxt %u", \ |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 649 | .format_args = "i4i4i4i4", \ |
| 650 | }; \ |
| 651 | DECLARE_ETD(_tc, _e, 4); \ |
| 652 | ed->data[0] = _tc->snd_nxt - _tc->iss; \ |
| 653 | ed->data[1] = offset; \ |
| 654 | ed->data[2] = n_bytes; \ |
Florin Coras | 93992a9 | 2017-05-24 18:03:56 -0700 | [diff] [blame] | 655 | ed->data[3] = _tc->snd_rxt_bytes; \ |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 656 | } |
| 657 | |
| 658 | #define TCP_EVT_CC_EVT_HANDLER(_tc, _sub_evt, ...) \ |
| 659 | { \ |
| 660 | ELOG_TYPE_DECLARE (_e) = \ |
| 661 | { \ |
Florin Coras | 93992a9 | 2017-05-24 18:03:56 -0700 | [diff] [blame] | 662 | .format = "cc: %s wnd %u snd_cong %u rxt_bytes %u", \ |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 663 | .format_args = "t4i4i4i4", \ |
| 664 | .n_enum_strings = 5, \ |
| 665 | .enum_strings = { \ |
Florin Coras | 93992a9 | 2017-05-24 18:03:56 -0700 | [diff] [blame] | 666 | "fast-rxt", \ |
| 667 | "rxt-timeout", \ |
| 668 | "first-rxt", \ |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 669 | "recovered", \ |
| 670 | "congestion", \ |
| 671 | }, \ |
| 672 | }; \ |
| 673 | DECLARE_ETD(_tc, _e, 4); \ |
| 674 | ed->data[0] = _sub_evt; \ |
| 675 | ed->data[1] = tcp_available_snd_space (_tc); \ |
| 676 | ed->data[2] = _tc->snd_congestion - _tc->iss; \ |
Florin Coras | 93992a9 | 2017-05-24 18:03:56 -0700 | [diff] [blame] | 677 | ed->data[3] = _tc->snd_rxt_bytes; \ |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 678 | } |
| 679 | |
| 680 | #define TCP_EVT_CC_PACK_HANDLER(_tc, ...) \ |
| 681 | { \ |
| 682 | ELOG_TYPE_DECLARE (_e) = \ |
| 683 | { \ |
| 684 | .format = "pack: snd_una %u snd_una_max %u", \ |
| 685 | .format_args = "i4i4", \ |
| 686 | }; \ |
| 687 | DECLARE_ETD(_tc, _e, 2); \ |
| 688 | ed->data[0] = _tc->snd_una - _tc->iss; \ |
| 689 | ed->data[1] = _tc->snd_una_max - _tc->iss; \ |
| 690 | } |
| 691 | |
Florin Coras | f03a59a | 2017-06-09 21:07:32 -0700 | [diff] [blame] | 692 | /* |
| 693 | * Congestion control stats |
| 694 | */ |
| 695 | #if TCP_DEBUG_CC_STAT |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 696 | |
Florin Coras | f03a59a | 2017-06-09 21:07:32 -0700 | [diff] [blame] | 697 | #define STATS_INTERVAL 1 |
| 698 | |
| 699 | #define TCP_EVT_CC_RTO_STAT_HANDLER(_tc, ...) \ |
Florin Coras | 3e350af | 2017-03-30 02:54:28 -0700 | [diff] [blame] | 700 | { \ |
Florin Coras | f03a59a | 2017-06-09 21:07:32 -0700 | [diff] [blame] | 701 | if (_tc->c_cc_stat_tstamp + STATS_INTERVAL < tcp_time_now()) \ |
Florin Coras | 3e350af | 2017-03-30 02:54:28 -0700 | [diff] [blame] | 702 | { \ |
| 703 | ELOG_TYPE_DECLARE (_e) = \ |
| 704 | { \ |
Florin Coras | f03a59a | 2017-06-09 21:07:32 -0700 | [diff] [blame] | 705 | .format = "rto_stat: rto %u srtt %u rttvar %u ", \ |
| 706 | .format_args = "i4i4i4", \ |
Florin Coras | 3e350af | 2017-03-30 02:54:28 -0700 | [diff] [blame] | 707 | }; \ |
Florin Coras | f03a59a | 2017-06-09 21:07:32 -0700 | [diff] [blame] | 708 | DECLARE_ETD(_tc, _e, 3); \ |
| 709 | ed->data[0] = _tc->rto; \ |
| 710 | ed->data[1] = _tc->srtt; \ |
| 711 | ed->data[2] = _tc->rttvar; \ |
Florin Coras | 3e350af | 2017-03-30 02:54:28 -0700 | [diff] [blame] | 712 | } \ |
| 713 | } |
| 714 | |
Florin Coras | f03a59a | 2017-06-09 21:07:32 -0700 | [diff] [blame] | 715 | #define TCP_EVT_CC_STAT_HANDLER(_tc, ...) \ |
| 716 | { \ |
| 717 | if (_tc->c_cc_stat_tstamp + STATS_INTERVAL < tcp_time_now()) \ |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 718 | { \ |
| 719 | ELOG_TYPE_DECLARE (_e) = \ |
| 720 | { \ |
Florin Coras | f03a59a | 2017-06-09 21:07:32 -0700 | [diff] [blame] | 721 | .format = "cc_stat: cwnd %u flight %u space %u ssthresh %u snd_wnd %u",\ |
| 722 | .format_args = "i4i4i4i4i4", \ |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 723 | }; \ |
Florin Coras | f03a59a | 2017-06-09 21:07:32 -0700 | [diff] [blame] | 724 | DECLARE_ETD(_tc, _e, 5); \ |
| 725 | ed->data[0] = _tc->cwnd; \ |
| 726 | ed->data[1] = tcp_flight_size (_tc); \ |
| 727 | ed->data[2] = tcp_snd_space (_tc); \ |
| 728 | ed->data[3] = _tc->ssthresh; \ |
| 729 | ed->data[4] = _tc->snd_wnd; \ |
| 730 | TCP_EVT_CC_RTO_STAT_HANDLER (_tc); \ |
| 731 | _tc->c_cc_stat_tstamp = tcp_time_now(); \ |
| 732 | } \ |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 733 | } |
| 734 | |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 735 | #else |
Florin Coras | f03a59a | 2017-06-09 21:07:32 -0700 | [diff] [blame] | 736 | #define TCP_EVT_CC_STAT_HANDLER(_tc, ...) |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 737 | #endif |
| 738 | |
Florin Coras | e69f495 | 2017-03-07 10:06:24 -0800 | [diff] [blame] | 739 | #else |
Florin Coras | f03a59a | 2017-06-09 21:07:32 -0700 | [diff] [blame] | 740 | #define TCP_EVT_CC_RTX_HANDLER(_tc, offset, n_bytes, ...) |
| 741 | #define TCP_EVT_CC_EVT_HANDLER(_tc, _sub_evt, ...) |
| 742 | #define TCP_EVT_CC_PACK_HANDLER(_tc, ...) |
Florin Coras | 6534b7a | 2017-07-18 05:38:03 -0400 | [diff] [blame] | 743 | #define TCP_EVT_CC_STAT_HANDLER(_tc, ...) |
Florin Coras | e69f495 | 2017-03-07 10:06:24 -0800 | [diff] [blame] | 744 | #endif |
| 745 | |
Florin Coras | e69f495 | 2017-03-07 10:06:24 -0800 | [diff] [blame] | 746 | #endif /* SRC_VNET_TCP_TCP_DEBUG_H_ */ |
| 747 | /* |
| 748 | * fd.io coding-style-patch-verification: ON |
| 749 | * |
| 750 | * Local Variables: |
| 751 | * eval: (c-set-style "gnu") |
| 752 | * End: |
| 753 | */ |