4 * Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
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
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.
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.
34 #ifndef _RTE_ETH_CTRL_H_
35 #define _RTE_ETH_CTRL_H_
40 * Ethernet device features and related data structures used
41 * by control APIs should be defined in this file.
50 * Feature filter types
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_TUNNEL,
64 * Generic operations on filters
67 /** used to check whether the type filter is supported */
68 RTE_ETH_FILTER_NOP = 0,
69 RTE_ETH_FILTER_ADD, /**< add filter entry */
70 RTE_ETH_FILTER_UPDATE, /**< update filter entry */
71 RTE_ETH_FILTER_DELETE, /**< delete filter entry */
72 RTE_ETH_FILTER_FLUSH, /**< flush all entries */
73 RTE_ETH_FILTER_GET, /**< get filter entry */
74 RTE_ETH_FILTER_SET, /**< configurations */
75 RTE_ETH_FILTER_INFO, /**< retrieve information */
76 RTE_ETH_FILTER_STATS, /**< retrieve statistics */
83 enum rte_mac_filter_type {
84 RTE_MAC_PERFECT_MATCH = 1, /**< exact match of MAC addr. */
85 RTE_MACVLAN_PERFECT_MATCH, /**< exact match of MAC addr and VLAN ID. */
86 RTE_MAC_HASH_MATCH, /**< hash match of MAC addr. */
87 /** hash match of MAC addr and exact match of VLAN ID. */
88 RTE_MACVLAN_HASH_MATCH,
94 struct rte_eth_mac_filter {
95 uint8_t is_vf; /**< 1 for VF, 0 for port dev */
96 uint16_t dst_id; /**< VF ID, available when is_vf is 1*/
97 enum rte_mac_filter_type filter_type; /**< MAC filter type */
98 struct ether_addr mac_addr;
102 * Define all structures for Ethertype Filter type.
105 #define RTE_ETHTYPE_FLAGS_MAC 0x0001 /**< If set, compare mac */
106 #define RTE_ETHTYPE_FLAGS_DROP 0x0002 /**< If set, drop packet when match */
109 * A structure used to define the ethertype filter entry
110 * to support RTE_ETH_FILTER_ETHERTYPE with RTE_ETH_FILTER_ADD,
111 * RTE_ETH_FILTER_DELETE and RTE_ETH_FILTER_GET operations.
113 struct rte_eth_ethertype_filter {
114 struct ether_addr mac_addr; /**< Mac address to match. */
115 uint16_t ether_type; /**< Ether type to match */
116 uint16_t flags; /**< Flags from RTE_ETHTYPE_FLAGS_* */
117 uint16_t queue; /**< Queue assigned to when match*/
120 #define RTE_FLEX_FILTER_MAXLEN 128 /**< bytes to use in flex filter. */
121 #define RTE_FLEX_FILTER_MASK_SIZE \
122 (RTE_ALIGN(RTE_FLEX_FILTER_MAXLEN, CHAR_BIT) / CHAR_BIT)
123 /**< mask bytes in flex filter. */
126 * A structure used to define the flex filter entry
127 * to support RTE_ETH_FILTER_FLEXIBLE with RTE_ETH_FILTER_ADD,
128 * RTE_ETH_FILTER_DELETE and RTE_ETH_FILTER_GET operations.
130 struct rte_eth_flex_filter {
132 uint8_t bytes[RTE_FLEX_FILTER_MAXLEN]; /**< flex bytes in big endian.*/
133 uint8_t mask[RTE_FLEX_FILTER_MASK_SIZE]; /**< if mask bit is 1b, do
134 not compare corresponding byte. */
136 uint16_t queue; /**< Queue assigned to when match. */
142 enum rte_eth_tunnel_type {
143 RTE_TUNNEL_TYPE_NONE = 0,
144 RTE_TUNNEL_TYPE_VXLAN,
145 RTE_TUNNEL_TYPE_GENEVE,
146 RTE_TUNNEL_TYPE_TEREDO,
147 RTE_TUNNEL_TYPE_NVGRE,
152 * filter type of tunneling packet
154 #define ETH_TUNNEL_FILTER_OMAC 0x01 /**< filter by outer MAC addr */
155 #define ETH_TUNNEL_FILTER_OIP 0x02 /**< filter by outer IP Addr */
156 #define ETH_TUNNEL_FILTER_TENID 0x04 /**< filter by tenant ID */
157 #define ETH_TUNNEL_FILTER_IMAC 0x08 /**< filter by inner MAC addr */
158 #define ETH_TUNNEL_FILTER_IVLAN 0x10 /**< filter by inner VLAN ID */
159 #define ETH_TUNNEL_FILTER_IIP 0x20 /**< filter by inner IP addr */
161 #define RTE_TUNNEL_FILTER_IMAC_IVLAN (ETH_TUNNEL_FILTER_IMAC | \
162 ETH_TUNNEL_FILTER_IVLAN)
163 #define RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID (ETH_TUNNEL_FILTER_IMAC | \
164 ETH_TUNNEL_FILTER_IVLAN | \
165 ETH_TUNNEL_FILTER_TENID)
166 #define RTE_TUNNEL_FILTER_IMAC_TENID (ETH_TUNNEL_FILTER_IMAC | \
167 ETH_TUNNEL_FILTER_TENID)
168 #define RTE_TUNNEL_FILTER_OMAC_TENID_IMAC (ETH_TUNNEL_FILTER_OMAC | \
169 ETH_TUNNEL_FILTER_TENID | \
170 ETH_TUNNEL_FILTER_IMAC)
173 * Select IPv4 or IPv6 for tunnel filters.
175 enum rte_tunnel_iptype {
176 RTE_TUNNEL_IPTYPE_IPV4 = 0, /**< IPv4. */
177 RTE_TUNNEL_IPTYPE_IPV6, /**< IPv6. */
181 * Tunneling Packet filter configuration.
183 struct rte_eth_tunnel_filter_conf {
184 struct ether_addr *outer_mac; /**< Outer MAC address filter. */
185 struct ether_addr *inner_mac; /**< Inner MAC address filter. */
186 uint16_t inner_vlan; /**< Inner VLAN filter. */
187 enum rte_tunnel_iptype ip_type; /**< IP address type. */
189 uint32_t ipv4_addr; /**< IPv4 source address to match. */
190 uint32_t ipv6_addr[4]; /**< IPv6 source address to match. */
191 } ip_addr; /**< IPv4/IPv6 source address to match (union of above). */
193 uint16_t filter_type; /**< Filter type. */
194 enum rte_eth_tunnel_type tunnel_type; /**< Tunnel Type. */
195 uint32_t tenant_id; /** < Tenant number. */
196 uint16_t queue_id; /** < queue number. */
199 #define RTE_ETH_FDIR_MAX_FLEXLEN 16 /** < Max length of flexbytes. */
204 enum rte_eth_flow_type {
205 RTE_ETH_FLOW_TYPE_NONE = 0,
206 RTE_ETH_FLOW_TYPE_RAW,
207 RTE_ETH_FLOW_TYPE_UDPV4,
208 RTE_ETH_FLOW_TYPE_TCPV4,
209 RTE_ETH_FLOW_TYPE_SCTPV4,
210 RTE_ETH_FLOW_TYPE_IPV4_OTHER,
211 RTE_ETH_FLOW_TYPE_FRAG_IPV4,
212 RTE_ETH_FLOW_TYPE_UDPV6,
213 RTE_ETH_FLOW_TYPE_TCPV6,
214 RTE_ETH_FLOW_TYPE_SCTPV6,
215 RTE_ETH_FLOW_TYPE_IPV6_OTHER,
216 RTE_ETH_FLOW_TYPE_FRAG_IPV6,
217 RTE_ETH_FLOW_TYPE_MAX = 64,
221 * A structure used to define the input for IPV4 flow
223 struct rte_eth_ipv4_flow {
224 uint32_t src_ip; /**< IPv4 source address to match. */
225 uint32_t dst_ip; /**< IPv4 destination address to match. */
229 * A structure used to define the input for IPV4 UDP flow
231 struct rte_eth_udpv4_flow {
232 struct rte_eth_ipv4_flow ip; /**< IPv4 fields to match. */
233 uint16_t src_port; /**< UDP source port to match. */
234 uint16_t dst_port; /**< UDP destination port to match. */
238 * A structure used to define the input for IPV4 TCP flow
240 struct rte_eth_tcpv4_flow {
241 struct rte_eth_ipv4_flow ip; /**< IPv4 fields to match. */
242 uint16_t src_port; /**< TCP source port to match. */
243 uint16_t dst_port; /**< TCP destination port to match. */
247 * A structure used to define the input for IPV4 SCTP flow
249 struct rte_eth_sctpv4_flow {
250 struct rte_eth_ipv4_flow ip; /**< IPv4 fields to match. */
251 uint32_t verify_tag; /**< Verify tag to match */
255 * A structure used to define the input for IPV6 flow
257 struct rte_eth_ipv6_flow {
258 uint32_t src_ip[4]; /**< IPv6 source address to match. */
259 uint32_t dst_ip[4]; /**< IPv6 destination address to match. */
263 * A structure used to define the input for IPV6 UDP flow
265 struct rte_eth_udpv6_flow {
266 struct rte_eth_ipv6_flow ip; /**< IPv6 fields to match. */
267 uint16_t src_port; /**< UDP source port to match. */
268 uint16_t dst_port; /**< UDP destination port to match. */
272 * A structure used to define the input for IPV6 TCP flow
274 struct rte_eth_tcpv6_flow {
275 struct rte_eth_ipv6_flow ip; /**< IPv6 fields to match. */
276 uint16_t src_port; /**< TCP source port to match. */
277 uint16_t dst_port; /**< TCP destination port to match. */
281 * A structure used to define the input for IPV6 SCTP flow
283 struct rte_eth_sctpv6_flow {
284 struct rte_eth_ipv6_flow ip; /**< IPv6 fields to match. */
285 uint32_t verify_tag; /**< Verify tag to match */
289 * An union contains the inputs for all types of flow
291 union rte_eth_fdir_flow {
292 struct rte_eth_udpv4_flow udp4_flow;
293 struct rte_eth_tcpv4_flow tcp4_flow;
294 struct rte_eth_sctpv4_flow sctp4_flow;
295 struct rte_eth_ipv4_flow ip4_flow;
296 struct rte_eth_udpv6_flow udp6_flow;
297 struct rte_eth_tcpv6_flow tcp6_flow;
298 struct rte_eth_sctpv6_flow sctp6_flow;
299 struct rte_eth_ipv6_flow ipv6_flow;
303 * A structure used to contain extend input of flow
305 struct rte_eth_fdir_flow_ext {
307 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
308 /**< It is filled by the flexible payload to match. */
312 * A structure used to define the input for a flow director filter entry
314 struct rte_eth_fdir_input {
315 enum rte_eth_flow_type flow_type; /**< Type of flow */
316 union rte_eth_fdir_flow flow;
317 /**< Flow fields to match, dependent on flow_type */
318 struct rte_eth_fdir_flow_ext flow_ext;
319 /**< Additional fields to match */
323 * Behavior will be taken if FDIR match
325 enum rte_eth_fdir_behavior {
326 RTE_ETH_FDIR_ACCEPT = 0,
331 * Flow director report status
332 * It defines what will be reported if FDIR entry is matched.
334 enum rte_eth_fdir_status {
335 RTE_ETH_FDIR_NO_REPORT_STATUS = 0, /**< Report nothing. */
336 RTE_ETH_FDIR_REPORT_ID, /**< Only report FD ID. */
337 RTE_ETH_FDIR_REPORT_ID_FLEX_4, /**< Report FD ID and 4 flex bytes. */
338 RTE_ETH_FDIR_REPORT_FLEX_8, /**< Report 8 flex bytes. */
342 * A structure used to define an action when match FDIR packet filter.
344 struct rte_eth_fdir_action {
345 uint16_t rx_queue; /**< Queue assigned to if FDIR match. */
346 enum rte_eth_fdir_behavior behavior; /**< Behavior will be taken */
347 enum rte_eth_fdir_status report_status; /**< Status report option */
349 /**< If report_status is RTE_ETH_FDIR_REPORT_ID_FLEX_4 or
350 RTE_ETH_FDIR_REPORT_FLEX_8, flex_off specifies where the reported
351 flex bytes start from in flexible payload. */
355 * A structure used to define the flow director filter entry by filter_ctrl API
356 * It supports RTE_ETH_FILTER_FDIR with RTE_ETH_FILTER_ADD and
357 * RTE_ETH_FILTER_DELETE operations.
359 struct rte_eth_fdir_filter {
361 /**< ID, an unique value is required when deal with FDIR entry */
362 struct rte_eth_fdir_input input; /**< Input set */
363 struct rte_eth_fdir_action action; /**< Action taken when match */
367 * A structure used to configure FDIR masks that are used by the device
368 * to match the various fields of RX packet headers.
370 struct rte_eth_fdir_masks {
371 uint16_t vlan_tci_mask;
372 struct rte_eth_ipv4_flow ipv4_mask;
373 struct rte_eth_ipv6_flow ipv6_mask;
374 uint16_t src_port_mask;
375 uint16_t dst_port_mask;
381 enum rte_eth_payload_type {
382 RTE_ETH_PAYLOAD_UNKNOWN = 0,
387 RTE_ETH_PAYLOAD_MAX = 8,
391 * A structure used to select bytes extracted from the protocol layers to
392 * flexible payload for filter
394 struct rte_eth_flex_payload_cfg {
395 enum rte_eth_payload_type type; /**< Payload type */
396 uint16_t src_offset[RTE_ETH_FDIR_MAX_FLEXLEN];
397 /**< Offset in bytes from the beginning of packet's payload
398 src_offset[i] indicates the flexbyte i's offset in original
399 packet payload. This value should be less than
400 flex_payload_limit in struct rte_eth_fdir_info.*/
404 * A structure used to define FDIR masks for flexible payload
407 struct rte_eth_fdir_flex_mask {
408 enum rte_eth_flow_type flow_type; /**< Flow type */
409 uint8_t mask[RTE_ETH_FDIR_MAX_FLEXLEN];
410 /**< Mask for the whole flexible payload */
414 * A structure used to define all flexible payload related setting
415 * include flexpay load and flex mask
417 struct rte_eth_fdir_flex_conf {
418 uint16_t nb_payloads; /**< The number of following payload cfg */
419 uint16_t nb_flexmasks; /**< The number of following mask */
420 struct rte_eth_flex_payload_cfg flex_set[RTE_ETH_PAYLOAD_MAX];
421 /**< Flex payload configuration for each payload type */
422 struct rte_eth_fdir_flex_mask flex_mask[RTE_ETH_FLOW_TYPE_MAX];
423 /**< Flex mask configuration for each flow type */
427 * Flow Director setting modes: none, signature or perfect.
430 RTE_FDIR_MODE_NONE = 0, /**< Disable FDIR support. */
431 RTE_FDIR_MODE_SIGNATURE, /**< Enable FDIR signature filter mode. */
432 RTE_FDIR_MODE_PERFECT, /**< Enable FDIR perfect filter mode. */
436 * A structure used to get the information of flow director filter.
437 * It supports RTE_ETH_FILTER_FDIR with RTE_ETH_FILTER_INFO operation.
438 * It includes the mode, flexible payload configuration information,
439 * capabilities and supported flow types, flexible payload characters.
440 * It can be gotten to help taking specific configurations per device.
442 struct rte_eth_fdir_info {
443 enum rte_fdir_mode mode; /**< Flow director mode */
444 struct rte_eth_fdir_masks mask;
445 struct rte_eth_fdir_flex_conf flex_conf;
446 /**< Flex payload configuration information */
447 uint32_t guarant_spc; /**< Guaranteed spaces.*/
448 uint32_t best_spc; /**< Best effort spaces.*/
449 uint32_t flow_types_mask[RTE_ETH_FLOW_TYPE_MAX / sizeof(uint32_t)];
450 /**< Bit mask for every supported flow type. */
451 uint32_t max_flexpayload; /**< Total flex payload in bytes. */
452 uint32_t flex_payload_unit;
453 /**< Flexible payload unit in bytes. Size and alignments of all flex
454 payload segments should be multiplies of this value. */
455 uint32_t max_flex_payload_segment_num;
456 /**< Max number of flexible payload continuous segments.
457 Each segment should be a multiple of flex_payload_unit.*/
458 uint16_t flex_payload_limit;
459 /**< Maximum src_offset in bytes allowed. It indicates that
460 src_offset[i] in struct rte_eth_flex_payload_cfg should be
461 less than this value. */
462 uint32_t flex_bitmask_unit;
463 /**< Flex bitmask unit in bytes. Size of flex bitmasks should
464 be a multiply of this value. */
465 uint32_t max_flex_bitmask_num;
466 /**< Max supported size of flex bitmasks in flex_bitmask_unit */
470 * A structure used to define the statistics of flow director.
471 * It supports RTE_ETH_FILTER_FDIR with RTE_ETH_FILTER_STATS operation.
473 struct rte_eth_fdir_stats {
474 uint32_t collision; /**< Number of filters with collision. */
475 uint32_t free; /**< Number of free filters. */
477 /**< The lookup hash value of the added filter that updated the value
478 of the MAXLEN field */
479 uint32_t maxlen; /**< Longest linked list of filters. */
480 uint64_t add; /**< Number of added filters. */
481 uint64_t remove; /**< Number of removed filters. */
482 uint64_t f_add; /**< Number of failed added filters. */
483 uint64_t f_remove; /**< Number of failed removed filters. */
484 uint32_t guarant_cnt; /**< Number of filters in guaranteed spaces. */
485 uint32_t best_cnt; /**< Number of filters in best effort spaces. */
489 * Hash filter information types.
490 * - RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT is for getting/setting the
491 * information/configuration of 'symmetric hash enable' per port.
492 * - RTE_ETH_HASH_FILTER_GLOBAL_CONFIG is for getting/setting the global
493 * configurations of hash filters. Those global configurations are valid
494 * for all ports of the same NIC.
496 enum rte_eth_hash_filter_info_type {
497 RTE_ETH_HASH_FILTER_INFO_TYPE_UNKNOWN = 0,
498 /** Symmetric hash enable per port */
499 RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT,
500 /** Configure globally for hash filter */
501 RTE_ETH_HASH_FILTER_GLOBAL_CONFIG,
502 RTE_ETH_HASH_FILTER_INFO_TYPE_MAX,
506 * Hash function types.
508 enum rte_eth_hash_function {
509 RTE_ETH_HASH_FUNCTION_DEFAULT = 0,
510 RTE_ETH_HASH_FUNCTION_TOEPLITZ, /**< Toeplitz */
511 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR, /**< Simple XOR */
512 RTE_ETH_HASH_FUNCTION_MAX,
515 #define UINT32_BIT (CHAR_BIT * sizeof(uint32_t))
516 #define RTE_SYM_HASH_MASK_ARRAY_SIZE \
517 (RTE_ALIGN(RTE_ETH_FLOW_TYPE_MAX, UINT32_BIT)/UINT32_BIT)
519 * A structure used to set or get global hash function configurations which
520 * include symmetric hash enable per flow type and hash function type.
521 * Each bit in sym_hash_enable_mask[] indicates if the symmetric hash of the
522 * coresponding flow type is enabled or not.
523 * Each bit in valid_bit_mask[] indicates if the corresponding bit in
524 * sym_hash_enable_mask[] is valid or not. For the configurations gotten, it
525 * also means if the flow type is supported by hardware or not.
527 struct rte_eth_hash_global_conf {
528 enum rte_eth_hash_function hash_func; /**< Hash function type */
529 /** Bit mask for symmetric hash enable per flow type */
530 uint32_t sym_hash_enable_mask[RTE_SYM_HASH_MASK_ARRAY_SIZE];
531 /** Bit mask indicates if the corresponding bit is valid */
532 uint32_t valid_bit_mask[RTE_SYM_HASH_MASK_ARRAY_SIZE];
536 * A structure used to set or get hash filter information, to support filter
537 * type of 'RTE_ETH_FILTER_HASH' and its operations.
539 struct rte_eth_hash_filter_info {
540 enum rte_eth_hash_filter_info_type info_type; /**< Information type */
541 /** Details of hash filter information */
543 /** For RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT */
545 /** Global configurations of hash filter */
546 struct rte_eth_hash_global_conf global_conf;
554 #endif /* _RTE_ETH_CTRL_H_ */