2 * trace_util.h -- Trace Profile Utility header
4 * Copyright (c) 2016 Cisco and/or its affiliates.
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at:
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
18 #ifndef include_vnet_trace_util_h
19 #define include_vnet_trace_util_h
21 #define debug_ioam debug_ioam_fn
27 * On any node that participates in iOAM Trace.
29 * Step 1: Initialize this library by calling trace_init()
30 * Step 2: Setup a trace profile that contains all the parameters needed to compute cumulative:
31 * Call these functions:
33 * trace_profile_create
34 * Step 2a: On initial node enable the profile to be used:
35 * trace_profile_set_active / trace_profile_get_active will return the profile
41 typedef struct trace_profile_
46 /* Configured node-id */
54 /* Name of the default profile list in use */
55 trace_profile profile;
57 /* API message ID base */
61 vlib_main_t *vlib_main;
62 vnet_main_t *vnet_main;
65 extern trace_main_t trace_main;
68 * Initialize Trace profile
70 int trace_util_init (void);
74 * Find a trace profile
77 always_inline trace_profile *
78 trace_profile_find (void)
80 trace_main_t *sm = &trace_main;
82 return (&(sm->profile));
86 /* setup and clean up profile */
87 int trace_profile_create (trace_profile * profile, u8 trace_type, u8 num_elts,
88 u32 trace_tsp, u32 node_id, u32 app_data);
90 void clear_trace_profiles (void);
94 #define BIT_TTL_NODEID (1<<0)
95 #define BIT_ING_INTERFACE (1<<1)
96 #define BIT_EGR_INTERFACE (1<<2)
97 #define BIT_TIMESTAMP (1<<3)
98 #define BIT_APPDATA (1<<4)
99 #define TRACE_TYPE_MASK 0x1F /* Mask of all above bits */
102 0x00011111 iOAM-trace-type is 0x00011111 then the format of node
105 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
106 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
107 | Hop_Lim | node_id |
108 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
109 | ingress_if_id | egress_if_id |
110 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
112 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
114 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
117 #define TRACE_TYPE_IF_TS_APP 0x1f
125 } ioam_trace_if_ts_app_t;
128 0x00000111 iOAM-trace-type is 0x00000111 then the format is:
130 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
131 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
132 | Hop_Lim | node_id |
133 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
134 | ingress_if_id | egress_if_id |
135 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
139 #define TRACE_TYPE_IF 0x03
148 0x00001001 iOAM-trace-type is 0x00001001 then the format is:
150 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
151 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
152 | Hop_Lim | node_id |
153 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
155 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
159 #define TRACE_TYPE_TS 0x09
167 0x00010001 iOAM-trace-type is 0x00010001 then the format is:
170 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
171 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
172 | Hop_Lim | node_id |
173 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
175 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
180 #define TRACE_TYPE_APP 0x11
189 0x00011001 iOAM-trace-type is 0x00011001 then the format is:
191 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
192 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
193 | Hop_Lim | node_id |
194 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
196 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
198 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
201 #define TRACE_TYPE_TS_APP 0x19
207 } ioam_trace_ts_app_t;
212 fetch_trace_data_size (u8 trace_type)
214 u8 trace_data_size = 0;
216 if (trace_type == TRACE_TYPE_IF_TS_APP)
217 trace_data_size = sizeof (ioam_trace_if_ts_app_t);
218 else if (trace_type == TRACE_TYPE_IF)
219 trace_data_size = sizeof (ioam_trace_if_t);
220 else if (trace_type == TRACE_TYPE_TS)
221 trace_data_size = sizeof (ioam_trace_ts_t);
222 else if (trace_type == TRACE_TYPE_APP)
223 trace_data_size = sizeof (ioam_trace_app_t);
224 else if (trace_type == TRACE_TYPE_TS_APP)
225 trace_data_size = sizeof (ioam_trace_ts_app_t);
227 return trace_data_size;
230 int ioam_trace_get_sizeof_handler (u32 * result);
231 int ip6_trace_profile_setup (void);
232 int ip6_trace_profile_cleanup (void);
234 #define TSP_SECONDS 0
235 #define TSP_MILLISECONDS 1
236 #define TSP_MICROSECONDS 2
237 #define TSP_NANOSECONDS 3
242 * fd.io coding-style-patch-verification: ON
245 * eval: (c-set-style "gnu")