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