FD.io VPP  v21.06-3-gbb25fbf28
Vector Packet Processing
trace_api.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016 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  *------------------------------------------------------------------
17  * trace_api.c - iOAM Trace related APIs to create
18  * and maintain profiles
19  *------------------------------------------------------------------
20  */
21 
22 #include <vnet/vnet.h>
23 #include <vnet/plugin/plugin.h>
27 #include <vlibapi/api.h>
28 #include <vlibmemory/api.h>
29 
30 /* define message IDs */
31 #include <ioam/lib-trace/trace.api_enum.h>
32 #include <ioam/lib-trace/trace.api_types.h>
33 
36 {
37  int rv = 0;
38  vl_api_trace_profile_add_reply_t *rmp;
39  trace_profile *profile = NULL;
40 
41  profile = trace_profile_find ();
42  if (profile)
43  {
44  rv =
45  trace_profile_create (profile, mp->trace_type, mp->num_elts,
46  mp->trace_tsp, ntohl (mp->node_id),
47  ntohl (mp->app_data));
48  if (rv != 0)
49  goto ERROROUT;
50  }
51  else
52  {
53  rv = -3;
54  }
55 ERROROUT:
56  REPLY_MACRO (VL_API_TRACE_PROFILE_ADD_REPLY);
57 }
58 
59 
62 {
63  int rv = 0;
64  vl_api_trace_profile_del_reply_t *rmp;
65 
67 
68  REPLY_MACRO (VL_API_TRACE_PROFILE_DEL_REPLY);
69 }
70 
73 {
75  int rv = 0;
76  trace_profile *profile = trace_profile_find ();
77  if (profile->valid)
78  {
79  REPLY_MACRO2 (VL_API_TRACE_PROFILE_SHOW_CONFIG_REPLY,
80  rmp->trace_type = profile->trace_type;
81  rmp->num_elts = profile->num_elts;
82  rmp->trace_tsp = profile->trace_tsp;
83  rmp->node_id = htonl (profile->node_id);
84  rmp->app_data = htonl (profile->app_data);
85  );
86  }
87  else
88  {
89  REPLY_MACRO2 (VL_API_TRACE_PROFILE_SHOW_CONFIG_REPLY,
90  rmp->trace_type = 0;
91  rmp->num_elts = 0; rmp->trace_tsp = 0;
92  rmp->node_id = 0; rmp->app_data = 0;
93  );
94  }
95 }
96 
97 #include <ioam/lib-trace/trace.api.c>
98 static clib_error_t *
100 {
101  trace_main_t *sm = &trace_main;
102 
103  bzero (sm, sizeof (trace_main));
104  (void) trace_util_init ();
105 
106  sm->vlib_main = vm;
107  sm->vnet_main = vnet_get_main ();
108 
109  /* Ask for a correctly-sized block of API message decode slots */
111 
112  return 0;
113 }
114 
116 
117 /*
118  * fd.io coding-style-patch-verification: ON
119  *
120  * Local Variables:
121  * eval: (c-set-style "gnu")
122  * End:
123  */
vl_api_trace_profile_add_t
iOAM6 Trace - Set the iOAM6 trace profile
Definition: trace.api:26
api.h
vl_api_trace_profile_add_t::num_elts
u8 num_elts
Definition: trace.api:30
REPLY_MACRO2
#define REPLY_MACRO2(t, body)
Definition: api_helper_macros.h:65
vl_api_trace_profile_show_config_reply_t::trace_tsp
u8 trace_tsp
Definition: trace.api:68
trace_profile_find
static trace_profile * trace_profile_find(void)
Definition: trace_config.h:24
trace_main
trace_main_t trace_main
Definition: trace_util.c:23
trace_init
static clib_error_t * trace_init(vlib_main_t *vm)
Definition: trace_api.c:99
vm
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
Definition: nat44_ei.c:3047
api.h
trace_profile_::num_elts
u8 num_elts
Definition: trace_util.h:45
trace_profile_::trace_tsp
u32 trace_tsp
Definition: trace_util.h:49
vl_api_trace_profile_add_t::app_data
u32 app_data
Definition: trace.api:33
vl_api_trace_profile_show_config_t
Show trace Profile.
Definition: trace.api:49
trace_profile_::node_id
u32 node_id
Definition: trace_util.h:47
trace_profile_
Usage:
Definition: trace_util.h:41
vl_api_trace_profile_add_t::node_id
u32 node_id
Definition: trace.api:32
trace_main_t::vnet_main
vnet_main_t * vnet_main
Definition: trace_util.h:62
setup_message_id_table
static void setup_message_id_table(api_main_t *am)
Definition: bfd_api.c:451
trace_util.h
vl_api_trace_profile_show_config_reply_t::node_id
u32 node_id
Definition: trace.api:69
trace_util_init
int trace_util_init(void)
Definition: trace_util.c:47
vl_api_trace_profile_show_config_reply_t::app_data
u32 app_data
Definition: trace.api:70
vnet_get_main
vnet_main_t * vnet_get_main(void)
Definition: pnat_test_stubs.h:56
REPLY_MACRO
#define REPLY_MACRO(t)
Definition: api_helper_macros.h:30
vl_api_trace_profile_add_t::trace_tsp
u8 trace_tsp
Definition: trace.api:31
vl_api_trace_profile_show_config_t_handler
static void vl_api_trace_profile_show_config_t_handler(vl_api_trace_profile_show_config_t *mp)
Definition: trace_api.c:72
vl_api_trace_profile_add_t::trace_type
u8 trace_type
Definition: trace.api:29
plugin.h
trace_profile_create
int trace_profile_create(trace_profile *profile, u8 trace_type, u8 num_elts, u32 trace_tsp, u32 node_id, u32 app_data)
Definition: trace_util.c:57
vl_api_trace_profile_add_t_handler
static void vl_api_trace_profile_add_t_handler(vl_api_trace_profile_add_t *mp)
Definition: trace_api.c:35
trace_profile_::app_data
u32 app_data
Definition: trace_util.h:48
trace_config.h
clear_trace_profiles
void clear_trace_profiles(void)
Definition: trace_util.c:96
VLIB_INIT_FUNCTION
#define VLIB_INIT_FUNCTION(x)
Definition: init.h:172
trace_main_t::vlib_main
vlib_main_t * vlib_main
Definition: trace_util.h:61
api_helper_macros.h
vl_api_trace_profile_show_config_reply_t::trace_type
u8 trace_type
Definition: trace.api:66
trace_main_t::msg_id_base
u16 msg_id_base
Definition: trace_util.h:58
vl_api_trace_profile_show_config_reply_t
Show trace config response.
Definition: trace.api:63
vlib_main_t
Definition: main.h:102
trace_profile_::valid
u8 valid
Definition: trace_util.h:43
clib_error_t
Definition: clib_error.h:21
trace_profile_::trace_type
u8 trace_type
Definition: trace_util.h:44
vlib_init_function_t
clib_error_t *() vlib_init_function_t(struct vlib_main_t *vm)
Definition: init.h:51
rv
int __clib_unused rv
Definition: application.c:491
vl_api_trace_profile_del_t
Delete trace Profile.
Definition: trace.api:40
vnet.h
trace_main_t
Definition: trace_util.h:52
vl_api_trace_profile_del_t_handler
static void vl_api_trace_profile_del_t_handler(vl_api_trace_profile_del_t *mp)
Definition: trace_api.c:61
vl_api_trace_profile_show_config_reply_t::num_elts
u8 num_elts
Definition: trace.api:67