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