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