FD.io VPP  v18.01.2-1-g9b554f3
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 {
52  if (flow_id >= vec_len (ioam_analyser_main.aggregated_data))
53  return NULL;
54 
55  if (ioam_analyser_main.aggregated_data[flow_id].is_free)
56  ioam_analyser_main.aggregated_data[flow_id].is_free = 0;
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  */
#define NULL
Definition: clib.h:55
static int ip6_ioam_analyse_compare_path_delay(ip6_hop_by_hop_header_t *hbh0, ip6_hop_by_hop_header_t *hbh1, bool oneway)
static ioam_analyser_data_t * ioam_analyse_get_data_from_flow_id(u32 flow_id)
static f64 ip6_ioam_analyse_calc_delay(ioam_trace_hdr_t *trace, u16 trace_len, u8 oneway)
Definition: ioam_analyse.h:128
struct _vlib_node_registration vlib_node_registration_t
ip6_ioam_analyser_main_t ioam_analyser_main
Definition: node.c:63
IP6-iOAM analyser main structure.
#define always_inline
Definition: clib.h:92
#define PREDICT_FALSE(x)
Definition: clib.h:105
vlib_main_t * vm
Definition: buffer.c:283
static void * ip6_ioam_find_hbh_option(ip6_hop_by_hop_header_t *hbh0, u8 option)
vlib_node_registration_t analyse_node_local
(constructor) VLIB_REGISTER_NODE (analyse_node_local)
Definition: node.c:479
ioam_analyser_data_t * aggregated_data
This contains the aggregated data from the time VPP started analysing.
unsigned int u32
Definition: types.h:88
#define HBH_OPTION_TYPE_IOAM_TRACE_DATA_LIST
unsigned short u16
Definition: types.h:57
void ip6_ioam_analyse_register_handlers(void)
Definition: node.c:454
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
double f64
Definition: types.h:142
unsigned char u8
Definition: types.h:56
Analysed iOAM data.
Definition: ioam_analyse.h:97
clib_error_t * ip6_ioam_analyse_init(vlib_main_t *vm)
void ip6_ioam_analyse_unregister_handlers(void)
Definition: node.c:465
vlib_node_registration_t analyse_node_remote
(constructor) VLIB_REGISTER_NODE (analyse_node_remote)
Definition: node.c:498
#define MAX_IP6_HBH_OPTION