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 /** used to check whether the type filter is supported */
66 RTE_ETH_FILTER_NOP = 0,
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, /**< exact match of MAC addr and VLAN ID. */
84 RTE_MAC_HASH_MATCH, /**< hash match of MAC addr. */
85 /** hash match of MAC addr and exact match of VLAN ID. */
86 RTE_MACVLAN_HASH_MATCH,
92 struct rte_eth_mac_filter {
93 uint8_t is_vf; /**< 1 for VF, 0 for port dev */
94 uint16_t dst_id; /**< VF ID, available when is_vf is 1*/
95 enum rte_mac_filter_type filter_type; /**< MAC filter type */
96 struct ether_addr mac_addr;
100 * Define all structures for Ethertype Filter type.
103 #define RTE_ETHTYPE_FLAGS_MAC 0x0001 /**< If set, compare mac */
104 #define RTE_ETHTYPE_FLAGS_DROP 0x0002 /**< If set, drop packet when match */
107 * A structure used to define the ethertype filter entry
108 * to support RTE_ETH_FILTER_ETHERTYPE with RTE_ETH_FILTER_ADD,
109 * RTE_ETH_FILTER_DELETE and RTE_ETH_FILTER_GET operations.
111 struct rte_eth_ethertype_filter {
112 struct ether_addr mac_addr; /**< Mac address to match. */
113 uint16_t ether_type; /**< Ether type to match */
114 uint16_t flags; /**< Flags from RTE_ETHTYPE_FLAGS_* */
115 uint16_t queue; /**< Queue assigned to when match*/
121 enum rte_eth_tunnel_type {
122 RTE_TUNNEL_TYPE_NONE = 0,
123 RTE_TUNNEL_TYPE_VXLAN,
124 RTE_TUNNEL_TYPE_GENEVE,
125 RTE_TUNNEL_TYPE_TEREDO,
126 RTE_TUNNEL_TYPE_NVGRE,
131 * filter type of tunneling packet
133 #define ETH_TUNNEL_FILTER_OMAC 0x01 /**< filter by outer MAC addr */
134 #define ETH_TUNNEL_FILTER_OIP 0x02 /**< filter by outer IP Addr */
135 #define ETH_TUNNEL_FILTER_TENID 0x04 /**< filter by tenant ID */
136 #define ETH_TUNNEL_FILTER_IMAC 0x08 /**< filter by inner MAC addr */
137 #define ETH_TUNNEL_FILTER_IVLAN 0x10 /**< filter by inner VLAN ID */
138 #define ETH_TUNNEL_FILTER_IIP 0x20 /**< filter by inner IP addr */
140 #define RTE_TUNNEL_FILTER_IMAC_IVLAN (ETH_TUNNEL_FILTER_IMAC | \
141 ETH_TUNNEL_FILTER_IVLAN)
142 #define RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID (ETH_TUNNEL_FILTER_IMAC | \
143 ETH_TUNNEL_FILTER_IVLAN | \
144 ETH_TUNNEL_FILTER_TENID)
145 #define RTE_TUNNEL_FILTER_IMAC_TENID (ETH_TUNNEL_FILTER_IMAC | \
146 ETH_TUNNEL_FILTER_TENID)
147 #define RTE_TUNNEL_FILTER_OMAC_TENID_IMAC (ETH_TUNNEL_FILTER_OMAC | \
148 ETH_TUNNEL_FILTER_TENID | \
149 ETH_TUNNEL_FILTER_IMAC)
152 * Select IPv4 or IPv6 for tunnel filters.
154 enum rte_tunnel_iptype {
155 RTE_TUNNEL_IPTYPE_IPV4 = 0, /**< IPv4. */
156 RTE_TUNNEL_IPTYPE_IPV6, /**< IPv6. */
160 * Tunneling Packet filter configuration.
162 struct rte_eth_tunnel_filter_conf {
163 struct ether_addr *outer_mac; /**< Outer MAC address filter. */
164 struct ether_addr *inner_mac; /**< Inner MAC address filter. */
165 uint16_t inner_vlan; /**< Inner VLAN filter. */
166 enum rte_tunnel_iptype ip_type; /**< IP address type. */
168 uint32_t ipv4_addr; /**< IPv4 source address to match. */
169 uint32_t ipv6_addr[4]; /**< IPv6 source address to match. */
170 } ip_addr; /**< IPv4/IPv6 source address to match (union of above). */
172 uint16_t filter_type; /**< Filter type. */
173 enum rte_eth_tunnel_type tunnel_type; /**< Tunnel Type. */
174 uint32_t tenant_id; /** < Tenant number. */
175 uint16_t queue_id; /** < queue number. */
178 #define RTE_ETH_FDIR_MAX_FLEXLEN 16 /** < Max length of flexbytes. */
183 enum rte_eth_flow_type {
184 RTE_ETH_FLOW_TYPE_NONE = 0,
185 RTE_ETH_FLOW_TYPE_UDPV4,
186 RTE_ETH_FLOW_TYPE_TCPV4,
187 RTE_ETH_FLOW_TYPE_SCTPV4,
188 RTE_ETH_FLOW_TYPE_IPV4_OTHER,
189 RTE_ETH_FLOW_TYPE_FRAG_IPV4,
190 RTE_ETH_FLOW_TYPE_UDPV6,
191 RTE_ETH_FLOW_TYPE_TCPV6,
192 RTE_ETH_FLOW_TYPE_SCTPV6,
193 RTE_ETH_FLOW_TYPE_IPV6_OTHER,
194 RTE_ETH_FLOW_TYPE_FRAG_IPV6,
195 RTE_ETH_FLOW_TYPE_MAX = 64,
199 * A structure used to define the input for IPV4 flow
201 struct rte_eth_ipv4_flow {
202 uint32_t src_ip; /**< IPv4 source address to match. */
203 uint32_t dst_ip; /**< IPv4 destination address to match. */
207 * A structure used to define the input for IPV4 UDP flow
209 struct rte_eth_udpv4_flow {
210 struct rte_eth_ipv4_flow ip; /**< IPv4 fields to match. */
211 uint16_t src_port; /**< UDP source port to match. */
212 uint16_t dst_port; /**< UDP destination port to match. */
216 * A structure used to define the input for IPV4 TCP flow
218 struct rte_eth_tcpv4_flow {
219 struct rte_eth_ipv4_flow ip; /**< IPv4 fields to match. */
220 uint16_t src_port; /**< TCP source port to match. */
221 uint16_t dst_port; /**< TCP destination port to match. */
225 * A structure used to define the input for IPV4 SCTP flow
227 struct rte_eth_sctpv4_flow {
228 struct rte_eth_ipv4_flow ip; /**< IPv4 fields to match. */
229 uint32_t verify_tag; /**< Verify tag to match */
233 * A structure used to define the input for IPV6 flow
235 struct rte_eth_ipv6_flow {
236 uint32_t src_ip[4]; /**< IPv6 source address to match. */
237 uint32_t dst_ip[4]; /**< IPv6 destination address to match. */
241 * A structure used to define the input for IPV6 UDP flow
243 struct rte_eth_udpv6_flow {
244 struct rte_eth_ipv6_flow ip; /**< IPv6 fields to match. */
245 uint16_t src_port; /**< UDP source port to match. */
246 uint16_t dst_port; /**< UDP destination port to match. */
250 * A structure used to define the input for IPV6 TCP flow
252 struct rte_eth_tcpv6_flow {
253 struct rte_eth_ipv6_flow ip; /**< IPv6 fields to match. */
254 uint16_t src_port; /**< TCP source port to match. */
255 uint16_t dst_port; /**< TCP destination port to match. */
259 * A structure used to define the input for IPV6 SCTP flow
261 struct rte_eth_sctpv6_flow {
262 struct rte_eth_ipv6_flow ip; /**< IPv6 fields to match. */
263 uint32_t verify_tag; /**< Verify tag to match */
267 * An union contains the inputs for all types of flow
269 union rte_eth_fdir_flow {
270 struct rte_eth_udpv4_flow udp4_flow;
271 struct rte_eth_tcpv4_flow tcp4_flow;
272 struct rte_eth_sctpv4_flow sctp4_flow;
273 struct rte_eth_ipv4_flow ip4_flow;
274 struct rte_eth_udpv6_flow udp6_flow;
275 struct rte_eth_tcpv6_flow tcp6_flow;
276 struct rte_eth_sctpv6_flow sctp6_flow;
277 struct rte_eth_ipv6_flow ipv6_flow;
281 * A structure used to contain extend input of flow
283 struct rte_eth_fdir_flow_ext {
285 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
286 /**< It is filled by the flexible payload to match. */
290 * A structure used to define the input for a flow director filter entry
292 struct rte_eth_fdir_input {
293 enum rte_eth_flow_type flow_type; /**< Type of flow */
294 union rte_eth_fdir_flow flow;
295 /**< Flow fields to match, dependent on flow_type */
296 struct rte_eth_fdir_flow_ext flow_ext;
297 /**< Additional fields to match */
301 * Behavior will be taken if FDIR match
303 enum rte_eth_fdir_behavior {
304 RTE_ETH_FDIR_ACCEPT = 0,
309 * Flow director report status
310 * It defines what will be reported if FDIR entry is matched.
312 enum rte_eth_fdir_status {
313 RTE_ETH_FDIR_NO_REPORT_STATUS = 0, /**< Report nothing. */
314 RTE_ETH_FDIR_REPORT_ID, /**< Only report FD ID. */
315 RTE_ETH_FDIR_REPORT_ID_FLEX_4, /**< Report FD ID and 4 flex bytes. */
316 RTE_ETH_FDIR_REPORT_FLEX_8, /**< Report 8 flex bytes. */
320 * A structure used to define an action when match FDIR packet filter.
322 struct rte_eth_fdir_action {
323 uint16_t rx_queue; /**< Queue assigned to if FDIR match. */
324 enum rte_eth_fdir_behavior behavior; /**< Behavior will be taken */
325 enum rte_eth_fdir_status report_status; /**< Status report option */
327 /**< If report_status is RTE_ETH_FDIR_REPORT_ID_FLEX_4 or
328 RTE_ETH_FDIR_REPORT_FLEX_8, flex_off specifies where the reported
329 flex bytes start from in flexible payload. */
333 * A structure used to define the flow director filter entry by filter_ctrl API
334 * It supports RTE_ETH_FILTER_FDIR with RTE_ETH_FILTER_ADD and
335 * RTE_ETH_FILTER_DELETE operations.
337 struct rte_eth_fdir_filter {
339 /**< ID, an unique value is required when deal with FDIR entry */
340 struct rte_eth_fdir_input input; /**< Input set */
341 struct rte_eth_fdir_action action; /**< Action taken when match */
347 enum rte_eth_payload_type {
348 RTE_ETH_PAYLOAD_UNKNOWN = 0,
352 RTE_ETH_PAYLOAD_MAX = 8,
356 * A structure used to select bytes extracted from the protocol layers to
357 * flexible payload for filter
359 struct rte_eth_flex_payload_cfg {
360 enum rte_eth_payload_type type; /**< Payload type */
361 uint16_t src_offset[RTE_ETH_FDIR_MAX_FLEXLEN];
362 /**< Offset in bytes from the beginning of packet's payload
363 src_offset[i] indicates the flexbyte i's offset in original
364 packet payload. This value should be less than
365 flex_payload_limit in struct rte_eth_fdir_info.*/
369 * A structure used to define FDIR masks for flexible payload
372 struct rte_eth_fdir_flex_mask {
373 enum rte_eth_flow_type flow_type; /**< Flow type */
374 uint8_t mask[RTE_ETH_FDIR_MAX_FLEXLEN];
375 /**< Mask for the whole flexible payload */
379 * A structure used to define all flexible payload related setting
380 * include flexpay load and flex mask
382 struct rte_eth_fdir_flex_conf {
383 uint16_t nb_payloads; /**< The number of following payload cfg */
384 uint16_t nb_flexmasks; /**< The number of following mask */
385 struct rte_eth_flex_payload_cfg flex_set[RTE_ETH_PAYLOAD_MAX];
386 /**< Flex payload configuration for each payload type */
387 struct rte_eth_fdir_flex_mask flex_mask[RTE_ETH_FLOW_TYPE_MAX];
388 /**< Flex mask configuration for each flow type */
392 * Flow Director setting modes: none, signature or perfect.
395 RTE_FDIR_MODE_NONE = 0, /**< Disable FDIR support. */
396 RTE_FDIR_MODE_SIGNATURE, /**< Enable FDIR signature filter mode. */
397 RTE_FDIR_MODE_PERFECT, /**< Enable FDIR perfect filter mode. */
401 * A structure used to get the information of flow director filter.
402 * It supports RTE_ETH_FILTER_FDIR with RTE_ETH_FILTER_INFO operation.
403 * It includes the mode, flexible payload configuration information,
404 * capabilities and supported flow types, flexible payload characters.
405 * It can be gotten to help taking specific configurations per device.
407 struct rte_eth_fdir_info {
408 enum rte_fdir_mode mode; /**< Flow director mode */
409 struct rte_eth_fdir_flex_conf flex_conf;
410 /**< Flex payload configuration information */
411 uint32_t guarant_spc; /**< Guaranteed spaces.*/
412 uint32_t best_spc; /**< Best effort spaces.*/
413 uint32_t flow_types_mask[RTE_ETH_FLOW_TYPE_MAX / sizeof(uint32_t)];
414 /**< Bit mask for every supported flow type. */
415 uint32_t max_flexpayload; /**< Total flex payload in bytes. */
416 uint32_t flex_payload_unit;
417 /**< Flexible payload unit in bytes. Size and alignments of all flex
418 payload segments should be multiplies of this value. */
419 uint32_t max_flex_payload_segment_num;
420 /**< Max number of flexible payload continuous segments.
421 Each segment should be a multiple of flex_payload_unit.*/
422 uint16_t flex_payload_limit;
423 /**< Maximum src_offset in bytes allowed. It indicates that
424 src_offset[i] in struct rte_eth_flex_payload_cfg should be
425 less than this value. */
426 uint32_t flex_bitmask_unit;
427 /**< Flex bitmask unit in bytes. Size of flex bitmasks should
428 be a multiply of this value. */
429 uint32_t max_flex_bitmask_num;
430 /**< Max supported size of flex bitmasks in flex_bitmask_unit */
434 * A structure used to define the statistics of flow director.
435 * It supports RTE_ETH_FILTER_FDIR with RTE_ETH_FILTER_STATS operation.
437 struct rte_eth_fdir_stats {
438 uint32_t collision; /**< Number of filters with collision. */
439 uint32_t free; /**< Number of free filters. */
441 /**< The lookup hash value of the added filter that updated the value
442 of the MAXLEN field */
443 uint32_t maxlen; /**< Longest linked list of filters. */
444 uint64_t add; /**< Number of added filters. */
445 uint64_t remove; /**< Number of removed filters. */
446 uint64_t f_add; /**< Number of failed added filters. */
447 uint64_t f_remove; /**< Number of failed removed filters. */
448 uint32_t guarant_cnt; /**< Number of filters in guaranteed spaces. */
449 uint32_t best_cnt; /**< Number of filters in best effort spaces. */
456 #endif /* _RTE_ETH_CTRL_H_ */