flow: add vnet/flow formal API
[vpp.git] / src / vnet / flow / flow_types.api
1 /* Hey Emacs use -*- mode: C -*- */
2 /*
3  * Copyright (c) 2020 Intel and/or its affiliates.
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at:
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 option version = "0.0.1";
18 import "vnet/ethernet/ethernet_types.api";
19 import "vnet/ip/ip_types.api";
20
21 enum flow_type
22 {
23   FLOW_TYPE_ETHERNET = 1,
24   FLOW_TYPE_IP4_N_TUPLE,
25   FLOW_TYPE_IP6_N_TUPLE,
26   FLOW_TYPE_IP4_N_TUPLE_TAGGED,
27   FLOW_TYPE_IP6_N_TUPLE_TAGGED,
28   FLOW_TYPE_IP4_L2TPV3OIP,
29   FLOW_TYPE_IP4_IPSEC_ESP,
30   FLOW_TYPE_IP4_IPSEC_AH,
31   FLOW_TYPE_IP4_VXLAN,
32   FLOW_TYPE_IP6_VXLAN,
33   FLOW_TYPE_IP4_GTPC,
34   FLOW_TYPE_IP4_GTPU,
35 };
36
37 enum flow_action
38 {
39   FLOW_ACTION_COUNT = 1,
40   FLOW_ACTION_MARK = 2,
41   FLOW_ACTION_BUFFER_ADVANCE = 4,
42   FLOW_ACTION_REDIRECT_TO_NODE = 8,
43   FLOW_ACTION_REDIRECT_TO_QUEUE = 16,
44   FLOW_ACTION_DROP = 64,
45 };
46
47 typedef ip_port_and_mask
48 {
49   u16 port;
50   u16 mask;
51 };
52
53 typedef flow_ethernet
54 {
55   i32 foo;
56   vl_api_mac_address_t src_addr;
57   vl_api_mac_address_t dst_addr;
58   u16 type;
59 };
60
61 typedef flow_ip4_n_tuple
62 {
63   i32 foo;
64   vl_api_ip4_address_and_mask_t src_addr;
65   vl_api_ip4_address_and_mask_t dst_addr;
66   vl_api_ip_port_and_mask_t src_port;
67   vl_api_ip_port_and_mask_t dst_port;
68   vl_api_ip_proto_t protocol;
69 };
70
71 typedef flow_ip6_n_tuple
72 {
73   i32 foo;
74   vl_api_ip6_address_and_mask_t src_addr;
75   vl_api_ip6_address_and_mask_t dst_addr;
76   vl_api_ip_port_and_mask_t src_port;
77   vl_api_ip_port_and_mask_t dst_port;
78   vl_api_ip_proto_t protocol;
79 };
80
81 typedef flow_ip4_n_tuple_tagged
82 {
83   i32 foo;
84   vl_api_ip4_address_and_mask_t src_addr;
85   vl_api_ip4_address_and_mask_t dst_addr;
86   vl_api_ip_port_and_mask_t src_port;
87   vl_api_ip_port_and_mask_t dst_port;
88   vl_api_ip_proto_t protocol;
89 };
90
91 typedef flow_ip6_n_tuple_tagged
92 {
93   i32 foo;
94   vl_api_ip6_address_and_mask_t src_addr;
95   vl_api_ip6_address_and_mask_t dst_addr;
96   vl_api_ip_port_and_mask_t src_port;
97   vl_api_ip_port_and_mask_t dst_port;
98   vl_api_ip_proto_t protocol;
99 };
100
101 typedef flow_ip4_l2tpv3oip
102 {
103   i32 foo;
104   vl_api_ip4_address_and_mask_t src_addr;
105   vl_api_ip4_address_and_mask_t dst_addr;
106   vl_api_ip_port_and_mask_t src_port;
107   vl_api_ip_port_and_mask_t dst_port;
108   vl_api_ip_proto_t protocol;
109   u32 session_id;
110 };
111
112 typedef flow_ip4_ipsec_esp
113 {
114   i32 foo;
115   vl_api_ip4_address_and_mask_t src_addr;
116   vl_api_ip4_address_and_mask_t dst_addr;
117   vl_api_ip_port_and_mask_t src_port;
118   vl_api_ip_port_and_mask_t dst_port;
119   vl_api_ip_proto_t protocol;
120   u32 spi;
121 };
122
123 typedef flow_ip4_ipsec_ah
124 {
125   i32 foo;
126   vl_api_ip4_address_and_mask_t src_addr;
127   vl_api_ip4_address_and_mask_t dst_addr;
128   vl_api_ip_port_and_mask_t src_port;
129   vl_api_ip_port_and_mask_t dst_port;
130   vl_api_ip_proto_t protocol;
131   u32 spi;
132 };
133
134 typedef flow_ip4_vxlan
135 {
136   i32 foo;
137   vl_api_ip4_address_t src_addr;
138   vl_api_ip4_address_t dst_addr;
139   u16 dst_port;
140   u16 vni;
141 };
142
143 typedef flow_ip6_vxlan
144 {
145   i32 foo;
146   vl_api_ip6_address_t src_addr;
147   vl_api_ip6_address_t dst_addr;
148   u16 dst_port;
149   u16 vni;
150 };
151
152 typedef flow_ip4_gtpc
153 {
154   i32 foo;
155   vl_api_ip4_address_and_mask_t src_addr;
156   vl_api_ip4_address_and_mask_t dst_addr;
157   vl_api_ip_port_and_mask_t src_port;
158   vl_api_ip_port_and_mask_t dst_port;
159   vl_api_ip_proto_t protocol;
160   u32 teid;
161 };
162
163 typedef flow_ip4_gtpu
164 {
165   i32 foo;
166   vl_api_ip4_address_and_mask_t src_addr;
167   vl_api_ip4_address_and_mask_t dst_addr;
168   vl_api_ip_port_and_mask_t src_port;
169   vl_api_ip_port_and_mask_t dst_port;
170   vl_api_ip_proto_t protocol;
171   u32 teid;
172 };
173
174 union flow
175 {
176   vl_api_flow_ethernet_t ethernet;
177   vl_api_flow_ip4_n_tuple_t ip4_n_tuple;
178   vl_api_flow_ip6_n_tuple_t ip6_n_tuple;
179   vl_api_flow_ip4_n_tuple_tagged_t ip4_n_tuple_tagged;
180   vl_api_flow_ip6_n_tuple_tagged_t ip6_n_tuple_tagged;
181   vl_api_flow_ip4_l2tpv3oip_t ip4_l2tpv3oip;
182   vl_api_flow_ip4_ipsec_esp_t ip4_ipsec_esp;
183   vl_api_flow_ip4_ipsec_ah_t ip4_ipsec_ah;
184   vl_api_flow_ip4_vxlan_t ip4_vxlan;
185   vl_api_flow_ip6_vxlan_t ip6_vxlan;
186   vl_api_flow_ip4_gtpc_t ip4_gtpc;
187   vl_api_flow_ip4_gtpu_t ip4_gtpu;
188 };
189
190 /* main flow struct */
191 typedef flow_rule
192 {
193   /* flow type */
194   vl_api_flow_type_t type;
195   
196   /* flow index */
197   u32 index;
198   
199   /* bitmap of flow actions (FLOW_ACTION_*) */
200   vl_api_flow_action_t actions;
201
202   /* flow id for VNET_FLOW_ACTION_MARK */
203   u32 mark_flow_id;
204
205   /* node index and next index for FLOW_ACTION_REDIRECT_TO_NODE */
206   u32 redirect_node_index;
207   u32 redirect_device_input_next_index;
208
209   /* queue for FLOW_ACTION_REDIRECT_TO_QUEUE */
210   u32 redirect_queue;
211
212   /* buffer offset for FLOW_ACTION_BUFFER_ADVANCE */
213   i32 buffer_advance;
214   
215   /* flow enum */
216   vl_api_flow_t flow;
217 };
218