FD.io VPP  v18.04-17-g3a0d853
Vector Packet Processing
session_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 #ifndef SRC_VNET_SESSION_SESSION_DEBUG_H_
16 #define SRC_VNET_SESSION_SESSION_DEBUG_H_
17 
18 #include <vnet/session/transport.h>
19 #include <vlib/vlib.h>
20 
21 #define foreach_session_dbg_evt \
22  _(ENQ, "enqueue") \
23  _(DEQ, "dequeue") \
24  _(DEQ_NODE, "dequeue") \
25  _(POLL_GAP_TRACK, "poll gap track") \
26 
27 typedef enum _session_evt_dbg
28 {
29 #define _(sym, str) SESSION_EVT_##sym,
31 #undef _
33 
34 #define SESSION_DEBUG (0 && TRANSPORT_DEBUG)
35 #define SESSION_DEQ_NODE_EVTS (0)
36 #define SESSION_EVT_POLL_DBG (0)
37 
38 #if SESSION_DEBUG
39 
40 #define SESSION_DBG(_fmt, _args...) clib_warning (_fmt, ##_args)
41 
42 #define DEC_SESSION_ETD(_s, _e, _size) \
43  struct \
44  { \
45  u32 data[_size]; \
46  } * ed; \
47  transport_proto_vft_t *vft = \
48  transport_protocol_get_vft (_s->session_type); \
49  transport_connection_t *_tc = \
50  vft->get_connection (_s->connection_index, _s->thread_index); \
51  ed = ELOG_TRACK_DATA (&vlib_global_main.elog_main, \
52  _e, _tc->elog_track)
53 
54 #define DEC_SESSION_ED(_e, _size) \
55  struct \
56  { \
57  u32 data[_size]; \
58  } * ed; \
59  ed = ELOG_DATA (&vlib_global_main.elog_main, _e)
60 
61 #define SESSION_EVT_DEQ_HANDLER(_s, _body) \
62 { \
63  ELOG_TYPE_DECLARE (_e) = \
64  { \
65  .format = "deq: id %d len %d rd %d wnd %d", \
66  .format_args = "i4i4i4i4", \
67  }; \
68  DEC_SESSION_ETD(_s, _e, 4); \
69  do { _body; } while (0); \
70 }
71 
72 #define SESSION_EVT_ENQ_HANDLER(_s, _body) \
73 { \
74  ELOG_TYPE_DECLARE (_e) = \
75  { \
76  .format = "enq: id %d length %d", \
77  .format_args = "i4i4", \
78  }; \
79  DEC_SESSION_ETD(_s, _e, 2); \
80  do { _body; } while (0); \
81 }
82 
83 #if SESSION_DEQ_NODE_EVTS && SESSION_DEBUG > 1
84 #define SESSION_EVT_DEQ_NODE_HANDLER(_node_evt) \
85 { \
86  ELOG_TYPE_DECLARE (_e) = \
87  { \
88  .format = "deq-node: %s", \
89  .format_args = "t4", \
90  .n_enum_strings = 2, \
91  .enum_strings = { \
92  "start", \
93  "end", \
94  }, \
95  }; \
96  DEC_SESSION_ED(_e, 1); \
97  ed->data[0] = _node_evt; \
98 }
99 #else
100 #define SESSION_EVT_DEQ_NODE_HANDLER(_node_evt)
101 #endif /* SESSION_DEQ_NODE_EVTS */
102 
103 #if SESSION_EVT_POLL_DBG && SESSION_DEBUG > 1
104 #define SESSION_EVT_POLL_GAP(_smm, _my_thread_index) \
105 { \
106  ELOG_TYPE_DECLARE (_e) = \
107  { \
108  .format = "nixon-gap: %d MS", \
109  .format_args = "i4", \
110  }; \
111  DEC_SESSION_ED(_e, 1); \
112  ed->data[0] = (u32) ((now - \
113  _smm->last_event_poll_by_thread[my_thread_index])*1000.0); \
114 }
115 #define SESSION_EVT_POLL_GAP_TRACK_HANDLER(_smm, _my_thread_index) \
116 { \
117  if (PREDICT_TRUE( \
118  smm->last_event_poll_by_thread[my_thread_index] != 0.0)) \
119  if (now > smm->last_event_poll_by_thread[_my_thread_index] + 500e-6)\
120  SESSION_EVT_POLL_GAP(smm, my_thread_index); \
121  _smm->last_event_poll_by_thread[my_thread_index] = now; \
122 }
123 
124 #else
125 #define SESSION_EVT_POLL_GAP(_smm, _my_thread_index)
126 #define SESSION_EVT_POLL_GAP_TRACK_HANDLER(_smm, _my_thread_index)
127 #endif /* SESSION_EVT_POLL_DBG */
128 
129 #define CONCAT_HELPER(_a, _b) _a##_b
130 #define CC(_a, _b) CONCAT_HELPER(_a, _b)
131 #define SESSION_EVT_DBG(_evt, _args...) CC(_evt, _HANDLER)(_args)
132 
133 #else
134 #define SESSION_EVT_DBG(_evt, _args...)
135 #define SESSION_DBG(_fmt, _args...)
136 #endif /* SESSION_DEBUG */
137 
138 #endif /* SRC_VNET_SESSION_SESSION_DEBUG_H_ */
139 /*
140  * fd.io coding-style-patch-verification: ON
141  *
142  * Local Variables:
143  * eval: (c-set-style "gnu")
144  * End:
145  */
#define foreach_session_dbg_evt
Definition: session_debug.h:21
enum _session_evt_dbg session_evt_dbg_e