4 * Copyright(c) 2010-2015 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 * 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
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_PORT 18
78 /**< Consider device port number as a flow differentiator */
79 #define RTE_ETH_FLOW_VXLAN 19 /**< VXLAN protocol based flow */
80 #define RTE_ETH_FLOW_GENEVE 20 /**< GENEVE protocol based flow */
81 #define RTE_ETH_FLOW_NVGRE 21 /**< NVGRE protocol based flow */
82 #define RTE_ETH_FLOW_MAX 22
85 * Feature filter types
87 enum rte_filter_type {
88 RTE_ETH_FILTER_NONE = 0,
89 RTE_ETH_FILTER_MACVLAN,
90 RTE_ETH_FILTER_ETHERTYPE,
91 RTE_ETH_FILTER_FLEXIBLE,
93 RTE_ETH_FILTER_NTUPLE,
94 RTE_ETH_FILTER_TUNNEL,
97 RTE_ETH_FILTER_L2_TUNNEL,
102 * Generic operations on filters
105 /** used to check whether the type filter is supported */
106 RTE_ETH_FILTER_NOP = 0,
107 RTE_ETH_FILTER_ADD, /**< add filter entry */
108 RTE_ETH_FILTER_UPDATE, /**< update filter entry */
109 RTE_ETH_FILTER_DELETE, /**< delete filter entry */
110 RTE_ETH_FILTER_FLUSH, /**< flush all entries */
111 RTE_ETH_FILTER_GET, /**< get filter entry */
112 RTE_ETH_FILTER_SET, /**< configurations */
113 RTE_ETH_FILTER_INFO, /**< retrieve information */
114 RTE_ETH_FILTER_STATS, /**< retrieve statistics */
115 RTE_ETH_FILTER_OP_MAX
121 enum rte_mac_filter_type {
122 RTE_MAC_PERFECT_MATCH = 1, /**< exact match of MAC addr. */
123 RTE_MACVLAN_PERFECT_MATCH, /**< exact match of MAC addr and VLAN ID. */
124 RTE_MAC_HASH_MATCH, /**< hash match of MAC addr. */
125 /** hash match of MAC addr and exact match of VLAN ID. */
126 RTE_MACVLAN_HASH_MATCH,
132 struct rte_eth_mac_filter {
133 uint8_t is_vf; /**< 1 for VF, 0 for port dev */
134 uint16_t dst_id; /**< VF ID, available when is_vf is 1*/
135 enum rte_mac_filter_type filter_type; /**< MAC filter type */
136 struct ether_addr mac_addr;
140 * Define all structures for Ethertype Filter type.
143 #define RTE_ETHTYPE_FLAGS_MAC 0x0001 /**< If set, compare mac */
144 #define RTE_ETHTYPE_FLAGS_DROP 0x0002 /**< If set, drop packet when match */
147 * A structure used to define the ethertype filter entry
148 * to support RTE_ETH_FILTER_ETHERTYPE with RTE_ETH_FILTER_ADD,
149 * RTE_ETH_FILTER_DELETE and RTE_ETH_FILTER_GET operations.
151 struct rte_eth_ethertype_filter {
152 struct ether_addr mac_addr; /**< Mac address to match. */
153 uint16_t ether_type; /**< Ether type to match */
154 uint16_t flags; /**< Flags from RTE_ETHTYPE_FLAGS_* */
155 uint16_t queue; /**< Queue assigned to when match*/
158 #define RTE_FLEX_FILTER_MAXLEN 128 /**< bytes to use in flex filter. */
159 #define RTE_FLEX_FILTER_MASK_SIZE \
160 (RTE_ALIGN(RTE_FLEX_FILTER_MAXLEN, CHAR_BIT) / CHAR_BIT)
161 /**< mask bytes in flex filter. */
164 * A structure used to define the flex filter entry
165 * to support RTE_ETH_FILTER_FLEXIBLE with RTE_ETH_FILTER_ADD,
166 * RTE_ETH_FILTER_DELETE and RTE_ETH_FILTER_GET operations.
168 struct rte_eth_flex_filter {
170 uint8_t bytes[RTE_FLEX_FILTER_MAXLEN]; /**< flex bytes in big endian.*/
171 uint8_t mask[RTE_FLEX_FILTER_MASK_SIZE]; /**< if mask bit is 1b, do
172 not compare corresponding byte. */
174 uint16_t queue; /**< Queue assigned to when match. */
178 * A structure used to define the TCP syn filter entry
179 * to support RTE_ETH_FILTER_SYN with RTE_ETH_FILTER_ADD,
180 * RTE_ETH_FILTER_DELETE and RTE_ETH_FILTER_GET operations.
182 struct rte_eth_syn_filter {
183 uint8_t hig_pri; /**< 1 - higher priority than other filters,
184 0 - lower priority. */
185 uint16_t queue; /**< Queue assigned to when match */
189 * Define all structures for ntuple Filter type.
192 #define RTE_NTUPLE_FLAGS_DST_IP 0x0001 /**< If set, dst_ip is part of ntuple */
193 #define RTE_NTUPLE_FLAGS_SRC_IP 0x0002 /**< If set, src_ip is part of ntuple */
194 #define RTE_NTUPLE_FLAGS_DST_PORT 0x0004 /**< If set, dst_port is part of ntuple */
195 #define RTE_NTUPLE_FLAGS_SRC_PORT 0x0008 /**< If set, src_port is part of ntuple */
196 #define RTE_NTUPLE_FLAGS_PROTO 0x0010 /**< If set, protocol is part of ntuple */
197 #define RTE_NTUPLE_FLAGS_TCP_FLAG 0x0020 /**< If set, tcp flag is involved */
199 #define RTE_5TUPLE_FLAGS ( \
200 RTE_NTUPLE_FLAGS_DST_IP | \
201 RTE_NTUPLE_FLAGS_SRC_IP | \
202 RTE_NTUPLE_FLAGS_DST_PORT | \
203 RTE_NTUPLE_FLAGS_SRC_PORT | \
204 RTE_NTUPLE_FLAGS_PROTO)
206 #define RTE_2TUPLE_FLAGS ( \
207 RTE_NTUPLE_FLAGS_DST_PORT | \
208 RTE_NTUPLE_FLAGS_PROTO)
210 #define TCP_URG_FLAG 0x20
211 #define TCP_ACK_FLAG 0x10
212 #define TCP_PSH_FLAG 0x08
213 #define TCP_RST_FLAG 0x04
214 #define TCP_SYN_FLAG 0x02
215 #define TCP_FIN_FLAG 0x01
216 #define TCP_FLAG_ALL 0x3F
219 * A structure used to define the ntuple filter entry
220 * to support RTE_ETH_FILTER_NTUPLE with RTE_ETH_FILTER_ADD,
221 * RTE_ETH_FILTER_DELETE and RTE_ETH_FILTER_GET operations.
223 struct rte_eth_ntuple_filter {
224 uint16_t flags; /**< Flags from RTE_NTUPLE_FLAGS_* */
225 uint32_t dst_ip; /**< Destination IP address in big endian. */
226 uint32_t dst_ip_mask; /**< Mask of destination IP address. */
227 uint32_t src_ip; /**< Source IP address in big endian. */
228 uint32_t src_ip_mask; /**< Mask of destination IP address. */
229 uint16_t dst_port; /**< Destination port in big endian. */
230 uint16_t dst_port_mask; /**< Mask of destination port. */
231 uint16_t src_port; /**< Source Port in big endian. */
232 uint16_t src_port_mask; /**< Mask of source port. */
233 uint8_t proto; /**< L4 protocol. */
234 uint8_t proto_mask; /**< Mask of L4 protocol. */
235 /** tcp_flags only meaningful when the proto is TCP.
236 The packet matched above ntuple fields and contain
237 any set bit in tcp_flags will hit this filter. */
239 uint16_t priority; /**< seven levels (001b-111b), 111b is highest,
240 used when more than one filter matches. */
241 uint16_t queue; /**< Queue assigned to when match*/
247 enum rte_eth_tunnel_type {
248 RTE_TUNNEL_TYPE_NONE = 0,
249 RTE_TUNNEL_TYPE_VXLAN,
250 RTE_TUNNEL_TYPE_GENEVE,
251 RTE_TUNNEL_TYPE_TEREDO,
252 RTE_TUNNEL_TYPE_NVGRE,
253 RTE_TUNNEL_TYPE_IP_IN_GRE,
254 RTE_L2_TUNNEL_TYPE_E_TAG,
259 * filter type of tunneling packet
261 #define ETH_TUNNEL_FILTER_OMAC 0x01 /**< filter by outer MAC addr */
262 #define ETH_TUNNEL_FILTER_OIP 0x02 /**< filter by outer IP Addr */
263 #define ETH_TUNNEL_FILTER_TENID 0x04 /**< filter by tenant ID */
264 #define ETH_TUNNEL_FILTER_IMAC 0x08 /**< filter by inner MAC addr */
265 #define ETH_TUNNEL_FILTER_IVLAN 0x10 /**< filter by inner VLAN ID */
266 #define ETH_TUNNEL_FILTER_IIP 0x20 /**< filter by inner IP addr */
268 #define RTE_TUNNEL_FILTER_IMAC_IVLAN (ETH_TUNNEL_FILTER_IMAC | \
269 ETH_TUNNEL_FILTER_IVLAN)
270 #define RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID (ETH_TUNNEL_FILTER_IMAC | \
271 ETH_TUNNEL_FILTER_IVLAN | \
272 ETH_TUNNEL_FILTER_TENID)
273 #define RTE_TUNNEL_FILTER_IMAC_TENID (ETH_TUNNEL_FILTER_IMAC | \
274 ETH_TUNNEL_FILTER_TENID)
275 #define RTE_TUNNEL_FILTER_OMAC_TENID_IMAC (ETH_TUNNEL_FILTER_OMAC | \
276 ETH_TUNNEL_FILTER_TENID | \
277 ETH_TUNNEL_FILTER_IMAC)
280 * Select IPv4 or IPv6 for tunnel filters.
282 enum rte_tunnel_iptype {
283 RTE_TUNNEL_IPTYPE_IPV4 = 0, /**< IPv4. */
284 RTE_TUNNEL_IPTYPE_IPV6, /**< IPv6. */
288 * Tunneling Packet filter configuration.
290 struct rte_eth_tunnel_filter_conf {
291 struct ether_addr outer_mac; /**< Outer MAC address to match. */
292 struct ether_addr inner_mac; /**< Inner MAC address to match. */
293 uint16_t inner_vlan; /**< Inner VLAN to match. */
294 enum rte_tunnel_iptype ip_type; /**< IP address type. */
295 /** Outer destination IP address to match if ETH_TUNNEL_FILTER_OIP
296 is set in filter_type, or inner destination IP address to match
297 if ETH_TUNNEL_FILTER_IIP is set in filter_type . */
299 uint32_t ipv4_addr; /**< IPv4 address in big endian. */
300 uint32_t ipv6_addr[4]; /**< IPv6 address in big endian. */
302 /** Flags from ETH_TUNNEL_FILTER_XX - see above. */
303 uint16_t filter_type;
304 enum rte_eth_tunnel_type tunnel_type; /**< Tunnel Type. */
305 uint32_t tenant_id; /**< Tenant ID to match. VNI, GRE key... */
306 uint16_t queue_id; /**< Queue assigned to if match. */
310 * Global eth device configuration type.
312 enum rte_eth_global_cfg_type {
313 RTE_ETH_GLOBAL_CFG_TYPE_UNKNOWN = 0,
314 RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN,
315 RTE_ETH_GLOBAL_CFG_TYPE_MAX,
319 * Global eth device configuration.
321 struct rte_eth_global_cfg {
322 enum rte_eth_global_cfg_type cfg_type; /**< Global config type. */
324 uint8_t gre_key_len; /**< Valid GRE key length in byte. */
325 uint64_t reserved; /**< Reserve space for future use. */
329 #define RTE_ETH_FDIR_MAX_FLEXLEN 16 /**< Max length of flexbytes. */
330 #define RTE_ETH_INSET_SIZE_MAX 128 /**< Max length of input set. */
333 * Input set fields for Flow Director and Hash filters
335 enum rte_eth_input_set_field {
336 RTE_ETH_INPUT_SET_UNKNOWN = 0,
339 RTE_ETH_INPUT_SET_L2_SRC_MAC = 1,
340 RTE_ETH_INPUT_SET_L2_DST_MAC,
341 RTE_ETH_INPUT_SET_L2_OUTER_VLAN,
342 RTE_ETH_INPUT_SET_L2_INNER_VLAN,
343 RTE_ETH_INPUT_SET_L2_ETHERTYPE,
346 RTE_ETH_INPUT_SET_L3_SRC_IP4 = 129,
347 RTE_ETH_INPUT_SET_L3_DST_IP4,
348 RTE_ETH_INPUT_SET_L3_SRC_IP6,
349 RTE_ETH_INPUT_SET_L3_DST_IP6,
350 RTE_ETH_INPUT_SET_L3_IP4_TOS,
351 RTE_ETH_INPUT_SET_L3_IP4_PROTO,
352 RTE_ETH_INPUT_SET_L3_IP6_TC,
353 RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER,
354 RTE_ETH_INPUT_SET_L3_IP4_TTL,
355 RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS,
358 RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT = 257,
359 RTE_ETH_INPUT_SET_L4_UDP_DST_PORT,
360 RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT,
361 RTE_ETH_INPUT_SET_L4_TCP_DST_PORT,
362 RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT,
363 RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT,
364 RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG,
367 RTE_ETH_INPUT_SET_TUNNEL_L2_INNER_DST_MAC = 385,
368 RTE_ETH_INPUT_SET_TUNNEL_L2_INNER_SRC_MAC,
369 RTE_ETH_INPUT_SET_TUNNEL_L2_INNER_VLAN,
370 RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY,
371 RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY,
373 /* Flexible Payload */
374 RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD = 641,
375 RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD,
376 RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD,
377 RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD,
378 RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD,
379 RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD,
380 RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD,
381 RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD,
383 RTE_ETH_INPUT_SET_DEFAULT = 65533,
384 RTE_ETH_INPUT_SET_NONE = 65534,
385 RTE_ETH_INPUT_SET_MAX = 65535,
389 * Filters input set operations
391 enum rte_filter_input_set_op {
392 RTE_ETH_INPUT_SET_OP_UNKNOWN,
393 RTE_ETH_INPUT_SET_SELECT, /**< select input set */
394 RTE_ETH_INPUT_SET_ADD, /**< add input set entry */
395 RTE_ETH_INPUT_SET_OP_MAX
400 * A structure used to define the input set configuration for
401 * flow director and hash filters
403 struct rte_eth_input_set_conf {
406 enum rte_eth_input_set_field field[RTE_ETH_INSET_SIZE_MAX];
407 enum rte_filter_input_set_op op;
411 * A structure used to define the input for L2 flow
413 struct rte_eth_l2_flow {
414 uint16_t ether_type; /**< Ether type in big endian */
418 * A structure used to define the input for IPV4 flow
420 struct rte_eth_ipv4_flow {
421 uint32_t src_ip; /**< IPv4 source address in big endian. */
422 uint32_t dst_ip; /**< IPv4 destination address in big endian. */
423 uint8_t tos; /**< Type of service to match. */
424 uint8_t ttl; /**< Time to live to match. */
425 uint8_t proto; /**< Protocol, next header in big endian. */
429 * A structure used to define the input for IPV4 UDP flow
431 struct rte_eth_udpv4_flow {
432 struct rte_eth_ipv4_flow ip; /**< IPv4 fields to match. */
433 uint16_t src_port; /**< UDP source port in big endian. */
434 uint16_t dst_port; /**< UDP destination port in big endian. */
438 * A structure used to define the input for IPV4 TCP flow
440 struct rte_eth_tcpv4_flow {
441 struct rte_eth_ipv4_flow ip; /**< IPv4 fields to match. */
442 uint16_t src_port; /**< TCP source port in big endian. */
443 uint16_t dst_port; /**< TCP destination port in big endian. */
447 * A structure used to define the input for IPV4 SCTP flow
449 struct rte_eth_sctpv4_flow {
450 struct rte_eth_ipv4_flow ip; /**< IPv4 fields to match. */
451 uint16_t src_port; /**< SCTP source port in big endian. */
452 uint16_t dst_port; /**< SCTP destination port in big endian. */
453 uint32_t verify_tag; /**< Verify tag in big endian */
457 * A structure used to define the input for IPV6 flow
459 struct rte_eth_ipv6_flow {
460 uint32_t src_ip[4]; /**< IPv6 source address in big endian. */
461 uint32_t dst_ip[4]; /**< IPv6 destination address in big endian. */
462 uint8_t tc; /**< Traffic class to match. */
463 uint8_t proto; /**< Protocol, next header to match. */
464 uint8_t hop_limits; /**< Hop limits to match. */
468 * A structure used to define the input for IPV6 UDP flow
470 struct rte_eth_udpv6_flow {
471 struct rte_eth_ipv6_flow ip; /**< IPv6 fields to match. */
472 uint16_t src_port; /**< UDP source port in big endian. */
473 uint16_t dst_port; /**< UDP destination port in big endian. */
477 * A structure used to define the input for IPV6 TCP flow
479 struct rte_eth_tcpv6_flow {
480 struct rte_eth_ipv6_flow ip; /**< IPv6 fields to match. */
481 uint16_t src_port; /**< TCP source port to in big endian. */
482 uint16_t dst_port; /**< TCP destination port in big endian. */
486 * A structure used to define the input for IPV6 SCTP flow
488 struct rte_eth_sctpv6_flow {
489 struct rte_eth_ipv6_flow ip; /**< IPv6 fields to match. */
490 uint16_t src_port; /**< SCTP source port in big endian. */
491 uint16_t dst_port; /**< SCTP destination port in big endian. */
492 uint32_t verify_tag; /**< Verify tag in big endian. */
496 * A structure used to define the input for MAC VLAN flow
498 struct rte_eth_mac_vlan_flow {
499 struct ether_addr mac_addr; /**< Mac address to match. */
503 * Tunnel type for flow director.
505 enum rte_eth_fdir_tunnel_type {
506 RTE_FDIR_TUNNEL_TYPE_UNKNOWN = 0,
507 RTE_FDIR_TUNNEL_TYPE_NVGRE,
508 RTE_FDIR_TUNNEL_TYPE_VXLAN,
512 * A structure used to define the input for tunnel flow, now it's VxLAN or
515 struct rte_eth_tunnel_flow {
516 enum rte_eth_fdir_tunnel_type tunnel_type; /**< Tunnel type to match. */
517 /** Tunnel ID to match. TNI, VNI... in big endian. */
519 struct ether_addr mac_addr; /**< Mac address to match. */
523 * An union contains the inputs for all types of flow
524 * Items in flows need to be in big endian
526 union rte_eth_fdir_flow {
527 struct rte_eth_l2_flow l2_flow;
528 struct rte_eth_udpv4_flow udp4_flow;
529 struct rte_eth_tcpv4_flow tcp4_flow;
530 struct rte_eth_sctpv4_flow sctp4_flow;
531 struct rte_eth_ipv4_flow ip4_flow;
532 struct rte_eth_udpv6_flow udp6_flow;
533 struct rte_eth_tcpv6_flow tcp6_flow;
534 struct rte_eth_sctpv6_flow sctp6_flow;
535 struct rte_eth_ipv6_flow ipv6_flow;
536 struct rte_eth_mac_vlan_flow mac_vlan_flow;
537 struct rte_eth_tunnel_flow tunnel_flow;
541 * A structure used to contain extend input of flow
543 struct rte_eth_fdir_flow_ext {
545 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
546 /**< It is filled by the flexible payload to match. */
547 uint8_t is_vf; /**< 1 for VF, 0 for port dev */
548 uint16_t dst_id; /**< VF ID, available when is_vf is 1*/
552 * A structure used to define the input for a flow director filter entry
554 struct rte_eth_fdir_input {
556 union rte_eth_fdir_flow flow;
557 /**< Flow fields to match, dependent on flow_type */
558 struct rte_eth_fdir_flow_ext flow_ext;
559 /**< Additional fields to match */
563 * Behavior will be taken if FDIR match
565 enum rte_eth_fdir_behavior {
566 RTE_ETH_FDIR_ACCEPT = 0,
568 RTE_ETH_FDIR_PASSTHRU,
572 * Flow director report status
573 * It defines what will be reported if FDIR entry is matched.
575 enum rte_eth_fdir_status {
576 RTE_ETH_FDIR_NO_REPORT_STATUS = 0, /**< Report nothing. */
577 RTE_ETH_FDIR_REPORT_ID, /**< Only report FD ID. */
578 RTE_ETH_FDIR_REPORT_ID_FLEX_4, /**< Report FD ID and 4 flex bytes. */
579 RTE_ETH_FDIR_REPORT_FLEX_8, /**< Report 8 flex bytes. */
583 * A structure used to define an action when match FDIR packet filter.
585 struct rte_eth_fdir_action {
586 uint16_t rx_queue; /**< Queue assigned to if FDIR match. */
587 enum rte_eth_fdir_behavior behavior; /**< Behavior will be taken */
588 enum rte_eth_fdir_status report_status; /**< Status report option */
590 /**< If report_status is RTE_ETH_FDIR_REPORT_ID_FLEX_4 or
591 RTE_ETH_FDIR_REPORT_FLEX_8, flex_off specifies where the reported
592 flex bytes start from in flexible payload. */
596 * A structure used to define the flow director filter entry by filter_ctrl API
597 * It supports RTE_ETH_FILTER_FDIR with RTE_ETH_FILTER_ADD and
598 * RTE_ETH_FILTER_DELETE operations.
600 struct rte_eth_fdir_filter {
602 /**< ID, an unique value is required when deal with FDIR entry */
603 struct rte_eth_fdir_input input; /**< Input set */
604 struct rte_eth_fdir_action action; /**< Action taken when match */
608 * A structure used to configure FDIR masks that are used by the device
609 * to match the various fields of RX packet headers.
611 struct rte_eth_fdir_masks {
612 uint16_t vlan_tci_mask; /**< Bit mask for vlan_tci in big endian */
613 /** Bit mask for ipv4 flow in big endian. */
614 struct rte_eth_ipv4_flow ipv4_mask;
615 /** Bit maks for ipv6 flow in big endian. */
616 struct rte_eth_ipv6_flow ipv6_mask;
617 /** Bit mask for L4 source port in big endian. */
618 uint16_t src_port_mask;
619 /** Bit mask for L4 destination port in big endian. */
620 uint16_t dst_port_mask;
621 /** 6 bit mask for proper 6 bytes of Mac address, bit 0 matches the
622 first byte on the wire */
623 uint8_t mac_addr_byte_mask;
624 /** Bit mask for tunnel ID in big endian. */
625 uint32_t tunnel_id_mask;
626 uint8_t tunnel_type_mask; /**< 1 - Match tunnel type,
627 0 - Ignore tunnel type. */
633 enum rte_eth_payload_type {
634 RTE_ETH_PAYLOAD_UNKNOWN = 0,
639 RTE_ETH_PAYLOAD_MAX = 8,
643 * A structure used to select bytes extracted from the protocol layers to
644 * flexible payload for filter
646 struct rte_eth_flex_payload_cfg {
647 enum rte_eth_payload_type type; /**< Payload type */
648 uint16_t src_offset[RTE_ETH_FDIR_MAX_FLEXLEN];
649 /**< Offset in bytes from the beginning of packet's payload
650 src_offset[i] indicates the flexbyte i's offset in original
651 packet payload. This value should be less than
652 flex_payload_limit in struct rte_eth_fdir_info.*/
656 * A structure used to define FDIR masks for flexible payload
659 struct rte_eth_fdir_flex_mask {
661 uint8_t mask[RTE_ETH_FDIR_MAX_FLEXLEN];
662 /**< Mask for the whole flexible payload */
666 * A structure used to define all flexible payload related setting
667 * include flex payload and flex mask
669 struct rte_eth_fdir_flex_conf {
670 uint16_t nb_payloads; /**< The number of following payload cfg */
671 uint16_t nb_flexmasks; /**< The number of following mask */
672 struct rte_eth_flex_payload_cfg flex_set[RTE_ETH_PAYLOAD_MAX];
673 /**< Flex payload configuration for each payload type */
674 struct rte_eth_fdir_flex_mask flex_mask[RTE_ETH_FLOW_MAX];
675 /**< Flex mask configuration for each flow type */
679 * Flow Director setting modes: none, signature or perfect.
682 RTE_FDIR_MODE_NONE = 0, /**< Disable FDIR support. */
683 RTE_FDIR_MODE_SIGNATURE, /**< Enable FDIR signature filter mode. */
684 RTE_FDIR_MODE_PERFECT, /**< Enable FDIR perfect filter mode. */
685 RTE_FDIR_MODE_PERFECT_MAC_VLAN, /**< Enable FDIR filter mode - MAC VLAN. */
686 RTE_FDIR_MODE_PERFECT_TUNNEL, /**< Enable FDIR filter mode - tunnel. */
689 #define UINT32_BIT (CHAR_BIT * sizeof(uint32_t))
690 #define RTE_FLOW_MASK_ARRAY_SIZE \
691 (RTE_ALIGN(RTE_ETH_FLOW_MAX, UINT32_BIT)/UINT32_BIT)
694 * A structure used to get the information of flow director filter.
695 * It supports RTE_ETH_FILTER_FDIR with RTE_ETH_FILTER_INFO operation.
696 * It includes the mode, flexible payload configuration information,
697 * capabilities and supported flow types, flexible payload characters.
698 * It can be gotten to help taking specific configurations per device.
700 struct rte_eth_fdir_info {
701 enum rte_fdir_mode mode; /**< Flow director mode */
702 struct rte_eth_fdir_masks mask;
703 /** Flex payload configuration information */
704 struct rte_eth_fdir_flex_conf flex_conf;
705 uint32_t guarant_spc; /**< Guaranteed spaces.*/
706 uint32_t best_spc; /**< Best effort spaces.*/
707 /** Bit mask for every supported flow type. */
708 uint32_t flow_types_mask[RTE_FLOW_MASK_ARRAY_SIZE];
709 uint32_t max_flexpayload; /**< Total flex payload in bytes. */
710 /** Flexible payload unit in bytes. Size and alignments of all flex
711 payload segments should be multiplies of this value. */
712 uint32_t flex_payload_unit;
713 /** Max number of flexible payload continuous segments.
714 Each segment should be a multiple of flex_payload_unit.*/
715 uint32_t max_flex_payload_segment_num;
716 /** Maximum src_offset in bytes allowed. It indicates that
717 src_offset[i] in struct rte_eth_flex_payload_cfg should be less
719 uint16_t flex_payload_limit;
720 /** Flex bitmask unit in bytes. Size of flex bitmasks should be a
721 multiply of this value. */
722 uint32_t flex_bitmask_unit;
723 /** Max supported size of flex bitmasks in flex_bitmask_unit */
724 uint32_t max_flex_bitmask_num;
728 * A structure used to define the statistics of flow director.
729 * It supports RTE_ETH_FILTER_FDIR with RTE_ETH_FILTER_STATS operation.
731 struct rte_eth_fdir_stats {
732 uint32_t collision; /**< Number of filters with collision. */
733 uint32_t free; /**< Number of free filters. */
735 /**< The lookup hash value of the added filter that updated the value
736 of the MAXLEN field */
737 uint32_t maxlen; /**< Longest linked list of filters. */
738 uint64_t add; /**< Number of added filters. */
739 uint64_t remove; /**< Number of removed filters. */
740 uint64_t f_add; /**< Number of failed added filters. */
741 uint64_t f_remove; /**< Number of failed removed filters. */
742 uint32_t guarant_cnt; /**< Number of filters in guaranteed spaces. */
743 uint32_t best_cnt; /**< Number of filters in best effort spaces. */
747 * Flow Director filter information types.
749 enum rte_eth_fdir_filter_info_type {
750 RTE_ETH_FDIR_FILTER_INFO_TYPE_UNKNOWN = 0,
751 /** Flow Director filter input set configuration */
752 RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT,
753 RTE_ETH_FDIR_FILTER_INFO_TYPE_MAX,
757 * A structure used to set FDIR filter information, to support filter type
758 * of 'RTE_ETH_FILTER_FDIR' RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT operation.
760 struct rte_eth_fdir_filter_info {
761 enum rte_eth_fdir_filter_info_type info_type; /**< Information type */
762 /** Details of fdir filter information */
764 /** Flow Director input set configuration per port */
765 struct rte_eth_input_set_conf input_set_conf;
770 * Hash filter information types.
771 * - RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT is for getting/setting the
772 * information/configuration of 'symmetric hash enable' per port.
773 * - RTE_ETH_HASH_FILTER_GLOBAL_CONFIG is for getting/setting the global
774 * configurations of hash filters. Those global configurations are valid
775 * for all ports of the same NIC.
776 * - RTE_ETH_HASH_FILTER_INPUT_SET_SELECT is for setting the global
777 * hash input set fields
779 enum rte_eth_hash_filter_info_type {
780 RTE_ETH_HASH_FILTER_INFO_TYPE_UNKNOWN = 0,
781 /** Symmetric hash enable per port */
782 RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT,
783 /** Configure globally for hash filter */
784 RTE_ETH_HASH_FILTER_GLOBAL_CONFIG,
785 /** Global Hash filter input set configuration */
786 RTE_ETH_HASH_FILTER_INPUT_SET_SELECT,
787 RTE_ETH_HASH_FILTER_INFO_TYPE_MAX,
791 * Hash function types.
793 enum rte_eth_hash_function {
794 RTE_ETH_HASH_FUNCTION_DEFAULT = 0,
795 RTE_ETH_HASH_FUNCTION_TOEPLITZ, /**< Toeplitz */
796 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR, /**< Simple XOR */
797 RTE_ETH_HASH_FUNCTION_MAX,
800 #define RTE_SYM_HASH_MASK_ARRAY_SIZE \
801 (RTE_ALIGN(RTE_ETH_FLOW_MAX, UINT32_BIT)/UINT32_BIT)
803 * A structure used to set or get global hash function configurations which
804 * include symmetric hash enable per flow type and hash function type.
805 * Each bit in sym_hash_enable_mask[] indicates if the symmetric hash of the
806 * corresponding flow type is enabled or not.
807 * Each bit in valid_bit_mask[] indicates if the corresponding bit in
808 * sym_hash_enable_mask[] is valid or not. For the configurations gotten, it
809 * also means if the flow type is supported by hardware or not.
811 struct rte_eth_hash_global_conf {
812 enum rte_eth_hash_function hash_func; /**< Hash function type */
813 /** Bit mask for symmetric hash enable per flow type */
814 uint32_t sym_hash_enable_mask[RTE_SYM_HASH_MASK_ARRAY_SIZE];
815 /** Bit mask indicates if the corresponding bit is valid */
816 uint32_t valid_bit_mask[RTE_SYM_HASH_MASK_ARRAY_SIZE];
820 * A structure used to set or get hash filter information, to support filter
821 * type of 'RTE_ETH_FILTER_HASH' and its operations.
823 struct rte_eth_hash_filter_info {
824 enum rte_eth_hash_filter_info_type info_type; /**< Information type */
825 /** Details of hash filter information */
827 /** For RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT */
829 /** Global configurations of hash filter */
830 struct rte_eth_hash_global_conf global_conf;
831 /** Global configurations of hash filter input set */
832 struct rte_eth_input_set_conf input_set_conf;
837 * l2 tunnel configuration.
839 struct rte_eth_l2_tunnel_conf {
840 enum rte_eth_tunnel_type l2_tunnel_type;
841 uint16_t ether_type; /* ether type in l2 header */
842 uint32_t tunnel_id; /* port tag id for e-tag */
843 uint16_t vf_id; /* VF id for tag insertion */
844 uint32_t pool; /* destination pool for tag based forwarding */
851 #endif /* _RTE_ETH_CTRL_H_ */