ethdev: new ntuple filter API
[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  * Feature filter types
51  */
52 enum rte_filter_type {
53         RTE_ETH_FILTER_NONE = 0,
54         RTE_ETH_FILTER_MACVLAN,
55         RTE_ETH_FILTER_ETHERTYPE,
56         RTE_ETH_FILTER_FLEXIBLE,
57         RTE_ETH_FILTER_SYN,
58         RTE_ETH_FILTER_NTUPLE,
59         RTE_ETH_FILTER_TUNNEL,
60         RTE_ETH_FILTER_FDIR,
61         RTE_ETH_FILTER_HASH,
62         RTE_ETH_FILTER_MAX
63 };
64
65 /**
66  * Generic operations on filters
67  */
68 enum rte_filter_op {
69         /** used to check whether the type filter is supported */
70         RTE_ETH_FILTER_NOP = 0,
71         RTE_ETH_FILTER_ADD,      /**< add filter entry */
72         RTE_ETH_FILTER_UPDATE,   /**< update filter entry */
73         RTE_ETH_FILTER_DELETE,   /**< delete filter entry */
74         RTE_ETH_FILTER_FLUSH,    /**< flush all entries */
75         RTE_ETH_FILTER_GET,      /**< get filter entry */
76         RTE_ETH_FILTER_SET,      /**< configurations */
77         RTE_ETH_FILTER_INFO,     /**< retrieve information */
78         RTE_ETH_FILTER_STATS,    /**< retrieve statistics */
79         RTE_ETH_FILTER_OP_MAX
80 };
81
82 /*
83  * MAC filter type
84  */
85 enum rte_mac_filter_type {
86         RTE_MAC_PERFECT_MATCH = 1, /**< exact match of MAC addr. */
87         RTE_MACVLAN_PERFECT_MATCH, /**< exact match of MAC addr and VLAN ID. */
88         RTE_MAC_HASH_MATCH, /**< hash match of MAC addr. */
89         /** hash match of MAC addr and exact match of VLAN ID. */
90         RTE_MACVLAN_HASH_MATCH,
91 };
92
93 /**
94  * MAC filter info
95  */
96 struct rte_eth_mac_filter {
97         uint8_t is_vf; /**< 1 for VF, 0 for port dev */
98         uint16_t dst_id; /**< VF ID, available when is_vf is 1*/
99         enum rte_mac_filter_type filter_type; /**< MAC filter type */
100         struct ether_addr mac_addr;
101 };
102
103 /**
104  * Define all structures for Ethertype Filter type.
105  */
106
107 #define RTE_ETHTYPE_FLAGS_MAC    0x0001 /**< If set, compare mac */
108 #define RTE_ETHTYPE_FLAGS_DROP   0x0002 /**< If set, drop packet when match */
109
110 /**
111  * A structure used to define the ethertype filter entry
112  * to support RTE_ETH_FILTER_ETHERTYPE with RTE_ETH_FILTER_ADD,
113  * RTE_ETH_FILTER_DELETE and RTE_ETH_FILTER_GET operations.
114  */
115 struct rte_eth_ethertype_filter {
116         struct ether_addr mac_addr;   /**< Mac address to match. */
117         uint16_t ether_type;          /**< Ether type to match */
118         uint16_t flags;               /**< Flags from RTE_ETHTYPE_FLAGS_* */
119         uint16_t queue;               /**< Queue assigned to when match*/
120 };
121
122 #define RTE_FLEX_FILTER_MAXLEN  128     /**< bytes to use in flex filter. */
123 #define RTE_FLEX_FILTER_MASK_SIZE       \
124         (RTE_ALIGN(RTE_FLEX_FILTER_MAXLEN, CHAR_BIT) / CHAR_BIT)
125                                         /**< mask bytes in flex filter. */
126
127 /**
128  *  A structure used to define the flex filter entry
129  *  to support RTE_ETH_FILTER_FLEXIBLE with RTE_ETH_FILTER_ADD,
130  *  RTE_ETH_FILTER_DELETE and RTE_ETH_FILTER_GET operations.
131  */
132 struct rte_eth_flex_filter {
133         uint16_t len;
134         uint8_t bytes[RTE_FLEX_FILTER_MAXLEN];  /**< flex bytes in big endian.*/
135         uint8_t mask[RTE_FLEX_FILTER_MASK_SIZE];    /**< if mask bit is 1b, do
136                                         not compare corresponding byte. */
137         uint8_t priority;
138         uint16_t queue;       /**< Queue assigned to when match. */
139 };
140
141 /**
142  * A structure used to define the TCP syn filter entry
143  * to support RTE_ETH_FILTER_SYN with RTE_ETH_FILTER_ADD,
144  * RTE_ETH_FILTER_DELETE and RTE_ETH_FILTER_GET operations.
145  */
146 struct rte_eth_syn_filter {
147         uint8_t hig_pri;     /**< 1 - higher priority than other filters,
148                                   0 - lower priority. */
149         uint16_t queue;      /**< Queue assigned to when match */
150 };
151
152 /**
153  * Define all structures for ntuple Filter type.
154  */
155
156 #define RTE_NTUPLE_FLAGS_DST_IP    0x0001 /**< If set, dst_ip is part of ntuple */
157 #define RTE_NTUPLE_FLAGS_SRC_IP    0x0002 /**< If set, src_ip is part of ntuple */
158 #define RTE_NTUPLE_FLAGS_DST_PORT  0x0004 /**< If set, dst_port is part of ntuple */
159 #define RTE_NTUPLE_FLAGS_SRC_PORT  0x0008 /**< If set, src_port is part of ntuple */
160 #define RTE_NTUPLE_FLAGS_PROTO     0x0010 /**< If set, protocol is part of ntuple */
161 #define RTE_NTUPLE_FLAGS_TCP_FLAG  0x0020 /**< If set, tcp flag is involved */
162
163 #define RTE_5TUPLE_FLAGS ( \
164                 RTE_NTUPLE_FLAGS_DST_IP | \
165                 RTE_NTUPLE_FLAGS_SRC_IP | \
166                 RTE_NTUPLE_FLAGS_DST_PORT | \
167                 RTE_NTUPLE_FLAGS_SRC_PORT | \
168                 RTE_NTUPLE_FLAGS_PROTO)
169
170 #define RTE_2TUPLE_FLAGS ( \
171                 RTE_NTUPLE_FLAGS_DST_PORT | \
172                 RTE_NTUPLE_FLAGS_PROTO)
173
174
175 /**
176  * A structure used to define the ntuple filter entry
177  * to support RTE_ETH_FILTER_NTUPLE with RTE_ETH_FILTER_ADD,
178  * RTE_ETH_FILTER_DELETE and RTE_ETH_FILTER_GET operations.
179  */
180 struct rte_eth_ntuple_filter {
181         uint16_t flags;          /**< Flags from RTE_NTUPLE_FLAGS_* */
182         uint32_t dst_ip;         /**< Destination IP address in big endian. */
183         uint32_t dst_ip_mask;    /**< Mask of destination IP address. */
184         uint32_t src_ip;         /**< Source IP address in big endian. */
185         uint32_t src_ip_mask;    /**< Mask of destination IP address. */
186         uint16_t dst_port;       /**< Destination port in big endian. */
187         uint16_t dst_port_mask;  /**< Mask of destination port. */
188         uint16_t src_port;       /**< Source Port in big endian. */
189         uint16_t src_port_mask;  /**< Mask of source port. */
190         uint8_t proto;           /**< L4 protocol. */
191         uint8_t proto_mask;      /**< Mask of L4 protocol. */
192         /** tcp_flags only meaningful when the proto is TCP.
193             The packet matched above ntuple fields and contain
194             any set bit in tcp_flags will hit this filter. */
195         uint8_t tcp_flags;
196         uint16_t priority;       /**< seven levels (001b-111b), 111b is highest,
197                                       used when more than one filter matches. */
198         uint16_t queue;          /**< Queue assigned to when match*/
199 };
200
201 /**
202  * Tunneled type.
203  */
204 enum rte_eth_tunnel_type {
205         RTE_TUNNEL_TYPE_NONE = 0,
206         RTE_TUNNEL_TYPE_VXLAN,
207         RTE_TUNNEL_TYPE_GENEVE,
208         RTE_TUNNEL_TYPE_TEREDO,
209         RTE_TUNNEL_TYPE_NVGRE,
210         RTE_TUNNEL_TYPE_MAX,
211 };
212
213 /**
214  * filter type of tunneling packet
215  */
216 #define ETH_TUNNEL_FILTER_OMAC  0x01 /**< filter by outer MAC addr */
217 #define ETH_TUNNEL_FILTER_OIP   0x02 /**< filter by outer IP Addr */
218 #define ETH_TUNNEL_FILTER_TENID 0x04 /**< filter by tenant ID */
219 #define ETH_TUNNEL_FILTER_IMAC  0x08 /**< filter by inner MAC addr */
220 #define ETH_TUNNEL_FILTER_IVLAN 0x10 /**< filter by inner VLAN ID */
221 #define ETH_TUNNEL_FILTER_IIP   0x20 /**< filter by inner IP addr */
222
223 #define RTE_TUNNEL_FILTER_IMAC_IVLAN (ETH_TUNNEL_FILTER_IMAC | \
224                                         ETH_TUNNEL_FILTER_IVLAN)
225 #define RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID (ETH_TUNNEL_FILTER_IMAC | \
226                                         ETH_TUNNEL_FILTER_IVLAN | \
227                                         ETH_TUNNEL_FILTER_TENID)
228 #define RTE_TUNNEL_FILTER_IMAC_TENID (ETH_TUNNEL_FILTER_IMAC | \
229                                         ETH_TUNNEL_FILTER_TENID)
230 #define RTE_TUNNEL_FILTER_OMAC_TENID_IMAC (ETH_TUNNEL_FILTER_OMAC | \
231                                         ETH_TUNNEL_FILTER_TENID | \
232                                         ETH_TUNNEL_FILTER_IMAC)
233
234 /**
235  *  Select IPv4 or IPv6 for tunnel filters.
236  */
237 enum rte_tunnel_iptype {
238         RTE_TUNNEL_IPTYPE_IPV4 = 0, /**< IPv4. */
239         RTE_TUNNEL_IPTYPE_IPV6,     /**< IPv6. */
240 };
241
242 /**
243  * Tunneling Packet filter configuration.
244  */
245 struct rte_eth_tunnel_filter_conf {
246         struct ether_addr *outer_mac;  /**< Outer MAC address filter. */
247         struct ether_addr *inner_mac;  /**< Inner MAC address filter. */
248         uint16_t inner_vlan;           /**< Inner VLAN filter. */
249         enum rte_tunnel_iptype ip_type; /**< IP address type. */
250         union {
251                 uint32_t ipv4_addr;    /**< IPv4 source address to match. */
252                 uint32_t ipv6_addr[4]; /**< IPv6 source address to match. */
253         } ip_addr; /**< IPv4/IPv6 source address to match (union of above). */
254
255         uint16_t filter_type;   /**< Filter type. */
256         enum rte_eth_tunnel_type tunnel_type; /**< Tunnel Type. */
257         uint32_t tenant_id;     /** < Tenant number. */
258         uint16_t queue_id;      /** < queue number. */
259 };
260
261 #define RTE_ETH_FDIR_MAX_FLEXLEN         16 /** < Max length of flexbytes. */
262
263 /**
264  * Flow type
265  */
266 enum rte_eth_flow_type {
267         RTE_ETH_FLOW_TYPE_NONE = 0,
268         RTE_ETH_FLOW_TYPE_RAW,
269         RTE_ETH_FLOW_TYPE_UDPV4,
270         RTE_ETH_FLOW_TYPE_TCPV4,
271         RTE_ETH_FLOW_TYPE_SCTPV4,
272         RTE_ETH_FLOW_TYPE_IPV4_OTHER,
273         RTE_ETH_FLOW_TYPE_FRAG_IPV4,
274         RTE_ETH_FLOW_TYPE_UDPV6,
275         RTE_ETH_FLOW_TYPE_TCPV6,
276         RTE_ETH_FLOW_TYPE_SCTPV6,
277         RTE_ETH_FLOW_TYPE_IPV6_OTHER,
278         RTE_ETH_FLOW_TYPE_FRAG_IPV6,
279         RTE_ETH_FLOW_TYPE_MAX = 64,
280 };
281
282 /**
283  * A structure used to define the input for IPV4 flow
284  */
285 struct rte_eth_ipv4_flow {
286         uint32_t src_ip;      /**< IPv4 source address to match. */
287         uint32_t dst_ip;      /**< IPv4 destination address to match. */
288 };
289
290 /**
291  * A structure used to define the input for IPV4 UDP flow
292  */
293 struct rte_eth_udpv4_flow {
294         struct rte_eth_ipv4_flow ip; /**< IPv4 fields to match. */
295         uint16_t src_port;           /**< UDP source port to match. */
296         uint16_t dst_port;           /**< UDP destination port to match. */
297 };
298
299 /**
300  * A structure used to define the input for IPV4 TCP flow
301  */
302 struct rte_eth_tcpv4_flow {
303         struct rte_eth_ipv4_flow ip; /**< IPv4 fields to match. */
304         uint16_t src_port;           /**< TCP source port to match. */
305         uint16_t dst_port;           /**< TCP destination port to match. */
306 };
307
308 /**
309  * A structure used to define the input for IPV4 SCTP flow
310  */
311 struct rte_eth_sctpv4_flow {
312         struct rte_eth_ipv4_flow ip; /**< IPv4 fields to match. */
313         uint32_t verify_tag;         /**< Verify tag to match */
314 };
315
316 /**
317  * A structure used to define the input for IPV6 flow
318  */
319 struct rte_eth_ipv6_flow {
320         uint32_t src_ip[4];      /**< IPv6 source address to match. */
321         uint32_t dst_ip[4];      /**< IPv6 destination address to match. */
322 };
323
324 /**
325  * A structure used to define the input for IPV6 UDP flow
326  */
327 struct rte_eth_udpv6_flow {
328         struct rte_eth_ipv6_flow ip; /**< IPv6 fields to match. */
329         uint16_t src_port;           /**< UDP source port to match. */
330         uint16_t dst_port;           /**< UDP destination port to match. */
331 };
332
333 /**
334  * A structure used to define the input for IPV6 TCP flow
335  */
336 struct rte_eth_tcpv6_flow {
337         struct rte_eth_ipv6_flow ip; /**< IPv6 fields to match. */
338         uint16_t src_port;           /**< TCP source port to match. */
339         uint16_t dst_port;           /**< TCP destination port to match. */
340 };
341
342 /**
343  * A structure used to define the input for IPV6 SCTP flow
344  */
345 struct rte_eth_sctpv6_flow {
346         struct rte_eth_ipv6_flow ip; /**< IPv6 fields to match. */
347         uint32_t verify_tag;         /**< Verify tag to match */
348 };
349
350 /**
351  * An union contains the inputs for all types of flow
352  */
353 union rte_eth_fdir_flow {
354         struct rte_eth_udpv4_flow  udp4_flow;
355         struct rte_eth_tcpv4_flow  tcp4_flow;
356         struct rte_eth_sctpv4_flow sctp4_flow;
357         struct rte_eth_ipv4_flow   ip4_flow;
358         struct rte_eth_udpv6_flow  udp6_flow;
359         struct rte_eth_tcpv6_flow  tcp6_flow;
360         struct rte_eth_sctpv6_flow sctp6_flow;
361         struct rte_eth_ipv6_flow   ipv6_flow;
362 };
363
364 /**
365  * A structure used to contain extend input of flow
366  */
367 struct rte_eth_fdir_flow_ext {
368         uint16_t vlan_tci;
369         uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
370         /**< It is filled by the flexible payload to match. */
371 };
372
373 /**
374  * A structure used to define the input for a flow director filter entry
375  */
376 struct rte_eth_fdir_input {
377         enum rte_eth_flow_type flow_type;      /**< Type of flow */
378         union rte_eth_fdir_flow flow;
379         /**< Flow fields to match, dependent on flow_type */
380         struct rte_eth_fdir_flow_ext flow_ext;
381         /**< Additional fields to match */
382 };
383
384 /**
385  * Behavior will be taken if FDIR match
386  */
387 enum rte_eth_fdir_behavior {
388         RTE_ETH_FDIR_ACCEPT = 0,
389         RTE_ETH_FDIR_REJECT,
390 };
391
392 /**
393  * Flow director report status
394  * It defines what will be reported if FDIR entry is matched.
395  */
396 enum rte_eth_fdir_status {
397         RTE_ETH_FDIR_NO_REPORT_STATUS = 0, /**< Report nothing. */
398         RTE_ETH_FDIR_REPORT_ID,            /**< Only report FD ID. */
399         RTE_ETH_FDIR_REPORT_ID_FLEX_4,     /**< Report FD ID and 4 flex bytes. */
400         RTE_ETH_FDIR_REPORT_FLEX_8,        /**< Report 8 flex bytes. */
401 };
402
403 /**
404  * A structure used to define an action when match FDIR packet filter.
405  */
406 struct rte_eth_fdir_action {
407         uint16_t rx_queue;        /**< Queue assigned to if FDIR match. */
408         enum rte_eth_fdir_behavior behavior;     /**< Behavior will be taken */
409         enum rte_eth_fdir_status report_status;  /**< Status report option */
410         uint8_t flex_off;
411         /**< If report_status is RTE_ETH_FDIR_REPORT_ID_FLEX_4 or
412              RTE_ETH_FDIR_REPORT_FLEX_8, flex_off specifies where the reported
413              flex bytes start from in flexible payload. */
414 };
415
416 /**
417  * A structure used to define the flow director filter entry by filter_ctrl API
418  * It supports RTE_ETH_FILTER_FDIR with RTE_ETH_FILTER_ADD and
419  * RTE_ETH_FILTER_DELETE operations.
420  */
421 struct rte_eth_fdir_filter {
422         uint32_t soft_id;
423         /**< ID, an unique value is required when deal with FDIR entry */
424         struct rte_eth_fdir_input input;    /**< Input set */
425         struct rte_eth_fdir_action action;  /**< Action taken when match */
426 };
427
428 /**
429  *  A structure used to configure FDIR masks that are used by the device
430  *  to match the various fields of RX packet headers.
431  */
432 struct rte_eth_fdir_masks {
433         uint16_t vlan_tci_mask;
434         struct rte_eth_ipv4_flow   ipv4_mask;
435         struct rte_eth_ipv6_flow   ipv6_mask;
436         uint16_t src_port_mask;
437         uint16_t dst_port_mask;
438 };
439
440 /**
441  * Payload type
442  */
443 enum rte_eth_payload_type {
444         RTE_ETH_PAYLOAD_UNKNOWN = 0,
445         RTE_ETH_RAW_PAYLOAD,
446         RTE_ETH_L2_PAYLOAD,
447         RTE_ETH_L3_PAYLOAD,
448         RTE_ETH_L4_PAYLOAD,
449         RTE_ETH_PAYLOAD_MAX = 8,
450 };
451
452 /**
453  * A structure used to select bytes extracted from the protocol layers to
454  * flexible payload for filter
455  */
456 struct rte_eth_flex_payload_cfg {
457         enum rte_eth_payload_type type;  /**< Payload type */
458         uint16_t src_offset[RTE_ETH_FDIR_MAX_FLEXLEN];
459         /**< Offset in bytes from the beginning of packet's payload
460              src_offset[i] indicates the flexbyte i's offset in original
461              packet payload. This value should be less than
462              flex_payload_limit in struct rte_eth_fdir_info.*/
463 };
464
465 /**
466  * A structure used to define FDIR masks for flexible payload
467  * for each flow type
468  */
469 struct rte_eth_fdir_flex_mask {
470         enum rte_eth_flow_type flow_type;  /**< Flow type */
471         uint8_t mask[RTE_ETH_FDIR_MAX_FLEXLEN];
472         /**< Mask for the whole flexible payload */
473 };
474
475 /**
476  * A structure used to define all flexible payload related setting
477  * include flexpay load and flex mask
478  */
479 struct rte_eth_fdir_flex_conf {
480         uint16_t nb_payloads;  /**< The number of following payload cfg */
481         uint16_t nb_flexmasks; /**< The number of following mask */
482         struct rte_eth_flex_payload_cfg flex_set[RTE_ETH_PAYLOAD_MAX];
483         /**< Flex payload configuration for each payload type */
484         struct rte_eth_fdir_flex_mask flex_mask[RTE_ETH_FLOW_TYPE_MAX];
485         /**< Flex mask configuration for each flow type */
486 };
487
488 /**
489  *  Flow Director setting modes: none, signature or perfect.
490  */
491 enum rte_fdir_mode {
492         RTE_FDIR_MODE_NONE      = 0, /**< Disable FDIR support. */
493         RTE_FDIR_MODE_SIGNATURE,     /**< Enable FDIR signature filter mode. */
494         RTE_FDIR_MODE_PERFECT,       /**< Enable FDIR perfect filter mode. */
495 };
496
497 /**
498  * A structure used to get the information of flow director filter.
499  * It supports RTE_ETH_FILTER_FDIR with RTE_ETH_FILTER_INFO operation.
500  * It includes the mode, flexible payload configuration information,
501  * capabilities and supported flow types, flexible payload characters.
502  * It can be gotten to help taking specific configurations per device.
503  */
504 struct rte_eth_fdir_info {
505         enum rte_fdir_mode mode;     /**< Flow director mode */
506         struct rte_eth_fdir_masks mask;
507         struct rte_eth_fdir_flex_conf flex_conf;
508         /**< Flex payload configuration information */
509         uint32_t guarant_spc;          /**< Guaranteed spaces.*/
510         uint32_t best_spc;             /**< Best effort spaces.*/
511         uint32_t flow_types_mask[RTE_ETH_FLOW_TYPE_MAX / sizeof(uint32_t)];
512         /**< Bit mask for every supported flow type. */
513         uint32_t max_flexpayload;      /**< Total flex payload in bytes. */
514         uint32_t flex_payload_unit;
515         /**< Flexible payload unit in bytes. Size and alignments of all flex
516              payload segments should be multiplies of this value. */
517         uint32_t max_flex_payload_segment_num;
518         /**< Max number of flexible payload continuous segments.
519              Each segment should be a multiple of flex_payload_unit.*/
520         uint16_t flex_payload_limit;
521         /**< Maximum src_offset in bytes allowed. It indicates that
522              src_offset[i] in struct rte_eth_flex_payload_cfg should be
523              less than this value. */
524         uint32_t flex_bitmask_unit;
525         /**< Flex bitmask unit in bytes. Size of flex bitmasks should
526              be a multiply of this value. */
527         uint32_t max_flex_bitmask_num;
528         /**< Max supported size of flex bitmasks in flex_bitmask_unit */
529 };
530
531 /**
532  * A structure used to define the statistics of flow director.
533  * It supports RTE_ETH_FILTER_FDIR with RTE_ETH_FILTER_STATS operation.
534  */
535 struct rte_eth_fdir_stats {
536         uint32_t collision;    /**< Number of filters with collision. */
537         uint32_t free;         /**< Number of free filters. */
538         uint32_t maxhash;
539         /**< The lookup hash value of the added filter that updated the value
540            of the MAXLEN field */
541         uint32_t maxlen;       /**< Longest linked list of filters. */
542         uint64_t add;          /**< Number of added filters. */
543         uint64_t remove;       /**< Number of removed filters. */
544         uint64_t f_add;        /**< Number of failed added filters. */
545         uint64_t f_remove;     /**< Number of failed removed filters. */
546         uint32_t guarant_cnt;  /**< Number of filters in guaranteed spaces. */
547         uint32_t best_cnt;     /**< Number of filters in best effort spaces. */
548 };
549
550 /**
551  * Hash filter information types.
552  * - RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT is for getting/setting the
553  *   information/configuration of 'symmetric hash enable' per port.
554  * - RTE_ETH_HASH_FILTER_GLOBAL_CONFIG is for getting/setting the global
555  *   configurations of hash filters. Those global configurations are valid
556  *   for all ports of the same NIC.
557  */
558 enum rte_eth_hash_filter_info_type {
559         RTE_ETH_HASH_FILTER_INFO_TYPE_UNKNOWN = 0,
560         /** Symmetric hash enable per port */
561         RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT,
562         /** Configure globally for hash filter */
563         RTE_ETH_HASH_FILTER_GLOBAL_CONFIG,
564         RTE_ETH_HASH_FILTER_INFO_TYPE_MAX,
565 };
566
567 /**
568  * Hash function types.
569  */
570 enum rte_eth_hash_function {
571         RTE_ETH_HASH_FUNCTION_DEFAULT = 0,
572         RTE_ETH_HASH_FUNCTION_TOEPLITZ, /**< Toeplitz */
573         RTE_ETH_HASH_FUNCTION_SIMPLE_XOR, /**< Simple XOR */
574         RTE_ETH_HASH_FUNCTION_MAX,
575 };
576
577 #define UINT32_BIT (CHAR_BIT * sizeof(uint32_t))
578 #define RTE_SYM_HASH_MASK_ARRAY_SIZE \
579         (RTE_ALIGN(RTE_ETH_FLOW_TYPE_MAX, UINT32_BIT)/UINT32_BIT)
580 /**
581  * A structure used to set or get global hash function configurations which
582  * include symmetric hash enable per flow type and hash function type.
583  * Each bit in sym_hash_enable_mask[] indicates if the symmetric hash of the
584  * coresponding flow type is enabled or not.
585  * Each bit in valid_bit_mask[] indicates if the corresponding bit in
586  * sym_hash_enable_mask[] is valid or not. For the configurations gotten, it
587  * also means if the flow type is supported by hardware or not.
588  */
589 struct rte_eth_hash_global_conf {
590         enum rte_eth_hash_function hash_func; /**< Hash function type */
591         /** Bit mask for symmetric hash enable per flow type */
592         uint32_t sym_hash_enable_mask[RTE_SYM_HASH_MASK_ARRAY_SIZE];
593         /** Bit mask indicates if the corresponding bit is valid */
594         uint32_t valid_bit_mask[RTE_SYM_HASH_MASK_ARRAY_SIZE];
595 };
596
597 /**
598  * A structure used to set or get hash filter information, to support filter
599  * type of 'RTE_ETH_FILTER_HASH' and its operations.
600  */
601 struct rte_eth_hash_filter_info {
602         enum rte_eth_hash_filter_info_type info_type; /**< Information type */
603         /** Details of hash filter information */
604         union {
605                 /** For RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT */
606                 uint8_t enable;
607                 /** Global configurations of hash filter */
608                 struct rte_eth_hash_global_conf global_conf;
609         } info;
610 };
611
612 #ifdef __cplusplus
613 }
614 #endif
615
616 #endif /* _RTE_ETH_CTRL_H_ */