FD.io VPP  v17.10-9-gd594711
Vector Packet Processing
tcp_debug.h
Go to the documentation of this file.
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)
22 #define TCP_DEBUG_SM (0)
23 #define TCP_DEBUG_CC (0)
24 #define TCP_DEBUG_CC_STAT (1)
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") \
35  _(SYNACK_SENT, "SYNACK sent") \
36  _(SYNACK_RCVD, "SYNACK rcvd") \
37  _(SYN_RXT, "SYN retransmit") \
38  _(FIN_SENT, "FIN sent") \
39  _(ACK_SENT, "ACK sent") \
40  _(DUPACK_SENT, "DUPACK sent") \
41  _(RST_SENT, "RST sent") \
42  _(SYN_RCVD, "SYN rcvd") \
43  _(ACK_RCVD, "ACK rcvd") \
44  _(DUPACK_RCVD, "DUPACK rcvd") \
45  _(FIN_RCVD, "FIN rcvd") \
46  _(RST_RCVD, "RST rcvd") \
47  _(STATE_CHANGE, "state change") \
48  _(PKTIZE, "packetize") \
49  _(INPUT, "in") \
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") \
56  _(CC_STAT, "cc stats") \
57  _(CC_RTO_STAT, "cc rto stats") \
58  _(SEG_INVALID, "invalid segment") \
59  _(PAWS_FAIL, "failed paws check") \
60  _(ACK_RCV_ERR, "invalid ack") \
61  _(RCV_WND_SHRUNK, "shrunk rcv_wnd") \
62 
63 typedef enum _tcp_dbg
64 {
65 #define _(sym, str) TCP_DBG_##sym,
67 #undef _
68 } tcp_dbg_e;
69 
70 typedef enum _tcp_dbg_evt
71 {
72 #define _(sym, str) TCP_EVT_##sym,
74 #undef _
76 
77 #if TCP_DEBUG
78 
79 #define TRANSPORT_DEBUG (1)
80 
81 /*
82  * Infra and evt track setup
83  */
84 
85 #define TCP_DBG(_fmt, _args...) clib_warning (_fmt, ##_args)
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 
95 #define TCP_DBG_IP_TAG_LCL(_tc) \
96 { \
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); \
150  elog_track_register (&vlib_global_main.elog_main, &_tc->c_elog_track);\
151  TCP_DBG_IP_TAG_LCL(_tc); \
152  TCP_DBG_IP_TAG_RMT(_tc); \
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 { \
162  TCP_EVT_INIT_HANDLER(_tc, 0); \
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 { \
185  TCP_EVT_INIT_HANDLER(_tc, 1); \
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 
194 #define TCP_EVT_SYN_RCVD_HANDLER(_tc,_init, ...) \
195 { \
196  if (_init) \
197  TCP_EVT_INIT_HANDLER(_tc, 0); \
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 
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  }; \
227  DECLARE_ETD(_tc, _e, 1); \
228  ed->data[0] = _tc->c_c_index; \
229  TCP_EVT_DEALLOC_HANDLER(_tc); \
230 }
231 
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...)
237 #define TCP_DBG(_fmt, _args...)
238 #endif
239 
240 /*
241  * State machine
242  */
243 #if TCP_DEBUG_SM
244 
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 
270 #define TCP_EVT_SYN_SENT_HANDLER(_tc, ...) \
271 { \
272  ELOG_TYPE_DECLARE (_e) = \
273  { \
274  .format = "syn-tx: iss %u snd_una %u snd_una_max %u snd_nxt %u", \
275  .format_args = "i4i4i4i4", \
276  }; \
277  DECLARE_ETD(_tc, _e, 4); \
278  ed->data[0] = _tc->iss; \
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; \
282  TCP_EVT_STATE_CHANGE_HANDLER(_tc); \
283 }
284 
285 #define TCP_EVT_SYNACK_SENT_HANDLER(_tc, ...) \
286 { \
287  ELOG_TYPE_DECLARE (_e) = \
288  { \
289  .format = "synack-tx: iss %u irs %u snd_una %u snd_nxt %u rcv_nxt %u",\
290  .format_args = "i4i4i4i4i4", \
291  }; \
292  DECLARE_ETD(_tc, _e, 5); \
293  ed->data[0] = _tc->iss; \
294  ed->data[1] = _tc->irs; \
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; \
298 }
299 
300 #define TCP_EVT_SYNACK_RCVD_HANDLER(_tc, ...) \
301 { \
302  ELOG_TYPE_DECLARE (_e) = \
303  { \
304  .format = "synack-rx: iss %u irs %u snd_una %u snd_nxt %u rcv_nxt %u",\
305  .format_args = "i4i4i4i4i4", \
306  }; \
307  DECLARE_ETD(_tc, _e, 5); \
308  ed->data[0] = _tc->iss; \
309  ed->data[1] = _tc->irs; \
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; \
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  { \
369  .format = "%s-rxt: iss %u irs %u snd_nxt %u rcv_nxt %u", \
370  .format_args = "t4i4i4i4i4", \
371  .n_enum_strings = 2, \
372  .enum_strings = { \
373  "syn", \
374  "syn-ack", \
375  }, \
376  }; \
377  DECLARE_ETD(_tc, _e, 5); \
378  ed->data[0] = _type; \
379  ed->data[1] = _tc->iss; \
380  ed->data[2] = _tc->irs; \
381  ed->data[3] = _tc->snd_nxt - _tc->iss; \
382  ed->data[4] = _tc->rcv_nxt - _tc->irs; \
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 
399 #define TCP_EVT_ACK_SENT_HANDLER(_tc, ...) \
400 { \
401  ELOG_TYPE_DECLARE (_e) = \
402  { \
403  .format = "ack-tx: acked %u rcv_nxt %u rcv_wnd %u snd_nxt %u snd_wnd %u",\
404  .format_args = "i4i4i4i4i4", \
405  }; \
406  DECLARE_ETD(_tc, _e, 5); \
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; \
411  ed->data[4] = _tc->snd_wnd; \
412 }
413 
414 #define TCP_EVT_ACK_RCVD_HANDLER(_tc, ...) \
415 { \
416  ELOG_TYPE_DECLARE (_e) = \
417  { \
418  .format = "ack-rx: %u snd_una %u snd_wnd %u cwnd %u inflight %u", \
419  .format_args = "i4i4i4i4i4", \
420  }; \
421  DECLARE_ETD(_tc, _e, 5); \
422  ed->data[0] = _tc->bytes_acked; \
423  ed->data[1] = _tc->snd_una - _tc->iss; \
424  ed->data[2] = _tc->snd_wnd; \
425  ed->data[3] = _tc->cwnd; \
426  ed->data[4] = tcp_flight_size(_tc); \
427 }
428 
429 #define TCP_EVT_PKTIZE_HANDLER(_tc, ...) \
430 { \
431  ELOG_TYPE_DECLARE (_e) = \
432  { \
433  .format = "tx: una %u snd_nxt %u space %u flight %u rcv_wnd %u",\
434  .format_args = "i4i4i4i4i4", \
435  }; \
436  DECLARE_ETD(_tc, _e, 5); \
437  ed->data[0] = _tc->snd_una - _tc->iss; \
438  ed->data[1] = _tc->snd_nxt - _tc->iss; \
439  ed->data[2] = tcp_available_output_snd_space (_tc); \
440  ed->data[3] = tcp_flight_size (_tc); \
441  ed->data[4] = _tc->rcv_wnd; \
442 }
443 
444 #define TCP_EVT_INPUT_HANDLER(_tc, _type, _len, _written, ...) \
445 { \
446  ELOG_TYPE_DECLARE (_e) = \
447  { \
448  .format = "in: %s len %u written %d rcv_nxt %u rcv_wnd(o) %d", \
449  .format_args = "t4i4i4i4i4", \
450  .n_enum_strings = 2, \
451  .enum_strings = { \
452  "order", \
453  "ooo", \
454  }, \
455  }; \
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); \
462 }
463 
464 #define TCP_EVT_TIMER_POP_HANDLER(_tc_index, _timer_id, ...) \
465 { \
466  tcp_connection_t *_tc; \
467  if (_timer_id == TCP_TIMER_RETRANSMIT_SYN \
468  || _timer_id == TCP_TIMER_ESTABLISH) \
469  { \
470  _tc = tcp_half_open_connection_get (_tc_index); \
471  } \
472  else \
473  { \
474  u32 _thread_index = vlib_get_thread_index (); \
475  _tc = tcp_connection_get (_tc_index, _thread_index); \
476  } \
477  ELOG_TYPE_DECLARE (_e) = \
478  { \
479  .format = "timer-pop: %s (%d)", \
480  .format_args = "t4i4", \
481  .n_enum_strings = 7, \
482  .enum_strings = { \
483  "retransmit", \
484  "delack", \
485  "persist", \
486  "keep", \
487  "waitclose", \
488  "retransmit syn", \
489  "establish", \
490  }, \
491  }; \
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  { \
500  clib_warning ("pop %d for unexisting connection %d", _timer_id, \
501  _tc_index); \
502  } \
503 }
504 
505 #define TCP_EVT_SEG_INVALID_HANDLER(_tc, _seq, _end, ...) \
506 { \
507  ELOG_TYPE_DECLARE (_e) = \
508  { \
509  .format = "seg-inv: seq %u end %u rcv_las %u rcv_nxt %u rcv_wnd %u",\
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 
520 #define TCP_EVT_PAWS_FAIL_HANDLER(_tc, _seq, _end, ...) \
521 { \
522  ELOG_TYPE_DECLARE (_e) = \
523  { \
524  .format = "paws-err: seq %u end %u tsval %u tsval_recent %u", \
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; \
530  ed->data[2] = _tc->rcv_opts.tsval; \
531  ed->data[3] = _tc->tsval_recent; \
532 }
533 
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 
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, ...)
574 #define TCP_EVT_ACK_RCVD_HANDLER(_tc, ...)
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  */
587 #if TCP_DEBUG_SM > 2
588 #define TCP_EVT_SND_WND_HANDLER(_tc, ...) \
589 { \
590  ELOG_TYPE_DECLARE (_e) = \
591  { \
592  .format = "snd-wnd update: %u ", \
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 
615 /*
616  * Congestion Control
617  */
618 
619 #if TCP_DEBUG_CC
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 
644 #define TCP_EVT_CC_RTX_HANDLER(_tc, offset, n_bytes, ...) \
645 { \
646  ELOG_TYPE_DECLARE (_e) = \
647  { \
648  .format = "rxt: snd_nxt %u offset %u snd %u rxt %u", \
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; \
655  ed->data[3] = _tc->snd_rxt_bytes; \
656 }
657 
658 #define TCP_EVT_DUPACK_SENT_HANDLER(_tc, ...) \
659 { \
660  ELOG_TYPE_DECLARE (_e) = \
661  { \
662  .format = "dack-tx: rcv_nxt %u rcv_wnd %u snd_nxt %u av_wnd %u snd_wnd %u",\
663  .format_args = "i4i4i4i4i4", \
664  }; \
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; \
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 }
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
706 
707 /*
708  * Congestion control stats
709  */
710 #if TCP_DEBUG_CC_STAT
711 
712 #define STATS_INTERVAL 1
713 
714 #define TCP_EVT_CC_RTO_STAT_HANDLER(_tc, ...) \
715 { \
716 if (_tc->c_cc_stat_tstamp + STATS_INTERVAL < tcp_time_now()) \
717 { \
718  ELOG_TYPE_DECLARE (_e) = \
719  { \
720  .format = "rto_stat: rto %u srtt %u rttvar %u ", \
721  .format_args = "i4i4i4", \
722  }; \
723  DECLARE_ETD(_tc, _e, 3); \
724  ed->data[0] = _tc->rto; \
725  ed->data[1] = _tc->srtt; \
726  ed->data[2] = _tc->rttvar; \
727 } \
728 }
729 
730 #define TCP_EVT_CC_STAT_HANDLER(_tc, ...) \
731 { \
732 if (_tc->c_cc_stat_tstamp + STATS_INTERVAL < tcp_time_now()) \
733 { \
734  ELOG_TYPE_DECLARE (_e) = \
735  { \
736  .format = "cc_stat: cwnd %u flight %u space %u ssthresh %u snd_wnd %u",\
737  .format_args = "i4i4i4i4i4", \
738  }; \
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 } \
748 }
749 
750 #else
751 #define TCP_EVT_CC_STAT_HANDLER(_tc, ...)
752 #endif
753 
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  */
enum _tcp_dbg tcp_dbg_e
#define foreach_tcp_dbg_evt
Definition: tcp_debug.h:26
enum _tcp_dbg_evt tcp_dbg_evt_e