FD.io VPP  v17.04.2-2-ga8f93f8
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 <vnet/session/session.h>
20 #include <vlib/vlib.h>
21 
22 #define foreach_session_dbg_evt \
23  _(ENQ, "enqueue") \
24  _(DEQ, "dequeue")
25 
26 typedef enum _session_evt_dbg
27 {
28 #define _(sym, str) SESSION_EVT_##sym,
30 #undef _
32 
33 #if TRANSPORT_DEBUG
34 
35 #define DEC_SESSION_ETD(_s, _e, _size) \
36  struct \
37  { \
38  u32 data[_size]; \
39  } * ed; \
40  transport_proto_vft_t *vft = \
41  session_get_transport_vft (_s->session_type); \
42  transport_connection_t *_tc = \
43  vft->get_connection (_s->connection_index, _s->thread_index); \
44  ed = ELOG_TRACK_DATA (&vlib_global_main.elog_main, \
45  _e, _tc->elog_track)
46 
47 
48 #define SESSION_EVT_DEQ_HANDLER(_s, _body) \
49 { \
50  ELOG_TYPE_DECLARE (_e) = \
51  { \
52  .format = "deq: id %d len %d rd %d wnd %d", \
53  .format_args = "i4i4i4i4", \
54  }; \
55  DEC_SESSION_ETD(_s, _e, 4); \
56  do { _body; } while (0); \
57 }
58 
59 #define SESSION_EVT_ENQ_HANDLER(_s, _body) \
60 { \
61  ELOG_TYPE_DECLARE (_e) = \
62  { \
63  .format = "enq: id %d length %d", \
64  .format_args = "i4i4", \
65  }; \
66  DEC_SESSION_ETD(_s, _e, 2); \
67  do { _body; } while (0); \
68 }
69 
70 #define CONCAT_HELPER(_a, _b) _a##_b
71 #define CC(_a, _b) CONCAT_HELPER(_a, _b)
72 
73 #define SESSION_EVT_DBG(_s, _evt, _body) CC(_evt, _HANDLER)(_s, _body)
74 
75 #else
76 #define SESSION_EVT_DBG(_s, _evt, _body)
77 #endif
78 
79 #endif /* SRC_VNET_SESSION_SESSION_DEBUG_H_ */
80 /*
81  * fd.io coding-style-patch-verification: ON
82  *
83  * Local Variables:
84  * eval: (c-set-style "gnu")
85  * End:
86  */
#define foreach_session_dbg_evt
Definition: session_debug.h:22
enum _session_evt_dbg session_evt_dbg_e