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