eal/linux: rework loop in hugepage init
[dpdk.git] / lib / librte_ether / rte_eth_ctrl.h
1 /*-
2  *   BSD LICENSE
3  *
4  *   Copyright(c) 2010-2014 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 #define RTE_ETH_FDIR_MAX_FLEXLEN         16 /** < Max length of flexbytes. */
299
300 /**
301  * A structure used to define the input for L2 flow
302  */
303 struct rte_eth_l2_flow {
304         uint16_t ether_type;          /**< Ether type to match */
305 };
306
307 /**
308  * A structure used to define the input for IPV4 flow
309  */
310 struct rte_eth_ipv4_flow {
311         uint32_t src_ip;      /**< IPv4 source address to match. */
312         uint32_t dst_ip;      /**< IPv4 destination address to match. */
313 };
314
315 /**
316  * A structure used to define the input for IPV4 UDP flow
317  */
318 struct rte_eth_udpv4_flow {
319         struct rte_eth_ipv4_flow ip; /**< IPv4 fields to match. */
320         uint16_t src_port;           /**< UDP source port to match. */
321         uint16_t dst_port;           /**< UDP destination port to match. */
322 };
323
324 /**
325  * A structure used to define the input for IPV4 TCP flow
326  */
327 struct rte_eth_tcpv4_flow {
328         struct rte_eth_ipv4_flow ip; /**< IPv4 fields to match. */
329         uint16_t src_port;           /**< TCP source port to match. */
330         uint16_t dst_port;           /**< TCP destination port to match. */
331 };
332
333 /**
334  * A structure used to define the input for IPV4 SCTP flow
335  */
336 struct rte_eth_sctpv4_flow {
337         struct rte_eth_ipv4_flow ip; /**< IPv4 fields to match. */
338         uint32_t verify_tag;         /**< Verify tag to match */
339 };
340
341 /**
342  * A structure used to define the input for IPV6 flow
343  */
344 struct rte_eth_ipv6_flow {
345         uint32_t src_ip[4];      /**< IPv6 source address to match. */
346         uint32_t dst_ip[4];      /**< IPv6 destination address to match. */
347 };
348
349 /**
350  * A structure used to define the input for IPV6 UDP flow
351  */
352 struct rte_eth_udpv6_flow {
353         struct rte_eth_ipv6_flow ip; /**< IPv6 fields to match. */
354         uint16_t src_port;           /**< UDP source port to match. */
355         uint16_t dst_port;           /**< UDP destination port to match. */
356 };
357
358 /**
359  * A structure used to define the input for IPV6 TCP flow
360  */
361 struct rte_eth_tcpv6_flow {
362         struct rte_eth_ipv6_flow ip; /**< IPv6 fields to match. */
363         uint16_t src_port;           /**< TCP source port to match. */
364         uint16_t dst_port;           /**< TCP destination port to match. */
365 };
366
367 /**
368  * A structure used to define the input for IPV6 SCTP flow
369  */
370 struct rte_eth_sctpv6_flow {
371         struct rte_eth_ipv6_flow ip; /**< IPv6 fields to match. */
372         uint32_t verify_tag;         /**< Verify tag to match */
373 };
374
375 /**
376  * An union contains the inputs for all types of flow
377  */
378 union rte_eth_fdir_flow {
379         struct rte_eth_l2_flow     l2_flow;
380         struct rte_eth_udpv4_flow  udp4_flow;
381         struct rte_eth_tcpv4_flow  tcp4_flow;
382         struct rte_eth_sctpv4_flow sctp4_flow;
383         struct rte_eth_ipv4_flow   ip4_flow;
384         struct rte_eth_udpv6_flow  udp6_flow;
385         struct rte_eth_tcpv6_flow  tcp6_flow;
386         struct rte_eth_sctpv6_flow sctp6_flow;
387         struct rte_eth_ipv6_flow   ipv6_flow;
388 };
389
390 /**
391  * A structure used to contain extend input of flow
392  */
393 struct rte_eth_fdir_flow_ext {
394         uint16_t vlan_tci;
395         uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
396         /**< It is filled by the flexible payload to match. */
397 };
398
399 /**
400  * A structure used to define the input for a flow director filter entry
401  */
402 struct rte_eth_fdir_input {
403         uint16_t flow_type;
404         union rte_eth_fdir_flow flow;
405         /**< Flow fields to match, dependent on flow_type */
406         struct rte_eth_fdir_flow_ext flow_ext;
407         /**< Additional fields to match */
408 };
409
410 /**
411  * Behavior will be taken if FDIR match
412  */
413 enum rte_eth_fdir_behavior {
414         RTE_ETH_FDIR_ACCEPT = 0,
415         RTE_ETH_FDIR_REJECT,
416 };
417
418 /**
419  * Flow director report status
420  * It defines what will be reported if FDIR entry is matched.
421  */
422 enum rte_eth_fdir_status {
423         RTE_ETH_FDIR_NO_REPORT_STATUS = 0, /**< Report nothing. */
424         RTE_ETH_FDIR_REPORT_ID,            /**< Only report FD ID. */
425         RTE_ETH_FDIR_REPORT_ID_FLEX_4,     /**< Report FD ID and 4 flex bytes. */
426         RTE_ETH_FDIR_REPORT_FLEX_8,        /**< Report 8 flex bytes. */
427 };
428
429 /**
430  * A structure used to define an action when match FDIR packet filter.
431  */
432 struct rte_eth_fdir_action {
433         uint16_t rx_queue;        /**< Queue assigned to if FDIR match. */
434         enum rte_eth_fdir_behavior behavior;     /**< Behavior will be taken */
435         enum rte_eth_fdir_status report_status;  /**< Status report option */
436         uint8_t flex_off;
437         /**< If report_status is RTE_ETH_FDIR_REPORT_ID_FLEX_4 or
438              RTE_ETH_FDIR_REPORT_FLEX_8, flex_off specifies where the reported
439              flex bytes start from in flexible payload. */
440 };
441
442 /**
443  * A structure used to define the flow director filter entry by filter_ctrl API
444  * It supports RTE_ETH_FILTER_FDIR with RTE_ETH_FILTER_ADD and
445  * RTE_ETH_FILTER_DELETE operations.
446  */
447 struct rte_eth_fdir_filter {
448         uint32_t soft_id;
449         /**< ID, an unique value is required when deal with FDIR entry */
450         struct rte_eth_fdir_input input;    /**< Input set */
451         struct rte_eth_fdir_action action;  /**< Action taken when match */
452 };
453
454 /**
455  *  A structure used to configure FDIR masks that are used by the device
456  *  to match the various fields of RX packet headers.
457  */
458 struct rte_eth_fdir_masks {
459         uint16_t vlan_tci_mask;
460         struct rte_eth_ipv4_flow   ipv4_mask;
461         struct rte_eth_ipv6_flow   ipv6_mask;
462         uint16_t src_port_mask;
463         uint16_t dst_port_mask;
464 };
465
466 /**
467  * Payload type
468  */
469 enum rte_eth_payload_type {
470         RTE_ETH_PAYLOAD_UNKNOWN = 0,
471         RTE_ETH_RAW_PAYLOAD,
472         RTE_ETH_L2_PAYLOAD,
473         RTE_ETH_L3_PAYLOAD,
474         RTE_ETH_L4_PAYLOAD,
475         RTE_ETH_PAYLOAD_MAX = 8,
476 };
477
478 /**
479  * A structure used to select bytes extracted from the protocol layers to
480  * flexible payload for filter
481  */
482 struct rte_eth_flex_payload_cfg {
483         enum rte_eth_payload_type type;  /**< Payload type */
484         uint16_t src_offset[RTE_ETH_FDIR_MAX_FLEXLEN];
485         /**< Offset in bytes from the beginning of packet's payload
486              src_offset[i] indicates the flexbyte i's offset in original
487              packet payload. This value should be less than
488              flex_payload_limit in struct rte_eth_fdir_info.*/
489 };
490
491 /**
492  * A structure used to define FDIR masks for flexible payload
493  * for each flow type
494  */
495 struct rte_eth_fdir_flex_mask {
496         uint16_t flow_type;
497         uint8_t mask[RTE_ETH_FDIR_MAX_FLEXLEN];
498         /**< Mask for the whole flexible payload */
499 };
500
501 /**
502  * A structure used to define all flexible payload related setting
503  * include flexpay load and flex mask
504  */
505 struct rte_eth_fdir_flex_conf {
506         uint16_t nb_payloads;  /**< The number of following payload cfg */
507         uint16_t nb_flexmasks; /**< The number of following mask */
508         struct rte_eth_flex_payload_cfg flex_set[RTE_ETH_PAYLOAD_MAX];
509         /**< Flex payload configuration for each payload type */
510         struct rte_eth_fdir_flex_mask flex_mask[RTE_ETH_FLOW_MAX];
511         /**< Flex mask configuration for each flow type */
512 };
513
514 /**
515  *  Flow Director setting modes: none, signature or perfect.
516  */
517 enum rte_fdir_mode {
518         RTE_FDIR_MODE_NONE      = 0, /**< Disable FDIR support. */
519         RTE_FDIR_MODE_SIGNATURE,     /**< Enable FDIR signature filter mode. */
520         RTE_FDIR_MODE_PERFECT,       /**< Enable FDIR perfect filter mode. */
521 };
522
523 #define UINT32_BIT (CHAR_BIT * sizeof(uint32_t))
524 #define RTE_FLOW_MASK_ARRAY_SIZE \
525         (RTE_ALIGN(RTE_ETH_FLOW_MAX, UINT32_BIT)/UINT32_BIT)
526
527 /**
528  * A structure used to get the information of flow director filter.
529  * It supports RTE_ETH_FILTER_FDIR with RTE_ETH_FILTER_INFO operation.
530  * It includes the mode, flexible payload configuration information,
531  * capabilities and supported flow types, flexible payload characters.
532  * It can be gotten to help taking specific configurations per device.
533  */
534 struct rte_eth_fdir_info {
535         enum rte_fdir_mode mode; /**< Flow director mode */
536         struct rte_eth_fdir_masks mask;
537         /** Flex payload configuration information */
538         struct rte_eth_fdir_flex_conf flex_conf;
539         uint32_t guarant_spc; /**< Guaranteed spaces.*/
540         uint32_t best_spc; /**< Best effort spaces.*/
541         /** Bit mask for every supported flow type. */
542         uint32_t flow_types_mask[RTE_FLOW_MASK_ARRAY_SIZE];
543         uint32_t max_flexpayload; /**< Total flex payload in bytes. */
544         /** Flexible payload unit in bytes. Size and alignments of all flex
545             payload segments should be multiplies of this value. */
546         uint32_t flex_payload_unit;
547         /** Max number of flexible payload continuous segments.
548             Each segment should be a multiple of flex_payload_unit.*/
549         uint32_t max_flex_payload_segment_num;
550         /** Maximum src_offset in bytes allowed. It indicates that
551             src_offset[i] in struct rte_eth_flex_payload_cfg should be less
552             than this value. */
553         uint16_t flex_payload_limit;
554         /** Flex bitmask unit in bytes. Size of flex bitmasks should be a
555             multiply of this value. */
556         uint32_t flex_bitmask_unit;
557         /** Max supported size of flex bitmasks in flex_bitmask_unit */
558         uint32_t max_flex_bitmask_num;
559 };
560
561 /**
562  * A structure used to define the statistics of flow director.
563  * It supports RTE_ETH_FILTER_FDIR with RTE_ETH_FILTER_STATS operation.
564  */
565 struct rte_eth_fdir_stats {
566         uint32_t collision;    /**< Number of filters with collision. */
567         uint32_t free;         /**< Number of free filters. */
568         uint32_t maxhash;
569         /**< The lookup hash value of the added filter that updated the value
570            of the MAXLEN field */
571         uint32_t maxlen;       /**< Longest linked list of filters. */
572         uint64_t add;          /**< Number of added filters. */
573         uint64_t remove;       /**< Number of removed filters. */
574         uint64_t f_add;        /**< Number of failed added filters. */
575         uint64_t f_remove;     /**< Number of failed removed filters. */
576         uint32_t guarant_cnt;  /**< Number of filters in guaranteed spaces. */
577         uint32_t best_cnt;     /**< Number of filters in best effort spaces. */
578 };
579
580 /**
581  * Hash filter information types.
582  * - RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT is for getting/setting the
583  *   information/configuration of 'symmetric hash enable' per port.
584  * - RTE_ETH_HASH_FILTER_GLOBAL_CONFIG is for getting/setting the global
585  *   configurations of hash filters. Those global configurations are valid
586  *   for all ports of the same NIC.
587  */
588 enum rte_eth_hash_filter_info_type {
589         RTE_ETH_HASH_FILTER_INFO_TYPE_UNKNOWN = 0,
590         /** Symmetric hash enable per port */
591         RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT,
592         /** Configure globally for hash filter */
593         RTE_ETH_HASH_FILTER_GLOBAL_CONFIG,
594         RTE_ETH_HASH_FILTER_INFO_TYPE_MAX,
595 };
596
597 /**
598  * Hash function types.
599  */
600 enum rte_eth_hash_function {
601         RTE_ETH_HASH_FUNCTION_DEFAULT = 0,
602         RTE_ETH_HASH_FUNCTION_TOEPLITZ, /**< Toeplitz */
603         RTE_ETH_HASH_FUNCTION_SIMPLE_XOR, /**< Simple XOR */
604         RTE_ETH_HASH_FUNCTION_MAX,
605 };
606
607 #define RTE_SYM_HASH_MASK_ARRAY_SIZE \
608         (RTE_ALIGN(RTE_ETH_FLOW_MAX, UINT32_BIT)/UINT32_BIT)
609 /**
610  * A structure used to set or get global hash function configurations which
611  * include symmetric hash enable per flow type and hash function type.
612  * Each bit in sym_hash_enable_mask[] indicates if the symmetric hash of the
613  * coresponding flow type is enabled or not.
614  * Each bit in valid_bit_mask[] indicates if the corresponding bit in
615  * sym_hash_enable_mask[] is valid or not. For the configurations gotten, it
616  * also means if the flow type is supported by hardware or not.
617  */
618 struct rte_eth_hash_global_conf {
619         enum rte_eth_hash_function hash_func; /**< Hash function type */
620         /** Bit mask for symmetric hash enable per flow type */
621         uint32_t sym_hash_enable_mask[RTE_SYM_HASH_MASK_ARRAY_SIZE];
622         /** Bit mask indicates if the corresponding bit is valid */
623         uint32_t valid_bit_mask[RTE_SYM_HASH_MASK_ARRAY_SIZE];
624 };
625
626 /**
627  * A structure used to set or get hash filter information, to support filter
628  * type of 'RTE_ETH_FILTER_HASH' and its operations.
629  */
630 struct rte_eth_hash_filter_info {
631         enum rte_eth_hash_filter_info_type info_type; /**< Information type */
632         /** Details of hash filter information */
633         union {
634                 /** For RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT */
635                 uint8_t enable;
636                 /** Global configurations of hash filter */
637                 struct rte_eth_hash_global_conf global_conf;
638         } info;
639 };
640
641 #ifdef __cplusplus
642 }
643 #endif
644
645 #endif /* _RTE_ETH_CTRL_H_ */