FD.io VPP  v21.06-3-gbb25fbf28
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>
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 /* *INDENT-OFF* */
76 typedef struct __attribute__ ((aligned (8))) {
79  u8 src_mac[6];
80  u8 dst_mac[6];
82  ip46_address_t src_address;
83  ip46_address_t dst_address;
89 /* *INDENT-ON* */
90 
91 typedef struct
92 {
96 
97 typedef struct
98 {
107  union
108  {
109  struct
110  {
112  } tcp;
113  } prot;
115 
116 /**
117  * @file
118  * @brief flow-per-packet plugin header file
119  */
120 typedef struct
121 {
122  /** API message ID base */
124 
126  u16 template_reports[FLOW_N_RECORDS];
127  u16 template_size[FLOW_N_RECORDS];
128 
129  /** Time reference pair */
132 
133  /** Per CPU flow-state */
134  u8 ht_log2len; /* Hash table size is 2^log2len */
137  /* *INDENT-OFF* */
138  TWT (tw_timer_wheel) ** timers_per_worker;
139  /* *INDENT-ON* */
141 
146 
148  bool disabled;
149 
150  u16 template_per_flow[FLOW_N_VARIANTS];
152 
153  /** convenience vlib_main_t pointer */
155  /** convenience vnet_main_t pointer */
158 
161 
162 void flowprobe_flush_callback_ip4 (void);
163 void flowprobe_flush_callback_ip6 (void);
164 void flowprobe_flush_callback_l2 (void);
165 u8 *format_flowprobe_entry (u8 * s, va_list * args);
166 
167 #endif
168 
169 /*
170  * fd.io coding-style-patch-verification: ON
171  *
172  * Local Variables:
173  * eval: (c-set-style "gnu")
174  * End:
175  */
flowprobe_protocol_context_t
Definition: flowprobe.h:63
flowprobe_key_t::rx_sw_if_index
u32 rx_sw_if_index
Definition: flowprobe.h:77
src_mac
vl_api_mac_address_t src_mac
Definition: acl_types.api:94
flowprobe_main_t::hash_per_worker
u32 ** hash_per_worker
Definition: flowprobe.h:135
flowprobe_main_t::pool_per_worker
flowprobe_entry_t ** pool_per_worker
Definition: flowprobe.h:136
FLOW_N_VARIANTS
@ FLOW_N_VARIANTS
Definition: flowprobe.h:53
timestamp_nsec_t::sec
u32 sec
Definition: flowprobe.h:93
flowprobe_key_t::src_address
ip46_address_t src_address
Definition: flowprobe.h:82
flow_report_classify.h
timestamp_nsec_t::nsec
u32 nsec
Definition: flowprobe.h:94
u16
unsigned short u16
Definition: types.h:57
flowprobe_main_t::nanosecond_time_0
u64 nanosecond_time_0
Time reference pair.
Definition: flowprobe.h:130
flowprobe_walker_node
vlib_node_registration_t flowprobe_walker_node
(constructor) VLIB_REGISTER_NODE (flowprobe_walker_node)
Definition: node.c:1033
flowprobe_key_t::protocol
u8 protocol
Definition: flowprobe.h:84
flowprobe_main_t
Definition: flowprobe.h:120
vlib_frame_t
Definition: node.h:372
ethernet.h
flowprobe_entry_t::flow_start
timestamp_nsec_t flow_start
Definition: flowprobe.h:102
flowprobe_protocol_context_t::buffers_per_worker
vlib_buffer_t ** buffers_per_worker
ipfix buffers under construction, per-worker thread
Definition: flowprobe.h:68
flowprobe_entry_t::flow_end
timestamp_nsec_t flow_end
Definition: flowprobe.h:103
flowprobe_main_t::record
flowprobe_record_t record
Definition: flowprobe.h:142
error.h
flowprobe_entry_t::flags
u16 flags
Definition: flowprobe.h:111
flowprobe_key_t::dst_port
u16 dst_port
Definition: flowprobe.h:86
flowprobe_key_t::tx_sw_if_index
u32 tx_sw_if_index
Definition: flowprobe.h:78
flowprobe_entry_t::last_exported
f64 last_exported
Definition: flowprobe.h:105
flowprobe_entry_t
Definition: flowprobe.h:97
flowprobe_key_t::dst_address
ip46_address_t dst_address
Definition: flowprobe.h:83
flowprobe_main
flowprobe_main_t flowprobe_main
Definition: flowprobe.c:39
flowprobe_main_t::vlib_time_0
f64 vlib_time_0
Definition: flowprobe.h:131
flowprobe_flush_callback_l2
void flowprobe_flush_callback_l2(void)
Definition: node.c:892
flowprobe_key_t::ethertype
u16 ethertype
Definition: flowprobe.h:81
flowprobe_main_t::vlib_main
vlib_main_t * vlib_main
convenience vlib_main_t pointer
Definition: flowprobe.h:154
flowprobe_main_t::disabled
bool disabled
Definition: flowprobe.h:148
flowprobe_entry_t::packetcount
u64 packetcount
Definition: flowprobe.h:100
FLOW_RECORD_L2_IP4
@ FLOW_RECORD_L2_IP4
Definition: flowprobe.h:40
f64
double f64
Definition: types.h:142
TWT
#define TWT(a)
Definition: tw_timer_template.h:27
flowprobe_entry_t::key
flowprobe_key_t key
Definition: flowprobe.h:99
flowprobe_key_t
Definition: flowprobe.h:76
timestamp_nsec_t
Definition: flowprobe.h:91
flowprobe_entry_t::octetcount
u64 octetcount
Definition: flowprobe.h:101
vlib_node_registration_t
struct _vlib_node_registration vlib_node_registration_t
flowprobe_flush_callback_ip6
void flowprobe_flush_callback_ip6(void)
Definition: node.c:886
flow_report.h
flowprobe_key_t::src_port
u16 src_port
Definition: flowprobe.h:85
flowprobe_variant_t
flowprobe_variant_t
Definition: flowprobe.h:46
flowprobe_record_t
flowprobe_record_t
Definition: flowprobe.h:35
FLOW_VARIANT_L2
@ FLOW_VARIANT_L2
Definition: flowprobe.h:50
vnet_main_t
Definition: vnet.h:76
flowprobe_main_t::msg_id_base
u16 msg_id_base
API message ID base.
Definition: flowprobe.h:123
FLOW_RECORD_L2_IP6
@ FLOW_RECORD_L2_IP6
Definition: flowprobe.h:41
flowprobe_main_t::flow_per_interface
u8 * flow_per_interface
Definition: flowprobe.h:151
u64
unsigned long u64
Definition: types.h:89
format_flowprobe_entry
u8 * format_flowprobe_entry(u8 *s, va_list *args)
Definition: flowprobe.c:726
flowprobe_entry_t::last_updated
f64 last_updated
Definition: flowprobe.h:104
flowprobe_main_t::active_timer
u32 active_timer
Definition: flowprobe.h:143
ip.h
u32
unsigned int u32
Definition: types.h:88
FLOW_RECORD_L3
@ FLOW_RECORD_L3
Definition: flowprobe.h:38
FLOW_VARIANT_L2_IP4
@ FLOW_VARIANT_L2_IP4
Definition: flowprobe.h:51
flowprobe_main_t::expired_passive_per_worker
u32 ** expired_passive_per_worker
Definition: flowprobe.h:140
FLOW_VARIANT_IP6
@ FLOW_VARIANT_IP6
Definition: flowprobe.h:49
FLOW_VARIANT_L2_IP6
@ FLOW_VARIANT_L2_IP6
Definition: flowprobe.h:52
flowprobe_main_t::passive_timer
u32 passive_timer
Definition: flowprobe.h:144
flowprobe_key_t::which
flowprobe_variant_t which
Definition: flowprobe.h:87
vlib_main_t
Definition: main.h:102
flowprobe_flush_callback_ip4
void flowprobe_flush_callback_ip4(void)
Definition: node.c:880
flowprobe_protocol_context_t::next_record_offset_per_worker
u16 * next_record_offset_per_worker
next record offset, per worker thread
Definition: flowprobe.h:72
hash.h
u8
unsigned char u8
Definition: types.h:56
FLOW_RECORD_L2
@ FLOW_RECORD_L2
Definition: flowprobe.h:37
flowprobe_protocol_context_t::frames_per_worker
vlib_frame_t ** frames_per_worker
frames containing ipfix buffers, per-worker thread
Definition: flowprobe.h:70
FLOW_VARIANT_IP4
@ FLOW_VARIANT_IP4
Definition: flowprobe.h:48
context
u32 context
Definition: ip.api:780
vnet.h
STATIC_ASSERT
STATIC_ASSERT(sizeof(flowprobe_variant_t)==1, "flowprobe_variant_t is expected to be 1 byte, " "revisit padding in flowprobe_key_t")
tw_timer_2t_1w_2048sl.h
flowprobe_main_t::vnet_main
vnet_main_t * vnet_main
convenience vnet_main_t pointer
Definition: flowprobe.h:156
FLOW_N_RECORDS
@ FLOW_N_RECORDS
Definition: flowprobe.h:42
FLOW_RECORD_L4
@ FLOW_RECORD_L4
Definition: flowprobe.h:39
flowprobe_entry_t::passive_timer_handle
u32 passive_timer_handle
Definition: flowprobe.h:106
flowprobe_main_t::initialized
bool initialized
Definition: flowprobe.h:147
flowprobe_protocol_context_t::flags
flowprobe_record_t flags
Definition: flowprobe.h:66
flowprobe_main_t::ht_log2len
u8 ht_log2len
Per CPU flow-state.
Definition: flowprobe.h:134
flowprobe_main_t::stateless_entry
flowprobe_entry_t * stateless_entry
Definition: flowprobe.h:145
vlib_buffer_t
VLIB buffer representation.
Definition: buffer.h:111