ethdev: add VXLAN-GPE tunnel type
[dpdk.git] / lib / librte_ethdev / rte_eth_ctrl.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2010-2015 Intel Corporation
3  */
4
5 #ifndef _RTE_ETH_CTRL_H_
6 #define _RTE_ETH_CTRL_H_
7
8 #include <stdint.h>
9 #include <rte_common.h>
10 #include "rte_ether.h"
11
12 /**
13  * @file
14  *
15  * Ethernet device features and related data structures used
16  * by control APIs should be defined in this file.
17  *
18  */
19
20 #ifdef __cplusplus
21 extern "C" {
22 #endif
23
24 /*
25  * A packet can be identified by hardware as different flow types. Different
26  * NIC hardwares may support different flow types.
27  * Basically, the NIC hardware identifies the flow type as deep protocol as
28  * possible, and exclusively. For example, if a packet is identified as
29  * 'RTE_ETH_FLOW_NONFRAG_IPV4_TCP', it will not be any of other flow types,
30  * though it is an actual IPV4 packet.
31  * Note that the flow types are used to define RSS offload types in
32  * rte_ethdev.h.
33  */
34 #define RTE_ETH_FLOW_UNKNOWN             0
35 #define RTE_ETH_FLOW_RAW                 1
36 #define RTE_ETH_FLOW_IPV4                2
37 #define RTE_ETH_FLOW_FRAG_IPV4           3
38 #define RTE_ETH_FLOW_NONFRAG_IPV4_TCP    4
39 #define RTE_ETH_FLOW_NONFRAG_IPV4_UDP    5
40 #define RTE_ETH_FLOW_NONFRAG_IPV4_SCTP   6
41 #define RTE_ETH_FLOW_NONFRAG_IPV4_OTHER  7
42 #define RTE_ETH_FLOW_IPV6                8
43 #define RTE_ETH_FLOW_FRAG_IPV6           9
44 #define RTE_ETH_FLOW_NONFRAG_IPV6_TCP   10
45 #define RTE_ETH_FLOW_NONFRAG_IPV6_UDP   11
46 #define RTE_ETH_FLOW_NONFRAG_IPV6_SCTP  12
47 #define RTE_ETH_FLOW_NONFRAG_IPV6_OTHER 13
48 #define RTE_ETH_FLOW_L2_PAYLOAD         14
49 #define RTE_ETH_FLOW_IPV6_EX            15
50 #define RTE_ETH_FLOW_IPV6_TCP_EX        16
51 #define RTE_ETH_FLOW_IPV6_UDP_EX        17
52 #define RTE_ETH_FLOW_PORT               18
53         /**< Consider device port number as a flow differentiator */
54 #define RTE_ETH_FLOW_VXLAN              19 /**< VXLAN protocol based flow */
55 #define RTE_ETH_FLOW_GENEVE             20 /**< GENEVE protocol based flow */
56 #define RTE_ETH_FLOW_NVGRE              21 /**< NVGRE protocol based flow */
57 #define RTE_ETH_FLOW_VXLAN_GPE          22 /**< VXLAN-GPE protocol based flow */
58 #define RTE_ETH_FLOW_MAX                23
59
60 /**
61  * Feature filter types
62  */
63 enum rte_filter_type {
64         RTE_ETH_FILTER_NONE = 0,
65         RTE_ETH_FILTER_MACVLAN,
66         RTE_ETH_FILTER_ETHERTYPE,
67         RTE_ETH_FILTER_FLEXIBLE,
68         RTE_ETH_FILTER_SYN,
69         RTE_ETH_FILTER_NTUPLE,
70         RTE_ETH_FILTER_TUNNEL,
71         RTE_ETH_FILTER_FDIR,
72         RTE_ETH_FILTER_HASH,
73         RTE_ETH_FILTER_L2_TUNNEL,
74         RTE_ETH_FILTER_GENERIC,
75         RTE_ETH_FILTER_MAX
76 };
77
78 /**
79  * Generic operations on filters
80  */
81 enum rte_filter_op {
82         /** used to check whether the type filter is supported */
83         RTE_ETH_FILTER_NOP = 0,
84         RTE_ETH_FILTER_ADD,      /**< add filter entry */
85         RTE_ETH_FILTER_UPDATE,   /**< update filter entry */
86         RTE_ETH_FILTER_DELETE,   /**< delete filter entry */
87         RTE_ETH_FILTER_FLUSH,    /**< flush all entries */
88         RTE_ETH_FILTER_GET,      /**< get filter entry */
89         RTE_ETH_FILTER_SET,      /**< configurations */
90         RTE_ETH_FILTER_INFO,     /**< retrieve information */
91         RTE_ETH_FILTER_STATS,    /**< retrieve statistics */
92         RTE_ETH_FILTER_OP_MAX
93 };
94
95 /**
96  * MAC filter type
97  */
98 enum rte_mac_filter_type {
99         RTE_MAC_PERFECT_MATCH = 1, /**< exact match of MAC addr. */
100         RTE_MACVLAN_PERFECT_MATCH, /**< exact match of MAC addr and VLAN ID. */
101         RTE_MAC_HASH_MATCH, /**< hash match of MAC addr. */
102         /** hash match of MAC addr and exact match of VLAN ID. */
103         RTE_MACVLAN_HASH_MATCH,
104 };
105
106 /**
107  * MAC filter info
108  */
109 struct rte_eth_mac_filter {
110         uint8_t is_vf; /**< 1 for VF, 0 for port dev */
111         uint16_t dst_id; /**< VF ID, available when is_vf is 1*/
112         enum rte_mac_filter_type filter_type; /**< MAC filter type */
113         struct ether_addr mac_addr;
114 };
115
116 /**
117  * Define all structures for Ethertype Filter type.
118  */
119
120 #define RTE_ETHTYPE_FLAGS_MAC    0x0001 /**< If set, compare mac */
121 #define RTE_ETHTYPE_FLAGS_DROP   0x0002 /**< If set, drop packet when match */
122
123 /**
124  * A structure used to define the ethertype filter entry
125  * to support RTE_ETH_FILTER_ETHERTYPE with RTE_ETH_FILTER_ADD,
126  * RTE_ETH_FILTER_DELETE and RTE_ETH_FILTER_GET operations.
127  */
128 struct rte_eth_ethertype_filter {
129         struct ether_addr mac_addr;   /**< Mac address to match. */
130         uint16_t ether_type;          /**< Ether type to match */
131         uint16_t flags;               /**< Flags from RTE_ETHTYPE_FLAGS_* */
132         uint16_t queue;               /**< Queue assigned to when match*/
133 };
134
135 #define RTE_FLEX_FILTER_MAXLEN  128     /**< bytes to use in flex filter. */
136 #define RTE_FLEX_FILTER_MASK_SIZE       \
137         (RTE_ALIGN(RTE_FLEX_FILTER_MAXLEN, CHAR_BIT) / CHAR_BIT)
138                                         /**< mask bytes in flex filter. */
139
140 /**
141  *  A structure used to define the flex filter entry
142  *  to support RTE_ETH_FILTER_FLEXIBLE with RTE_ETH_FILTER_ADD,
143  *  RTE_ETH_FILTER_DELETE and RTE_ETH_FILTER_GET operations.
144  */
145 struct rte_eth_flex_filter {
146         uint16_t len;
147         uint8_t bytes[RTE_FLEX_FILTER_MAXLEN];  /**< flex bytes in big endian.*/
148         uint8_t mask[RTE_FLEX_FILTER_MASK_SIZE];    /**< if mask bit is 1b, do
149                                         not compare corresponding byte. */
150         uint8_t priority;
151         uint16_t queue;       /**< Queue assigned to when match. */
152 };
153
154 /**
155  * A structure used to define the TCP syn filter entry
156  * to support RTE_ETH_FILTER_SYN with RTE_ETH_FILTER_ADD,
157  * RTE_ETH_FILTER_DELETE and RTE_ETH_FILTER_GET operations.
158  */
159 struct rte_eth_syn_filter {
160         uint8_t hig_pri;     /**< 1 - higher priority than other filters,
161                                   0 - lower priority. */
162         uint16_t queue;      /**< Queue assigned to when match */
163 };
164
165 /**
166  * Define all structures for ntuple Filter type.
167  */
168
169 #define RTE_NTUPLE_FLAGS_DST_IP    0x0001 /**< If set, dst_ip is part of ntuple */
170 #define RTE_NTUPLE_FLAGS_SRC_IP    0x0002 /**< If set, src_ip is part of ntuple */
171 #define RTE_NTUPLE_FLAGS_DST_PORT  0x0004 /**< If set, dst_port is part of ntuple */
172 #define RTE_NTUPLE_FLAGS_SRC_PORT  0x0008 /**< If set, src_port is part of ntuple */
173 #define RTE_NTUPLE_FLAGS_PROTO     0x0010 /**< If set, protocol is part of ntuple */
174 #define RTE_NTUPLE_FLAGS_TCP_FLAG  0x0020 /**< If set, tcp flag is involved */
175
176 #define RTE_5TUPLE_FLAGS ( \
177                 RTE_NTUPLE_FLAGS_DST_IP | \
178                 RTE_NTUPLE_FLAGS_SRC_IP | \
179                 RTE_NTUPLE_FLAGS_DST_PORT | \
180                 RTE_NTUPLE_FLAGS_SRC_PORT | \
181                 RTE_NTUPLE_FLAGS_PROTO)
182
183 #define RTE_2TUPLE_FLAGS ( \
184                 RTE_NTUPLE_FLAGS_DST_PORT | \
185                 RTE_NTUPLE_FLAGS_PROTO)
186
187 #define TCP_URG_FLAG 0x20
188 #define TCP_ACK_FLAG 0x10
189 #define TCP_PSH_FLAG 0x08
190 #define TCP_RST_FLAG 0x04
191 #define TCP_SYN_FLAG 0x02
192 #define TCP_FIN_FLAG 0x01
193 #define TCP_FLAG_ALL 0x3F
194
195 /**
196  * A structure used to define the ntuple filter entry
197  * to support RTE_ETH_FILTER_NTUPLE with RTE_ETH_FILTER_ADD,
198  * RTE_ETH_FILTER_DELETE and RTE_ETH_FILTER_GET operations.
199  */
200 struct rte_eth_ntuple_filter {
201         uint16_t flags;          /**< Flags from RTE_NTUPLE_FLAGS_* */
202         uint32_t dst_ip;         /**< Destination IP address in big endian. */
203         uint32_t dst_ip_mask;    /**< Mask of destination IP address. */
204         uint32_t src_ip;         /**< Source IP address in big endian. */
205         uint32_t src_ip_mask;    /**< Mask of destination IP address. */
206         uint16_t dst_port;       /**< Destination port in big endian. */
207         uint16_t dst_port_mask;  /**< Mask of destination port. */
208         uint16_t src_port;       /**< Source Port in big endian. */
209         uint16_t src_port_mask;  /**< Mask of source port. */
210         uint8_t proto;           /**< L4 protocol. */
211         uint8_t proto_mask;      /**< Mask of L4 protocol. */
212         /** tcp_flags only meaningful when the proto is TCP.
213             The packet matched above ntuple fields and contain
214             any set bit in tcp_flags will hit this filter. */
215         uint8_t tcp_flags;
216         uint16_t priority;       /**< seven levels (001b-111b), 111b is highest,
217                                       used when more than one filter matches. */
218         uint16_t queue;          /**< Queue assigned to when match*/
219 };
220
221 /**
222  * Tunneled type.
223  */
224 enum rte_eth_tunnel_type {
225         RTE_TUNNEL_TYPE_NONE = 0,
226         RTE_TUNNEL_TYPE_VXLAN,
227         RTE_TUNNEL_TYPE_GENEVE,
228         RTE_TUNNEL_TYPE_TEREDO,
229         RTE_TUNNEL_TYPE_NVGRE,
230         RTE_TUNNEL_TYPE_IP_IN_GRE,
231         RTE_L2_TUNNEL_TYPE_E_TAG,
232         RTE_TUNNEL_TYPE_VXLAN_GPE,
233         RTE_TUNNEL_TYPE_MAX,
234 };
235
236 /**
237  * filter type of tunneling packet
238  */
239 #define ETH_TUNNEL_FILTER_OMAC  0x01 /**< filter by outer MAC addr */
240 #define ETH_TUNNEL_FILTER_OIP   0x02 /**< filter by outer IP Addr */
241 #define ETH_TUNNEL_FILTER_TENID 0x04 /**< filter by tenant ID */
242 #define ETH_TUNNEL_FILTER_IMAC  0x08 /**< filter by inner MAC addr */
243 #define ETH_TUNNEL_FILTER_IVLAN 0x10 /**< filter by inner VLAN ID */
244 #define ETH_TUNNEL_FILTER_IIP   0x20 /**< filter by inner IP addr */
245
246 #define RTE_TUNNEL_FILTER_IMAC_IVLAN (ETH_TUNNEL_FILTER_IMAC | \
247                                         ETH_TUNNEL_FILTER_IVLAN)
248 #define RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID (ETH_TUNNEL_FILTER_IMAC | \
249                                         ETH_TUNNEL_FILTER_IVLAN | \
250                                         ETH_TUNNEL_FILTER_TENID)
251 #define RTE_TUNNEL_FILTER_IMAC_TENID (ETH_TUNNEL_FILTER_IMAC | \
252                                         ETH_TUNNEL_FILTER_TENID)
253 #define RTE_TUNNEL_FILTER_OMAC_TENID_IMAC (ETH_TUNNEL_FILTER_OMAC | \
254                                         ETH_TUNNEL_FILTER_TENID | \
255                                         ETH_TUNNEL_FILTER_IMAC)
256
257 /**
258  *  Select IPv4 or IPv6 for tunnel filters.
259  */
260 enum rte_tunnel_iptype {
261         RTE_TUNNEL_IPTYPE_IPV4 = 0, /**< IPv4. */
262         RTE_TUNNEL_IPTYPE_IPV6,     /**< IPv6. */
263 };
264
265 /**
266  * Tunneling Packet filter configuration.
267  */
268 struct rte_eth_tunnel_filter_conf {
269         struct ether_addr outer_mac;    /**< Outer MAC address to match. */
270         struct ether_addr inner_mac;    /**< Inner MAC address to match. */
271         uint16_t inner_vlan;            /**< Inner VLAN to match. */
272         enum rte_tunnel_iptype ip_type; /**< IP address type. */
273         /** Outer destination IP address to match if ETH_TUNNEL_FILTER_OIP
274             is set in filter_type, or inner destination IP address to match
275             if ETH_TUNNEL_FILTER_IIP is set in filter_type . */
276         union {
277                 uint32_t ipv4_addr;     /**< IPv4 address in big endian. */
278                 uint32_t ipv6_addr[4];  /**< IPv6 address in big endian. */
279         } ip_addr;
280         /** Flags from ETH_TUNNEL_FILTER_XX - see above. */
281         uint16_t filter_type;
282         enum rte_eth_tunnel_type tunnel_type; /**< Tunnel Type. */
283         uint32_t tenant_id;     /**< Tenant ID to match. VNI, GRE key... */
284         uint16_t queue_id;      /**< Queue assigned to if match. */
285 };
286
287 /**
288  * Global eth device configuration type.
289  */
290 enum rte_eth_global_cfg_type {
291         RTE_ETH_GLOBAL_CFG_TYPE_UNKNOWN = 0,
292         RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN,
293         RTE_ETH_GLOBAL_CFG_TYPE_MAX,
294 };
295
296 /**
297  * Global eth device configuration.
298  */
299 struct rte_eth_global_cfg {
300         enum rte_eth_global_cfg_type cfg_type; /**< Global config type. */
301         union {
302                 uint8_t gre_key_len; /**< Valid GRE key length in byte. */
303                 uint64_t reserved; /**< Reserve space for future use. */
304         } cfg;
305 };
306
307 #define RTE_ETH_FDIR_MAX_FLEXLEN 16  /**< Max length of flexbytes. */
308 #define RTE_ETH_INSET_SIZE_MAX   128 /**< Max length of input set. */
309
310 /**
311  * Input set fields for Flow Director and Hash filters
312  */
313 enum rte_eth_input_set_field {
314         RTE_ETH_INPUT_SET_UNKNOWN = 0,
315
316         /* L2 */
317         RTE_ETH_INPUT_SET_L2_SRC_MAC = 1,
318         RTE_ETH_INPUT_SET_L2_DST_MAC,
319         RTE_ETH_INPUT_SET_L2_OUTER_VLAN,
320         RTE_ETH_INPUT_SET_L2_INNER_VLAN,
321         RTE_ETH_INPUT_SET_L2_ETHERTYPE,
322
323         /* L3 */
324         RTE_ETH_INPUT_SET_L3_SRC_IP4 = 129,
325         RTE_ETH_INPUT_SET_L3_DST_IP4,
326         RTE_ETH_INPUT_SET_L3_SRC_IP6,
327         RTE_ETH_INPUT_SET_L3_DST_IP6,
328         RTE_ETH_INPUT_SET_L3_IP4_TOS,
329         RTE_ETH_INPUT_SET_L3_IP4_PROTO,
330         RTE_ETH_INPUT_SET_L3_IP6_TC,
331         RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER,
332         RTE_ETH_INPUT_SET_L3_IP4_TTL,
333         RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS,
334
335         /* L4 */
336         RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT = 257,
337         RTE_ETH_INPUT_SET_L4_UDP_DST_PORT,
338         RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT,
339         RTE_ETH_INPUT_SET_L4_TCP_DST_PORT,
340         RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT,
341         RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT,
342         RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG,
343
344         /* Tunnel */
345         RTE_ETH_INPUT_SET_TUNNEL_L2_INNER_DST_MAC = 385,
346         RTE_ETH_INPUT_SET_TUNNEL_L2_INNER_SRC_MAC,
347         RTE_ETH_INPUT_SET_TUNNEL_L2_INNER_VLAN,
348         RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY,
349         RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY,
350
351         /* Flexible Payload */
352         RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD = 641,
353         RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD,
354         RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD,
355         RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD,
356         RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD,
357         RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD,
358         RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD,
359         RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD,
360
361         RTE_ETH_INPUT_SET_DEFAULT = 65533,
362         RTE_ETH_INPUT_SET_NONE = 65534,
363         RTE_ETH_INPUT_SET_MAX = 65535,
364 };
365
366 /**
367  * Filters input set operations
368  */
369 enum rte_filter_input_set_op {
370         RTE_ETH_INPUT_SET_OP_UNKNOWN,
371         RTE_ETH_INPUT_SET_SELECT, /**< select input set */
372         RTE_ETH_INPUT_SET_ADD,    /**< add input set entry */
373         RTE_ETH_INPUT_SET_OP_MAX
374 };
375
376
377 /**
378  * A structure used to define the input set configuration for
379  * flow director and hash filters
380  */
381 struct rte_eth_input_set_conf {
382         uint16_t flow_type;
383         uint16_t inset_size;
384         enum rte_eth_input_set_field field[RTE_ETH_INSET_SIZE_MAX];
385         enum rte_filter_input_set_op op;
386 };
387
388 /**
389  * A structure used to define the input for L2 flow
390  */
391 struct rte_eth_l2_flow {
392         uint16_t ether_type;          /**< Ether type in big endian */
393 };
394
395 /**
396  * A structure used to define the input for IPV4 flow
397  */
398 struct rte_eth_ipv4_flow {
399         uint32_t src_ip;      /**< IPv4 source address in big endian. */
400         uint32_t dst_ip;      /**< IPv4 destination address in big endian. */
401         uint8_t  tos;         /**< Type of service to match. */
402         uint8_t  ttl;         /**< Time to live to match. */
403         uint8_t  proto;       /**< Protocol, next header in big endian. */
404 };
405
406 /**
407  * A structure used to define the input for IPV4 UDP flow
408  */
409 struct rte_eth_udpv4_flow {
410         struct rte_eth_ipv4_flow ip; /**< IPv4 fields to match. */
411         uint16_t src_port;           /**< UDP source port in big endian. */
412         uint16_t dst_port;           /**< UDP destination port in big endian. */
413 };
414
415 /**
416  * A structure used to define the input for IPV4 TCP flow
417  */
418 struct rte_eth_tcpv4_flow {
419         struct rte_eth_ipv4_flow ip; /**< IPv4 fields to match. */
420         uint16_t src_port;           /**< TCP source port in big endian. */
421         uint16_t dst_port;           /**< TCP destination port in big endian. */
422 };
423
424 /**
425  * A structure used to define the input for IPV4 SCTP flow
426  */
427 struct rte_eth_sctpv4_flow {
428         struct rte_eth_ipv4_flow ip; /**< IPv4 fields to match. */
429         uint16_t src_port;           /**< SCTP source port in big endian. */
430         uint16_t dst_port;           /**< SCTP destination port in big endian. */
431         uint32_t verify_tag;         /**< Verify tag in big endian */
432 };
433
434 /**
435  * A structure used to define the input for IPV6 flow
436  */
437 struct rte_eth_ipv6_flow {
438         uint32_t src_ip[4];      /**< IPv6 source address in big endian. */
439         uint32_t dst_ip[4];      /**< IPv6 destination address in big endian. */
440         uint8_t  tc;             /**< Traffic class to match. */
441         uint8_t  proto;          /**< Protocol, next header to match. */
442         uint8_t  hop_limits;     /**< Hop limits to match. */
443 };
444
445 /**
446  * A structure used to define the input for IPV6 UDP flow
447  */
448 struct rte_eth_udpv6_flow {
449         struct rte_eth_ipv6_flow ip; /**< IPv6 fields to match. */
450         uint16_t src_port;           /**< UDP source port in big endian. */
451         uint16_t dst_port;           /**< UDP destination port in big endian. */
452 };
453
454 /**
455  * A structure used to define the input for IPV6 TCP flow
456  */
457 struct rte_eth_tcpv6_flow {
458         struct rte_eth_ipv6_flow ip; /**< IPv6 fields to match. */
459         uint16_t src_port;           /**< TCP source port to in big endian. */
460         uint16_t dst_port;           /**< TCP destination port in big endian. */
461 };
462
463 /**
464  * A structure used to define the input for IPV6 SCTP flow
465  */
466 struct rte_eth_sctpv6_flow {
467         struct rte_eth_ipv6_flow ip; /**< IPv6 fields to match. */
468         uint16_t src_port;           /**< SCTP source port in big endian. */
469         uint16_t dst_port;           /**< SCTP destination port in big endian. */
470         uint32_t verify_tag;         /**< Verify tag in big endian. */
471 };
472
473 /**
474  * A structure used to define the input for MAC VLAN flow
475  */
476 struct rte_eth_mac_vlan_flow {
477         struct ether_addr mac_addr;  /**< Mac address to match. */
478 };
479
480 /**
481  * Tunnel type for flow director.
482  */
483 enum rte_eth_fdir_tunnel_type {
484         RTE_FDIR_TUNNEL_TYPE_UNKNOWN = 0,
485         RTE_FDIR_TUNNEL_TYPE_NVGRE,
486         RTE_FDIR_TUNNEL_TYPE_VXLAN,
487 };
488
489 /**
490  * A structure used to define the input for tunnel flow, now it's VxLAN or
491  * NVGRE
492  */
493 struct rte_eth_tunnel_flow {
494         enum rte_eth_fdir_tunnel_type tunnel_type; /**< Tunnel type to match. */
495         /** Tunnel ID to match. TNI, VNI... in big endian. */
496         uint32_t tunnel_id;
497         struct ether_addr mac_addr;                /**< Mac address to match. */
498 };
499
500 /**
501  * An union contains the inputs for all types of flow
502  * Items in flows need to be in big endian
503  */
504 union rte_eth_fdir_flow {
505         struct rte_eth_l2_flow     l2_flow;
506         struct rte_eth_udpv4_flow  udp4_flow;
507         struct rte_eth_tcpv4_flow  tcp4_flow;
508         struct rte_eth_sctpv4_flow sctp4_flow;
509         struct rte_eth_ipv4_flow   ip4_flow;
510         struct rte_eth_udpv6_flow  udp6_flow;
511         struct rte_eth_tcpv6_flow  tcp6_flow;
512         struct rte_eth_sctpv6_flow sctp6_flow;
513         struct rte_eth_ipv6_flow   ipv6_flow;
514         struct rte_eth_mac_vlan_flow mac_vlan_flow;
515         struct rte_eth_tunnel_flow   tunnel_flow;
516 };
517
518 /**
519  * A structure used to contain extend input of flow
520  */
521 struct rte_eth_fdir_flow_ext {
522         uint16_t vlan_tci;
523         uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
524         /**< It is filled by the flexible payload to match. */
525         uint8_t is_vf;   /**< 1 for VF, 0 for port dev */
526         uint16_t dst_id; /**< VF ID, available when is_vf is 1*/
527 };
528
529 /**
530  * A structure used to define the input for a flow director filter entry
531  */
532 struct rte_eth_fdir_input {
533         uint16_t flow_type;
534         union rte_eth_fdir_flow flow;
535         /**< Flow fields to match, dependent on flow_type */
536         struct rte_eth_fdir_flow_ext flow_ext;
537         /**< Additional fields to match */
538 };
539
540 /**
541  * Behavior will be taken if FDIR match
542  */
543 enum rte_eth_fdir_behavior {
544         RTE_ETH_FDIR_ACCEPT = 0,
545         RTE_ETH_FDIR_REJECT,
546         RTE_ETH_FDIR_PASSTHRU,
547 };
548
549 /**
550  * Flow director report status
551  * It defines what will be reported if FDIR entry is matched.
552  */
553 enum rte_eth_fdir_status {
554         RTE_ETH_FDIR_NO_REPORT_STATUS = 0, /**< Report nothing. */
555         RTE_ETH_FDIR_REPORT_ID,            /**< Only report FD ID. */
556         RTE_ETH_FDIR_REPORT_ID_FLEX_4,     /**< Report FD ID and 4 flex bytes. */
557         RTE_ETH_FDIR_REPORT_FLEX_8,        /**< Report 8 flex bytes. */
558 };
559
560 /**
561  * A structure used to define an action when match FDIR packet filter.
562  */
563 struct rte_eth_fdir_action {
564         uint16_t rx_queue;        /**< Queue assigned to if FDIR match. */
565         enum rte_eth_fdir_behavior behavior;     /**< Behavior will be taken */
566         enum rte_eth_fdir_status report_status;  /**< Status report option */
567         uint8_t flex_off;
568         /**< If report_status is RTE_ETH_FDIR_REPORT_ID_FLEX_4 or
569              RTE_ETH_FDIR_REPORT_FLEX_8, flex_off specifies where the reported
570              flex bytes start from in flexible payload. */
571 };
572
573 /**
574  * A structure used to define the flow director filter entry by filter_ctrl API
575  * It supports RTE_ETH_FILTER_FDIR with RTE_ETH_FILTER_ADD and
576  * RTE_ETH_FILTER_DELETE operations.
577  */
578 struct rte_eth_fdir_filter {
579         uint32_t soft_id;
580         /**< ID, an unique value is required when deal with FDIR entry */
581         struct rte_eth_fdir_input input;    /**< Input set */
582         struct rte_eth_fdir_action action;  /**< Action taken when match */
583 };
584
585 /**
586  *  A structure used to configure FDIR masks that are used by the device
587  *  to match the various fields of RX packet headers.
588  */
589 struct rte_eth_fdir_masks {
590         uint16_t vlan_tci_mask;   /**< Bit mask for vlan_tci in big endian */
591         /** Bit mask for ipv4 flow in big endian. */
592         struct rte_eth_ipv4_flow   ipv4_mask;
593         /** Bit maks for ipv6 flow in big endian. */
594         struct rte_eth_ipv6_flow   ipv6_mask;
595         /** Bit mask for L4 source port in big endian. */
596         uint16_t src_port_mask;
597         /** Bit mask for L4 destination port in big endian. */
598         uint16_t dst_port_mask;
599         /** 6 bit mask for proper 6 bytes of Mac address, bit 0 matches the
600             first byte on the wire */
601         uint8_t mac_addr_byte_mask;
602         /** Bit mask for tunnel ID in big endian. */
603         uint32_t tunnel_id_mask;
604         uint8_t tunnel_type_mask; /**< 1 - Match tunnel type,
605                                        0 - Ignore tunnel type. */
606 };
607
608 /**
609  * Payload type
610  */
611 enum rte_eth_payload_type {
612         RTE_ETH_PAYLOAD_UNKNOWN = 0,
613         RTE_ETH_RAW_PAYLOAD,
614         RTE_ETH_L2_PAYLOAD,
615         RTE_ETH_L3_PAYLOAD,
616         RTE_ETH_L4_PAYLOAD,
617         RTE_ETH_PAYLOAD_MAX = 8,
618 };
619
620 /**
621  * A structure used to select bytes extracted from the protocol layers to
622  * flexible payload for filter
623  */
624 struct rte_eth_flex_payload_cfg {
625         enum rte_eth_payload_type type;  /**< Payload type */
626         uint16_t src_offset[RTE_ETH_FDIR_MAX_FLEXLEN];
627         /**< Offset in bytes from the beginning of packet's payload
628              src_offset[i] indicates the flexbyte i's offset in original
629              packet payload. This value should be less than
630              flex_payload_limit in struct rte_eth_fdir_info.*/
631 };
632
633 /**
634  * A structure used to define FDIR masks for flexible payload
635  * for each flow type
636  */
637 struct rte_eth_fdir_flex_mask {
638         uint16_t flow_type;
639         uint8_t mask[RTE_ETH_FDIR_MAX_FLEXLEN];
640         /**< Mask for the whole flexible payload */
641 };
642
643 /**
644  * A structure used to define all flexible payload related setting
645  * include flex payload and flex mask
646  */
647 struct rte_eth_fdir_flex_conf {
648         uint16_t nb_payloads;  /**< The number of following payload cfg */
649         uint16_t nb_flexmasks; /**< The number of following mask */
650         struct rte_eth_flex_payload_cfg flex_set[RTE_ETH_PAYLOAD_MAX];
651         /**< Flex payload configuration for each payload type */
652         struct rte_eth_fdir_flex_mask flex_mask[RTE_ETH_FLOW_MAX];
653         /**< Flex mask configuration for each flow type */
654 };
655
656 /**
657  *  Flow Director setting modes: none, signature or perfect.
658  */
659 enum rte_fdir_mode {
660         RTE_FDIR_MODE_NONE      = 0, /**< Disable FDIR support. */
661         RTE_FDIR_MODE_SIGNATURE,     /**< Enable FDIR signature filter mode. */
662         RTE_FDIR_MODE_PERFECT,       /**< Enable FDIR perfect filter mode. */
663         RTE_FDIR_MODE_PERFECT_MAC_VLAN, /**< Enable FDIR filter mode - MAC VLAN. */
664         RTE_FDIR_MODE_PERFECT_TUNNEL,   /**< Enable FDIR filter mode - tunnel. */
665 };
666
667 #define UINT64_BIT (CHAR_BIT * sizeof(uint64_t))
668 #define RTE_FLOW_MASK_ARRAY_SIZE \
669         (RTE_ALIGN(RTE_ETH_FLOW_MAX, UINT64_BIT)/UINT64_BIT)
670
671 /**
672  * A structure used to get the information of flow director filter.
673  * It supports RTE_ETH_FILTER_FDIR with RTE_ETH_FILTER_INFO operation.
674  * It includes the mode, flexible payload configuration information,
675  * capabilities and supported flow types, flexible payload characters.
676  * It can be gotten to help taking specific configurations per device.
677  */
678 struct rte_eth_fdir_info {
679         enum rte_fdir_mode mode; /**< Flow director mode */
680         struct rte_eth_fdir_masks mask;
681         /** Flex payload configuration information */
682         struct rte_eth_fdir_flex_conf flex_conf;
683         uint32_t guarant_spc; /**< Guaranteed spaces.*/
684         uint32_t best_spc; /**< Best effort spaces.*/
685         /** Bit mask for every supported flow type. */
686         uint64_t flow_types_mask[RTE_FLOW_MASK_ARRAY_SIZE];
687         uint32_t max_flexpayload; /**< Total flex payload in bytes. */
688         /** Flexible payload unit in bytes. Size and alignments of all flex
689             payload segments should be multiplies of this value. */
690         uint32_t flex_payload_unit;
691         /** Max number of flexible payload continuous segments.
692             Each segment should be a multiple of flex_payload_unit.*/
693         uint32_t max_flex_payload_segment_num;
694         /** Maximum src_offset in bytes allowed. It indicates that
695             src_offset[i] in struct rte_eth_flex_payload_cfg should be less
696             than this value. */
697         uint16_t flex_payload_limit;
698         /** Flex bitmask unit in bytes. Size of flex bitmasks should be a
699             multiply of this value. */
700         uint32_t flex_bitmask_unit;
701         /** Max supported size of flex bitmasks in flex_bitmask_unit */
702         uint32_t max_flex_bitmask_num;
703 };
704
705 /**
706  * A structure used to define the statistics of flow director.
707  * It supports RTE_ETH_FILTER_FDIR with RTE_ETH_FILTER_STATS operation.
708  */
709 struct rte_eth_fdir_stats {
710         uint32_t collision;    /**< Number of filters with collision. */
711         uint32_t free;         /**< Number of free filters. */
712         uint32_t maxhash;
713         /**< The lookup hash value of the added filter that updated the value
714            of the MAXLEN field */
715         uint32_t maxlen;       /**< Longest linked list of filters. */
716         uint64_t add;          /**< Number of added filters. */
717         uint64_t remove;       /**< Number of removed filters. */
718         uint64_t f_add;        /**< Number of failed added filters. */
719         uint64_t f_remove;     /**< Number of failed removed filters. */
720         uint32_t guarant_cnt;  /**< Number of filters in guaranteed spaces. */
721         uint32_t best_cnt;     /**< Number of filters in best effort spaces. */
722 };
723
724 /**
725  * Flow Director filter information types.
726  */
727 enum rte_eth_fdir_filter_info_type {
728         RTE_ETH_FDIR_FILTER_INFO_TYPE_UNKNOWN = 0,
729         /** Flow Director filter input set configuration */
730         RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT,
731         RTE_ETH_FDIR_FILTER_INFO_TYPE_MAX,
732 };
733
734 /**
735  * A structure used to set FDIR filter information, to support filter type
736  * of 'RTE_ETH_FILTER_FDIR' RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT operation.
737  */
738 struct rte_eth_fdir_filter_info {
739         enum rte_eth_fdir_filter_info_type info_type; /**< Information type */
740         /** Details of fdir filter information */
741         union {
742                 /** Flow Director input set configuration per port */
743                 struct rte_eth_input_set_conf input_set_conf;
744         } info;
745 };
746
747 /**
748  * Hash filter information types.
749  * - RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT is for getting/setting the
750  *   information/configuration of 'symmetric hash enable' per port.
751  * - RTE_ETH_HASH_FILTER_GLOBAL_CONFIG is for getting/setting the global
752  *   configurations of hash filters. Those global configurations are valid
753  *   for all ports of the same NIC.
754  * - RTE_ETH_HASH_FILTER_INPUT_SET_SELECT is for setting the global
755  *   hash input set fields
756  */
757 enum rte_eth_hash_filter_info_type {
758         RTE_ETH_HASH_FILTER_INFO_TYPE_UNKNOWN = 0,
759         /** Symmetric hash enable per port */
760         RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT,
761         /** Configure globally for hash filter */
762         RTE_ETH_HASH_FILTER_GLOBAL_CONFIG,
763         /** Global Hash filter input set configuration */
764         RTE_ETH_HASH_FILTER_INPUT_SET_SELECT,
765         RTE_ETH_HASH_FILTER_INFO_TYPE_MAX,
766 };
767
768 /**
769  * Hash function types.
770  */
771 enum rte_eth_hash_function {
772         RTE_ETH_HASH_FUNCTION_DEFAULT = 0,
773         RTE_ETH_HASH_FUNCTION_TOEPLITZ, /**< Toeplitz */
774         RTE_ETH_HASH_FUNCTION_SIMPLE_XOR, /**< Simple XOR */
775         RTE_ETH_HASH_FUNCTION_MAX,
776 };
777
778 #define RTE_SYM_HASH_MASK_ARRAY_SIZE \
779         (RTE_ALIGN(RTE_ETH_FLOW_MAX, UINT64_BIT)/UINT64_BIT)
780 /**
781  * A structure used to set or get global hash function configurations which
782  * include symmetric hash enable per flow type and hash function type.
783  * Each bit in sym_hash_enable_mask[] indicates if the symmetric hash of the
784  * corresponding flow type is enabled or not.
785  * Each bit in valid_bit_mask[] indicates if the corresponding bit in
786  * sym_hash_enable_mask[] is valid or not. For the configurations gotten, it
787  * also means if the flow type is supported by hardware or not.
788  */
789 struct rte_eth_hash_global_conf {
790         enum rte_eth_hash_function hash_func; /**< Hash function type */
791         /** Bit mask for symmetric hash enable per flow type */
792         uint64_t sym_hash_enable_mask[RTE_SYM_HASH_MASK_ARRAY_SIZE];
793         /** Bit mask indicates if the corresponding bit is valid */
794         uint64_t valid_bit_mask[RTE_SYM_HASH_MASK_ARRAY_SIZE];
795 };
796
797 /**
798  * A structure used to set or get hash filter information, to support filter
799  * type of 'RTE_ETH_FILTER_HASH' and its operations.
800  */
801 struct rte_eth_hash_filter_info {
802         enum rte_eth_hash_filter_info_type info_type; /**< Information type */
803         /** Details of hash filter information */
804         union {
805                 /** For RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT */
806                 uint8_t enable;
807                 /** Global configurations of hash filter */
808                 struct rte_eth_hash_global_conf global_conf;
809                 /** Global configurations of hash filter input set */
810                 struct rte_eth_input_set_conf input_set_conf;
811         } info;
812 };
813
814 /**
815  * l2 tunnel configuration.
816  */
817 struct rte_eth_l2_tunnel_conf {
818         enum rte_eth_tunnel_type l2_tunnel_type;
819         uint16_t ether_type; /* ether type in l2 header */
820         uint32_t tunnel_id; /* port tag id for e-tag */
821         uint16_t vf_id; /* VF id for tag insertion */
822         uint32_t pool; /* destination pool for tag based forwarding */
823 };
824
825 #ifdef __cplusplus
826 }
827 #endif
828
829 #endif /* _RTE_ETH_CTRL_H_ */