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