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 #include <vnet/ip/ip6_hop_by_hop.h>
22 #define debug_ioam debug_ioam_fn
28 * On any node that participates in iOAM Trace.
30 * Step 1: Initialize this library by calling trace_init()
31 * Step 2: Setup a trace profile that contains all the parameters needed to compute cumulative:
32 * Call these functions:
34 * trace_profile_create
35 * Step 2a: On initial node enable the profile to be used:
36 * trace_profile_set_active / trace_profile_get_active will return the profile
42 typedef struct trace_profile_
47 /* Configured node-id */
55 /* Name of the default profile list in use */
56 trace_profile profile;
58 /* API message ID base */
62 vlib_main_t *vlib_main;
63 vnet_main_t *vnet_main;
66 extern trace_main_t trace_main;
69 * Initialize Trace profile
71 int trace_util_init (void);
75 * Find a trace profile by ID
77 always_inline trace_profile *trace_profile_find (void);
79 always_inline trace_profile *
80 trace_profile_find (void)
82 trace_main_t *sm = &trace_main;
84 return (&(sm->profile));
88 /* setup and clean up profile */
89 int trace_profile_create (trace_profile * profile, u8 trace_type, u8 num_elts,
90 u32 trace_tsp, u32 node_id, u32 app_data);
92 void clear_trace_profiles (void);
96 #define BIT_TTL_NODEID (1<<0)
97 #define BIT_ING_INTERFACE (1<<1)
98 #define BIT_EGR_INTERFACE (1<<2)
99 #define BIT_TIMESTAMP (1<<3)
100 #define BIT_APPDATA (1<<4)
101 #define TRACE_TYPE_MASK 0x1F /* Mask of all above bits */
104 0x00011111 iOAM-trace-type is 0x00011111 then the format of node
107 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
108 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
109 | Hop_Lim | node_id |
110 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
111 | ingress_if_id | egress_if_id |
112 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
114 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
116 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
119 #define TRACE_TYPE_IF_TS_APP 0x1f
127 } ioam_trace_if_ts_app_t;
130 0x00000111 iOAM-trace-type is 0x00000111 then the format is:
132 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
133 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
134 | Hop_Lim | node_id |
135 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
136 | ingress_if_id | egress_if_id |
137 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
141 #define TRACE_TYPE_IF 0x03
150 0x00001001 iOAM-trace-type is 0x00001001 then the format is:
152 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
153 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
154 | Hop_Lim | node_id |
155 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
157 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
161 #define TRACE_TYPE_TS 0x09
169 0x00010001 iOAM-trace-type is 0x00010001 then the format is:
172 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
173 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
174 | Hop_Lim | node_id |
175 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
177 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
182 #define TRACE_TYPE_APP 0x11
191 0x00011001 iOAM-trace-type is 0x00011001 then the format is:
193 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
194 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
195 | Hop_Lim | node_id |
196 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
198 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
200 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
203 #define TRACE_TYPE_TS_APP 0x19
209 } ioam_trace_ts_app_t;
213 typedef CLIB_PACKED(struct {
214 ip6_hop_by_hop_option_t hdr;
216 u8 data_list_elts_left;
217 u32 elts[0]; /* Variable type. So keep it generic */
218 }) ioam_trace_option_t;
223 fetch_trace_data_size (u8 trace_type)
225 u8 trace_data_size = 0;
227 if (trace_type == TRACE_TYPE_IF_TS_APP)
228 trace_data_size = sizeof (ioam_trace_if_ts_app_t);
229 else if (trace_type == TRACE_TYPE_IF)
230 trace_data_size = sizeof (ioam_trace_if_t);
231 else if (trace_type == TRACE_TYPE_TS)
232 trace_data_size = sizeof (ioam_trace_ts_t);
233 else if (trace_type == TRACE_TYPE_APP)
234 trace_data_size = sizeof (ioam_trace_app_t);
235 else if (trace_type == TRACE_TYPE_TS_APP)
236 trace_data_size = sizeof (ioam_trace_ts_app_t);
238 return trace_data_size;
241 int ioam_trace_get_sizeof_handler (u32 * result);
245 * fd.io coding-style-patch-verification: ON
248 * eval: (c-set-style "gnu")