blob: d0a1d46ee996aac2a33c98fd91e4f792fe701dd8 [file] [log] [blame]
Dave Barach9b8ffd92016-07-08 08:13:45 -04001/*
Ed Warnickecb9cada2015-12-08 15:45:58 -07002 *------------------------------------------------------------------
3 * cj.h
4 *
5 * Copyright (c) 2013 Cisco and/or its affiliates.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at:
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *------------------------------------------------------------------
18 */
19
20#ifndef __included_cj_h__
21#define __included_cj_h__
22
Dave Barach9b8ffd92016-07-08 08:13:45 -040023typedef struct
24{
Ed Warnickecb9cada2015-12-08 15:45:58 -070025 f64 time;
Damjan Marion586afd72017-04-05 19:18:20 +020026 u32 thread_index;
Ed Warnickecb9cada2015-12-08 15:45:58 -070027 u32 type;
28 u64 data[2];
29} cj_record_t;
30
Dave Barach9b8ffd92016-07-08 08:13:45 -040031typedef struct
32{
Ed Warnickecb9cada2015-12-08 15:45:58 -070033 volatile u64 tail;
Dave Barach9b8ffd92016-07-08 08:13:45 -040034 cj_record_t *records;
Ed Warnickecb9cada2015-12-08 15:45:58 -070035 u32 num_records;
36 volatile u32 enable;
Dave Barach9b8ffd92016-07-08 08:13:45 -040037
38 vlib_main_t *vlib_main;
Ed Warnickecb9cada2015-12-08 15:45:58 -070039} cj_main_t;
40
Dave Barach9b8ffd92016-07-08 08:13:45 -040041void cj_log (u32 type, void *data0, void *data1);
Ed Warnickecb9cada2015-12-08 15:45:58 -070042
Dave Barach9b8ffd92016-07-08 08:13:45 -040043/*
Ed Warnickecb9cada2015-12-08 15:45:58 -070044 * Supply in application main, so we can log from any library...
45 * Declare a weak reference in the library, off you go.
46 */
47
48#define DECLARE_CJ_GLOBAL_LOG \
49void cj_global_log (unsigned type, void * data0, void * data1) \
50 __attribute__ ((weak)); \
51 \
52unsigned __cj_type; \
53void * __cj_data0; \
54void * __cj_data1; \
55 \
56void \
57cj_global_log (unsigned type, void * data0, void * data1) \
58{ \
59 __cj_type = type; \
60 __cj_data0 = data0; \
61 __cj_data1 = data1; \
62}
63
64#define CJ_GLOBAL_LOG_PROTOTYPE
Dave Barach9b8ffd92016-07-08 08:13:45 -040065void
66cj_global_log (unsigned type, void *data0, void *data1)
67__attribute__ ((weak));
Ed Warnickecb9cada2015-12-08 15:45:58 -070068
Dave Barach9b8ffd92016-07-08 08:13:45 -040069void cj_stop (void);
Ed Warnickecb9cada2015-12-08 15:45:58 -070070
71#endif /* __included_cj_h__ */
Dave Barach9b8ffd92016-07-08 08:13:45 -040072
73/*
74 * fd.io coding-style-patch-verification: ON
75 *
76 * Local Variables:
77 * eval: (c-set-style "gnu")
78 * End:
79 */