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:
7 * http://www.apache.org/licenses/LICENSE-2.0
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.
15 #ifndef SRC_VNET_SESSION_SESSION_DEBUG_H_
16 #define SRC_VNET_SESSION_SESSION_DEBUG_H_
18 #include <vnet/session/transport.h>
19 #include <vlib/vlib.h>
21 #define foreach_session_dbg_evt \
24 _(DEQ_NODE, "dequeue") \
25 _(POLL_GAP_TRACK, "poll gap track") \
27 typedef enum _session_evt_dbg
29 #define _(sym, str) SESSION_EVT_##sym,
30 foreach_session_dbg_evt
34 #define SESSION_DEBUG (0 && TRANSPORT_DEBUG)
35 #define SESSION_DEQ_NODE_EVTS (0)
36 #define SESSION_EVT_POLL_DBG (0)
40 #define SESSION_DBG(_fmt, _args...) clib_warning (_fmt, ##_args)
42 #define DEC_SESSION_ETD(_s, _e, _size) \
47 transport_connection_t *_tc = session_get_transport (_s); \
48 ed = ELOG_TRACK_DATA (&vlib_global_main.elog_main, \
51 #define DEC_SESSION_ED(_e, _size) \
56 ed = ELOG_DATA (&vlib_global_main.elog_main, _e)
58 #define SESSION_EVT_DEQ_HANDLER(_s, _body) \
60 ELOG_TYPE_DECLARE (_e) = \
62 .format = "deq: id %d len %d rd %d wnd %d", \
63 .format_args = "i4i4i4i4", \
65 DEC_SESSION_ETD(_s, _e, 4); \
66 do { _body; } while (0); \
69 #define SESSION_EVT_ENQ_HANDLER(_s, _body) \
71 ELOG_TYPE_DECLARE (_e) = \
73 .format = "enq: id %d length %d", \
74 .format_args = "i4i4", \
76 DEC_SESSION_ETD(_s, _e, 2); \
77 do { _body; } while (0); \
80 #if SESSION_DEQ_NODE_EVTS && SESSION_DEBUG > 1
81 #define SESSION_EVT_DEQ_NODE_HANDLER(_node_evt) \
83 ELOG_TYPE_DECLARE (_e) = \
85 .format = "deq-node: %s", \
86 .format_args = "t4", \
87 .n_enum_strings = 2, \
93 DEC_SESSION_ED(_e, 1); \
94 ed->data[0] = _node_evt; \
97 #define SESSION_EVT_DEQ_NODE_HANDLER(_node_evt)
98 #endif /* SESSION_DEQ_NODE_EVTS */
100 #if SESSION_EVT_POLL_DBG && SESSION_DEBUG > 1
101 #define SESSION_EVT_POLL_GAP(_smm, _ti) \
103 ELOG_TYPE_DECLARE (_e) = \
105 .format = "nixon-gap: %d us", \
106 .format_args = "i4", \
108 DEC_SESSION_ED(_e, 1); \
109 ed->data[0] = (u32) ((now - \
110 _smm->last_event_poll_by_thread[_ti])*1000000.0); \
112 #define SESSION_EVT_POLL_GAP_TRACK_HANDLER(_smm, _ti) \
114 if (PREDICT_TRUE (smm->last_event_poll_by_thread[_ti] != 0.0)) \
115 if (now > smm->last_event_poll_by_thread[_ti] + 500e-6) \
116 SESSION_EVT_POLL_GAP(smm, _ti); \
117 _smm->last_event_poll_by_thread[_ti] = now; \
121 #define SESSION_EVT_POLL_GAP(_smm, _my_thread_index)
122 #define SESSION_EVT_POLL_GAP_TRACK_HANDLER(_smm, _my_thread_index)
123 #endif /* SESSION_EVT_POLL_DBG */
125 #define CONCAT_HELPER(_a, _b) _a##_b
126 #define CC(_a, _b) CONCAT_HELPER(_a, _b)
127 #define SESSION_EVT_DBG(_evt, _args...) CC(_evt, _HANDLER)(_args)
130 #define SESSION_EVT_DBG(_evt, _args...)
131 #define SESSION_DBG(_fmt, _args...)
132 #endif /* SESSION_DEBUG */
134 #endif /* SRC_VNET_SESSION_SESSION_DEBUG_H_ */
136 * fd.io coding-style-patch-verification: ON
139 * eval: (c-set-style "gnu")