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_TUNNEL,
62 * Generic operations on filters
65 RTE_ETH_FILTER_NOP = 0,
66 /**< used to check whether the type filter is supported */
67 RTE_ETH_FILTER_ADD, /**< add filter entry */
68 RTE_ETH_FILTER_UPDATE, /**< update filter entry */
69 RTE_ETH_FILTER_DELETE, /**< delete filter entry */
70 RTE_ETH_FILTER_FLUSH, /**< flush all entries */
71 RTE_ETH_FILTER_GET, /**< get filter entry */
72 RTE_ETH_FILTER_SET, /**< configurations */
73 RTE_ETH_FILTER_INFO, /**< retrieve information */
74 RTE_ETH_FILTER_STATS, /**< retrieve statistics */
81 enum rte_mac_filter_type {
82 RTE_MAC_PERFECT_MATCH = 1, /**< exact match of MAC addr. */
83 RTE_MACVLAN_PERFECT_MATCH,
84 /**< exact match of MAC addr and VLAN ID. */
85 RTE_MAC_HASH_MATCH, /**< hash match of MAC addr. */
86 RTE_MACVLAN_HASH_MATCH,
87 /**< hash match of MAC addr and exact match of VLAN ID. */
93 struct rte_eth_mac_filter {
94 uint8_t is_vf; /**< 1 for VF, 0 for port dev */
95 uint16_t dst_id; /**< VF ID, available when is_vf is 1*/
96 enum rte_mac_filter_type filter_type; /**< MAC filter type */
97 struct ether_addr mac_addr;
101 * Define all structures for Ethertype Filter type.
104 #define RTE_ETHTYPE_FLAGS_MAC 0x0001 /**< If set, compare mac */
105 #define RTE_ETHTYPE_FLAGS_DROP 0x0002 /**< If set, drop packet when match */
108 * A structure used to define the ethertype filter entry
109 * to support RTE_ETH_FILTER_ETHERTYPE with RTE_ETH_FILTER_ADD,
110 * RTE_ETH_FILTER_DELETE and RTE_ETH_FILTER_GET operations.
112 struct rte_eth_ethertype_filter {
113 struct ether_addr mac_addr; /**< Mac address to match. */
114 uint16_t ether_type; /**< Ether type to match */
115 uint16_t flags; /**< Flags from RTE_ETHTYPE_FLAGS_* */
116 uint16_t queue; /**< Queue assigned to when match*/
122 enum rte_eth_tunnel_type {
123 RTE_TUNNEL_TYPE_NONE = 0,
124 RTE_TUNNEL_TYPE_VXLAN,
125 RTE_TUNNEL_TYPE_GENEVE,
126 RTE_TUNNEL_TYPE_TEREDO,
127 RTE_TUNNEL_TYPE_NVGRE,
132 * filter type of tunneling packet
134 #define ETH_TUNNEL_FILTER_OMAC 0x01 /**< filter by outer MAC addr */
135 #define ETH_TUNNEL_FILTER_OIP 0x02 /**< filter by outer IP Addr */
136 #define ETH_TUNNEL_FILTER_TENID 0x04 /**< filter by tenant ID */
137 #define ETH_TUNNEL_FILTER_IMAC 0x08 /**< filter by inner MAC addr */
138 #define ETH_TUNNEL_FILTER_IVLAN 0x10 /**< filter by inner VLAN ID */
139 #define ETH_TUNNEL_FILTER_IIP 0x20 /**< filter by inner IP addr */
141 #define RTE_TUNNEL_FILTER_IMAC_IVLAN (ETH_TUNNEL_FILTER_IMAC | \
142 ETH_TUNNEL_FILTER_IVLAN)
143 #define RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID (ETH_TUNNEL_FILTER_IMAC | \
144 ETH_TUNNEL_FILTER_IVLAN | \
145 ETH_TUNNEL_FILTER_TENID)
146 #define RTE_TUNNEL_FILTER_IMAC_TENID (ETH_TUNNEL_FILTER_IMAC | \
147 ETH_TUNNEL_FILTER_TENID)
148 #define RTE_TUNNEL_FILTER_OMAC_TENID_IMAC (ETH_TUNNEL_FILTER_OMAC | \
149 ETH_TUNNEL_FILTER_TENID | \
150 ETH_TUNNEL_FILTER_IMAC)
153 * Select IPv4 or IPv6 for tunnel filters.
155 enum rte_tunnel_iptype {
156 RTE_TUNNEL_IPTYPE_IPV4 = 0, /**< IPv4. */
157 RTE_TUNNEL_IPTYPE_IPV6, /**< IPv6. */
161 * Tunneling Packet filter configuration.
163 struct rte_eth_tunnel_filter_conf {
164 struct ether_addr *outer_mac; /**< Outer MAC address filter. */
165 struct ether_addr *inner_mac; /**< Inner MAC address filter. */
166 uint16_t inner_vlan; /**< Inner VLAN filter. */
167 enum rte_tunnel_iptype ip_type; /**< IP address type. */
169 uint32_t ipv4_addr; /**< IPv4 source address to match. */
170 uint32_t ipv6_addr[4]; /**< IPv6 source address to match. */
171 } ip_addr; /**< IPv4/IPv6 source address to match (union of above). */
173 uint16_t filter_type; /**< Filter type. */
174 enum rte_eth_tunnel_type tunnel_type; /**< Tunnel Type. */
175 uint32_t tenant_id; /** < Tenant number. */
176 uint16_t queue_id; /** < queue number. */
179 #define RTE_ETH_FDIR_MAX_FLEXLEN 16 /** < Max length of flexbytes. */
184 enum rte_eth_flow_type {
185 RTE_ETH_FLOW_TYPE_NONE = 0,
186 RTE_ETH_FLOW_TYPE_UDPV4,
187 RTE_ETH_FLOW_TYPE_TCPV4,
188 RTE_ETH_FLOW_TYPE_SCTPV4,
189 RTE_ETH_FLOW_TYPE_IPV4_OTHER,
190 RTE_ETH_FLOW_TYPE_FRAG_IPV4,
191 RTE_ETH_FLOW_TYPE_UDPV6,
192 RTE_ETH_FLOW_TYPE_TCPV6,
193 RTE_ETH_FLOW_TYPE_SCTPV6,
194 RTE_ETH_FLOW_TYPE_IPV6_OTHER,
195 RTE_ETH_FLOW_TYPE_FRAG_IPV6,
196 RTE_ETH_FLOW_TYPE_MAX = 64,
200 * A structure used to define the input for IPV4 flow
202 struct rte_eth_ipv4_flow {
203 uint32_t src_ip; /**< IPv4 source address to match. */
204 uint32_t dst_ip; /**< IPv4 destination address to match. */
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 to match. */
213 uint16_t dst_port; /**< UDP destination port to match. */
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 to match. */
222 uint16_t dst_port; /**< TCP destination port to match. */
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 uint32_t verify_tag; /**< Verify tag to match */
234 * A structure used to define the input for IPV6 flow
236 struct rte_eth_ipv6_flow {
237 uint32_t src_ip[4]; /**< IPv6 source address to match. */
238 uint32_t dst_ip[4]; /**< IPv6 destination address to match. */
242 * A structure used to define the input for IPV6 UDP flow
244 struct rte_eth_udpv6_flow {
245 struct rte_eth_ipv6_flow ip; /**< IPv6 fields to match. */
246 uint16_t src_port; /**< UDP source port to match. */
247 uint16_t dst_port; /**< UDP destination port to match. */
251 * A structure used to define the input for IPV6 TCP flow
253 struct rte_eth_tcpv6_flow {
254 struct rte_eth_ipv6_flow ip; /**< IPv6 fields to match. */
255 uint16_t src_port; /**< TCP source port to match. */
256 uint16_t dst_port; /**< TCP destination port to match. */
260 * A structure used to define the input for IPV6 SCTP flow
262 struct rte_eth_sctpv6_flow {
263 struct rte_eth_ipv6_flow ip; /**< IPv6 fields to match. */
264 uint32_t verify_tag; /**< Verify tag to match */
268 * An union contains the inputs for all types of flow
270 union rte_eth_fdir_flow {
271 struct rte_eth_udpv4_flow udp4_flow;
272 struct rte_eth_tcpv4_flow tcp4_flow;
273 struct rte_eth_sctpv4_flow sctp4_flow;
274 struct rte_eth_ipv4_flow ip4_flow;
275 struct rte_eth_udpv6_flow udp6_flow;
276 struct rte_eth_tcpv6_flow tcp6_flow;
277 struct rte_eth_sctpv6_flow sctp6_flow;
278 struct rte_eth_ipv6_flow ipv6_flow;
282 * A structure used to contain extend input of flow
284 struct rte_eth_fdir_flow_ext {
286 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
287 /**< It is filled by the flexible payload to match. */
291 * A structure used to define the input for a flow director filter entry
293 struct rte_eth_fdir_input {
294 enum rte_eth_flow_type flow_type; /**< Type of flow */
295 union rte_eth_fdir_flow flow;
296 /**< Flow fields to match, dependent on flow_type */
297 struct rte_eth_fdir_flow_ext flow_ext;
298 /**< Additional fields to match */
302 * Behavior will be taken if FDIR match
304 enum rte_eth_fdir_behavior {
305 RTE_ETH_FDIR_ACCEPT = 0,
310 * Flow director report status
311 * It defines what will be reported if FDIR entry is matched.
313 enum rte_eth_fdir_status {
314 RTE_ETH_FDIR_NO_REPORT_STATUS = 0, /**< Report nothing. */
315 RTE_ETH_FDIR_REPORT_ID, /**< Only report FD ID. */
316 RTE_ETH_FDIR_REPORT_ID_FLEX_4, /**< Report FD ID and 4 flex bytes. */
317 RTE_ETH_FDIR_REPORT_FLEX_8, /**< Report 8 flex bytes. */
321 * A structure used to define an action when match FDIR packet filter.
323 struct rte_eth_fdir_action {
324 uint16_t rx_queue; /**< Queue assigned to if FDIR match. */
325 enum rte_eth_fdir_behavior behavior; /**< Behavior will be taken */
326 enum rte_eth_fdir_status report_status; /**< Status report option */
328 /**< If report_status is RTE_ETH_FDIR_REPORT_ID_FLEX_4 or
329 RTE_ETH_FDIR_REPORT_FLEX_8, flex_off specifies where the reported
330 flex bytes start from in flexible payload. */
334 * A structure used to define the flow director filter entry by filter_ctrl API
335 * It supports RTE_ETH_FILTER_FDIR with RTE_ETH_FILTER_ADD and
336 * RTE_ETH_FILTER_DELETE operations.
338 struct rte_eth_fdir_filter {
340 /**< ID, an unique value is required when deal with FDIR entry */
341 struct rte_eth_fdir_input input; /**< Input set */
342 struct rte_eth_fdir_action action; /**< Action taken when match */
348 enum rte_eth_payload_type {
349 RTE_ETH_PAYLOAD_UNKNOWN = 0,
353 RTE_ETH_PAYLOAD_MAX = 8,
357 * A structure used to select bytes extracted from the protocol layers to
358 * flexible payload for filter
360 struct rte_eth_flex_payload_cfg {
361 enum rte_eth_payload_type type; /**< Payload type */
362 uint16_t src_offset[RTE_ETH_FDIR_MAX_FLEXLEN];
363 /**< Offset in bytes from the beginning of packet's payload
364 src_offset[i] indicates the flexbyte i's offset in original
365 packet payload. This value should be less than
366 flex_payload_limit in struct rte_eth_fdir_info.*/
370 * A structure used to define FDIR masks for flexible payload
373 struct rte_eth_fdir_flex_mask {
374 enum rte_eth_flow_type flow_type; /**< Flow type */
375 uint8_t mask[RTE_ETH_FDIR_MAX_FLEXLEN];
376 /**< Mask for the whole flexible payload */
380 * A structure used to define all flexible payload related setting
381 * include flexpay load and flex mask
383 struct rte_eth_fdir_flex_conf {
384 uint16_t nb_payloads; /**< The number of following payload cfg */
385 uint16_t nb_flexmasks; /**< The number of following mask */
386 struct rte_eth_flex_payload_cfg flex_set[RTE_ETH_PAYLOAD_MAX];
387 /**< Flex payload configuration for each payload type */
388 struct rte_eth_fdir_flex_mask flex_mask[RTE_ETH_FLOW_TYPE_MAX];
389 /**< Flex mask configuration for each flow type */
393 * Flow Director setting modes: none, signature or perfect.
396 RTE_FDIR_MODE_NONE = 0, /**< Disable FDIR support. */
397 RTE_FDIR_MODE_SIGNATURE, /**< Enable FDIR signature filter mode. */
398 RTE_FDIR_MODE_PERFECT, /**< Enable FDIR perfect filter mode. */
402 * A structure used to get the information of flow director filter.
403 * It supports RTE_ETH_FILTER_FDIR with RTE_ETH_FILTER_INFO operation.
404 * It includes the mode, flexible payload configuration information,
405 * capabilities and supported flow types, flexible payload characters.
406 * It can be gotten to help taking specific configurations per device.
408 struct rte_eth_fdir_info {
409 enum rte_fdir_mode mode; /**< Flow director mode */
410 struct rte_eth_fdir_flex_conf flex_conf;
411 /**< Flex payload configuration information */
412 uint32_t guarant_spc; /**< Guaranteed spaces.*/
413 uint32_t best_spc; /**< Best effort spaces.*/
414 uint32_t flow_types_mask[RTE_ETH_FLOW_TYPE_MAX / sizeof(uint32_t)];
415 /**< Bit mask for every supported flow type. */
416 uint32_t max_flexpayload; /**< Total flex payload in bytes. */
417 uint32_t flex_payload_unit;
418 /**< Flexible payload unit in bytes. Size and alignments of all flex
419 payload segments should be multiplies of this value. */
420 uint32_t max_flex_payload_segment_num;
421 /**< Max number of flexible payload continuous segments.
422 Each segment should be a multiple of flex_payload_unit.*/
423 uint16_t flex_payload_limit;
424 /**< Maximum src_offset in bytes allowed. It indicates that
425 src_offset[i] in struct rte_eth_flex_payload_cfg should be
426 less than this value. */
427 uint32_t flex_bitmask_unit;
428 /**< Flex bitmask unit in bytes. Size of flex bitmasks should
429 be a multiply of this value. */
430 uint32_t max_flex_bitmask_num;
431 /**< Max supported size of flex bitmasks in flex_bitmask_unit */
435 * A structure used to define the statistics of flow director.
436 * It supports RTE_ETH_FILTER_FDIR with RTE_ETH_FILTER_STATS operation.
438 struct rte_eth_fdir_stats {
439 uint32_t collision; /**< Number of filters with collision. */
440 uint32_t free; /**< Number of free filters. */
442 /**< The lookup hash value of the added filter that updated the value
443 of the MAXLEN field */
444 uint32_t maxlen; /**< Longest linked list of filters. */
445 uint64_t add; /**< Number of added filters. */
446 uint64_t remove; /**< Number of removed filters. */
447 uint64_t f_add; /**< Number of failed added filters. */
448 uint64_t f_remove; /**< Number of failed removed filters. */
449 uint32_t guarant_cnt; /**< Number of filters in guaranteed spaces. */
450 uint32_t best_cnt; /**< Number of filters in best effort spaces. */
457 #endif /* _RTE_ETH_CTRL_H_ */