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>
14 * @deprecated Please use rte_flow API instead of this legacy one.
17 * Ethernet device features and related data structures used
18 * by control APIs should be defined in this file.
26 * Feature filter types
28 enum rte_filter_type {
29 RTE_ETH_FILTER_NONE = 0,
30 RTE_ETH_FILTER_ETHERTYPE,
31 RTE_ETH_FILTER_FLEXIBLE,
33 RTE_ETH_FILTER_NTUPLE,
34 RTE_ETH_FILTER_TUNNEL,
37 RTE_ETH_FILTER_L2_TUNNEL,
38 RTE_ETH_FILTER_GENERIC,
43 * Generic operations on filters
46 /** used to check whether the type filter is supported */
47 RTE_ETH_FILTER_NOP = 0,
48 RTE_ETH_FILTER_ADD, /**< add filter entry */
49 RTE_ETH_FILTER_UPDATE, /**< update filter entry */
50 RTE_ETH_FILTER_DELETE, /**< delete filter entry */
51 RTE_ETH_FILTER_FLUSH, /**< flush all entries */
52 RTE_ETH_FILTER_GET, /**< get filter entry */
53 RTE_ETH_FILTER_SET, /**< configurations */
54 RTE_ETH_FILTER_INFO, /**< retrieve information */
55 RTE_ETH_FILTER_STATS, /**< retrieve statistics */
60 * Define all structures for ntuple Filter type.
63 #define RTE_NTUPLE_FLAGS_DST_IP 0x0001 /**< If set, dst_ip is part of ntuple */
64 #define RTE_NTUPLE_FLAGS_SRC_IP 0x0002 /**< If set, src_ip is part of ntuple */
65 #define RTE_NTUPLE_FLAGS_DST_PORT 0x0004 /**< If set, dst_port is part of ntuple */
66 #define RTE_NTUPLE_FLAGS_SRC_PORT 0x0008 /**< If set, src_port is part of ntuple */
67 #define RTE_NTUPLE_FLAGS_PROTO 0x0010 /**< If set, protocol is part of ntuple */
68 #define RTE_NTUPLE_FLAGS_TCP_FLAG 0x0020 /**< If set, tcp flag is involved */
70 #define RTE_5TUPLE_FLAGS ( \
71 RTE_NTUPLE_FLAGS_DST_IP | \
72 RTE_NTUPLE_FLAGS_SRC_IP | \
73 RTE_NTUPLE_FLAGS_DST_PORT | \
74 RTE_NTUPLE_FLAGS_SRC_PORT | \
75 RTE_NTUPLE_FLAGS_PROTO)
77 #define RTE_2TUPLE_FLAGS ( \
78 RTE_NTUPLE_FLAGS_DST_PORT | \
79 RTE_NTUPLE_FLAGS_PROTO)
81 #define RTE_NTUPLE_TCP_FLAGS_MASK 0x3F /**< TCP flags filter can match. */
84 * A structure used to define the ntuple filter entry
85 * to support RTE_ETH_FILTER_NTUPLE data representation.
87 struct rte_eth_ntuple_filter {
88 uint16_t flags; /**< Flags from RTE_NTUPLE_FLAGS_* */
89 uint32_t dst_ip; /**< Destination IP address in big endian. */
90 uint32_t dst_ip_mask; /**< Mask of destination IP address. */
91 uint32_t src_ip; /**< Source IP address in big endian. */
92 uint32_t src_ip_mask; /**< Mask of destination IP address. */
93 uint16_t dst_port; /**< Destination port in big endian. */
94 uint16_t dst_port_mask; /**< Mask of destination port. */
95 uint16_t src_port; /**< Source Port in big endian. */
96 uint16_t src_port_mask; /**< Mask of source port. */
97 uint8_t proto; /**< L4 protocol. */
98 uint8_t proto_mask; /**< Mask of L4 protocol. */
99 /** tcp_flags only meaningful when the proto is TCP.
100 The packet matched above ntuple fields and contain
101 any set bit in tcp_flags will hit this filter. */
103 uint16_t priority; /**< seven levels (001b-111b), 111b is highest,
104 used when more than one filter matches. */
105 uint16_t queue; /**< Queue assigned to when match*/
108 #define RTE_ETH_FDIR_MAX_FLEXLEN 16 /**< Max length of flexbytes. */
109 #define RTE_ETH_INSET_SIZE_MAX 128 /**< Max length of input set. */
112 * Input set fields for Flow Director and Hash filters
114 enum rte_eth_input_set_field {
115 RTE_ETH_INPUT_SET_UNKNOWN = 0,
118 RTE_ETH_INPUT_SET_L2_SRC_MAC = 1,
119 RTE_ETH_INPUT_SET_L2_DST_MAC,
120 RTE_ETH_INPUT_SET_L2_OUTER_VLAN,
121 RTE_ETH_INPUT_SET_L2_INNER_VLAN,
122 RTE_ETH_INPUT_SET_L2_ETHERTYPE,
125 RTE_ETH_INPUT_SET_L3_SRC_IP4 = 129,
126 RTE_ETH_INPUT_SET_L3_DST_IP4,
127 RTE_ETH_INPUT_SET_L3_SRC_IP6,
128 RTE_ETH_INPUT_SET_L3_DST_IP6,
129 RTE_ETH_INPUT_SET_L3_IP4_TOS,
130 RTE_ETH_INPUT_SET_L3_IP4_PROTO,
131 RTE_ETH_INPUT_SET_L3_IP6_TC,
132 RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER,
133 RTE_ETH_INPUT_SET_L3_IP4_TTL,
134 RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS,
137 RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT = 257,
138 RTE_ETH_INPUT_SET_L4_UDP_DST_PORT,
139 RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT,
140 RTE_ETH_INPUT_SET_L4_TCP_DST_PORT,
141 RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT,
142 RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT,
143 RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG,
146 RTE_ETH_INPUT_SET_TUNNEL_L2_INNER_DST_MAC = 385,
147 RTE_ETH_INPUT_SET_TUNNEL_L2_INNER_SRC_MAC,
148 RTE_ETH_INPUT_SET_TUNNEL_L2_INNER_VLAN,
149 RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY,
150 RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY,
152 /* Flexible Payload */
153 RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD = 641,
154 RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD,
155 RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD,
156 RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD,
157 RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD,
158 RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD,
159 RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD,
160 RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD,
162 RTE_ETH_INPUT_SET_DEFAULT = 65533,
163 RTE_ETH_INPUT_SET_NONE = 65534,
164 RTE_ETH_INPUT_SET_MAX = 65535,
168 * Filters input set operations
170 enum rte_filter_input_set_op {
171 RTE_ETH_INPUT_SET_OP_UNKNOWN,
172 RTE_ETH_INPUT_SET_SELECT, /**< select input set */
173 RTE_ETH_INPUT_SET_ADD, /**< add input set entry */
174 RTE_ETH_INPUT_SET_OP_MAX
179 * A structure used to define the input set configuration for
180 * flow director and hash filters
182 struct rte_eth_input_set_conf {
185 enum rte_eth_input_set_field field[RTE_ETH_INSET_SIZE_MAX];
186 enum rte_filter_input_set_op op;
190 * A structure used to define the input for L2 flow
192 struct rte_eth_l2_flow {
193 uint16_t ether_type; /**< Ether type in big endian */
197 * A structure used to define the input for IPV4 flow
199 struct rte_eth_ipv4_flow {
200 uint32_t src_ip; /**< IPv4 source address in big endian. */
201 uint32_t dst_ip; /**< IPv4 destination address in big endian. */
202 uint8_t tos; /**< Type of service to match. */
203 uint8_t ttl; /**< Time to live to match. */
204 uint8_t proto; /**< Protocol, next header in big endian. */
208 * A structure used to define the input for IPV4 UDP flow
210 struct rte_eth_udpv4_flow {
211 struct rte_eth_ipv4_flow ip; /**< IPv4 fields to match. */
212 uint16_t src_port; /**< UDP source port in big endian. */
213 uint16_t dst_port; /**< UDP destination port in big endian. */
217 * A structure used to define the input for IPV4 TCP flow
219 struct rte_eth_tcpv4_flow {
220 struct rte_eth_ipv4_flow ip; /**< IPv4 fields to match. */
221 uint16_t src_port; /**< TCP source port in big endian. */
222 uint16_t dst_port; /**< TCP destination port in big endian. */
226 * A structure used to define the input for IPV4 SCTP flow
228 struct rte_eth_sctpv4_flow {
229 struct rte_eth_ipv4_flow ip; /**< IPv4 fields to match. */
230 uint16_t src_port; /**< SCTP source port in big endian. */
231 uint16_t dst_port; /**< SCTP destination port in big endian. */
232 uint32_t verify_tag; /**< Verify tag in big endian */
236 * A structure used to define the input for IPV6 flow
238 struct rte_eth_ipv6_flow {
239 uint32_t src_ip[4]; /**< IPv6 source address in big endian. */
240 uint32_t dst_ip[4]; /**< IPv6 destination address in big endian. */
241 uint8_t tc; /**< Traffic class to match. */
242 uint8_t proto; /**< Protocol, next header to match. */
243 uint8_t hop_limits; /**< Hop limits to match. */
247 * A structure used to define the input for IPV6 UDP flow
249 struct rte_eth_udpv6_flow {
250 struct rte_eth_ipv6_flow ip; /**< IPv6 fields to match. */
251 uint16_t src_port; /**< UDP source port in big endian. */
252 uint16_t dst_port; /**< UDP destination port in big endian. */
256 * A structure used to define the input for IPV6 TCP flow
258 struct rte_eth_tcpv6_flow {
259 struct rte_eth_ipv6_flow ip; /**< IPv6 fields to match. */
260 uint16_t src_port; /**< TCP source port to in big endian. */
261 uint16_t dst_port; /**< TCP destination port in big endian. */
265 * A structure used to define the input for IPV6 SCTP flow
267 struct rte_eth_sctpv6_flow {
268 struct rte_eth_ipv6_flow ip; /**< IPv6 fields to match. */
269 uint16_t src_port; /**< SCTP source port in big endian. */
270 uint16_t dst_port; /**< SCTP destination port in big endian. */
271 uint32_t verify_tag; /**< Verify tag in big endian. */
275 * A structure used to define the input for MAC VLAN flow
277 struct rte_eth_mac_vlan_flow {
278 struct rte_ether_addr mac_addr; /**< Mac address to match. */
282 * Tunnel type for flow director.
284 enum rte_eth_fdir_tunnel_type {
285 RTE_FDIR_TUNNEL_TYPE_UNKNOWN = 0,
286 RTE_FDIR_TUNNEL_TYPE_NVGRE,
287 RTE_FDIR_TUNNEL_TYPE_VXLAN,
291 * A structure used to define the input for tunnel flow, now it's VxLAN or
294 struct rte_eth_tunnel_flow {
295 enum rte_eth_fdir_tunnel_type tunnel_type; /**< Tunnel type to match. */
296 /** Tunnel ID to match. TNI, VNI... in big endian. */
298 struct rte_ether_addr mac_addr; /**< Mac address to match. */
302 * An union contains the inputs for all types of flow
303 * Items in flows need to be in big endian
305 union rte_eth_fdir_flow {
306 struct rte_eth_l2_flow l2_flow;
307 struct rte_eth_udpv4_flow udp4_flow;
308 struct rte_eth_tcpv4_flow tcp4_flow;
309 struct rte_eth_sctpv4_flow sctp4_flow;
310 struct rte_eth_ipv4_flow ip4_flow;
311 struct rte_eth_udpv6_flow udp6_flow;
312 struct rte_eth_tcpv6_flow tcp6_flow;
313 struct rte_eth_sctpv6_flow sctp6_flow;
314 struct rte_eth_ipv6_flow ipv6_flow;
315 struct rte_eth_mac_vlan_flow mac_vlan_flow;
316 struct rte_eth_tunnel_flow tunnel_flow;
320 * A structure used to contain extend input of flow
322 struct rte_eth_fdir_flow_ext {
324 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
325 /**< It is filled by the flexible payload to match. */
326 uint8_t is_vf; /**< 1 for VF, 0 for port dev */
327 uint16_t dst_id; /**< VF ID, available when is_vf is 1*/
331 * A structure used to define the input for a flow director filter entry
333 struct rte_eth_fdir_input {
335 union rte_eth_fdir_flow flow;
336 /**< Flow fields to match, dependent on flow_type */
337 struct rte_eth_fdir_flow_ext flow_ext;
338 /**< Additional fields to match */
342 * Behavior will be taken if FDIR match
344 enum rte_eth_fdir_behavior {
345 RTE_ETH_FDIR_ACCEPT = 0,
347 RTE_ETH_FDIR_PASSTHRU,
351 * Flow director report status
352 * It defines what will be reported if FDIR entry is matched.
354 enum rte_eth_fdir_status {
355 RTE_ETH_FDIR_NO_REPORT_STATUS = 0, /**< Report nothing. */
356 RTE_ETH_FDIR_REPORT_ID, /**< Only report FD ID. */
357 RTE_ETH_FDIR_REPORT_ID_FLEX_4, /**< Report FD ID and 4 flex bytes. */
358 RTE_ETH_FDIR_REPORT_FLEX_8, /**< Report 8 flex bytes. */
362 * A structure used to define an action when match FDIR packet filter.
364 struct rte_eth_fdir_action {
365 uint16_t rx_queue; /**< Queue assigned to if FDIR match. */
366 enum rte_eth_fdir_behavior behavior; /**< Behavior will be taken */
367 enum rte_eth_fdir_status report_status; /**< Status report option */
369 /**< If report_status is RTE_ETH_FDIR_REPORT_ID_FLEX_4 or
370 RTE_ETH_FDIR_REPORT_FLEX_8, flex_off specifies where the reported
371 flex bytes start from in flexible payload. */
375 * A structure used to define the flow director filter entry by filter_ctrl API.
377 struct rte_eth_fdir_filter {
379 /**< ID, an unique value is required when deal with FDIR entry */
380 struct rte_eth_fdir_input input; /**< Input set */
381 struct rte_eth_fdir_action action; /**< Action taken when match */
385 * A structure used to configure FDIR masks that are used by the device
386 * to match the various fields of RX packet headers.
388 struct rte_eth_fdir_masks {
389 uint16_t vlan_tci_mask; /**< Bit mask for vlan_tci in big endian */
390 /** Bit mask for ipv4 flow in big endian. */
391 struct rte_eth_ipv4_flow ipv4_mask;
392 /** Bit mask for ipv6 flow in big endian. */
393 struct rte_eth_ipv6_flow ipv6_mask;
394 /** Bit mask for L4 source port in big endian. */
395 uint16_t src_port_mask;
396 /** Bit mask for L4 destination port in big endian. */
397 uint16_t dst_port_mask;
398 /** 6 bit mask for proper 6 bytes of Mac address, bit 0 matches the
399 first byte on the wire */
400 uint8_t mac_addr_byte_mask;
401 /** Bit mask for tunnel ID in big endian. */
402 uint32_t tunnel_id_mask;
403 uint8_t tunnel_type_mask; /**< 1 - Match tunnel type,
404 0 - Ignore tunnel type. */
410 enum rte_eth_payload_type {
411 RTE_ETH_PAYLOAD_UNKNOWN = 0,
416 RTE_ETH_PAYLOAD_MAX = 8,
420 * A structure used to select bytes extracted from the protocol layers to
421 * flexible payload for filter
423 struct rte_eth_flex_payload_cfg {
424 enum rte_eth_payload_type type; /**< Payload type */
425 uint16_t src_offset[RTE_ETH_FDIR_MAX_FLEXLEN];
426 /**< Offset in bytes from the beginning of packet's payload
427 src_offset[i] indicates the flexbyte i's offset in original
428 packet payload. This value should be less than
429 flex_payload_limit in struct rte_eth_fdir_info.*/
433 * A structure used to define FDIR masks for flexible payload
436 struct rte_eth_fdir_flex_mask {
438 uint8_t mask[RTE_ETH_FDIR_MAX_FLEXLEN];
439 /**< Mask for the whole flexible payload */
443 * A structure used to define all flexible payload related setting
444 * include flex payload and flex mask
446 struct rte_eth_fdir_flex_conf {
447 uint16_t nb_payloads; /**< The number of following payload cfg */
448 uint16_t nb_flexmasks; /**< The number of following mask */
449 struct rte_eth_flex_payload_cfg flex_set[RTE_ETH_PAYLOAD_MAX];
450 /**< Flex payload configuration for each payload type */
451 struct rte_eth_fdir_flex_mask flex_mask[RTE_ETH_FLOW_MAX];
452 /**< Flex mask configuration for each flow type */
456 * Flow Director setting modes: none, signature or perfect.
459 RTE_FDIR_MODE_NONE = 0, /**< Disable FDIR support. */
460 RTE_FDIR_MODE_SIGNATURE, /**< Enable FDIR signature filter mode. */
461 RTE_FDIR_MODE_PERFECT, /**< Enable FDIR perfect filter mode. */
462 RTE_FDIR_MODE_PERFECT_MAC_VLAN, /**< Enable FDIR filter mode - MAC VLAN. */
463 RTE_FDIR_MODE_PERFECT_TUNNEL, /**< Enable FDIR filter mode - tunnel. */
466 #define UINT64_BIT (CHAR_BIT * sizeof(uint64_t))
467 #define RTE_FLOW_MASK_ARRAY_SIZE \
468 (RTE_ALIGN(RTE_ETH_FLOW_MAX, UINT64_BIT)/UINT64_BIT)
471 * A structure used to get the information of flow director filter.
472 * It supports RTE_ETH_FILTER_FDIR with RTE_ETH_FILTER_INFO operation.
473 * It includes the mode, flexible payload configuration information,
474 * capabilities and supported flow types, flexible payload characters.
475 * It can be gotten to help taking specific configurations per device.
477 struct rte_eth_fdir_info {
478 enum rte_fdir_mode mode; /**< Flow director mode */
479 struct rte_eth_fdir_masks mask;
480 /** Flex payload configuration information */
481 struct rte_eth_fdir_flex_conf flex_conf;
482 uint32_t guarant_spc; /**< Guaranteed spaces.*/
483 uint32_t best_spc; /**< Best effort spaces.*/
484 /** Bit mask for every supported flow type. */
485 uint64_t flow_types_mask[RTE_FLOW_MASK_ARRAY_SIZE];
486 uint32_t max_flexpayload; /**< Total flex payload in bytes. */
487 /** Flexible payload unit in bytes. Size and alignments of all flex
488 payload segments should be multiplies of this value. */
489 uint32_t flex_payload_unit;
490 /** Max number of flexible payload continuous segments.
491 Each segment should be a multiple of flex_payload_unit.*/
492 uint32_t max_flex_payload_segment_num;
493 /** Maximum src_offset in bytes allowed. It indicates that
494 src_offset[i] in struct rte_eth_flex_payload_cfg should be less
496 uint16_t flex_payload_limit;
497 /** Flex bitmask unit in bytes. Size of flex bitmasks should be a
498 multiply of this value. */
499 uint32_t flex_bitmask_unit;
500 /** Max supported size of flex bitmasks in flex_bitmask_unit */
501 uint32_t max_flex_bitmask_num;
505 * A structure used to define the statistics of flow director.
506 * It supports RTE_ETH_FILTER_FDIR with RTE_ETH_FILTER_STATS operation.
508 struct rte_eth_fdir_stats {
509 uint32_t collision; /**< Number of filters with collision. */
510 uint32_t free; /**< Number of free filters. */
512 /**< The lookup hash value of the added filter that updated the value
513 of the MAXLEN field */
514 uint32_t maxlen; /**< Longest linked list of filters. */
515 uint64_t add; /**< Number of added filters. */
516 uint64_t remove; /**< Number of removed filters. */
517 uint64_t f_add; /**< Number of failed added filters. */
518 uint64_t f_remove; /**< Number of failed removed filters. */
519 uint32_t guarant_cnt; /**< Number of filters in guaranteed spaces. */
520 uint32_t best_cnt; /**< Number of filters in best effort spaces. */
524 * l2 tunnel configuration.
526 struct rte_eth_l2_tunnel_conf {
527 enum rte_eth_tunnel_type l2_tunnel_type;
528 uint16_t ether_type; /* ether type in l2 header */
529 uint32_t tunnel_id; /* port tag id for e-tag */
530 uint16_t vf_id; /* VF id for tag insertion */
531 uint32_t pool; /* destination pool for tag based forwarding */
538 #endif /* _RTE_ETH_CTRL_H_ */