2 * Copyright (c) 2016 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:
7 * http://www.apache.org/licenses/LICENSE-2.0
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.
16 #ifndef included_vnet_flow_flow_h
17 #define included_vnet_flow_flow_h
19 #include <vppinfra/clib.h>
20 #include <vppinfra/pcap.h>
21 #include <vnet/l3_types.h>
22 #include <vnet/ip/ip4_packet.h>
23 #include <vnet/ip/ip6_packet.h>
25 #define foreach_flow_type \
26 _(IP4_N_TUPLE, ip4_n_tuple, "ipv4-n-tuple") \
27 _(IP6_N_TUPLE, ip6_n_tuple, "ipv4-n-tuple") \
28 _(IP4_VXLAN, ip4_vxlan, "ipv4-vxlan") \
29 _(IP6_VXLAN, ip6_vxlan, "ipv6-vxlan")
31 #define foreach_flow_entry_ip4_n_tuple \
32 _fe(ip4_address_and_mask_t, src_addr) \
33 _fe(ip4_address_and_mask_t, dst_addr) \
34 _fe(ip_port_and_mask_t, src_port) \
35 _fe(ip_port_and_mask_t, dst_port) \
36 _fe(ip_protocol_t, protocol)
38 #define foreach_flow_entry_ip6_n_tuple \
39 _fe(ip6_address_and_mask_t, src_addr) \
40 _fe(ip6_address_and_mask_t, dst_addr) \
41 _fe(ip_port_and_mask_t, src_port) \
42 _fe(ip_port_and_mask_t, dst_port) \
43 _fe(ip_protocol_t, protocol)
45 #define foreach_flow_entry_ip4_vxlan \
46 _fe(ip4_address_t, src_addr) \
47 _fe(ip4_address_t, dst_addr) \
51 #define foreach_flow_entry_ip6_vxlan \
52 _fe(ip6_address_t, src_addr) \
53 _fe(ip6_address_t, dst_addr) \
57 #define foreach_flow_action \
58 _(0, COUNT, "count") \
60 _(2, BUFFER_ADVANCE, "buffer-advance") \
61 _(3, REDIRECT_TO_NODE, "redirect-to-node") \
62 _(4, REDIRECT_TO_QUEUE, "redirect-to-queue") \
67 #define _(v,n,s) VNET_FLOW_ACTION_##n = (1 << v),
73 #define foreach_flow_error \
74 _( -1, NOT_SUPPORTED, "not supported") \
75 _( -2, ALREADY_DONE, "already done") \
76 _( -3, ALREADY_EXISTS, "already exists") \
77 _( -4, NO_SUCH_ENTRY, "no such entry") \
78 _( -5, NO_SUCH_INTERFACE, "no such interface") \
79 _( -6, INTERNAL, "internal error")
83 VNET_FLOW_NO_ERROR = 0,
84 #define _(v,n,s) VNET_FLOW_ERROR_##n = v,
96 VNET_FLOW_TYPE_UNKNOWN,
97 #define _(a,b,c) VNET_FLOW_TYPE_##a,
105 * Create typedef struct vnet_flow_XXX_t
107 #define _fe(a, b) a b;
111 foreach_flow_entry_##b \
117 /* main flow struct */
121 vnet_flow_type_t type;
126 /* bitmap of flow actions (VNET_FLOW_ACTION_*) */
129 /* flow id for VNET_FLOW_ACTION_MARK */
132 /* node index and next index for VNET_FLOW_ACTION_REDIRECT_TO_NODE */
133 u32 redirect_node_index;
134 u32 redirect_device_input_next_index;
136 /* queue for VNET_FLOW_ACTION_REDIRECT_TO_QUEUE */
139 /* buffer offset for VNET_FLOW_ACTION_BUFFER_ADVANCE */
144 #define _(a,b,c) vnet_flow_##b##_t b;
149 /* per-interface private data */
153 int vnet_flow_get_range (vnet_main_t * vnm, char *owner, u32 count,
155 int vnet_flow_add (vnet_main_t * vnm, vnet_flow_t * flow, u32 * flow_index);
156 int vnet_flow_enable (vnet_main_t * vnm, u32 flow_index, u32 hw_if_index);
157 int vnet_flow_disable (vnet_main_t * vnm, u32 flow_index, u32 hw_if_index);
158 int vnet_flow_del (vnet_main_t * vnm, u32 flow_index);
159 vnet_flow_t *vnet_get_flow (u32 flow_index);
170 /* pool of device flow entries */
171 vnet_flow_t *global_flow_pool;
173 /* flow ids allocated */
176 /* vector of flow ranges */
177 vnet_flow_range_t *ranges;
181 extern vnet_flow_main_t flow_main;
183 format_function_t format_flow_actions;
184 format_function_t format_flow_enabled_hw;
186 #endif /* included_vnet_flow_flow_h */
189 * fd.io coding-style-patch-verification: ON
192 * eval: (c-set-style "gnu")