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