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_TUNNEL,
61 * Generic operations on filters
64 RTE_ETH_FILTER_NOP = 0,
65 /**< used to check whether the type filter is supported */
66 RTE_ETH_FILTER_ADD, /**< add filter entry */
67 RTE_ETH_FILTER_UPDATE, /**< update filter entry */
68 RTE_ETH_FILTER_DELETE, /**< delete filter entry */
69 RTE_ETH_FILTER_FLUSH, /**< flush all entries */
70 RTE_ETH_FILTER_GET, /**< get filter entry */
71 RTE_ETH_FILTER_SET, /**< configurations */
72 RTE_ETH_FILTER_INFO, /**< retrieve information */
79 enum rte_mac_filter_type {
80 RTE_MAC_PERFECT_MATCH = 1, /**< exact match of MAC addr. */
81 RTE_MACVLAN_PERFECT_MATCH,
82 /**< exact match of MAC addr and VLAN ID. */
83 RTE_MAC_HASH_MATCH, /**< hash match of MAC addr. */
84 RTE_MACVLAN_HASH_MATCH,
85 /**< hash match of MAC addr and exact match of VLAN ID. */
91 struct rte_eth_mac_filter {
92 uint8_t is_vf; /**< 1 for VF, 0 for port dev */
93 uint16_t dst_id; /**< VF ID, available when is_vf is 1*/
94 enum rte_mac_filter_type filter_type; /**< MAC filter type */
95 struct ether_addr mac_addr;
101 enum rte_eth_tunnel_type {
102 RTE_TUNNEL_TYPE_NONE = 0,
103 RTE_TUNNEL_TYPE_VXLAN,
104 RTE_TUNNEL_TYPE_GENEVE,
105 RTE_TUNNEL_TYPE_TEREDO,
106 RTE_TUNNEL_TYPE_NVGRE,
111 * filter type of tunneling packet
113 #define ETH_TUNNEL_FILTER_OMAC 0x01 /**< filter by outer MAC addr */
114 #define ETH_TUNNEL_FILTER_OIP 0x02 /**< filter by outer IP Addr */
115 #define ETH_TUNNEL_FILTER_TENID 0x04 /**< filter by tenant ID */
116 #define ETH_TUNNEL_FILTER_IMAC 0x08 /**< filter by inner MAC addr */
117 #define ETH_TUNNEL_FILTER_IVLAN 0x10 /**< filter by inner VLAN ID */
118 #define ETH_TUNNEL_FILTER_IIP 0x20 /**< filter by inner IP addr */
120 #define RTE_TUNNEL_FILTER_IMAC_IVLAN (ETH_TUNNEL_FILTER_IMAC | \
121 ETH_TUNNEL_FILTER_IVLAN)
122 #define RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID (ETH_TUNNEL_FILTER_IMAC | \
123 ETH_TUNNEL_FILTER_IVLAN | \
124 ETH_TUNNEL_FILTER_TENID)
125 #define RTE_TUNNEL_FILTER_IMAC_TENID (ETH_TUNNEL_FILTER_IMAC | \
126 ETH_TUNNEL_FILTER_TENID)
127 #define RTE_TUNNEL_FILTER_OMAC_TENID_IMAC (ETH_TUNNEL_FILTER_OMAC | \
128 ETH_TUNNEL_FILTER_TENID | \
129 ETH_TUNNEL_FILTER_IMAC)
132 * Select IPv4 or IPv6 for tunnel filters.
134 enum rte_tunnel_iptype {
135 RTE_TUNNEL_IPTYPE_IPV4 = 0, /**< IPv4. */
136 RTE_TUNNEL_IPTYPE_IPV6, /**< IPv6. */
140 * Tunneling Packet filter configuration.
142 struct rte_eth_tunnel_filter_conf {
143 struct ether_addr *outer_mac; /**< Outer MAC address filter. */
144 struct ether_addr *inner_mac; /**< Inner MAC address filter. */
145 uint16_t inner_vlan; /**< Inner VLAN filter. */
146 enum rte_tunnel_iptype ip_type; /**< IP address type. */
148 uint32_t ipv4_addr; /**< IPv4 source address to match. */
149 uint32_t ipv6_addr[4]; /**< IPv6 source address to match. */
150 } ip_addr; /**< IPv4/IPv6 source address to match (union of above). */
152 uint16_t filter_type; /**< Filter type. */
153 enum rte_eth_tunnel_type tunnel_type; /**< Tunnel Type. */
154 uint32_t tenant_id; /** < Tenant number. */
155 uint16_t queue_id; /** < queue number. */
158 #define RTE_ETH_FDIR_MAX_FLEXLEN 16 /** < Max length of flexbytes. */
163 enum rte_eth_flow_type {
164 RTE_ETH_FLOW_TYPE_NONE = 0,
165 RTE_ETH_FLOW_TYPE_UDPV4,
166 RTE_ETH_FLOW_TYPE_TCPV4,
167 RTE_ETH_FLOW_TYPE_SCTPV4,
168 RTE_ETH_FLOW_TYPE_IPV4_OTHER,
169 RTE_ETH_FLOW_TYPE_FRAG_IPV4,
170 RTE_ETH_FLOW_TYPE_UDPV6,
171 RTE_ETH_FLOW_TYPE_TCPV6,
172 RTE_ETH_FLOW_TYPE_SCTPV6,
173 RTE_ETH_FLOW_TYPE_IPV6_OTHER,
174 RTE_ETH_FLOW_TYPE_FRAG_IPV6,
175 RTE_ETH_FLOW_TYPE_MAX = 64,
179 * A structure used to define the input for IPV4 flow
181 struct rte_eth_ipv4_flow {
182 uint32_t src_ip; /**< IPv4 source address to match. */
183 uint32_t dst_ip; /**< IPv4 destination address to match. */
187 * A structure used to define the input for IPV4 UDP flow
189 struct rte_eth_udpv4_flow {
190 struct rte_eth_ipv4_flow ip; /**< IPv4 fields to match. */
191 uint16_t src_port; /**< UDP source port to match. */
192 uint16_t dst_port; /**< UDP destination port to match. */
196 * A structure used to define the input for IPV4 TCP flow
198 struct rte_eth_tcpv4_flow {
199 struct rte_eth_ipv4_flow ip; /**< IPv4 fields to match. */
200 uint16_t src_port; /**< TCP source port to match. */
201 uint16_t dst_port; /**< TCP destination port to match. */
205 * A structure used to define the input for IPV4 SCTP flow
207 struct rte_eth_sctpv4_flow {
208 struct rte_eth_ipv4_flow ip; /**< IPv4 fields to match. */
209 uint32_t verify_tag; /**< Verify tag to match */
213 * A structure used to define the input for IPV6 flow
215 struct rte_eth_ipv6_flow {
216 uint32_t src_ip[4]; /**< IPv6 source address to match. */
217 uint32_t dst_ip[4]; /**< IPv6 destination address to match. */
221 * A structure used to define the input for IPV6 UDP flow
223 struct rte_eth_udpv6_flow {
224 struct rte_eth_ipv6_flow ip; /**< IPv6 fields to match. */
225 uint16_t src_port; /**< UDP source port to match. */
226 uint16_t dst_port; /**< UDP destination port to match. */
230 * A structure used to define the input for IPV6 TCP flow
232 struct rte_eth_tcpv6_flow {
233 struct rte_eth_ipv6_flow ip; /**< IPv6 fields to match. */
234 uint16_t src_port; /**< TCP source port to match. */
235 uint16_t dst_port; /**< TCP destination port to match. */
239 * A structure used to define the input for IPV6 SCTP flow
241 struct rte_eth_sctpv6_flow {
242 struct rte_eth_ipv6_flow ip; /**< IPv6 fields to match. */
243 uint32_t verify_tag; /**< Verify tag to match */
247 * An union contains the inputs for all types of flow
249 union rte_eth_fdir_flow {
250 struct rte_eth_udpv4_flow udp4_flow;
251 struct rte_eth_tcpv4_flow tcp4_flow;
252 struct rte_eth_sctpv4_flow sctp4_flow;
253 struct rte_eth_ipv4_flow ip4_flow;
254 struct rte_eth_udpv6_flow udp6_flow;
255 struct rte_eth_tcpv6_flow tcp6_flow;
256 struct rte_eth_sctpv6_flow sctp6_flow;
257 struct rte_eth_ipv6_flow ip6_flow;
261 * A structure used to contain extend input of flow
263 struct rte_eth_fdir_flow_ext {
265 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
266 /**< It is filled by the flexible payload to match. */
270 * A structure used to define the input for a flow director filter entry
272 struct rte_eth_fdir_input {
273 enum rte_eth_flow_type flow_type; /**< Type of flow */
274 union rte_eth_fdir_flow flow;
275 /**< Flow fields to match, dependent on flow_type */
276 struct rte_eth_fdir_flow_ext flow_ext;
277 /**< Additional fields to match */
281 * Behavior will be taken if FDIR match
283 enum rte_eth_fdir_behavior {
284 RTE_ETH_FDIR_ACCEPT = 0,
289 * Flow director report status
290 * It defines what will be reported if FDIR entry is matched.
292 enum rte_eth_fdir_status {
293 RTE_ETH_FDIR_NO_REPORT_STATUS = 0, /**< Report nothing. */
294 RTE_ETH_FDIR_REPORT_ID, /**< Only report FD ID. */
295 RTE_ETH_FDIR_REPORT_ID_FLEX_4, /**< Report FD ID and 4 flex bytes. */
296 RTE_ETH_FDIR_REPORT_FLEX_8, /**< Report 8 flex bytes. */
300 * A structure used to define an action when match FDIR packet filter.
302 struct rte_eth_fdir_action {
303 uint16_t rx_queue; /**< Queue assigned to if FDIR match. */
304 enum rte_eth_fdir_behavior behavior; /**< Behavior will be taken */
305 enum rte_eth_fdir_status report_status; /**< Status report option */
307 /**< If report_status is RTE_ETH_FDIR_REPORT_ID_FLEX_4 or
308 RTE_ETH_FDIR_REPORT_FLEX_8, flex_off specifies where the reported
309 flex bytes start from in flexible payload. */
313 * A structure used to define the flow director filter entry by filter_ctrl API
314 * It supports RTE_ETH_FILTER_FDIR with RTE_ETH_FILTER_ADD and
315 * RTE_ETH_FILTER_DELETE operations.
317 struct rte_eth_fdir_filter {
319 /**< ID, an unique value is required when deal with FDIR entry */
320 struct rte_eth_fdir_input input; /**< Input set */
321 struct rte_eth_fdir_action action; /**< Action taken when match */
327 enum rte_eth_payload_type {
328 RTE_ETH_PAYLOAD_UNKNOWN = 0,
332 RTE_ETH_PAYLOAD_MAX = 8,
336 * A structure used to select bytes extracted from the protocol layers to
337 * flexible payload for filter
339 struct rte_eth_flex_payload_cfg {
340 enum rte_eth_payload_type type; /**< Payload type */
341 uint16_t src_offset[RTE_ETH_FDIR_MAX_FLEXLEN];
342 /**< Offset in bytes from the beginning of packet's payload
343 src_offset[i] indicates the flexbyte i's offset in original
344 packet payload. This value should be less than
345 flex_payload_limit in struct rte_eth_fdir_info.*/
349 * A structure used to define FDIR masks for flexible payload
352 struct rte_eth_fdir_flex_mask {
353 enum rte_eth_flow_type flow_type; /**< Flow type */
354 uint8_t mask[RTE_ETH_FDIR_MAX_FLEXLEN];
355 /**< Mask for the whole flexible payload */
359 * A structure used to define all flexible payload related setting
360 * include flexpay load and flex mask
362 struct rte_eth_fdir_flex_conf {
363 uint16_t nb_payloads; /**< The number of following payload cfg */
364 uint16_t nb_flexmasks; /**< The number of following mask */
365 struct rte_eth_flex_payload_cfg flex_set[RTE_ETH_PAYLOAD_MAX];
366 /**< Flex payload configuration for each payload type */
367 struct rte_eth_fdir_flex_mask flex_mask[RTE_ETH_FLOW_TYPE_MAX];
368 /**< Flex mask configuration for each flow type */
372 * Flow Director setting modes: none, signature or perfect.
375 RTE_FDIR_MODE_NONE = 0, /**< Disable FDIR support. */
376 RTE_FDIR_MODE_SIGNATURE, /**< Enable FDIR signature filter mode. */
377 RTE_FDIR_MODE_PERFECT, /**< Enable FDIR perfect filter mode. */
381 * A structure used to get the information of flow director filter.
382 * It supports RTE_ETH_FILTER_FDIR with RTE_ETH_FILTER_INFO operation.
383 * It includes the mode, flexible payload configuration information,
384 * capabilities and supported flow types, flexible payload characters.
385 * It can be gotten to help taking specific configurations per device.
387 struct rte_eth_fdir_info {
388 enum rte_fdir_mode mode; /**< Flow director mode */
389 struct rte_eth_fdir_flex_conf flex_conf;
390 /**< Flex payload configuration information */
391 uint32_t guarant_spc; /**< Guaranteed spaces.*/
392 uint32_t best_spc; /**< Best effort spaces.*/
393 uint32_t flow_types_mask[RTE_ETH_FLOW_TYPE_MAX / sizeof(uint32_t)];
394 /**< Bit mask for every supported flow type. */
395 uint32_t max_flexpayload; /**< Total flex payload in bytes. */
396 uint32_t flex_payload_unit;
397 /**< Flexible payload unit in bytes. Size and alignments of all flex
398 payload segments should be multiplies of this value. */
399 uint32_t max_flex_payload_segment_num;
400 /**< Max number of flexible payload continuous segments.
401 Each segment should be a multiple of flex_payload_unit.*/
402 uint16_t flex_payload_limit;
403 /**< Maximum src_offset in bytes allowed. It indicates that
404 src_offset[i] in struct rte_eth_flex_payload_cfg should be
405 less than this value. */
406 uint32_t flex_bitmask_unit;
407 /**< Flex bitmask unit in bytes. Size of flex bitmasks should
408 be a multiply of this value. */
409 uint32_t max_flex_bitmask_num;
410 /**< Max supported size of flex bitmasks in flex_bitmask_unit */
417 #endif /* _RTE_ETH_CTRL_H_ */