blob: be51bca2a26fdf398520428ca79a005985219969 [file] [log] [blame]
Florin Corase69f4952017-03-07 10:06:24 -08001/*
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 Corasf03a59a2017-06-09 21:07:32 -070022#define TCP_DEBUG_SM (0)
Florin Coras6792ec02017-03-13 03:49:51 -070023#define TCP_DEBUG_CC (1)
Florin Corasf03a59a2017-06-09 21:07:32 -070024#define TCP_DEBUG_CC_STAT (1)
25#define TCP_DEBUG_SM_VERBOSE (0)
Florin Corase69f4952017-03-07 10:06:24 -080026
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 Coras3e350af2017-03-30 02:54:28 -070036 _(SYN_RTX, "SYN retransmit") \
Florin Corase69f4952017-03-07 10:06:24 -080037 _(FIN_SENT, "FIN sent") \
Florin Coras6792ec02017-03-13 03:49:51 -070038 _(ACK_SENT, "ACK sent") \
39 _(DUPACK_SENT, "DUPACK sent") \
Florin Corase69f4952017-03-07 10:06:24 -080040 _(RST_SENT, "RST sent") \
41 _(SYN_RCVD, "SYN rcvd") \
42 _(ACK_RCVD, "ACK rcvd") \
Florin Coras6792ec02017-03-13 03:49:51 -070043 _(DUPACK_RCVD, "DUPACK rcvd") \
Florin Corase69f4952017-03-07 10:06:24 -080044 _(FIN_RCVD, "FIN rcvd") \
45 _(RST_RCVD, "RST rcvd") \
46 _(PKTIZE, "packetize") \
47 _(INPUT, "in") \
Florin Coras6792ec02017-03-13 03:49:51 -070048 _(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 Corasf03a59a2017-06-09 21:07:32 -070054 _(CC_STAT, "cc stats") \
55 _(CC_RTO_STAT, "cc rto stats") \
Florin Coras6792ec02017-03-13 03:49:51 -070056 _(SEG_INVALID, "invalid segment") \
Florin Corasc28764f2017-04-26 00:08:42 -070057 _(PAWS_FAIL, "failed paws check") \
Florin Coras6792ec02017-03-13 03:49:51 -070058 _(ACK_RCV_ERR, "invalid ack") \
Florin Coras3e350af2017-03-30 02:54:28 -070059 _(RCV_WND_SHRUNK, "shrunk rcv_wnd") \
Florin Corase69f4952017-03-07 10:06:24 -080060
61typedef enum _tcp_dbg
62{
63#define _(sym, str) TCP_DBG_##sym,
64 foreach_tcp_dbg_evt
65#undef _
66} tcp_dbg_e;
67
68typedef 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 Corasf03a59a2017-06-09 21:07:32 -070079/*
80 * Infra and evt track setup
81 */
82
Florin Corase69f4952017-03-07 10:06:24 -080083#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 Coras6792ec02017-03-13 03:49:51 -070099#define TCP_EVT_INIT_HANDLER(_tc, _fmt, ...) \
Florin Corase69f4952017-03-07 10:06:24 -0800100{ \
101 _tc->c_elog_track.name = \
Florin Coras6792ec02017-03-13 03:49:51 -0700102 (char *) format (0, _fmt, _tc->c_c_index, 0); \
Florin Corase69f4952017-03-07 10:06:24 -0800103 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 Coras6792ec02017-03-13 03:49:51 -0700113 TCP_EVT_INIT_HANDLER(_tc, "s%d%c"); \
Florin Corase69f4952017-03-07 10:06:24 -0800114 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 Coras6792ec02017-03-13 03:49:51 -0700136 TCP_EVT_INIT_HANDLER(_tc, "l%d%c"); \
Florin Corase69f4952017-03-07 10:06:24 -0800137 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 Coras6792ec02017-03-13 03:49:51 -0700164 DECLARE_ETD(_tc, _e, 1); \
Florin Corase69f4952017-03-07 10:06:24 -0800165 ed->data[0] = _tc->c_c_index; \
166 TCP_EVT_DEALLOC_HANDLER(_tc); \
167}
168
Florin Corasf03a59a2017-06-09 21:07:32 -0700169#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 Coras6792ec02017-03-13 03:49:51 -0700193#define TCP_EVT_ACK_SENT_HANDLER(_tc, ...) \
194{ \
195 ELOG_TYPE_DECLARE (_e) = \
196 { \
Florin Coras3e350af2017-03-30 02:54:28 -0700197 .format = "ack_tx: acked %u rcv_nxt %u rcv_wnd %u snd_nxt %u snd_wnd %u",\
198 .format_args = "i4i4i4i4i4", \
Florin Coras6792ec02017-03-13 03:49:51 -0700199 }; \
Florin Coras3e350af2017-03-30 02:54:28 -0700200 DECLARE_ETD(_tc, _e, 5); \
Florin Coras6792ec02017-03-13 03:49:51 -0700201 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 Coras3e350af2017-03-30 02:54:28 -0700205 ed->data[4] = _tc->snd_wnd; \
Florin Coras6792ec02017-03-13 03:49:51 -0700206}
207
208#define TCP_EVT_DUPACK_SENT_HANDLER(_tc, ...) \
209{ \
210 ELOG_TYPE_DECLARE (_e) = \
211 { \
Florin Coras3e350af2017-03-30 02:54:28 -0700212 .format = "dack_tx: rcv_nxt %u rcv_wnd %u snd_nxt %u av_wnd %u snd_wnd %u",\
213 .format_args = "i4i4i4i4i4", \
Florin Coras6792ec02017-03-13 03:49:51 -0700214 }; \
Florin Coras3e350af2017-03-30 02:54:28 -0700215 DECLARE_ETD(_tc, _e, 5); \
Florin Coras6792ec02017-03-13 03:49:51 -0700216 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 Coras3e350af2017-03-30 02:54:28 -0700220 ed->data[4] = _tc->snd_wnd; \
Florin Coras6792ec02017-03-13 03:49:51 -0700221}
222
Florin Corase69f4952017-03-07 10:06:24 -0800223#define TCP_EVT_SYN_SENT_HANDLER(_tc, ...) \
224{ \
225 ELOG_TYPE_DECLARE (_e) = \
226 { \
Florin Coras3e350af2017-03-30 02:54:28 -0700227 .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 Corase69f4952017-03-07 10:06:24 -0800239 .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 Coras6792ec02017-03-13 03:49:51 -0700249 .format = "FINtx: snd_nxt %d rcv_nxt %d", \
Florin Corase69f4952017-03-07 10:06:24 -0800250 .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 Coras6792ec02017-03-13 03:49:51 -0700261 .format = "RSTtx: snd_nxt %d rcv_nxt %d", \
Florin Corase69f4952017-03-07 10:06:24 -0800262 .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 Corase69f4952017-03-07 10:06:24 -0800269#define TCP_EVT_FIN_RCVD_HANDLER(_tc, ...) \
270{ \
271 ELOG_TYPE_DECLARE (_e) = \
272 { \
Florin Coras6792ec02017-03-13 03:49:51 -0700273 .format = "FINrx: snd_nxt %d rcv_nxt %d", \
Florin Corase69f4952017-03-07 10:06:24 -0800274 .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 Coras6792ec02017-03-13 03:49:51 -0700285 .format = "RSTrx: snd_nxt %d rcv_nxt %d", \
Florin Corase69f4952017-03-07 10:06:24 -0800286 .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 Coras3e350af2017-03-30 02:54:28 -0700293#define TCP_EVT_ACK_RCVD_HANDLER(_tc, ...) \
Florin Corase69f4952017-03-07 10:06:24 -0800294{ \
295 ELOG_TYPE_DECLARE (_e) = \
296 { \
Florin Coras3e350af2017-03-30 02:54:28 -0700297 .format = "acked: %u snd_una %u snd_wnd %u cwnd %u inflight %u", \
Florin Coras6792ec02017-03-13 03:49:51 -0700298 .format_args = "i4i4i4i4i4", \
Florin Corase69f4952017-03-07 10:06:24 -0800299 }; \
Florin Coras6792ec02017-03-13 03:49:51 -0700300 DECLARE_ETD(_tc, _e, 5); \
Florin Corase69f4952017-03-07 10:06:24 -0800301 ed->data[0] = _tc->bytes_acked; \
Florin Coras6792ec02017-03-13 03:49:51 -0700302 ed->data[1] = _tc->snd_una - _tc->iss; \
Florin Coras3e350af2017-03-30 02:54:28 -0700303 ed->data[2] = _tc->snd_wnd; \
Florin Coras6792ec02017-03-13 03:49:51 -0700304 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 Coras3e350af2017-03-30 02:54:28 -0700312 .format = "dack_rx: snd_una %u cwnd %u snd_wnd %u flight %u rcv_wnd %u",\
313 .format_args = "i4i4i4i4i4", \
Florin Coras6792ec02017-03-13 03:49:51 -0700314 }; \
Florin Coras3e350af2017-03-30 02:54:28 -0700315 DECLARE_ETD(_tc, _e, 5); \
Florin Coras6792ec02017-03-13 03:49:51 -0700316 ed->data[0] = _tc->snd_una - _tc->iss; \
Florin Corase69f4952017-03-07 10:06:24 -0800317 ed->data[1] = _tc->cwnd; \
Florin Coras6792ec02017-03-13 03:49:51 -0700318 ed->data[2] = _tc->snd_wnd; \
319 ed->data[3] = tcp_flight_size(_tc); \
Florin Coras3e350af2017-03-30 02:54:28 -0700320 ed->data[4] = _tc->rcv_wnd; \
Florin Corase69f4952017-03-07 10:06:24 -0800321}
322
323#define TCP_EVT_PKTIZE_HANDLER(_tc, ...) \
324{ \
325 ELOG_TYPE_DECLARE (_e) = \
326 { \
Florin Coras6792ec02017-03-13 03:49:51 -0700327 .format = "pktize: una %u snd_nxt %u space %u flight %u rcv_wnd %u",\
328 .format_args = "i4i4i4i4i4", \
Florin Corase69f4952017-03-07 10:06:24 -0800329 }; \
Florin Coras6792ec02017-03-13 03:49:51 -0700330 DECLARE_ETD(_tc, _e, 5); \
Florin Corase69f4952017-03-07 10:06:24 -0800331 ed->data[0] = _tc->snd_una - _tc->iss; \
332 ed->data[1] = _tc->snd_nxt - _tc->iss; \
Florin Coras6792ec02017-03-13 03:49:51 -0700333 ed->data[2] = tcp_available_snd_space (_tc); \
334 ed->data[3] = tcp_flight_size (_tc); \
335 ed->data[4] = _tc->rcv_wnd; \
Florin Corase69f4952017-03-07 10:06:24 -0800336}
337
Florin Coras6792ec02017-03-13 03:49:51 -0700338#define TCP_EVT_INPUT_HANDLER(_tc, _type, _len, _written, ...) \
Florin Corase69f4952017-03-07 10:06:24 -0800339{ \
340 ELOG_TYPE_DECLARE (_e) = \
341 { \
Florin Coras3e350af2017-03-30 02:54:28 -0700342 .format = "in: %s len %u written %d rcv_nxt %u rcv_wnd(o) %d", \
Florin Coras6792ec02017-03-13 03:49:51 -0700343 .format_args = "t4i4i4i4i4", \
344 .n_enum_strings = 2, \
345 .enum_strings = { \
346 "order", \
347 "ooo", \
348 }, \
Florin Corase69f4952017-03-07 10:06:24 -0800349 }; \
Florin Coras6792ec02017-03-13 03:49:51 -0700350 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 Corase69f4952017-03-07 10:06:24 -0800356}
357
358#define TCP_EVT_TIMER_POP_HANDLER(_tc_index, _timer_id, ...) \
359{ \
360 tcp_connection_t *_tc; \
flyingeagle23e8146b02017-04-26 20:06:52 +0800361 if (_timer_id == TCP_TIMER_RETRANSMIT_SYN \
362 || _timer_id == TCP_TIMER_ESTABLISH) \
Florin Corase69f4952017-03-07 10:06:24 -0800363 { \
364 _tc = tcp_half_open_connection_get (_tc_index); \
365 } \
366 else \
367 { \
Damjan Marion586afd72017-04-05 19:18:20 +0200368 u32 _thread_index = vlib_get_thread_index (); \
Florin Corase69f4952017-03-07 10:06:24 -0800369 _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 Coras3e350af2017-03-30 02:54:28 -0700379 "persist", \
Florin Corase69f4952017-03-07 10:06:24 -0800380 "keep", \
381 "waitclose", \
382 "retransmit syn", \
383 "establish", \
384 }, \
385 }; \
Dave Barach2c25a622017-06-26 11:35:07 -0400386 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 Corase69f4952017-03-07 10:06:24 -0800396}
397
Florin Coras6792ec02017-03-13 03:49:51 -0700398#define TCP_EVT_SEG_INVALID_HANDLER(_tc, _seq, _end, ...) \
399{ \
400 ELOG_TYPE_DECLARE (_e) = \
401 { \
Florin Coras3e350af2017-03-30 02:54:28 -0700402 .format = "seg-inv: seq %u end %u rcv_las %u rcv_nxt %u rcv_wnd %u",\
Florin Coras6792ec02017-03-13 03:49:51 -0700403 .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 Corasc28764f2017-04-26 00:08:42 -0700413#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 Coras93992a92017-05-24 18:03:56 -0700423 ed->data[2] = _tc->rcv_opts.tsval; \
Florin Corasc28764f2017-04-26 00:08:42 -0700424 ed->data[3] = _tc->tsval_recent; \
425}
426
Florin Coras6792ec02017-03-13 03:49:51 -0700427#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 Corasf03a59a2017-06-09 21:07:32 -0700448#define TCP_EVT_RCV_WND_SHRUNK_HANDLER(_tc, _obs, _av, ...) \
449{ \
450if (_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 Coras6792ec02017-03-13 03:49:51 -0700516/*
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 Coras93992a92017-05-24 18:03:56 -0700525 .format = "rxt: snd_nxt %u offset %u snd %u rxt %u", \
Florin Coras6792ec02017-03-13 03:49:51 -0700526 .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 Coras93992a92017-05-24 18:03:56 -0700532 ed->data[3] = _tc->snd_rxt_bytes; \
Florin Coras6792ec02017-03-13 03:49:51 -0700533}
534
535#define TCP_EVT_CC_EVT_HANDLER(_tc, _sub_evt, ...) \
536{ \
537 ELOG_TYPE_DECLARE (_e) = \
538 { \
Florin Coras93992a92017-05-24 18:03:56 -0700539 .format = "cc: %s wnd %u snd_cong %u rxt_bytes %u", \
Florin Coras6792ec02017-03-13 03:49:51 -0700540 .format_args = "t4i4i4i4", \
541 .n_enum_strings = 5, \
542 .enum_strings = { \
Florin Coras93992a92017-05-24 18:03:56 -0700543 "fast-rxt", \
544 "rxt-timeout", \
545 "first-rxt", \
Florin Coras6792ec02017-03-13 03:49:51 -0700546 "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 Coras93992a92017-05-24 18:03:56 -0700554 ed->data[3] = _tc->snd_rxt_bytes; \
Florin Coras6792ec02017-03-13 03:49:51 -0700555}
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 Corasf03a59a2017-06-09 21:07:32 -0700569/*
570 * Congestion control stats
571 */
572#if TCP_DEBUG_CC_STAT
Florin Coras6792ec02017-03-13 03:49:51 -0700573
Florin Corasf03a59a2017-06-09 21:07:32 -0700574#define STATS_INTERVAL 1
575
576#define TCP_EVT_CC_RTO_STAT_HANDLER(_tc, ...) \
Florin Coras3e350af2017-03-30 02:54:28 -0700577{ \
Florin Corasf03a59a2017-06-09 21:07:32 -0700578if (_tc->c_cc_stat_tstamp + STATS_INTERVAL < tcp_time_now()) \
Florin Coras3e350af2017-03-30 02:54:28 -0700579{ \
580 ELOG_TYPE_DECLARE (_e) = \
581 { \
Florin Corasf03a59a2017-06-09 21:07:32 -0700582 .format = "rto_stat: rto %u srtt %u rttvar %u ", \
583 .format_args = "i4i4i4", \
Florin Coras3e350af2017-03-30 02:54:28 -0700584 }; \
Florin Corasf03a59a2017-06-09 21:07:32 -0700585 DECLARE_ETD(_tc, _e, 3); \
586 ed->data[0] = _tc->rto; \
587 ed->data[1] = _tc->srtt; \
588 ed->data[2] = _tc->rttvar; \
Florin Coras3e350af2017-03-30 02:54:28 -0700589} \
590}
591
Florin Corasf03a59a2017-06-09 21:07:32 -0700592#define TCP_EVT_CC_STAT_HANDLER(_tc, ...) \
593{ \
594if (_tc->c_cc_stat_tstamp + STATS_INTERVAL < tcp_time_now()) \
Florin Coras6792ec02017-03-13 03:49:51 -0700595{ \
596 ELOG_TYPE_DECLARE (_e) = \
597 { \
Florin Corasf03a59a2017-06-09 21:07:32 -0700598 .format = "cc_stat: cwnd %u flight %u space %u ssthresh %u snd_wnd %u",\
599 .format_args = "i4i4i4i4i4", \
Florin Coras6792ec02017-03-13 03:49:51 -0700600 }; \
Florin Corasf03a59a2017-06-09 21:07:32 -0700601 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 Coras6792ec02017-03-13 03:49:51 -0700610}
611
Florin Coras6792ec02017-03-13 03:49:51 -0700612#else
Florin Corasf03a59a2017-06-09 21:07:32 -0700613#define TCP_EVT_CC_STAT_HANDLER(_tc, ...)
Florin Coras6792ec02017-03-13 03:49:51 -0700614#endif
615
Florin Corase69f4952017-03-07 10:06:24 -0800616#else
Florin Corasf03a59a2017-06-09 21:07:32 -0700617#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 Corase69f4952017-03-07 10:06:24 -0800620#endif
621
Florin Corase69f4952017-03-07 10:06:24 -0800622#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 */