enic: build integration
[dpdk.git] / lib / librte_ether / rte_eth_ctrl.h
1 /*-
2  *   BSD LICENSE
3  *
4  *   Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
5  *   All rights reserved.
6  *
7  *   Redistribution and use in source and binary forms, with or without
8  *   modification, are permitted provided that the following conditions
9  *   are met:
10  *
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
16  *       distribution.
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.
20  *
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.
32  */
33
34 #ifndef _RTE_ETH_CTRL_H_
35 #define _RTE_ETH_CTRL_H_
36
37 /**
38  * @file
39  *
40  * Ethernet device features and related data structures used
41  * by control APIs should be defined in this file.
42  *
43  */
44
45 #ifdef __cplusplus
46 extern "C" {
47 #endif
48
49 /**
50  * Feature filter types
51  */
52 enum rte_filter_type {
53         RTE_ETH_FILTER_NONE = 0,
54         RTE_ETH_FILTER_MACVLAN,
55         RTE_ETH_FILTER_TUNNEL,
56         RTE_ETH_FILTER_FDIR,
57         RTE_ETH_FILTER_MAX
58 };
59
60 /**
61  * Generic operations on filters
62  */
63 enum rte_filter_op {
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 */
73         RTE_ETH_FILTER_STATS,    /**< retrieve statistics */
74         RTE_ETH_FILTER_OP_MAX
75 };
76
77 /**
78  * MAC filter type
79  */
80 enum rte_mac_filter_type {
81         RTE_MAC_PERFECT_MATCH = 1, /**< exact match of MAC addr. */
82         RTE_MACVLAN_PERFECT_MATCH,
83         /**< exact match of MAC addr and VLAN ID. */
84         RTE_MAC_HASH_MATCH, /**< hash match of MAC addr. */
85         RTE_MACVLAN_HASH_MATCH,
86         /**< hash match of MAC addr and exact match of VLAN ID. */
87 };
88
89 /**
90  * MAC filter info
91  */
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;
97 };
98
99 /**
100  * Tunneled type.
101  */
102 enum rte_eth_tunnel_type {
103         RTE_TUNNEL_TYPE_NONE = 0,
104         RTE_TUNNEL_TYPE_VXLAN,
105         RTE_TUNNEL_TYPE_GENEVE,
106         RTE_TUNNEL_TYPE_TEREDO,
107         RTE_TUNNEL_TYPE_NVGRE,
108         RTE_TUNNEL_TYPE_MAX,
109 };
110
111 /**
112  * filter type of tunneling packet
113  */
114 #define ETH_TUNNEL_FILTER_OMAC  0x01 /**< filter by outer MAC addr */
115 #define ETH_TUNNEL_FILTER_OIP   0x02 /**< filter by outer IP Addr */
116 #define ETH_TUNNEL_FILTER_TENID 0x04 /**< filter by tenant ID */
117 #define ETH_TUNNEL_FILTER_IMAC  0x08 /**< filter by inner MAC addr */
118 #define ETH_TUNNEL_FILTER_IVLAN 0x10 /**< filter by inner VLAN ID */
119 #define ETH_TUNNEL_FILTER_IIP   0x20 /**< filter by inner IP addr */
120
121 #define RTE_TUNNEL_FILTER_IMAC_IVLAN (ETH_TUNNEL_FILTER_IMAC | \
122                                         ETH_TUNNEL_FILTER_IVLAN)
123 #define RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID (ETH_TUNNEL_FILTER_IMAC | \
124                                         ETH_TUNNEL_FILTER_IVLAN | \
125                                         ETH_TUNNEL_FILTER_TENID)
126 #define RTE_TUNNEL_FILTER_IMAC_TENID (ETH_TUNNEL_FILTER_IMAC | \
127                                         ETH_TUNNEL_FILTER_TENID)
128 #define RTE_TUNNEL_FILTER_OMAC_TENID_IMAC (ETH_TUNNEL_FILTER_OMAC | \
129                                         ETH_TUNNEL_FILTER_TENID | \
130                                         ETH_TUNNEL_FILTER_IMAC)
131
132 /**
133  *  Select IPv4 or IPv6 for tunnel filters.
134  */
135 enum rte_tunnel_iptype {
136         RTE_TUNNEL_IPTYPE_IPV4 = 0, /**< IPv4. */
137         RTE_TUNNEL_IPTYPE_IPV6,     /**< IPv6. */
138 };
139
140 /**
141  * Tunneling Packet filter configuration.
142  */
143 struct rte_eth_tunnel_filter_conf {
144         struct ether_addr *outer_mac;  /**< Outer MAC address filter. */
145         struct ether_addr *inner_mac;  /**< Inner MAC address filter. */
146         uint16_t inner_vlan;           /**< Inner VLAN filter. */
147         enum rte_tunnel_iptype ip_type; /**< IP address type. */
148         union {
149                 uint32_t ipv4_addr;    /**< IPv4 source address to match. */
150                 uint32_t ipv6_addr[4]; /**< IPv6 source address to match. */
151         } ip_addr; /**< IPv4/IPv6 source address to match (union of above). */
152
153         uint16_t filter_type;   /**< Filter type. */
154         enum rte_eth_tunnel_type tunnel_type; /**< Tunnel Type. */
155         uint32_t tenant_id;     /** < Tenant number. */
156         uint16_t queue_id;      /** < queue number. */
157 };
158
159 #define RTE_ETH_FDIR_MAX_FLEXLEN         16 /** < Max length of flexbytes. */
160
161 /**
162  * Flow type
163  */
164 enum rte_eth_flow_type {
165         RTE_ETH_FLOW_TYPE_NONE = 0,
166         RTE_ETH_FLOW_TYPE_UDPV4,
167         RTE_ETH_FLOW_TYPE_TCPV4,
168         RTE_ETH_FLOW_TYPE_SCTPV4,
169         RTE_ETH_FLOW_TYPE_IPV4_OTHER,
170         RTE_ETH_FLOW_TYPE_FRAG_IPV4,
171         RTE_ETH_FLOW_TYPE_UDPV6,
172         RTE_ETH_FLOW_TYPE_TCPV6,
173         RTE_ETH_FLOW_TYPE_SCTPV6,
174         RTE_ETH_FLOW_TYPE_IPV6_OTHER,
175         RTE_ETH_FLOW_TYPE_FRAG_IPV6,
176         RTE_ETH_FLOW_TYPE_MAX = 64,
177 };
178
179 /**
180  * A structure used to define the input for IPV4 flow
181  */
182 struct rte_eth_ipv4_flow {
183         uint32_t src_ip;      /**< IPv4 source address to match. */
184         uint32_t dst_ip;      /**< IPv4 destination address to match. */
185 };
186
187 /**
188  * A structure used to define the input for IPV4 UDP flow
189  */
190 struct rte_eth_udpv4_flow {
191         struct rte_eth_ipv4_flow ip; /**< IPv4 fields to match. */
192         uint16_t src_port;           /**< UDP source port to match. */
193         uint16_t dst_port;           /**< UDP destination port to match. */
194 };
195
196 /**
197  * A structure used to define the input for IPV4 TCP flow
198  */
199 struct rte_eth_tcpv4_flow {
200         struct rte_eth_ipv4_flow ip; /**< IPv4 fields to match. */
201         uint16_t src_port;           /**< TCP source port to match. */
202         uint16_t dst_port;           /**< TCP destination port to match. */
203 };
204
205 /**
206  * A structure used to define the input for IPV4 SCTP flow
207  */
208 struct rte_eth_sctpv4_flow {
209         struct rte_eth_ipv4_flow ip; /**< IPv4 fields to match. */
210         uint32_t verify_tag;         /**< Verify tag to match */
211 };
212
213 /**
214  * A structure used to define the input for IPV6 flow
215  */
216 struct rte_eth_ipv6_flow {
217         uint32_t src_ip[4];      /**< IPv6 source address to match. */
218         uint32_t dst_ip[4];      /**< IPv6 destination address to match. */
219 };
220
221 /**
222  * A structure used to define the input for IPV6 UDP flow
223  */
224 struct rte_eth_udpv6_flow {
225         struct rte_eth_ipv6_flow ip; /**< IPv6 fields to match. */
226         uint16_t src_port;           /**< UDP source port to match. */
227         uint16_t dst_port;           /**< UDP destination port to match. */
228 };
229
230 /**
231  * A structure used to define the input for IPV6 TCP flow
232  */
233 struct rte_eth_tcpv6_flow {
234         struct rte_eth_ipv6_flow ip; /**< IPv6 fields to match. */
235         uint16_t src_port;           /**< TCP source port to match. */
236         uint16_t dst_port;           /**< TCP destination port to match. */
237 };
238
239 /**
240  * A structure used to define the input for IPV6 SCTP flow
241  */
242 struct rte_eth_sctpv6_flow {
243         struct rte_eth_ipv6_flow ip; /**< IPv6 fields to match. */
244         uint32_t verify_tag;         /**< Verify tag to match */
245 };
246
247 /**
248  * An union contains the inputs for all types of flow
249  */
250 union rte_eth_fdir_flow {
251         struct rte_eth_udpv4_flow  udp4_flow;
252         struct rte_eth_tcpv4_flow  tcp4_flow;
253         struct rte_eth_sctpv4_flow sctp4_flow;
254         struct rte_eth_ipv4_flow   ip4_flow;
255         struct rte_eth_udpv6_flow  udp6_flow;
256         struct rte_eth_tcpv6_flow  tcp6_flow;
257         struct rte_eth_sctpv6_flow sctp6_flow;
258         struct rte_eth_ipv6_flow   ip6_flow;
259 };
260
261 /**
262  * A structure used to contain extend input of flow
263  */
264 struct rte_eth_fdir_flow_ext {
265         uint16_t vlan_tci;
266         uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
267         /**< It is filled by the flexible payload to match. */
268 };
269
270 /**
271  * A structure used to define the input for a flow director filter entry
272  */
273 struct rte_eth_fdir_input {
274         enum rte_eth_flow_type flow_type;      /**< Type of flow */
275         union rte_eth_fdir_flow flow;
276         /**< Flow fields to match, dependent on flow_type */
277         struct rte_eth_fdir_flow_ext flow_ext;
278         /**< Additional fields to match */
279 };
280
281 /**
282  * Behavior will be taken if FDIR match
283  */
284 enum rte_eth_fdir_behavior {
285         RTE_ETH_FDIR_ACCEPT = 0,
286         RTE_ETH_FDIR_REJECT,
287 };
288
289 /**
290  * Flow director report status
291  * It defines what will be reported if FDIR entry is matched.
292  */
293 enum rte_eth_fdir_status {
294         RTE_ETH_FDIR_NO_REPORT_STATUS = 0, /**< Report nothing. */
295         RTE_ETH_FDIR_REPORT_ID,            /**< Only report FD ID. */
296         RTE_ETH_FDIR_REPORT_ID_FLEX_4,     /**< Report FD ID and 4 flex bytes. */
297         RTE_ETH_FDIR_REPORT_FLEX_8,        /**< Report 8 flex bytes. */
298 };
299
300 /**
301  * A structure used to define an action when match FDIR packet filter.
302  */
303 struct rte_eth_fdir_action {
304         uint16_t rx_queue;        /**< Queue assigned to if FDIR match. */
305         enum rte_eth_fdir_behavior behavior;     /**< Behavior will be taken */
306         enum rte_eth_fdir_status report_status;  /**< Status report option */
307         uint8_t flex_off;
308         /**< If report_status is RTE_ETH_FDIR_REPORT_ID_FLEX_4 or
309              RTE_ETH_FDIR_REPORT_FLEX_8, flex_off specifies where the reported
310              flex bytes start from in flexible payload. */
311 };
312
313 /**
314  * A structure used to define the flow director filter entry by filter_ctrl API
315  * It supports RTE_ETH_FILTER_FDIR with RTE_ETH_FILTER_ADD and
316  * RTE_ETH_FILTER_DELETE operations.
317  */
318 struct rte_eth_fdir_filter {
319         uint32_t soft_id;
320         /**< ID, an unique value is required when deal with FDIR entry */
321         struct rte_eth_fdir_input input;    /**< Input set */
322         struct rte_eth_fdir_action action;  /**< Action taken when match */
323 };
324
325 /**
326  * Payload type
327  */
328 enum rte_eth_payload_type {
329         RTE_ETH_PAYLOAD_UNKNOWN = 0,
330         RTE_ETH_L2_PAYLOAD,
331         RTE_ETH_L3_PAYLOAD,
332         RTE_ETH_L4_PAYLOAD,
333         RTE_ETH_PAYLOAD_MAX = 8,
334 };
335
336 /**
337  * A structure used to select bytes extracted from the protocol layers to
338  * flexible payload for filter
339  */
340 struct rte_eth_flex_payload_cfg {
341         enum rte_eth_payload_type type;  /**< Payload type */
342         uint16_t src_offset[RTE_ETH_FDIR_MAX_FLEXLEN];
343         /**< Offset in bytes from the beginning of packet's payload
344              src_offset[i] indicates the flexbyte i's offset in original
345              packet payload. This value should be less than
346              flex_payload_limit in struct rte_eth_fdir_info.*/
347 };
348
349 /**
350  * A structure used to define FDIR masks for flexible payload
351  * for each flow type
352  */
353 struct rte_eth_fdir_flex_mask {
354         enum rte_eth_flow_type flow_type;  /**< Flow type */
355         uint8_t mask[RTE_ETH_FDIR_MAX_FLEXLEN];
356         /**< Mask for the whole flexible payload */
357 };
358
359 /**
360  * A structure used to define all flexible payload related setting
361  * include flexpay load and flex mask
362  */
363 struct rte_eth_fdir_flex_conf {
364         uint16_t nb_payloads;  /**< The number of following payload cfg */
365         uint16_t nb_flexmasks; /**< The number of following mask */
366         struct rte_eth_flex_payload_cfg flex_set[RTE_ETH_PAYLOAD_MAX];
367         /**< Flex payload configuration for each payload type */
368         struct rte_eth_fdir_flex_mask flex_mask[RTE_ETH_FLOW_TYPE_MAX];
369         /**< Flex mask configuration for each flow type */
370 };
371
372 /**
373  *  Flow Director setting modes: none, signature or perfect.
374  */
375 enum rte_fdir_mode {
376         RTE_FDIR_MODE_NONE      = 0, /**< Disable FDIR support. */
377         RTE_FDIR_MODE_SIGNATURE,     /**< Enable FDIR signature filter mode. */
378         RTE_FDIR_MODE_PERFECT,       /**< Enable FDIR perfect filter mode. */
379 };
380
381 /**
382  * A structure used to get the information of flow director filter.
383  * It supports RTE_ETH_FILTER_FDIR with RTE_ETH_FILTER_INFO operation.
384  * It includes the mode, flexible payload configuration information,
385  * capabilities and supported flow types, flexible payload characters.
386  * It can be gotten to help taking specific configurations per device.
387  */
388 struct rte_eth_fdir_info {
389         enum rte_fdir_mode mode;     /**< Flow director mode */
390         struct rte_eth_fdir_flex_conf flex_conf;
391         /**< Flex payload configuration information */
392         uint32_t guarant_spc;          /**< Guaranteed spaces.*/
393         uint32_t best_spc;             /**< Best effort spaces.*/
394         uint32_t flow_types_mask[RTE_ETH_FLOW_TYPE_MAX / sizeof(uint32_t)];
395         /**< Bit mask for every supported flow type. */
396         uint32_t max_flexpayload;      /**< Total flex payload in bytes. */
397         uint32_t flex_payload_unit;
398         /**< Flexible payload unit in bytes. Size and alignments of all flex
399              payload segments should be multiplies of this value. */
400         uint32_t max_flex_payload_segment_num;
401         /**< Max number of flexible payload continuous segments.
402              Each segment should be a multiple of flex_payload_unit.*/
403         uint16_t flex_payload_limit;
404         /**< Maximum src_offset in bytes allowed. It indicates that
405              src_offset[i] in struct rte_eth_flex_payload_cfg should be
406              less than this value. */
407         uint32_t flex_bitmask_unit;
408         /**< Flex bitmask unit in bytes. Size of flex bitmasks should
409              be a multiply of this value. */
410         uint32_t max_flex_bitmask_num;
411         /**< Max supported size of flex bitmasks in flex_bitmask_unit */
412 };
413
414 /**
415  * A structure used to define the statistics of flow director.
416  * It supports RTE_ETH_FILTER_FDIR with RTE_ETH_FILTER_STATS operation.
417  */
418 struct rte_eth_fdir_stats {
419         uint32_t collision;    /**< Number of filters with collision. */
420         uint32_t free;         /**< Number of free filters. */
421         uint32_t maxhash;
422         /**< The lookup hash value of the added filter that updated the value
423            of the MAXLEN field */
424         uint32_t maxlen;       /**< Longest linked list of filters. */
425         uint64_t add;          /**< Number of added filters. */
426         uint64_t remove;       /**< Number of removed filters. */
427         uint64_t f_add;        /**< Number of failed added filters. */
428         uint64_t f_remove;     /**< Number of failed removed filters. */
429         uint32_t guarant_cnt;  /**< Number of filters in guaranteed spaces. */
430         uint32_t best_cnt;     /**< Number of filters in best effort spaces. */
431 };
432
433 #ifdef __cplusplus
434 }
435 #endif
436
437 #endif /* _RTE_ETH_CTRL_H_ */