FD.io VPP  v21.10.1-2-g0a485f517
Vector Packet Processing
ip6_ioam_analyse.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017 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 PLUGINS_IOAM_PLUGIN_IOAM_ANALYSE_IP6_IOAM_ANALYSE_NODE_H_
17 #define PLUGINS_IOAM_PLUGIN_IOAM_ANALYSE_IP6_IOAM_ANALYSE_NODE_H_
18 
20 #include <vnet/ip/ip6_hop_by_hop.h>
22 
23 /** @brief IP6-iOAM analyser main structure.
24  @note cache aligned.
25 */
26 typedef struct
27 {
28  /** Array of function pointer to analyse each hop-by-hop option. */
29  int (*analyse_hbh_handler[MAX_IP6_HBH_OPTION]) (u32 flow_id,
31  opt, u16 len);
32 
33  /** This contains the aggregated data from the time VPP started analysing. */
35 
37 
39 
42 
44 
46 
48 
49 inline static ioam_analyser_data_t *
51 {
53  return NULL;
54 
57 
58  return (ioam_analyser_main.aggregated_data + flow_id);
59 }
60 
61 always_inline void *
63 {
64  ip6_hop_by_hop_option_t *opt0, *limit0;
65  u8 type0;
66 
67  opt0 = (ip6_hop_by_hop_option_t *) (hbh0 + 1);
68  limit0 =
69  (ip6_hop_by_hop_option_t *) ((u8 *) hbh0 + ((hbh0->length + 1) << 3));
70 
71  while (opt0 < limit0)
72  {
73  type0 = opt0->type;
74  if (type0 == option)
75  return ((void *) opt0);
76 
77  if (0 == type0)
78  {
79  opt0 = (ip6_hop_by_hop_option_t *) ((u8 *) opt0) + 1;
80  continue;
81  }
82  opt0 = (ip6_hop_by_hop_option_t *)
83  (((u8 *) opt0) + opt0->length + sizeof (ip6_hop_by_hop_option_t));
84  }
85 
86  return NULL;
87 }
88 
89 always_inline int
92  bool oneway)
93 {
94  ioam_trace_option_t *trace0 = NULL, *trace1 = NULL;
95  f64 delay0, delay1;
96 
97  trace0 =
99  trace1 =
101 
102  if (PREDICT_FALSE ((trace0 == NULL) && (trace1 == NULL)))
103  return 0;
104 
105  if (PREDICT_FALSE (trace1 == NULL))
106  return 1;
107 
108  if (PREDICT_FALSE (trace0 == NULL))
109  return -1;
110 
111  delay0 = ip6_ioam_analyse_calc_delay (&trace0->trace_hdr,
112  trace0->hdr.length - 2, oneway);
113  delay1 = ip6_ioam_analyse_calc_delay (&trace1->trace_hdr,
114  trace1->hdr.length - 2, oneway);
115 
116  return (delay0 - delay1);
117 }
118 
119 #endif /* PLUGINS_IOAM_PLUGIN_IOAM_ANALYSE_IP6_IOAM_ANALYSE_NODE_H_ */
120 
121 /*
122  * fd.io coding-style-patch-verification: ON
123  *
124  * Local Variables:
125  * eval: (c-set-style "gnu")
126  * End:
127  */
ip6_hop_by_hop_option_t::length
u8 length
Definition: ip6_hop_by_hop_packet.h:40
ioam_analyse_get_data_from_flow_id
static ioam_analyser_data_t * ioam_analyse_get_data_from_flow_id(u32 flow_id)
Definition: ip6_ioam_analyse.h:50
ip6_hop_by_hop_option_t::type
u8 type
Definition: ip6_hop_by_hop_packet.h:38
ip6_ioam_analyse_init
clib_error_t * ip6_ioam_analyse_init(vlib_main_t *vm)
MAX_IP6_HBH_OPTION
#define MAX_IP6_HBH_OPTION
Definition: ip6_hop_by_hop.h:22
u16
unsigned short u16
Definition: types.h:57
ip6_ioam_analyse_calc_delay
static f64 ip6_ioam_analyse_calc_delay(ioam_trace_hdr_t *trace, u16 trace_len, u8 oneway)
Definition: ioam_analyse.h:131
vm
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
Definition: nat44_ei.c:3047
ip6_hop_by_hop_option_t
Definition: ip6_hop_by_hop_packet.h:29
ip6_hop_by_hop_header_t
Definition: ip6_hop_by_hop_packet.h:18
ip6_ioam_analyser_main_t
IP6-iOAM analyser main structure.
Definition: ip6_ioam_analyse.h:26
vec_len
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
Definition: vec_bootstrap.h:142
len
u8 len
Definition: ip_types.api:103
ip6_hop_by_hop.h
ip6_ioam_analyse_unregister_handlers
void ip6_ioam_analyse_unregister_handlers(void)
Definition: node.c:460
PREDICT_FALSE
#define PREDICT_FALSE(x)
Definition: clib.h:124
ip6_ioam_find_hbh_option
static void * ip6_ioam_find_hbh_option(ip6_hop_by_hop_header_t *hbh0, u8 option)
Definition: ip6_ioam_analyse.h:62
analyse_node_remote
vlib_node_registration_t analyse_node_remote
(constructor) VLIB_REGISTER_NODE (analyse_node_remote)
Definition: node.c:493
f64
double f64
Definition: types.h:142
ip6_ioam_trace.h
ip6_ioam_analyse_register_handlers
void ip6_ioam_analyse_register_handlers(void)
Definition: node.c:449
vlib_node_registration_t
struct _vlib_node_registration vlib_node_registration_t
always_inline
#define always_inline
Definition: rdma_mlx5dv.h:23
u32
unsigned int u32
Definition: types.h:88
ip6_hop_by_hop_header_t::length
u8 length
Definition: ip6_hop_by_hop_packet.h:26
analyse_node_local
vlib_node_registration_t analyse_node_local
(constructor) VLIB_REGISTER_NODE (analyse_node_local)
Definition: node.c:474
ioam_analyser_data_t_::is_free
u8 is_free
Definition: ioam_analyse.h:102
ioam_analyser_data_t_
Analysed iOAM data.
Definition: ioam_analyse.h:98
vlib_main_t
Definition: main.h:102
ip6_ioam_analyser_main_t::aggregated_data
ioam_analyser_data_t * aggregated_data
This contains the aggregated data from the time VPP started analysing.
Definition: ip6_ioam_analyse.h:34
u8
unsigned char u8
Definition: types.h:56
clib_error_t
Definition: clib_error.h:21
ioam_analyse.h
ip6_ioam_analyse_compare_path_delay
static int ip6_ioam_analyse_compare_path_delay(ip6_hop_by_hop_header_t *hbh0, ip6_hop_by_hop_header_t *hbh1, bool oneway)
Definition: ip6_ioam_analyse.h:90
HBH_OPTION_TYPE_IOAM_TRACE_DATA_LIST
#define HBH_OPTION_TYPE_IOAM_TRACE_DATA_LIST
Definition: ip6_hop_by_hop_packet.h:44
ioam_analyser_main
ip6_ioam_analyser_main_t ioam_analyser_main
Definition: node.c:64