1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2015 Intel Corporation
5 #ifndef _RTE_ETH_CTRL_H_
6 #define _RTE_ETH_CTRL_H_
9 #include <rte_common.h>
10 #include "rte_ether.h"
15 * Ethernet device features and related data structures used
16 * by control APIs should be defined in this file.
25 * A packet can be identified by hardware as different flow types. Different
26 * NIC hardwares may support different flow types.
27 * Basically, the NIC hardware identifies the flow type as deep protocol as
28 * possible, and exclusively. For example, if a packet is identified as
29 * 'RTE_ETH_FLOW_NONFRAG_IPV4_TCP', it will not be any of other flow types,
30 * though it is an actual IPV4 packet.
31 * Note that the flow types are used to define RSS offload types in
34 #define RTE_ETH_FLOW_UNKNOWN 0
35 #define RTE_ETH_FLOW_RAW 1
36 #define RTE_ETH_FLOW_IPV4 2
37 #define RTE_ETH_FLOW_FRAG_IPV4 3
38 #define RTE_ETH_FLOW_NONFRAG_IPV4_TCP 4
39 #define RTE_ETH_FLOW_NONFRAG_IPV4_UDP 5
40 #define RTE_ETH_FLOW_NONFRAG_IPV4_SCTP 6
41 #define RTE_ETH_FLOW_NONFRAG_IPV4_OTHER 7
42 #define RTE_ETH_FLOW_IPV6 8
43 #define RTE_ETH_FLOW_FRAG_IPV6 9
44 #define RTE_ETH_FLOW_NONFRAG_IPV6_TCP 10
45 #define RTE_ETH_FLOW_NONFRAG_IPV6_UDP 11
46 #define RTE_ETH_FLOW_NONFRAG_IPV6_SCTP 12
47 #define RTE_ETH_FLOW_NONFRAG_IPV6_OTHER 13
48 #define RTE_ETH_FLOW_L2_PAYLOAD 14
49 #define RTE_ETH_FLOW_IPV6_EX 15
50 #define RTE_ETH_FLOW_IPV6_TCP_EX 16
51 #define RTE_ETH_FLOW_IPV6_UDP_EX 17
52 #define RTE_ETH_FLOW_PORT 18
53 /**< Consider device port number as a flow differentiator */
54 #define RTE_ETH_FLOW_VXLAN 19 /**< VXLAN protocol based flow */
55 #define RTE_ETH_FLOW_GENEVE 20 /**< GENEVE protocol based flow */
56 #define RTE_ETH_FLOW_NVGRE 21 /**< NVGRE protocol based flow */
57 #define RTE_ETH_FLOW_MAX 22
60 * Feature filter types
62 enum rte_filter_type {
63 RTE_ETH_FILTER_NONE = 0,
64 RTE_ETH_FILTER_MACVLAN,
65 RTE_ETH_FILTER_ETHERTYPE,
66 RTE_ETH_FILTER_FLEXIBLE,
68 RTE_ETH_FILTER_NTUPLE,
69 RTE_ETH_FILTER_TUNNEL,
72 RTE_ETH_FILTER_L2_TUNNEL,
73 RTE_ETH_FILTER_GENERIC,
78 * Generic operations on filters
81 /** used to check whether the type filter is supported */
82 RTE_ETH_FILTER_NOP = 0,
83 RTE_ETH_FILTER_ADD, /**< add filter entry */
84 RTE_ETH_FILTER_UPDATE, /**< update filter entry */
85 RTE_ETH_FILTER_DELETE, /**< delete filter entry */
86 RTE_ETH_FILTER_FLUSH, /**< flush all entries */
87 RTE_ETH_FILTER_GET, /**< get filter entry */
88 RTE_ETH_FILTER_SET, /**< configurations */
89 RTE_ETH_FILTER_INFO, /**< retrieve information */
90 RTE_ETH_FILTER_STATS, /**< retrieve statistics */
97 enum rte_mac_filter_type {
98 RTE_MAC_PERFECT_MATCH = 1, /**< exact match of MAC addr. */
99 RTE_MACVLAN_PERFECT_MATCH, /**< exact match of MAC addr and VLAN ID. */
100 RTE_MAC_HASH_MATCH, /**< hash match of MAC addr. */
101 /** hash match of MAC addr and exact match of VLAN ID. */
102 RTE_MACVLAN_HASH_MATCH,
108 struct rte_eth_mac_filter {
109 uint8_t is_vf; /**< 1 for VF, 0 for port dev */
110 uint16_t dst_id; /**< VF ID, available when is_vf is 1*/
111 enum rte_mac_filter_type filter_type; /**< MAC filter type */
112 struct ether_addr mac_addr;
116 * Define all structures for Ethertype Filter type.
119 #define RTE_ETHTYPE_FLAGS_MAC 0x0001 /**< If set, compare mac */
120 #define RTE_ETHTYPE_FLAGS_DROP 0x0002 /**< If set, drop packet when match */
123 * A structure used to define the ethertype filter entry
124 * to support RTE_ETH_FILTER_ETHERTYPE with RTE_ETH_FILTER_ADD,
125 * RTE_ETH_FILTER_DELETE and RTE_ETH_FILTER_GET operations.
127 struct rte_eth_ethertype_filter {
128 struct ether_addr mac_addr; /**< Mac address to match. */
129 uint16_t ether_type; /**< Ether type to match */
130 uint16_t flags; /**< Flags from RTE_ETHTYPE_FLAGS_* */
131 uint16_t queue; /**< Queue assigned to when match*/
134 #define RTE_FLEX_FILTER_MAXLEN 128 /**< bytes to use in flex filter. */
135 #define RTE_FLEX_FILTER_MASK_SIZE \
136 (RTE_ALIGN(RTE_FLEX_FILTER_MAXLEN, CHAR_BIT) / CHAR_BIT)
137 /**< mask bytes in flex filter. */
140 * A structure used to define the flex filter entry
141 * to support RTE_ETH_FILTER_FLEXIBLE with RTE_ETH_FILTER_ADD,
142 * RTE_ETH_FILTER_DELETE and RTE_ETH_FILTER_GET operations.
144 struct rte_eth_flex_filter {
146 uint8_t bytes[RTE_FLEX_FILTER_MAXLEN]; /**< flex bytes in big endian.*/
147 uint8_t mask[RTE_FLEX_FILTER_MASK_SIZE]; /**< if mask bit is 1b, do
148 not compare corresponding byte. */
150 uint16_t queue; /**< Queue assigned to when match. */
154 * A structure used to define the TCP syn filter entry
155 * to support RTE_ETH_FILTER_SYN with RTE_ETH_FILTER_ADD,
156 * RTE_ETH_FILTER_DELETE and RTE_ETH_FILTER_GET operations.
158 struct rte_eth_syn_filter {
159 uint8_t hig_pri; /**< 1 - higher priority than other filters,
160 0 - lower priority. */
161 uint16_t queue; /**< Queue assigned to when match */
165 * Define all structures for ntuple Filter type.
168 #define RTE_NTUPLE_FLAGS_DST_IP 0x0001 /**< If set, dst_ip is part of ntuple */
169 #define RTE_NTUPLE_FLAGS_SRC_IP 0x0002 /**< If set, src_ip is part of ntuple */
170 #define RTE_NTUPLE_FLAGS_DST_PORT 0x0004 /**< If set, dst_port is part of ntuple */
171 #define RTE_NTUPLE_FLAGS_SRC_PORT 0x0008 /**< If set, src_port is part of ntuple */
172 #define RTE_NTUPLE_FLAGS_PROTO 0x0010 /**< If set, protocol is part of ntuple */
173 #define RTE_NTUPLE_FLAGS_TCP_FLAG 0x0020 /**< If set, tcp flag is involved */
175 #define RTE_5TUPLE_FLAGS ( \
176 RTE_NTUPLE_FLAGS_DST_IP | \
177 RTE_NTUPLE_FLAGS_SRC_IP | \
178 RTE_NTUPLE_FLAGS_DST_PORT | \
179 RTE_NTUPLE_FLAGS_SRC_PORT | \
180 RTE_NTUPLE_FLAGS_PROTO)
182 #define RTE_2TUPLE_FLAGS ( \
183 RTE_NTUPLE_FLAGS_DST_PORT | \
184 RTE_NTUPLE_FLAGS_PROTO)
186 #define TCP_URG_FLAG 0x20
187 #define TCP_ACK_FLAG 0x10
188 #define TCP_PSH_FLAG 0x08
189 #define TCP_RST_FLAG 0x04
190 #define TCP_SYN_FLAG 0x02
191 #define TCP_FIN_FLAG 0x01
192 #define TCP_FLAG_ALL 0x3F
195 * A structure used to define the ntuple filter entry
196 * to support RTE_ETH_FILTER_NTUPLE with RTE_ETH_FILTER_ADD,
197 * RTE_ETH_FILTER_DELETE and RTE_ETH_FILTER_GET operations.
199 struct rte_eth_ntuple_filter {
200 uint16_t flags; /**< Flags from RTE_NTUPLE_FLAGS_* */
201 uint32_t dst_ip; /**< Destination IP address in big endian. */
202 uint32_t dst_ip_mask; /**< Mask of destination IP address. */
203 uint32_t src_ip; /**< Source IP address in big endian. */
204 uint32_t src_ip_mask; /**< Mask of destination IP address. */
205 uint16_t dst_port; /**< Destination port in big endian. */
206 uint16_t dst_port_mask; /**< Mask of destination port. */
207 uint16_t src_port; /**< Source Port in big endian. */
208 uint16_t src_port_mask; /**< Mask of source port. */
209 uint8_t proto; /**< L4 protocol. */
210 uint8_t proto_mask; /**< Mask of L4 protocol. */
211 /** tcp_flags only meaningful when the proto is TCP.
212 The packet matched above ntuple fields and contain
213 any set bit in tcp_flags will hit this filter. */
215 uint16_t priority; /**< seven levels (001b-111b), 111b is highest,
216 used when more than one filter matches. */
217 uint16_t queue; /**< Queue assigned to when match*/
223 enum rte_eth_tunnel_type {
224 RTE_TUNNEL_TYPE_NONE = 0,
225 RTE_TUNNEL_TYPE_VXLAN,
226 RTE_TUNNEL_TYPE_GENEVE,
227 RTE_TUNNEL_TYPE_TEREDO,
228 RTE_TUNNEL_TYPE_NVGRE,
229 RTE_TUNNEL_TYPE_IP_IN_GRE,
230 RTE_L2_TUNNEL_TYPE_E_TAG,
235 * filter type of tunneling packet
237 #define ETH_TUNNEL_FILTER_OMAC 0x01 /**< filter by outer MAC addr */
238 #define ETH_TUNNEL_FILTER_OIP 0x02 /**< filter by outer IP Addr */
239 #define ETH_TUNNEL_FILTER_TENID 0x04 /**< filter by tenant ID */
240 #define ETH_TUNNEL_FILTER_IMAC 0x08 /**< filter by inner MAC addr */
241 #define ETH_TUNNEL_FILTER_IVLAN 0x10 /**< filter by inner VLAN ID */
242 #define ETH_TUNNEL_FILTER_IIP 0x20 /**< filter by inner IP addr */
244 #define RTE_TUNNEL_FILTER_IMAC_IVLAN (ETH_TUNNEL_FILTER_IMAC | \
245 ETH_TUNNEL_FILTER_IVLAN)
246 #define RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID (ETH_TUNNEL_FILTER_IMAC | \
247 ETH_TUNNEL_FILTER_IVLAN | \
248 ETH_TUNNEL_FILTER_TENID)
249 #define RTE_TUNNEL_FILTER_IMAC_TENID (ETH_TUNNEL_FILTER_IMAC | \
250 ETH_TUNNEL_FILTER_TENID)
251 #define RTE_TUNNEL_FILTER_OMAC_TENID_IMAC (ETH_TUNNEL_FILTER_OMAC | \
252 ETH_TUNNEL_FILTER_TENID | \
253 ETH_TUNNEL_FILTER_IMAC)
256 * Select IPv4 or IPv6 for tunnel filters.
258 enum rte_tunnel_iptype {
259 RTE_TUNNEL_IPTYPE_IPV4 = 0, /**< IPv4. */
260 RTE_TUNNEL_IPTYPE_IPV6, /**< IPv6. */
264 * Tunneling Packet filter configuration.
266 struct rte_eth_tunnel_filter_conf {
267 struct ether_addr outer_mac; /**< Outer MAC address to match. */
268 struct ether_addr inner_mac; /**< Inner MAC address to match. */
269 uint16_t inner_vlan; /**< Inner VLAN to match. */
270 enum rte_tunnel_iptype ip_type; /**< IP address type. */
271 /** Outer destination IP address to match if ETH_TUNNEL_FILTER_OIP
272 is set in filter_type, or inner destination IP address to match
273 if ETH_TUNNEL_FILTER_IIP is set in filter_type . */
275 uint32_t ipv4_addr; /**< IPv4 address in big endian. */
276 uint32_t ipv6_addr[4]; /**< IPv6 address in big endian. */
278 /** Flags from ETH_TUNNEL_FILTER_XX - see above. */
279 uint16_t filter_type;
280 enum rte_eth_tunnel_type tunnel_type; /**< Tunnel Type. */
281 uint32_t tenant_id; /**< Tenant ID to match. VNI, GRE key... */
282 uint16_t queue_id; /**< Queue assigned to if match. */
286 * Global eth device configuration type.
288 enum rte_eth_global_cfg_type {
289 RTE_ETH_GLOBAL_CFG_TYPE_UNKNOWN = 0,
290 RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN,
291 RTE_ETH_GLOBAL_CFG_TYPE_MAX,
295 * Global eth device configuration.
297 struct rte_eth_global_cfg {
298 enum rte_eth_global_cfg_type cfg_type; /**< Global config type. */
300 uint8_t gre_key_len; /**< Valid GRE key length in byte. */
301 uint64_t reserved; /**< Reserve space for future use. */
305 #define RTE_ETH_FDIR_MAX_FLEXLEN 16 /**< Max length of flexbytes. */
306 #define RTE_ETH_INSET_SIZE_MAX 128 /**< Max length of input set. */
309 * Input set fields for Flow Director and Hash filters
311 enum rte_eth_input_set_field {
312 RTE_ETH_INPUT_SET_UNKNOWN = 0,
315 RTE_ETH_INPUT_SET_L2_SRC_MAC = 1,
316 RTE_ETH_INPUT_SET_L2_DST_MAC,
317 RTE_ETH_INPUT_SET_L2_OUTER_VLAN,
318 RTE_ETH_INPUT_SET_L2_INNER_VLAN,
319 RTE_ETH_INPUT_SET_L2_ETHERTYPE,
322 RTE_ETH_INPUT_SET_L3_SRC_IP4 = 129,
323 RTE_ETH_INPUT_SET_L3_DST_IP4,
324 RTE_ETH_INPUT_SET_L3_SRC_IP6,
325 RTE_ETH_INPUT_SET_L3_DST_IP6,
326 RTE_ETH_INPUT_SET_L3_IP4_TOS,
327 RTE_ETH_INPUT_SET_L3_IP4_PROTO,
328 RTE_ETH_INPUT_SET_L3_IP6_TC,
329 RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER,
330 RTE_ETH_INPUT_SET_L3_IP4_TTL,
331 RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS,
334 RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT = 257,
335 RTE_ETH_INPUT_SET_L4_UDP_DST_PORT,
336 RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT,
337 RTE_ETH_INPUT_SET_L4_TCP_DST_PORT,
338 RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT,
339 RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT,
340 RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG,
343 RTE_ETH_INPUT_SET_TUNNEL_L2_INNER_DST_MAC = 385,
344 RTE_ETH_INPUT_SET_TUNNEL_L2_INNER_SRC_MAC,
345 RTE_ETH_INPUT_SET_TUNNEL_L2_INNER_VLAN,
346 RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY,
347 RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY,
349 /* Flexible Payload */
350 RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD = 641,
351 RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD,
352 RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD,
353 RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD,
354 RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD,
355 RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD,
356 RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD,
357 RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD,
359 RTE_ETH_INPUT_SET_DEFAULT = 65533,
360 RTE_ETH_INPUT_SET_NONE = 65534,
361 RTE_ETH_INPUT_SET_MAX = 65535,
365 * Filters input set operations
367 enum rte_filter_input_set_op {
368 RTE_ETH_INPUT_SET_OP_UNKNOWN,
369 RTE_ETH_INPUT_SET_SELECT, /**< select input set */
370 RTE_ETH_INPUT_SET_ADD, /**< add input set entry */
371 RTE_ETH_INPUT_SET_OP_MAX
376 * A structure used to define the input set configuration for
377 * flow director and hash filters
379 struct rte_eth_input_set_conf {
382 enum rte_eth_input_set_field field[RTE_ETH_INSET_SIZE_MAX];
383 enum rte_filter_input_set_op op;
387 * A structure used to define the input for L2 flow
389 struct rte_eth_l2_flow {
390 uint16_t ether_type; /**< Ether type in big endian */
394 * A structure used to define the input for IPV4 flow
396 struct rte_eth_ipv4_flow {
397 uint32_t src_ip; /**< IPv4 source address in big endian. */
398 uint32_t dst_ip; /**< IPv4 destination address in big endian. */
399 uint8_t tos; /**< Type of service to match. */
400 uint8_t ttl; /**< Time to live to match. */
401 uint8_t proto; /**< Protocol, next header in big endian. */
405 * A structure used to define the input for IPV4 UDP flow
407 struct rte_eth_udpv4_flow {
408 struct rte_eth_ipv4_flow ip; /**< IPv4 fields to match. */
409 uint16_t src_port; /**< UDP source port in big endian. */
410 uint16_t dst_port; /**< UDP destination port in big endian. */
414 * A structure used to define the input for IPV4 TCP flow
416 struct rte_eth_tcpv4_flow {
417 struct rte_eth_ipv4_flow ip; /**< IPv4 fields to match. */
418 uint16_t src_port; /**< TCP source port in big endian. */
419 uint16_t dst_port; /**< TCP destination port in big endian. */
423 * A structure used to define the input for IPV4 SCTP flow
425 struct rte_eth_sctpv4_flow {
426 struct rte_eth_ipv4_flow ip; /**< IPv4 fields to match. */
427 uint16_t src_port; /**< SCTP source port in big endian. */
428 uint16_t dst_port; /**< SCTP destination port in big endian. */
429 uint32_t verify_tag; /**< Verify tag in big endian */
433 * A structure used to define the input for IPV6 flow
435 struct rte_eth_ipv6_flow {
436 uint32_t src_ip[4]; /**< IPv6 source address in big endian. */
437 uint32_t dst_ip[4]; /**< IPv6 destination address in big endian. */
438 uint8_t tc; /**< Traffic class to match. */
439 uint8_t proto; /**< Protocol, next header to match. */
440 uint8_t hop_limits; /**< Hop limits to match. */
444 * A structure used to define the input for IPV6 UDP flow
446 struct rte_eth_udpv6_flow {
447 struct rte_eth_ipv6_flow ip; /**< IPv6 fields to match. */
448 uint16_t src_port; /**< UDP source port in big endian. */
449 uint16_t dst_port; /**< UDP destination port in big endian. */
453 * A structure used to define the input for IPV6 TCP flow
455 struct rte_eth_tcpv6_flow {
456 struct rte_eth_ipv6_flow ip; /**< IPv6 fields to match. */
457 uint16_t src_port; /**< TCP source port to in big endian. */
458 uint16_t dst_port; /**< TCP destination port in big endian. */
462 * A structure used to define the input for IPV6 SCTP flow
464 struct rte_eth_sctpv6_flow {
465 struct rte_eth_ipv6_flow ip; /**< IPv6 fields to match. */
466 uint16_t src_port; /**< SCTP source port in big endian. */
467 uint16_t dst_port; /**< SCTP destination port in big endian. */
468 uint32_t verify_tag; /**< Verify tag in big endian. */
472 * A structure used to define the input for MAC VLAN flow
474 struct rte_eth_mac_vlan_flow {
475 struct ether_addr mac_addr; /**< Mac address to match. */
479 * Tunnel type for flow director.
481 enum rte_eth_fdir_tunnel_type {
482 RTE_FDIR_TUNNEL_TYPE_UNKNOWN = 0,
483 RTE_FDIR_TUNNEL_TYPE_NVGRE,
484 RTE_FDIR_TUNNEL_TYPE_VXLAN,
488 * A structure used to define the input for tunnel flow, now it's VxLAN or
491 struct rte_eth_tunnel_flow {
492 enum rte_eth_fdir_tunnel_type tunnel_type; /**< Tunnel type to match. */
493 /** Tunnel ID to match. TNI, VNI... in big endian. */
495 struct ether_addr mac_addr; /**< Mac address to match. */
499 * An union contains the inputs for all types of flow
500 * Items in flows need to be in big endian
502 union rte_eth_fdir_flow {
503 struct rte_eth_l2_flow l2_flow;
504 struct rte_eth_udpv4_flow udp4_flow;
505 struct rte_eth_tcpv4_flow tcp4_flow;
506 struct rte_eth_sctpv4_flow sctp4_flow;
507 struct rte_eth_ipv4_flow ip4_flow;
508 struct rte_eth_udpv6_flow udp6_flow;
509 struct rte_eth_tcpv6_flow tcp6_flow;
510 struct rte_eth_sctpv6_flow sctp6_flow;
511 struct rte_eth_ipv6_flow ipv6_flow;
512 struct rte_eth_mac_vlan_flow mac_vlan_flow;
513 struct rte_eth_tunnel_flow tunnel_flow;
517 * A structure used to contain extend input of flow
519 struct rte_eth_fdir_flow_ext {
521 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
522 /**< It is filled by the flexible payload to match. */
523 uint8_t is_vf; /**< 1 for VF, 0 for port dev */
524 uint16_t dst_id; /**< VF ID, available when is_vf is 1*/
528 * A structure used to define the input for a flow director filter entry
530 struct rte_eth_fdir_input {
532 union rte_eth_fdir_flow flow;
533 /**< Flow fields to match, dependent on flow_type */
534 struct rte_eth_fdir_flow_ext flow_ext;
535 /**< Additional fields to match */
539 * Behavior will be taken if FDIR match
541 enum rte_eth_fdir_behavior {
542 RTE_ETH_FDIR_ACCEPT = 0,
544 RTE_ETH_FDIR_PASSTHRU,
548 * Flow director report status
549 * It defines what will be reported if FDIR entry is matched.
551 enum rte_eth_fdir_status {
552 RTE_ETH_FDIR_NO_REPORT_STATUS = 0, /**< Report nothing. */
553 RTE_ETH_FDIR_REPORT_ID, /**< Only report FD ID. */
554 RTE_ETH_FDIR_REPORT_ID_FLEX_4, /**< Report FD ID and 4 flex bytes. */
555 RTE_ETH_FDIR_REPORT_FLEX_8, /**< Report 8 flex bytes. */
559 * A structure used to define an action when match FDIR packet filter.
561 struct rte_eth_fdir_action {
562 uint16_t rx_queue; /**< Queue assigned to if FDIR match. */
563 enum rte_eth_fdir_behavior behavior; /**< Behavior will be taken */
564 enum rte_eth_fdir_status report_status; /**< Status report option */
566 /**< If report_status is RTE_ETH_FDIR_REPORT_ID_FLEX_4 or
567 RTE_ETH_FDIR_REPORT_FLEX_8, flex_off specifies where the reported
568 flex bytes start from in flexible payload. */
572 * A structure used to define the flow director filter entry by filter_ctrl API
573 * It supports RTE_ETH_FILTER_FDIR with RTE_ETH_FILTER_ADD and
574 * RTE_ETH_FILTER_DELETE operations.
576 struct rte_eth_fdir_filter {
578 /**< ID, an unique value is required when deal with FDIR entry */
579 struct rte_eth_fdir_input input; /**< Input set */
580 struct rte_eth_fdir_action action; /**< Action taken when match */
584 * A structure used to configure FDIR masks that are used by the device
585 * to match the various fields of RX packet headers.
587 struct rte_eth_fdir_masks {
588 uint16_t vlan_tci_mask; /**< Bit mask for vlan_tci in big endian */
589 /** Bit mask for ipv4 flow in big endian. */
590 struct rte_eth_ipv4_flow ipv4_mask;
591 /** Bit maks for ipv6 flow in big endian. */
592 struct rte_eth_ipv6_flow ipv6_mask;
593 /** Bit mask for L4 source port in big endian. */
594 uint16_t src_port_mask;
595 /** Bit mask for L4 destination port in big endian. */
596 uint16_t dst_port_mask;
597 /** 6 bit mask for proper 6 bytes of Mac address, bit 0 matches the
598 first byte on the wire */
599 uint8_t mac_addr_byte_mask;
600 /** Bit mask for tunnel ID in big endian. */
601 uint32_t tunnel_id_mask;
602 uint8_t tunnel_type_mask; /**< 1 - Match tunnel type,
603 0 - Ignore tunnel type. */
609 enum rte_eth_payload_type {
610 RTE_ETH_PAYLOAD_UNKNOWN = 0,
615 RTE_ETH_PAYLOAD_MAX = 8,
619 * A structure used to select bytes extracted from the protocol layers to
620 * flexible payload for filter
622 struct rte_eth_flex_payload_cfg {
623 enum rte_eth_payload_type type; /**< Payload type */
624 uint16_t src_offset[RTE_ETH_FDIR_MAX_FLEXLEN];
625 /**< Offset in bytes from the beginning of packet's payload
626 src_offset[i] indicates the flexbyte i's offset in original
627 packet payload. This value should be less than
628 flex_payload_limit in struct rte_eth_fdir_info.*/
632 * A structure used to define FDIR masks for flexible payload
635 struct rte_eth_fdir_flex_mask {
637 uint8_t mask[RTE_ETH_FDIR_MAX_FLEXLEN];
638 /**< Mask for the whole flexible payload */
642 * A structure used to define all flexible payload related setting
643 * include flex payload and flex mask
645 struct rte_eth_fdir_flex_conf {
646 uint16_t nb_payloads; /**< The number of following payload cfg */
647 uint16_t nb_flexmasks; /**< The number of following mask */
648 struct rte_eth_flex_payload_cfg flex_set[RTE_ETH_PAYLOAD_MAX];
649 /**< Flex payload configuration for each payload type */
650 struct rte_eth_fdir_flex_mask flex_mask[RTE_ETH_FLOW_MAX];
651 /**< Flex mask configuration for each flow type */
655 * Flow Director setting modes: none, signature or perfect.
658 RTE_FDIR_MODE_NONE = 0, /**< Disable FDIR support. */
659 RTE_FDIR_MODE_SIGNATURE, /**< Enable FDIR signature filter mode. */
660 RTE_FDIR_MODE_PERFECT, /**< Enable FDIR perfect filter mode. */
661 RTE_FDIR_MODE_PERFECT_MAC_VLAN, /**< Enable FDIR filter mode - MAC VLAN. */
662 RTE_FDIR_MODE_PERFECT_TUNNEL, /**< Enable FDIR filter mode - tunnel. */
665 #define UINT32_BIT (CHAR_BIT * sizeof(uint32_t))
666 #define RTE_FLOW_MASK_ARRAY_SIZE \
667 (RTE_ALIGN(RTE_ETH_FLOW_MAX, UINT32_BIT)/UINT32_BIT)
670 * A structure used to get the information of flow director filter.
671 * It supports RTE_ETH_FILTER_FDIR with RTE_ETH_FILTER_INFO operation.
672 * It includes the mode, flexible payload configuration information,
673 * capabilities and supported flow types, flexible payload characters.
674 * It can be gotten to help taking specific configurations per device.
676 struct rte_eth_fdir_info {
677 enum rte_fdir_mode mode; /**< Flow director mode */
678 struct rte_eth_fdir_masks mask;
679 /** Flex payload configuration information */
680 struct rte_eth_fdir_flex_conf flex_conf;
681 uint32_t guarant_spc; /**< Guaranteed spaces.*/
682 uint32_t best_spc; /**< Best effort spaces.*/
683 /** Bit mask for every supported flow type. */
684 uint32_t flow_types_mask[RTE_FLOW_MASK_ARRAY_SIZE];
685 uint32_t max_flexpayload; /**< Total flex payload in bytes. */
686 /** Flexible payload unit in bytes. Size and alignments of all flex
687 payload segments should be multiplies of this value. */
688 uint32_t flex_payload_unit;
689 /** Max number of flexible payload continuous segments.
690 Each segment should be a multiple of flex_payload_unit.*/
691 uint32_t max_flex_payload_segment_num;
692 /** Maximum src_offset in bytes allowed. It indicates that
693 src_offset[i] in struct rte_eth_flex_payload_cfg should be less
695 uint16_t flex_payload_limit;
696 /** Flex bitmask unit in bytes. Size of flex bitmasks should be a
697 multiply of this value. */
698 uint32_t flex_bitmask_unit;
699 /** Max supported size of flex bitmasks in flex_bitmask_unit */
700 uint32_t max_flex_bitmask_num;
704 * A structure used to define the statistics of flow director.
705 * It supports RTE_ETH_FILTER_FDIR with RTE_ETH_FILTER_STATS operation.
707 struct rte_eth_fdir_stats {
708 uint32_t collision; /**< Number of filters with collision. */
709 uint32_t free; /**< Number of free filters. */
711 /**< The lookup hash value of the added filter that updated the value
712 of the MAXLEN field */
713 uint32_t maxlen; /**< Longest linked list of filters. */
714 uint64_t add; /**< Number of added filters. */
715 uint64_t remove; /**< Number of removed filters. */
716 uint64_t f_add; /**< Number of failed added filters. */
717 uint64_t f_remove; /**< Number of failed removed filters. */
718 uint32_t guarant_cnt; /**< Number of filters in guaranteed spaces. */
719 uint32_t best_cnt; /**< Number of filters in best effort spaces. */
723 * Flow Director filter information types.
725 enum rte_eth_fdir_filter_info_type {
726 RTE_ETH_FDIR_FILTER_INFO_TYPE_UNKNOWN = 0,
727 /** Flow Director filter input set configuration */
728 RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT,
729 RTE_ETH_FDIR_FILTER_INFO_TYPE_MAX,
733 * A structure used to set FDIR filter information, to support filter type
734 * of 'RTE_ETH_FILTER_FDIR' RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT operation.
736 struct rte_eth_fdir_filter_info {
737 enum rte_eth_fdir_filter_info_type info_type; /**< Information type */
738 /** Details of fdir filter information */
740 /** Flow Director input set configuration per port */
741 struct rte_eth_input_set_conf input_set_conf;
746 * Hash filter information types.
747 * - RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT is for getting/setting the
748 * information/configuration of 'symmetric hash enable' per port.
749 * - RTE_ETH_HASH_FILTER_GLOBAL_CONFIG is for getting/setting the global
750 * configurations of hash filters. Those global configurations are valid
751 * for all ports of the same NIC.
752 * - RTE_ETH_HASH_FILTER_INPUT_SET_SELECT is for setting the global
753 * hash input set fields
755 enum rte_eth_hash_filter_info_type {
756 RTE_ETH_HASH_FILTER_INFO_TYPE_UNKNOWN = 0,
757 /** Symmetric hash enable per port */
758 RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT,
759 /** Configure globally for hash filter */
760 RTE_ETH_HASH_FILTER_GLOBAL_CONFIG,
761 /** Global Hash filter input set configuration */
762 RTE_ETH_HASH_FILTER_INPUT_SET_SELECT,
763 RTE_ETH_HASH_FILTER_INFO_TYPE_MAX,
767 * Hash function types.
769 enum rte_eth_hash_function {
770 RTE_ETH_HASH_FUNCTION_DEFAULT = 0,
771 RTE_ETH_HASH_FUNCTION_TOEPLITZ, /**< Toeplitz */
772 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR, /**< Simple XOR */
773 RTE_ETH_HASH_FUNCTION_MAX,
776 #define RTE_SYM_HASH_MASK_ARRAY_SIZE \
777 (RTE_ALIGN(RTE_ETH_FLOW_MAX, UINT32_BIT)/UINT32_BIT)
779 * A structure used to set or get global hash function configurations which
780 * include symmetric hash enable per flow type and hash function type.
781 * Each bit in sym_hash_enable_mask[] indicates if the symmetric hash of the
782 * corresponding flow type is enabled or not.
783 * Each bit in valid_bit_mask[] indicates if the corresponding bit in
784 * sym_hash_enable_mask[] is valid or not. For the configurations gotten, it
785 * also means if the flow type is supported by hardware or not.
787 struct rte_eth_hash_global_conf {
788 enum rte_eth_hash_function hash_func; /**< Hash function type */
789 /** Bit mask for symmetric hash enable per flow type */
790 uint32_t sym_hash_enable_mask[RTE_SYM_HASH_MASK_ARRAY_SIZE];
791 /** Bit mask indicates if the corresponding bit is valid */
792 uint32_t valid_bit_mask[RTE_SYM_HASH_MASK_ARRAY_SIZE];
796 * A structure used to set or get hash filter information, to support filter
797 * type of 'RTE_ETH_FILTER_HASH' and its operations.
799 struct rte_eth_hash_filter_info {
800 enum rte_eth_hash_filter_info_type info_type; /**< Information type */
801 /** Details of hash filter information */
803 /** For RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT */
805 /** Global configurations of hash filter */
806 struct rte_eth_hash_global_conf global_conf;
807 /** Global configurations of hash filter input set */
808 struct rte_eth_input_set_conf input_set_conf;
813 * l2 tunnel configuration.
815 struct rte_eth_l2_tunnel_conf {
816 enum rte_eth_tunnel_type l2_tunnel_type;
817 uint16_t ether_type; /* ether type in l2 header */
818 uint32_t tunnel_id; /* port tag id for e-tag */
819 uint16_t vf_id; /* VF id for tag insertion */
820 uint32_t pool; /* destination pool for tag based forwarding */
827 #endif /* _RTE_ETH_CTRL_H_ */