FD.io VPP  v19.04.4-rc0-5-ge88582fac
Vector Packet Processing
elog_acl_trace.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018 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 _ELOG_ACL_TRACE_H_
17 #define _ELOG_ACL_TRACE_H_
18 
19 
20 /* use like: elog_acl_cond_trace_X1(am, (x < 0), "foobar: %d", "i4", int32_value); */
21 
22 #define elog_acl_cond_trace_X1(am, trace_cond, acl_elog_trace_format_label, acl_elog_trace_format_args, acl_elog_val1) \
23 do { \
24  if (trace_cond) { \
25  CLIB_UNUSED(struct { u8 available_space[18 - sizeof(acl_elog_val1)]; } *static_check); \
26  u16 thread_index = os_get_thread_index (); \
27  vlib_worker_thread_t * w = vlib_worker_threads + thread_index; \
28  ELOG_TYPE_DECLARE (e) = \
29  { \
30  .format = "(%02d) " acl_elog_trace_format_label, \
31  .format_args = "i2" acl_elog_trace_format_args, \
32  }; \
33  CLIB_PACKED(struct \
34  { \
35  u16 thread; \
36  typeof(acl_elog_val1) val1; \
37  }) *ed; \
38  ed = ELOG_TRACK_DATA (&vlib_global_main.elog_main, e, w->elog_track); \
39  ed->thread = thread_index; \
40  ed->val1 = acl_elog_val1; \
41  } \
42 } while (0)
43 
44 
45 /* use like: elog_acl_cond_trace_X2(am, (x<0), "foobar: %d some u64: %lu", "i4i8", int32_value, int64_value); */
46 
47 #define elog_acl_cond_trace_X2(am, trace_cond, acl_elog_trace_format_label, acl_elog_trace_format_args, \
48  acl_elog_val1, acl_elog_val2) \
49 do { \
50  if (trace_cond) { \
51  CLIB_UNUSED(struct { u8 available_space[18 - sizeof(acl_elog_val1) - sizeof(acl_elog_val2)]; } *static_check); \
52  u16 thread_index = os_get_thread_index (); \
53  vlib_worker_thread_t * w = vlib_worker_threads + thread_index; \
54  ELOG_TYPE_DECLARE (e) = \
55  { \
56  .format = "(%02d) " acl_elog_trace_format_label, \
57  .format_args = "i2" acl_elog_trace_format_args, \
58  }; \
59  CLIB_PACKED(struct \
60  { \
61  u16 thread; \
62  typeof(acl_elog_val1) val1; \
63  typeof(acl_elog_val2) val2; \
64  }) *ed; \
65  ed = ELOG_TRACK_DATA (&vlib_global_main.elog_main, e, w->elog_track); \
66  ed->thread = thread_index; \
67  ed->val1 = acl_elog_val1; \
68  ed->val2 = acl_elog_val2; \
69  } \
70 } while (0)
71 
72 
73 /* use like: elog_acl_cond_trace_X3(am, (x<0), "foobar: %d some u64 %lu baz: %d", "i4i8i4", int32_value, u64_value, int_value); */
74 
75 #define elog_acl_cond_trace_X3(am, trace_cond, acl_elog_trace_format_label, acl_elog_trace_format_args, acl_elog_val1, \
76  acl_elog_val2, acl_elog_val3) \
77 do { \
78  if (trace_cond) { \
79  CLIB_UNUSED(struct { u8 available_space[18 - sizeof(acl_elog_val1) - sizeof(acl_elog_val2) \
80  - sizeof(acl_elog_val3)]; } *static_check); \
81  u16 thread_index = os_get_thread_index (); \
82  vlib_worker_thread_t * w = vlib_worker_threads + thread_index; \
83  ELOG_TYPE_DECLARE (e) = \
84  { \
85  .format = "(%02d) " acl_elog_trace_format_label, \
86  .format_args = "i2" acl_elog_trace_format_args, \
87  }; \
88  CLIB_PACKED(struct \
89  { \
90  u16 thread; \
91  typeof(acl_elog_val1) val1; \
92  typeof(acl_elog_val2) val2; \
93  typeof(acl_elog_val3) val3; \
94  }) *ed; \
95  ed = ELOG_TRACK_DATA (&vlib_global_main.elog_main, e, w->elog_track); \
96  ed->thread = thread_index; \
97  ed->val1 = acl_elog_val1; \
98  ed->val2 = acl_elog_val2; \
99  ed->val3 = acl_elog_val3; \
100  } \
101 } while (0)
102 
103 
104 /* use like: elog_acl_cond_trace_X4(am, (x<0), "foobar: %d some int %d baz: %d bar: %d", "i4i4i4i4", int32_value, int32_value2, int_value, int_value); */
105 
106 #define elog_acl_cond_trace_X4(am, trace_cond, acl_elog_trace_format_label, acl_elog_trace_format_args, acl_elog_val1, \
107  acl_elog_val2, acl_elog_val3, acl_elog_val4) \
108 do { \
109  if (trace_cond) { \
110  CLIB_UNUSED(struct { u8 available_space[18 - sizeof(acl_elog_val1) - sizeof(acl_elog_val2) \
111  - sizeof(acl_elog_val3) -sizeof(acl_elog_val4)]; } *static_check); \
112  u16 thread_index = os_get_thread_index (); \
113  vlib_worker_thread_t * w = vlib_worker_threads + thread_index; \
114  ELOG_TYPE_DECLARE (e) = \
115  { \
116  .format = "(%02d) " acl_elog_trace_format_label, \
117  .format_args = "i2" acl_elog_trace_format_args, \
118  }; \
119  CLIB_PACKED(struct \
120  { \
121  u16 thread; \
122  typeof(acl_elog_val1) val1; \
123  typeof(acl_elog_val2) val2; \
124  typeof(acl_elog_val3) val3; \
125  typeof(acl_elog_val4) val4; \
126  }) *ed; \
127  ed = ELOG_TRACK_DATA (&vlib_global_main.elog_main, e, w->elog_track); \
128  ed->thread = thread_index; \
129  ed->val1 = acl_elog_val1; \
130  ed->val2 = acl_elog_val2; \
131  ed->val3 = acl_elog_val3; \
132  ed->val4 = acl_elog_val4; \
133  } \
134 } while (0)
135 
136 
137 #endif