FD.io VPP  v17.07.01-10-g3be13f0
Vector Packet Processing
flowprobe.h
Go to the documentation of this file.
1 /*
2  * flowprobe.h - ipfix probe plug-in header file
3  *
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:
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
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.
16  */
17 #ifndef __included_flowprobe_h__
18 #define __included_flowprobe_h__
19 
20 #include <vnet/vnet.h>
21 #include <vnet/ip/ip.h>
22 #include <vnet/ethernet/ethernet.h>
23 
24 #include <vppinfra/hash.h>
25 #include <vppinfra/error.h>
26 #include <vnet/flow/flow_report.h>
29 
30 /* Default timers in seconds */
31 #define FLOWPROBE_TIMER_ACTIVE (15)
32 #define FLOWPROBE_TIMER_PASSIVE 120 // XXXX: FOR TESTING (30*60)
33 #define FLOWPROBE_LOG2_HASHSIZE (18)
34 
35 typedef enum
36 {
37  FLOW_RECORD_L2 = 1 << 0,
38  FLOW_RECORD_L3 = 1 << 1,
39  FLOW_RECORD_L4 = 1 << 2,
42  FLOW_N_RECORDS = 1 << 5,
44 
45 /* *INDENT-OFF* */
46 typedef enum __attribute__ ((__packed__))
47 {
55 /* *INDENT-ON* */
56 
57 STATIC_ASSERT (sizeof (flowprobe_variant_t) == 1,
58  "flowprobe_variant_t is expected to be 1 byte, "
59  "revisit padding in flowprobe_key_t");
60 
61 #define FLOW_MAXIMUM_EXPORT_ENTRIES (1024)
62 
63 typedef struct
64 {
65  /* what to collect per variant */
67  /** ipfix buffers under construction, per-worker thread */
69  /** frames containing ipfix buffers, per-worker thread */
71  /** next record offset, per worker thread */
74 
75 #define FLOWPROBE_KEY_IN_U32 22
76 /* *INDENT-OFF* */
77 typedef CLIB_PACKED (union
78 {
79  struct {
80  u32 rx_sw_if_index;
81  u32 tx_sw_if_index;
82  u8 src_mac[6];
83  u8 dst_mac[6];
84  u16 ethertype;
85  ip46_address_t src_address;
86  ip46_address_t dst_address;
87  u8 protocol;
88  u16 src_port;
89  u16 dst_port;
90  flowprobe_variant_t which;
91  };
92  u32 as_u32[FLOWPROBE_KEY_IN_U32];
93 }) flowprobe_key_t;
94 /* *INDENT-ON* */
95 
96 STATIC_ASSERT (sizeof (flowprobe_key_t) == FLOWPROBE_KEY_IN_U32 *
97  sizeof (u32), "flowprobe_key_t padding is wrong");
98 
99 typedef struct
100 {
101  flowprobe_key_t key;
108 
109 /**
110  * @file
111  * @brief flow-per-packet plugin header file
112  */
113 typedef struct
114 {
115  /** API message ID base */
117 
119  u16 template_reports[FLOW_N_RECORDS];
120  u16 template_size[FLOW_N_RECORDS];
121 
122  /** Time reference pair */
125 
126  /** Per CPU flow-state */
127  u8 ht_log2len; /* Hash table size is 2^log2len */
130  /* *INDENT-OFF* */
131  TWT (tw_timer_wheel) ** timers_per_worker;
132  /* *INDENT-ON* */
134 
139 
141  bool disabled;
142 
143  u16 template_per_flow[FLOW_N_VARIANTS];
145 
146  /** convenience vlib_main_t pointer */
148  /** convenience vnet_main_t pointer */
151 
153 
154 void flowprobe_flush_callback_ip4 (void);
155 void flowprobe_flush_callback_ip6 (void);
156 void flowprobe_flush_callback_l2 (void);
157 u8 *format_flowprobe_entry (u8 * s, va_list * args);
158 
159 #endif
160 
161 /*
162  * fd.io coding-style-patch-verification: ON
163  *
164  * Local Variables:
165  * eval: (c-set-style "gnu")
166  * End:
167  */
flowprobe_variant_t
Definition: flowprobe.h:46
u32 ** expired_passive_per_worker
Definition: flowprobe.h:133
#define FLOWPROBE_KEY_IN_U32
Definition: flowprobe.h:75
void flowprobe_flush_callback_ip6(void)
Definition: node.c:844
flowprobe_key_t key
Definition: flowprobe.h:101
flowprobe_record_t record
Definition: flowprobe.h:135
u8 * format_flowprobe_entry(u8 *s, va_list *args)
Definition: flowprobe.c:749
flowprobe_entry_t * stateless_entry
Definition: flowprobe.h:138
u8 * flow_per_interface
Definition: flowprobe.h:144
flowprobe_entry_t ** pool_per_worker
Definition: flowprobe.h:129
vlib_frame_t ** frames_per_worker
frames containing ipfix buffers, per-worker thread
Definition: flowprobe.h:70
u32 ** hash_per_worker
Definition: flowprobe.h:128
unsigned long u64
Definition: types.h:89
void flowprobe_flush_callback_ip4(void)
Definition: node.c:838
u64 nanosecond_time_0
Time reference pair.
Definition: flowprobe.h:123
u8 ht_log2len
Per CPU flow-state.
Definition: flowprobe.h:127
#define TWT(a)
u32 passive_timer_handle
Definition: flowprobe.h:106
u64 packetcount
Definition: flowprobe.h:102
f64 last_exported
Definition: flowprobe.h:105
vnet_main_t * vnet_main
convenience vnet_main_t pointer
Definition: flowprobe.h:149
flowprobe_main_t flowprobe_main
Definition: flowprobe.c:54
STATIC_ASSERT(sizeof(flowprobe_variant_t)==1,"flowprobe_variant_t is expected to be 1 byte, ""revisit padding in flowprobe_key_t")
flowprobe_record_t
Definition: flowprobe.h:35
unsigned int u32
Definition: types.h:88
vlib_buffer_t ** buffers_per_worker
ipfix buffers under construction, per-worker thread
Definition: flowprobe.h:68
unsigned short u16
Definition: types.h:57
void flowprobe_flush_callback_l2(void)
Definition: node.c:850
double f64
Definition: types.h:142
unsigned char u8
Definition: types.h:56
f64 last_updated
Definition: flowprobe.h:104
u16 msg_id_base
API message ID base.
Definition: flowprobe.h:116
typedef CLIB_PACKED(union{struct{u32 rx_sw_if_index;u32 tx_sw_if_index;u8 src_mac[6];u8 dst_mac[6];u16 ethertype;ip46_address_t src_address;ip46_address_t dst_address;u8 protocol;u16 src_port;u16 dst_port;flowprobe_variant_t which;};u32 as_u32[FLOWPROBE_KEY_IN_U32];}) flowprobe_key_t
u16 * next_record_offset_per_worker
next record offset, per worker thread
Definition: flowprobe.h:72
flowprobe_record_t flags
Definition: flowprobe.h:66
u64 octetcount
Definition: flowprobe.h:103
Definition: flowprobe.h:99
vlib_main_t * vlib_main
convenience vlib_main_t pointer
Definition: flowprobe.h:147