2 * flowprobe.h - ipfix probe plug-in header file
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:
9 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #ifndef __included_flowprobe_h__
18 #define __included_flowprobe_h__
20 #include <vnet/vnet.h>
21 #include <vnet/ip/ip.h>
22 #include <vnet/ethernet/ethernet.h>
24 #include <vppinfra/hash.h>
25 #include <vppinfra/error.h>
26 #include <vnet/ipfix-export/flow_report.h>
27 #include <vnet/ipfix-export/flow_report_classify.h>
28 #include <vppinfra/tw_timer_2t_1w_2048sl.h>
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)
37 FLOW_RECORD_L2 = 1 << 0,
38 FLOW_RECORD_L3 = 1 << 1,
39 FLOW_RECORD_L4 = 1 << 2,
40 FLOW_RECORD_L2_IP4 = 1 << 3,
41 FLOW_RECORD_L2_IP6 = 1 << 4,
42 FLOW_N_RECORDS = 1 << 5,
46 typedef enum __attribute__ ((__packed__))
54 } flowprobe_variant_t;
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");
61 #define FLOW_MAXIMUM_EXPORT_ENTRIES (1024)
65 /* what to collect per variant */
66 flowprobe_record_t flags;
67 /** ipfix buffers under construction, per-worker thread */
68 vlib_buffer_t **buffers_per_worker;
69 /** frames containing ipfix buffers, per-worker thread */
70 vlib_frame_t **frames_per_worker;
71 /** next record offset, per worker thread */
72 u16 *next_record_offset_per_worker;
73 } flowprobe_protocol_context_t;
76 typedef struct __attribute__ ((aligned (8))) {
82 ip46_address_t src_address;
83 ip46_address_t dst_address;
87 flowprobe_variant_t which;
102 timestamp_nsec_t flow_start;
103 timestamp_nsec_t flow_end;
106 u32 passive_timer_handle;
118 * @brief flow-per-packet plugin header file
122 /** API message ID base */
125 flowprobe_protocol_context_t context[FLOW_N_VARIANTS];
126 u16 template_reports[FLOW_N_RECORDS];
127 u16 template_size[FLOW_N_RECORDS];
129 /** Time reference pair */
130 u64 nanosecond_time_0;
133 /** Per CPU flow-state */
134 u8 ht_log2len; /* Hash table size is 2^log2len */
135 u32 **hash_per_worker;
136 flowprobe_entry_t **pool_per_worker;
138 TWT (tw_timer_wheel) ** timers_per_worker;
140 u32 **expired_passive_per_worker;
142 flowprobe_record_t record;
145 flowprobe_entry_t *stateless_entry;
150 u16 template_per_flow[FLOW_N_VARIANTS];
151 u8 *flow_per_interface;
153 /** convenience vlib_main_t pointer */
154 vlib_main_t *vlib_main;
155 /** convenience vnet_main_t pointer */
156 vnet_main_t *vnet_main;
159 extern flowprobe_main_t flowprobe_main;
160 extern vlib_node_registration_t flowprobe_walker_node;
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);
170 * fd.io coding-style-patch-verification: ON
173 * eval: (c-set-style "gnu")