ethdev: increase RETA entry size
[dpdk.git] / lib / librte_ether / rte_ethdev.h
1 /*-
2  *   BSD LICENSE
3  *
4  *   Copyright(c) 2010-2015 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_ETHDEV_H_
35 #define _RTE_ETHDEV_H_
36
37 /**
38  * @file
39  *
40  * RTE Ethernet Device API
41  *
42  * The Ethernet Device API is composed of two parts:
43  *
44  * - The application-oriented Ethernet API that includes functions to setup
45  *   an Ethernet device (configure it, setup its RX and TX queues and start it),
46  *   to get its MAC address, the speed and the status of its physical link,
47  *   to receive and to transmit packets, and so on.
48  *
49  * - The driver-oriented Ethernet API that exports a function allowing
50  *   an Ethernet Poll Mode Driver (PMD) to simultaneously register itself as
51  *   an Ethernet device driver and as a PCI driver for a set of matching PCI
52  *   [Ethernet] devices classes.
53  *
54  * By default, all the functions of the Ethernet Device API exported by a PMD
55  * are lock-free functions which assume to not be invoked in parallel on
56  * different logical cores to work on the same target object.  For instance,
57  * the receive function of a PMD cannot be invoked in parallel on two logical
58  * cores to poll the same RX queue [of the same port]. Of course, this function
59  * can be invoked in parallel by different logical cores on different RX queues.
60  * It is the responsibility of the upper level application to enforce this rule.
61  *
62  * If needed, parallel accesses by multiple logical cores to shared queues
63  * shall be explicitly protected by dedicated inline lock-aware functions
64  * built on top of their corresponding lock-free functions of the PMD API.
65  *
66  * In all functions of the Ethernet API, the Ethernet device is
67  * designated by an integer >= 0 named the device port identifier.
68  *
69  * At the Ethernet driver level, Ethernet devices are represented by a generic
70  * data structure of type *rte_eth_dev*.
71  *
72  * Ethernet devices are dynamically registered during the PCI probing phase
73  * performed at EAL initialization time.
74  * When an Ethernet device is being probed, an *rte_eth_dev* structure and
75  * a new port identifier are allocated for that device. Then, the eth_dev_init()
76  * function supplied by the Ethernet driver matching the probed PCI
77  * device is invoked to properly initialize the device.
78  *
79  * The role of the device init function consists of resetting the hardware,
80  * checking access to Non-volatile Memory (NVM), reading the MAC address
81  * from NVM etc.
82  *
83  * If the device init operation is successful, the correspondence between
84  * the port identifier assigned to the new device and its associated
85  * *rte_eth_dev* structure is effectively registered.
86  * Otherwise, both the *rte_eth_dev* structure and the port identifier are
87  * freed.
88  *
89  * The functions exported by the application Ethernet API to setup a device
90  * designated by its port identifier must be invoked in the following order:
91  *     - rte_eth_dev_configure()
92  *     - rte_eth_tx_queue_setup()
93  *     - rte_eth_rx_queue_setup()
94  *     - rte_eth_dev_start()
95  *
96  * Then, the network application can invoke, in any order, the functions
97  * exported by the Ethernet API to get the MAC address of a given device, to
98  * get the speed and the status of a device physical link, to receive/transmit
99  * [burst of] packets, and so on.
100  *
101  * If the application wants to change the configuration (i.e. call
102  * rte_eth_dev_configure(), rte_eth_tx_queue_setup(), or
103  * rte_eth_rx_queue_setup()), it must call rte_eth_dev_stop() first to stop the
104  * device and then do the reconfiguration before calling rte_eth_dev_start()
105  * again. The tramsit and receive functions should not be invoked when the
106  * device is stopped.
107  *
108  * Please note that some configuration is not stored between calls to
109  * rte_eth_dev_stop()/rte_eth_dev_start(). The following configuration will
110  * be retained:
111  *
112  *     - flow control settings
113  *     - receive mode configuration (promiscuous mode, hardware checksum mode,
114  *       RSS/VMDQ settings etc.)
115  *     - VLAN filtering configuration
116  *     - MAC addresses supplied to MAC address array
117  *     - flow director filtering mode (but not filtering rules)
118  *     - NIC queue statistics mappings
119  *
120  * Any other configuration will not be stored and will need to be re-entered
121  * after a call to rte_eth_dev_start().
122  *
123  * Finally, a network application can close an Ethernet device by invoking the
124  * rte_eth_dev_close() function.
125  *
126  * Each function of the application Ethernet API invokes a specific function
127  * of the PMD that controls the target device designated by its port
128  * identifier.
129  * For this purpose, all device-specific functions of an Ethernet driver are
130  * supplied through a set of pointers contained in a generic structure of type
131  * *eth_dev_ops*.
132  * The address of the *eth_dev_ops* structure is stored in the *rte_eth_dev*
133  * structure by the device init function of the Ethernet driver, which is
134  * invoked during the PCI probing phase, as explained earlier.
135  *
136  * In other words, each function of the Ethernet API simply retrieves the
137  * *rte_eth_dev* structure associated with the device port identifier and
138  * performs an indirect invocation of the corresponding driver function
139  * supplied in the *eth_dev_ops* structure of the *rte_eth_dev* structure.
140  *
141  * For performance reasons, the address of the burst-oriented RX and TX
142  * functions of the Ethernet driver are not contained in the *eth_dev_ops*
143  * structure. Instead, they are directly stored at the beginning of the
144  * *rte_eth_dev* structure to avoid an extra indirect memory access during
145  * their invocation.
146  *
147  * RTE ethernet device drivers do not use interrupts for transmitting or
148  * receiving. Instead, Ethernet drivers export Poll-Mode receive and transmit
149  * functions to applications.
150  * Both receive and transmit functions are packet-burst oriented to minimize
151  * their cost per packet through the following optimizations:
152  *
153  * - Sharing among multiple packets the incompressible cost of the
154  *   invocation of receive/transmit functions.
155  *
156  * - Enabling receive/transmit functions to take advantage of burst-oriented
157  *   hardware features (L1 cache, prefetch instructions, NIC head/tail
158  *   registers) to minimize the number of CPU cycles per packet, for instance,
159  *   by avoiding useless read memory accesses to ring descriptors, or by
160  *   systematically using arrays of pointers that exactly fit L1 cache line
161  *   boundaries and sizes.
162  *
163  * The burst-oriented receive function does not provide any error notification,
164  * to avoid the corresponding overhead. As a hint, the upper-level application
165  * might check the status of the device link once being systematically returned
166  * a 0 value by the receive function of the driver for a given number of tries.
167  */
168
169 #ifdef __cplusplus
170 extern "C" {
171 #endif
172
173 #include <stdint.h>
174
175 #include <rte_dev.h>
176
177 /* Use this macro to check if LRO API is supported */
178 #define RTE_ETHDEV_HAS_LRO_SUPPORT
179
180 #include <rte_log.h>
181 #include <rte_interrupts.h>
182 #include <rte_pci.h>
183 #include <rte_dev.h>
184 #include <rte_devargs.h>
185 #include "rte_ether.h"
186 #include "rte_eth_ctrl.h"
187 #include "rte_dev_info.h"
188
189 struct rte_mbuf;
190
191 /**
192  * A structure used to retrieve statistics for an Ethernet port.
193  */
194 struct rte_eth_stats {
195         uint64_t ipackets;  /**< Total number of successfully received packets. */
196         uint64_t opackets;  /**< Total number of successfully transmitted packets.*/
197         uint64_t ibytes;    /**< Total number of successfully received bytes. */
198         uint64_t obytes;    /**< Total number of successfully transmitted bytes. */
199         uint64_t imissed;
200         /**< Total of RX packets dropped by the HW,
201          * because there are no available mbufs (i.e. RX queues are full).
202          */
203         uint64_t ibadcrc __rte_deprecated;
204         /**< Deprecated; Total of RX packets with CRC error. */
205         uint64_t ibadlen __rte_deprecated;
206         /**< Deprecated; Total of RX packets with bad length. */
207         uint64_t ierrors;   /**< Total number of erroneous received packets. */
208         uint64_t oerrors;   /**< Total number of failed transmitted packets. */
209         uint64_t imcasts;
210         /**< Deprecated; Total number of multicast received packets. */
211         uint64_t rx_nombuf; /**< Total number of RX mbuf allocation failures. */
212         uint64_t fdirmatch __rte_deprecated;
213         /**< Deprecated; Total number of RX packets matching a filter. */
214         uint64_t fdirmiss __rte_deprecated;
215         /**< Deprecated; Total number of RX packets not matching any filter. */
216         uint64_t tx_pause_xon __rte_deprecated;
217          /**< Deprecated; Total nb. of XON pause frame sent. */
218         uint64_t rx_pause_xon __rte_deprecated;
219         /**< Deprecated; Total nb. of XON pause frame received. */
220         uint64_t tx_pause_xoff __rte_deprecated;
221         /**< Deprecated; Total nb. of XOFF pause frame sent. */
222         uint64_t rx_pause_xoff __rte_deprecated;
223         /**< Deprecated; Total nb. of XOFF pause frame received. */
224         uint64_t q_ipackets[RTE_ETHDEV_QUEUE_STAT_CNTRS];
225         /**< Total number of queue RX packets. */
226         uint64_t q_opackets[RTE_ETHDEV_QUEUE_STAT_CNTRS];
227         /**< Total number of queue TX packets. */
228         uint64_t q_ibytes[RTE_ETHDEV_QUEUE_STAT_CNTRS];
229         /**< Total number of successfully received queue bytes. */
230         uint64_t q_obytes[RTE_ETHDEV_QUEUE_STAT_CNTRS];
231         /**< Total number of successfully transmitted queue bytes. */
232         uint64_t q_errors[RTE_ETHDEV_QUEUE_STAT_CNTRS];
233         /**< Total number of queue packets received that are dropped. */
234         uint64_t ilbpackets;
235         /**< Total number of good packets received from loopback,VF Only */
236         uint64_t olbpackets;
237         /**< Total number of good packets transmitted to loopback,VF Only */
238         uint64_t ilbbytes;
239         /**< Total number of good bytes received from loopback,VF Only */
240         uint64_t olbbytes;
241         /**< Total number of good bytes transmitted to loopback,VF Only */
242 };
243
244 /**
245  * A structure used to retrieve link-level information of an Ethernet port.
246  */
247 struct rte_eth_link {
248         uint16_t link_speed;      /**< ETH_LINK_SPEED_[10, 100, 1000, 10000] */
249         uint16_t link_duplex;     /**< ETH_LINK_[HALF_DUPLEX, FULL_DUPLEX] */
250         uint8_t  link_status : 1; /**< 1 -> link up, 0 -> link down */
251 }__attribute__((aligned(8)));     /**< aligned for atomic64 read/write */
252
253 #define ETH_LINK_SPEED_AUTONEG  0       /**< Auto-negotiate link speed. */
254 #define ETH_LINK_SPEED_10       10      /**< 10 megabits/second. */
255 #define ETH_LINK_SPEED_100      100     /**< 100 megabits/second. */
256 #define ETH_LINK_SPEED_1000     1000    /**< 1 gigabits/second. */
257 #define ETH_LINK_SPEED_10000    10000   /**< 10 gigabits/second. */
258 #define ETH_LINK_SPEED_10G      10000   /**< alias of 10 gigabits/second. */
259 #define ETH_LINK_SPEED_20G      20000   /**< 20 gigabits/second. */
260 #define ETH_LINK_SPEED_40G      40000   /**< 40 gigabits/second. */
261
262 #define ETH_LINK_AUTONEG_DUPLEX 0       /**< Auto-negotiate duplex. */
263 #define ETH_LINK_HALF_DUPLEX    1       /**< Half-duplex connection. */
264 #define ETH_LINK_FULL_DUPLEX    2       /**< Full-duplex connection. */
265
266 /**
267  * A structure used to configure the ring threshold registers of an RX/TX
268  * queue for an Ethernet port.
269  */
270 struct rte_eth_thresh {
271         uint8_t pthresh; /**< Ring prefetch threshold. */
272         uint8_t hthresh; /**< Ring host threshold. */
273         uint8_t wthresh; /**< Ring writeback threshold. */
274 };
275
276 /**
277  *  Simple flags are used for rte_eth_conf.rxmode.mq_mode.
278  */
279 #define ETH_MQ_RX_RSS_FLAG  0x1
280 #define ETH_MQ_RX_DCB_FLAG  0x2
281 #define ETH_MQ_RX_VMDQ_FLAG 0x4
282
283 /**
284  *  A set of values to identify what method is to be used to route
285  *  packets to multiple queues.
286  */
287 enum rte_eth_rx_mq_mode {
288         /** None of DCB,RSS or VMDQ mode */
289         ETH_MQ_RX_NONE = 0,
290
291         /** For RX side, only RSS is on */
292         ETH_MQ_RX_RSS = ETH_MQ_RX_RSS_FLAG,
293         /** For RX side,only DCB is on. */
294         ETH_MQ_RX_DCB = ETH_MQ_RX_DCB_FLAG,
295         /** Both DCB and RSS enable */
296         ETH_MQ_RX_DCB_RSS = ETH_MQ_RX_RSS_FLAG | ETH_MQ_RX_DCB_FLAG,
297
298         /** Only VMDQ, no RSS nor DCB */
299         ETH_MQ_RX_VMDQ_ONLY = ETH_MQ_RX_VMDQ_FLAG,
300         /** RSS mode with VMDQ */
301         ETH_MQ_RX_VMDQ_RSS = ETH_MQ_RX_RSS_FLAG | ETH_MQ_RX_VMDQ_FLAG,
302         /** Use VMDQ+DCB to route traffic to queues */
303         ETH_MQ_RX_VMDQ_DCB = ETH_MQ_RX_VMDQ_FLAG | ETH_MQ_RX_DCB_FLAG,
304         /** Enable both VMDQ and DCB in VMDq */
305         ETH_MQ_RX_VMDQ_DCB_RSS = ETH_MQ_RX_RSS_FLAG | ETH_MQ_RX_DCB_FLAG |
306                                  ETH_MQ_RX_VMDQ_FLAG,
307 };
308
309 /**
310  * for rx mq mode backward compatible
311  */
312 #define ETH_RSS                       ETH_MQ_RX_RSS
313 #define VMDQ_DCB                      ETH_MQ_RX_VMDQ_DCB
314 #define ETH_DCB_RX                    ETH_MQ_RX_DCB
315
316 /**
317  * A set of values to identify what method is to be used to transmit
318  * packets using multi-TCs.
319  */
320 enum rte_eth_tx_mq_mode {
321         ETH_MQ_TX_NONE    = 0,  /**< It is in neither DCB nor VT mode. */
322         ETH_MQ_TX_DCB,          /**< For TX side,only DCB is on. */
323         ETH_MQ_TX_VMDQ_DCB,     /**< For TX side,both DCB and VT is on. */
324         ETH_MQ_TX_VMDQ_ONLY,    /**< Only VT on, no DCB */
325 };
326
327 /**
328  * for tx mq mode backward compatible
329  */
330 #define ETH_DCB_NONE                ETH_MQ_TX_NONE
331 #define ETH_VMDQ_DCB_TX             ETH_MQ_TX_VMDQ_DCB
332 #define ETH_DCB_TX                  ETH_MQ_TX_DCB
333
334 /**
335  * A structure used to configure the RX features of an Ethernet port.
336  */
337 struct rte_eth_rxmode {
338         /** The multi-queue packet distribution mode to be used, e.g. RSS. */
339         enum rte_eth_rx_mq_mode mq_mode;
340         uint32_t max_rx_pkt_len;  /**< Only used if jumbo_frame enabled. */
341         uint16_t split_hdr_size;  /**< hdr buf size (header_split enabled).*/
342         uint16_t header_split : 1, /**< Header Split enable. */
343                 hw_ip_checksum   : 1, /**< IP/UDP/TCP checksum offload enable. */
344                 hw_vlan_filter   : 1, /**< VLAN filter enable. */
345                 hw_vlan_strip    : 1, /**< VLAN strip enable. */
346                 hw_vlan_extend   : 1, /**< Extended VLAN enable. */
347                 jumbo_frame      : 1, /**< Jumbo Frame Receipt enable. */
348                 hw_strip_crc     : 1, /**< Enable CRC stripping by hardware. */
349                 enable_scatter   : 1, /**< Enable scatter packets rx handler */
350                 enable_lro       : 1; /**< Enable LRO */
351 };
352
353 /**
354  * A structure used to configure the Receive Side Scaling (RSS) feature
355  * of an Ethernet port.
356  * If not NULL, the *rss_key* pointer of the *rss_conf* structure points
357  * to an array holding the RSS key to use for hashing specific header
358  * fields of received packets. The length of this array should be indicated
359  * by *rss_key_len* below. Otherwise, a default random hash key is used by
360  * the device driver.
361  *
362  * The *rss_key_len* field of the *rss_conf* structure indicates the length
363  * in bytes of the array pointed by *rss_key*. To be compatible, this length
364  * will be checked in i40e only. Others assume 40 bytes to be used as before.
365  *
366  * The *rss_hf* field of the *rss_conf* structure indicates the different
367  * types of IPv4/IPv6 packets to which the RSS hashing must be applied.
368  * Supplying an *rss_hf* equal to zero disables the RSS feature.
369  */
370 struct rte_eth_rss_conf {
371         uint8_t *rss_key;    /**< If not NULL, 40-byte hash key. */
372         uint8_t rss_key_len; /**< hash key length in bytes. */
373         uint64_t rss_hf;     /**< Hash functions to apply - see below. */
374 };
375
376 /*
377  * The RSS offload types are defined based on flow types which are defined
378  * in rte_eth_ctrl.h. Different NIC hardwares may support different RSS offload
379  * types. The supported flow types or RSS offload types can be queried by
380  * rte_eth_dev_info_get().
381  */
382 #define ETH_RSS_IPV4               (1ULL << RTE_ETH_FLOW_IPV4)
383 #define ETH_RSS_FRAG_IPV4          (1ULL << RTE_ETH_FLOW_FRAG_IPV4)
384 #define ETH_RSS_NONFRAG_IPV4_TCP   (1ULL << RTE_ETH_FLOW_NONFRAG_IPV4_TCP)
385 #define ETH_RSS_NONFRAG_IPV4_UDP   (1ULL << RTE_ETH_FLOW_NONFRAG_IPV4_UDP)
386 #define ETH_RSS_NONFRAG_IPV4_SCTP  (1ULL << RTE_ETH_FLOW_NONFRAG_IPV4_SCTP)
387 #define ETH_RSS_NONFRAG_IPV4_OTHER (1ULL << RTE_ETH_FLOW_NONFRAG_IPV4_OTHER)
388 #define ETH_RSS_IPV6               (1ULL << RTE_ETH_FLOW_IPV6)
389 #define ETH_RSS_FRAG_IPV6          (1ULL << RTE_ETH_FLOW_FRAG_IPV6)
390 #define ETH_RSS_NONFRAG_IPV6_TCP   (1ULL << RTE_ETH_FLOW_NONFRAG_IPV6_TCP)
391 #define ETH_RSS_NONFRAG_IPV6_UDP   (1ULL << RTE_ETH_FLOW_NONFRAG_IPV6_UDP)
392 #define ETH_RSS_NONFRAG_IPV6_SCTP  (1ULL << RTE_ETH_FLOW_NONFRAG_IPV6_SCTP)
393 #define ETH_RSS_NONFRAG_IPV6_OTHER (1ULL << RTE_ETH_FLOW_NONFRAG_IPV6_OTHER)
394 #define ETH_RSS_L2_PAYLOAD         (1ULL << RTE_ETH_FLOW_L2_PAYLOAD)
395 #define ETH_RSS_IPV6_EX            (1ULL << RTE_ETH_FLOW_IPV6_EX)
396 #define ETH_RSS_IPV6_TCP_EX        (1ULL << RTE_ETH_FLOW_IPV6_TCP_EX)
397 #define ETH_RSS_IPV6_UDP_EX        (1ULL << RTE_ETH_FLOW_IPV6_UDP_EX)
398
399 #define ETH_RSS_IP ( \
400         ETH_RSS_IPV4 | \
401         ETH_RSS_FRAG_IPV4 | \
402         ETH_RSS_NONFRAG_IPV4_OTHER | \
403         ETH_RSS_IPV6 | \
404         ETH_RSS_FRAG_IPV6 | \
405         ETH_RSS_NONFRAG_IPV6_OTHER | \
406         ETH_RSS_IPV6_EX)
407
408 #define ETH_RSS_UDP ( \
409         ETH_RSS_NONFRAG_IPV4_UDP | \
410         ETH_RSS_NONFRAG_IPV6_UDP | \
411         ETH_RSS_IPV6_UDP_EX)
412
413 #define ETH_RSS_TCP ( \
414         ETH_RSS_NONFRAG_IPV4_TCP | \
415         ETH_RSS_NONFRAG_IPV6_TCP | \
416         ETH_RSS_IPV6_TCP_EX)
417
418 #define ETH_RSS_SCTP ( \
419         ETH_RSS_NONFRAG_IPV4_SCTP | \
420         ETH_RSS_NONFRAG_IPV6_SCTP)
421
422 /**< Mask of valid RSS hash protocols */
423 #define ETH_RSS_PROTO_MASK ( \
424         ETH_RSS_IPV4 | \
425         ETH_RSS_FRAG_IPV4 | \
426         ETH_RSS_NONFRAG_IPV4_TCP | \
427         ETH_RSS_NONFRAG_IPV4_UDP | \
428         ETH_RSS_NONFRAG_IPV4_SCTP | \
429         ETH_RSS_NONFRAG_IPV4_OTHER | \
430         ETH_RSS_IPV6 | \
431         ETH_RSS_FRAG_IPV6 | \
432         ETH_RSS_NONFRAG_IPV6_TCP | \
433         ETH_RSS_NONFRAG_IPV6_UDP | \
434         ETH_RSS_NONFRAG_IPV6_SCTP | \
435         ETH_RSS_NONFRAG_IPV6_OTHER | \
436         ETH_RSS_L2_PAYLOAD | \
437         ETH_RSS_IPV6_EX | \
438         ETH_RSS_IPV6_TCP_EX | \
439         ETH_RSS_IPV6_UDP_EX)
440
441 /*
442  * Definitions used for redirection table entry size.
443  * Some RSS RETA sizes may not be supported by some drivers, check the
444  * documentation or the description of relevant functions for more details.
445  */
446 #define ETH_RSS_RETA_SIZE_64  64
447 #define ETH_RSS_RETA_SIZE_128 128
448 #define ETH_RSS_RETA_SIZE_512 512
449 #define RTE_RETA_GROUP_SIZE   64
450
451 /* Definitions used for VMDQ and DCB functionality */
452 #define ETH_VMDQ_MAX_VLAN_FILTERS   64 /**< Maximum nb. of VMDQ vlan filters. */
453 #define ETH_DCB_NUM_USER_PRIORITIES 8  /**< Maximum nb. of DCB priorities. */
454 #define ETH_VMDQ_DCB_NUM_QUEUES     128 /**< Maximum nb. of VMDQ DCB queues. */
455 #define ETH_DCB_NUM_QUEUES          128 /**< Maximum nb. of DCB queues. */
456
457 /* DCB capability defines */
458 #define ETH_DCB_PG_SUPPORT      0x00000001 /**< Priority Group(ETS) support. */
459 #define ETH_DCB_PFC_SUPPORT     0x00000002 /**< Priority Flow Control support. */
460
461 /* Definitions used for VLAN Offload functionality */
462 #define ETH_VLAN_STRIP_OFFLOAD   0x0001 /**< VLAN Strip  On/Off */
463 #define ETH_VLAN_FILTER_OFFLOAD  0x0002 /**< VLAN Filter On/Off */
464 #define ETH_VLAN_EXTEND_OFFLOAD  0x0004 /**< VLAN Extend On/Off */
465
466 /* Definitions used for mask VLAN setting */
467 #define ETH_VLAN_STRIP_MASK   0x0001 /**< VLAN Strip  setting mask */
468 #define ETH_VLAN_FILTER_MASK  0x0002 /**< VLAN Filter  setting mask*/
469 #define ETH_VLAN_EXTEND_MASK  0x0004 /**< VLAN Extend  setting mask*/
470 #define ETH_VLAN_ID_MAX       0x0FFF /**< VLAN ID is in lower 12 bits*/
471
472 /* Definitions used for receive MAC address   */
473 #define ETH_NUM_RECEIVE_MAC_ADDR  128 /**< Maximum nb. of receive mac addr. */
474
475 /* Definitions used for unicast hash  */
476 #define ETH_VMDQ_NUM_UC_HASH_ARRAY  128 /**< Maximum nb. of UC hash array. */
477
478 /* Definitions used for VMDQ pool rx mode setting */
479 #define ETH_VMDQ_ACCEPT_UNTAG   0x0001 /**< accept untagged packets. */
480 #define ETH_VMDQ_ACCEPT_HASH_MC 0x0002 /**< accept packets in multicast table . */
481 #define ETH_VMDQ_ACCEPT_HASH_UC 0x0004 /**< accept packets in unicast table. */
482 #define ETH_VMDQ_ACCEPT_BROADCAST   0x0008 /**< accept broadcast packets. */
483 #define ETH_VMDQ_ACCEPT_MULTICAST   0x0010 /**< multicast promiscuous. */
484
485 /** Maximum nb. of vlan per mirror rule */
486 #define ETH_MIRROR_MAX_VLANS       64
487
488 #define ETH_MIRROR_VIRTUAL_POOL_UP     0x01  /**< Virtual Pool uplink Mirroring. */
489 #define ETH_MIRROR_UPLINK_PORT         0x02  /**< Uplink Port Mirroring. */
490 #define ETH_MIRROR_DOWNLINK_PORT       0x04  /**< Downlink Port Mirroring. */
491 #define ETH_MIRROR_VLAN                0x08  /**< VLAN Mirroring. */
492 #define ETH_MIRROR_VIRTUAL_POOL_DOWN   0x10  /**< Virtual Pool downlink Mirroring. */
493
494 /**
495  * A structure used to configure VLAN traffic mirror of an Ethernet port.
496  */
497 struct rte_eth_vlan_mirror {
498         uint64_t vlan_mask; /**< mask for valid VLAN ID. */
499         /** VLAN ID list for vlan mirroring. */
500         uint16_t vlan_id[ETH_MIRROR_MAX_VLANS];
501 };
502
503 /**
504  * A structure used to configure traffic mirror of an Ethernet port.
505  */
506 struct rte_eth_mirror_conf {
507         uint8_t rule_type; /**< Mirroring rule type */
508         uint8_t dst_pool;  /**< Destination pool for this mirror rule. */
509         uint64_t pool_mask; /**< Bitmap of pool for pool mirroring */
510         /** VLAN ID setting for VLAN mirroring. */
511         struct rte_eth_vlan_mirror vlan;
512 };
513
514 /**
515  * A structure used to configure 64 entries of Redirection Table of the
516  * Receive Side Scaling (RSS) feature of an Ethernet port. To configure
517  * more than 64 entries supported by hardware, an array of this structure
518  * is needed.
519  */
520 struct rte_eth_rss_reta_entry64 {
521         uint64_t mask;
522         /**< Mask bits indicate which entries need to be updated/queried. */
523         uint16_t reta[RTE_RETA_GROUP_SIZE];
524         /**< Group of 64 redirection table entries. */
525 };
526
527 /**
528  * This enum indicates the possible number of traffic classes
529  * in DCB configratioins
530  */
531 enum rte_eth_nb_tcs {
532         ETH_4_TCS = 4, /**< 4 TCs with DCB. */
533         ETH_8_TCS = 8  /**< 8 TCs with DCB. */
534 };
535
536 /**
537  * This enum indicates the possible number of queue pools
538  * in VMDQ configurations.
539  */
540 enum rte_eth_nb_pools {
541         ETH_8_POOLS = 8,    /**< 8 VMDq pools. */
542         ETH_16_POOLS = 16,  /**< 16 VMDq pools. */
543         ETH_32_POOLS = 32,  /**< 32 VMDq pools. */
544         ETH_64_POOLS = 64   /**< 64 VMDq pools. */
545 };
546
547 /* This structure may be extended in future. */
548 struct rte_eth_dcb_rx_conf {
549         enum rte_eth_nb_tcs nb_tcs; /**< Possible DCB TCs, 4 or 8 TCs */
550         /** Traffic class each UP mapped to. */
551         uint8_t dcb_tc[ETH_DCB_NUM_USER_PRIORITIES];
552 };
553
554 struct rte_eth_vmdq_dcb_tx_conf {
555         enum rte_eth_nb_pools nb_queue_pools; /**< With DCB, 16 or 32 pools. */
556         /** Traffic class each UP mapped to. */
557         uint8_t dcb_tc[ETH_DCB_NUM_USER_PRIORITIES];
558 };
559
560 struct rte_eth_dcb_tx_conf {
561         enum rte_eth_nb_tcs nb_tcs; /**< Possible DCB TCs, 4 or 8 TCs. */
562         /** Traffic class each UP mapped to. */
563         uint8_t dcb_tc[ETH_DCB_NUM_USER_PRIORITIES];
564 };
565
566 struct rte_eth_vmdq_tx_conf {
567         enum rte_eth_nb_pools nb_queue_pools; /**< VMDq mode, 64 pools. */
568 };
569
570 /**
571  * A structure used to configure the VMDQ+DCB feature
572  * of an Ethernet port.
573  *
574  * Using this feature, packets are routed to a pool of queues, based
575  * on the vlan id in the vlan tag, and then to a specific queue within
576  * that pool, using the user priority vlan tag field.
577  *
578  * A default pool may be used, if desired, to route all traffic which
579  * does not match the vlan filter rules.
580  */
581 struct rte_eth_vmdq_dcb_conf {
582         enum rte_eth_nb_pools nb_queue_pools; /**< With DCB, 16 or 32 pools */
583         uint8_t enable_default_pool; /**< If non-zero, use a default pool */
584         uint8_t default_pool; /**< The default pool, if applicable */
585         uint8_t nb_pool_maps; /**< We can have up to 64 filters/mappings */
586         struct {
587                 uint16_t vlan_id; /**< The vlan id of the received frame */
588                 uint64_t pools;   /**< Bitmask of pools for packet rx */
589         } pool_map[ETH_VMDQ_MAX_VLAN_FILTERS]; /**< VMDq vlan pool maps. */
590         uint8_t dcb_tc[ETH_DCB_NUM_USER_PRIORITIES];
591         /**< Selects a queue in a pool */
592 };
593
594 struct rte_eth_vmdq_rx_conf {
595         enum rte_eth_nb_pools nb_queue_pools; /**< VMDq only mode, 8 or 64 pools */
596         uint8_t enable_default_pool; /**< If non-zero, use a default pool */
597         uint8_t default_pool; /**< The default pool, if applicable */
598         uint8_t enable_loop_back; /**< Enable VT loop back */
599         uint8_t nb_pool_maps; /**< We can have up to 64 filters/mappings */
600         uint32_t rx_mode; /**< Flags from ETH_VMDQ_ACCEPT_* */
601         struct {
602                 uint16_t vlan_id; /**< The vlan id of the received frame */
603                 uint64_t pools;   /**< Bitmask of pools for packet rx */
604         } pool_map[ETH_VMDQ_MAX_VLAN_FILTERS]; /**< VMDq vlan pool maps. */
605 };
606
607 /**
608  * A structure used to configure the TX features of an Ethernet port.
609  */
610 struct rte_eth_txmode {
611         enum rte_eth_tx_mq_mode mq_mode; /**< TX multi-queues mode. */
612
613         /* For i40e specifically */
614         uint16_t pvid;
615         uint8_t hw_vlan_reject_tagged : 1,
616                 /**< If set, reject sending out tagged pkts */
617                 hw_vlan_reject_untagged : 1,
618                 /**< If set, reject sending out untagged pkts */
619                 hw_vlan_insert_pvid : 1;
620                 /**< If set, enable port based VLAN insertion */
621 };
622
623 /**
624  * A structure used to configure an RX ring of an Ethernet port.
625  */
626 struct rte_eth_rxconf {
627         struct rte_eth_thresh rx_thresh; /**< RX ring threshold registers. */
628         uint16_t rx_free_thresh; /**< Drives the freeing of RX descriptors. */
629         uint8_t rx_drop_en; /**< Drop packets if no descriptors are available. */
630         uint8_t rx_deferred_start; /**< Do not start queue with rte_eth_dev_start(). */
631 };
632
633 #define ETH_TXQ_FLAGS_NOMULTSEGS 0x0001 /**< nb_segs=1 for all mbufs */
634 #define ETH_TXQ_FLAGS_NOREFCOUNT 0x0002 /**< refcnt can be ignored */
635 #define ETH_TXQ_FLAGS_NOMULTMEMP 0x0004 /**< all bufs come from same mempool */
636 #define ETH_TXQ_FLAGS_NOVLANOFFL 0x0100 /**< disable VLAN offload */
637 #define ETH_TXQ_FLAGS_NOXSUMSCTP 0x0200 /**< disable SCTP checksum offload */
638 #define ETH_TXQ_FLAGS_NOXSUMUDP  0x0400 /**< disable UDP checksum offload */
639 #define ETH_TXQ_FLAGS_NOXSUMTCP  0x0800 /**< disable TCP checksum offload */
640 #define ETH_TXQ_FLAGS_NOOFFLOADS \
641                 (ETH_TXQ_FLAGS_NOVLANOFFL | ETH_TXQ_FLAGS_NOXSUMSCTP | \
642                  ETH_TXQ_FLAGS_NOXSUMUDP  | ETH_TXQ_FLAGS_NOXSUMTCP)
643 #define ETH_TXQ_FLAGS_NOXSUMS \
644                 (ETH_TXQ_FLAGS_NOXSUMSCTP | ETH_TXQ_FLAGS_NOXSUMUDP | \
645                  ETH_TXQ_FLAGS_NOXSUMTCP)
646 /**
647  * A structure used to configure a TX ring of an Ethernet port.
648  */
649 struct rte_eth_txconf {
650         struct rte_eth_thresh tx_thresh; /**< TX ring threshold registers. */
651         uint16_t tx_rs_thresh; /**< Drives the setting of RS bit on TXDs. */
652         uint16_t tx_free_thresh; /**< Start freeing TX buffers if there are
653                                       less free descriptors than this value. */
654
655         uint32_t txq_flags; /**< Set flags for the Tx queue */
656         uint8_t tx_deferred_start; /**< Do not start queue with rte_eth_dev_start(). */
657 };
658
659 /**
660  * A structure contains information about HW descriptor ring limitations.
661  */
662 struct rte_eth_desc_lim {
663         uint16_t nb_max;   /**< Max allowed number of descriptors. */
664         uint16_t nb_min;   /**< Min allowed number of descriptors. */
665         uint16_t nb_align; /**< Number of descriptors should be aligned to. */
666 };
667
668 /**
669  * This enum indicates the flow control mode
670  */
671 enum rte_eth_fc_mode {
672         RTE_FC_NONE = 0, /**< Disable flow control. */
673         RTE_FC_RX_PAUSE, /**< RX pause frame, enable flowctrl on TX side. */
674         RTE_FC_TX_PAUSE, /**< TX pause frame, enable flowctrl on RX side. */
675         RTE_FC_FULL      /**< Enable flow control on both side. */
676 };
677
678 /**
679  * A structure used to configure Ethernet flow control parameter.
680  * These parameters will be configured into the register of the NIC.
681  * Please refer to the corresponding data sheet for proper value.
682  */
683 struct rte_eth_fc_conf {
684         uint32_t high_water;  /**< High threshold value to trigger XOFF */
685         uint32_t low_water;   /**< Low threshold value to trigger XON */
686         uint16_t pause_time;  /**< Pause quota in the Pause frame */
687         uint16_t send_xon;    /**< Is XON frame need be sent */
688         enum rte_eth_fc_mode mode;  /**< Link flow control mode */
689         uint8_t mac_ctrl_frame_fwd; /**< Forward MAC control frames */
690         uint8_t autoneg;      /**< Use Pause autoneg */
691 };
692
693 /**
694  * A structure used to configure Ethernet priority flow control parameter.
695  * These parameters will be configured into the register of the NIC.
696  * Please refer to the corresponding data sheet for proper value.
697  */
698 struct rte_eth_pfc_conf {
699         struct rte_eth_fc_conf fc; /**< General flow control parameter. */
700         uint8_t priority;          /**< VLAN User Priority. */
701 };
702
703 /**
704  *  Memory space that can be configured to store Flow Director filters
705  *  in the board memory.
706  */
707 enum rte_fdir_pballoc_type {
708         RTE_FDIR_PBALLOC_64K = 0,  /**< 64k. */
709         RTE_FDIR_PBALLOC_128K,     /**< 128k. */
710         RTE_FDIR_PBALLOC_256K,     /**< 256k. */
711 };
712
713 /**
714  *  Select report mode of FDIR hash information in RX descriptors.
715  */
716 enum rte_fdir_status_mode {
717         RTE_FDIR_NO_REPORT_STATUS = 0, /**< Never report FDIR hash. */
718         RTE_FDIR_REPORT_STATUS, /**< Only report FDIR hash for matching pkts. */
719         RTE_FDIR_REPORT_STATUS_ALWAYS, /**< Always report FDIR hash. */
720 };
721
722 /**
723  * A structure used to configure the Flow Director (FDIR) feature
724  * of an Ethernet port.
725  *
726  * If mode is RTE_FDIR_DISABLE, the pballoc value is ignored.
727  */
728 struct rte_fdir_conf {
729         enum rte_fdir_mode mode; /**< Flow Director mode. */
730         enum rte_fdir_pballoc_type pballoc; /**< Space for FDIR filters. */
731         enum rte_fdir_status_mode status;  /**< How to report FDIR hash. */
732         /** RX queue of packets matching a "drop" filter in perfect mode. */
733         uint8_t drop_queue;
734         struct rte_eth_fdir_masks mask;
735         struct rte_eth_fdir_flex_conf flex_conf;
736         /**< Flex payload configuration. */
737 };
738
739 /**
740  * UDP tunneling configuration.
741  */
742 struct rte_eth_udp_tunnel {
743         uint16_t udp_port;
744         uint8_t prot_type;
745 };
746
747 /**
748  * A structure used to enable/disable specific device interrupts.
749  */
750 struct rte_intr_conf {
751         /** enable/disable lsc interrupt. 0 (default) - disable, 1 enable */
752         uint16_t lsc;
753         /** enable/disable rxq interrupt. 0 (default) - disable, 1 enable */
754         uint16_t rxq;
755 };
756
757 /**
758  * A structure used to configure an Ethernet port.
759  * Depending upon the RX multi-queue mode, extra advanced
760  * configuration settings may be needed.
761  */
762 struct rte_eth_conf {
763         uint16_t link_speed;
764         /**< ETH_LINK_SPEED_10[0|00|000], or 0 for autonegotation */
765         uint16_t link_duplex;
766         /**< ETH_LINK_[HALF_DUPLEX|FULL_DUPLEX], or 0 for autonegotation */
767         struct rte_eth_rxmode rxmode; /**< Port RX configuration. */
768         struct rte_eth_txmode txmode; /**< Port TX configuration. */
769         uint32_t lpbk_mode; /**< Loopback operation mode. By default the value
770                                  is 0, meaning the loopback mode is disabled.
771                                  Read the datasheet of given ethernet controller
772                                  for details. The possible values of this field
773                                  are defined in implementation of each driver. */
774         struct {
775                 struct rte_eth_rss_conf rss_conf; /**< Port RSS configuration */
776                 struct rte_eth_vmdq_dcb_conf vmdq_dcb_conf;
777                 /**< Port vmdq+dcb configuration. */
778                 struct rte_eth_dcb_rx_conf dcb_rx_conf;
779                 /**< Port dcb RX configuration. */
780                 struct rte_eth_vmdq_rx_conf vmdq_rx_conf;
781                 /**< Port vmdq RX configuration. */
782         } rx_adv_conf; /**< Port RX filtering configuration (union). */
783         union {
784                 struct rte_eth_vmdq_dcb_tx_conf vmdq_dcb_tx_conf;
785                 /**< Port vmdq+dcb TX configuration. */
786                 struct rte_eth_dcb_tx_conf dcb_tx_conf;
787                 /**< Port dcb TX configuration. */
788                 struct rte_eth_vmdq_tx_conf vmdq_tx_conf;
789                 /**< Port vmdq TX configuration. */
790         } tx_adv_conf; /**< Port TX DCB configuration (union). */
791         /** Currently,Priority Flow Control(PFC) are supported,if DCB with PFC
792             is needed,and the variable must be set ETH_DCB_PFC_SUPPORT. */
793         uint32_t dcb_capability_en;
794         struct rte_fdir_conf fdir_conf; /**< FDIR configuration. */
795         struct rte_intr_conf intr_conf; /**< Interrupt mode configuration. */
796 };
797
798 /**
799  * A structure used to retrieve the contextual information of
800  * an Ethernet device, such as the controlling driver of the device,
801  * its PCI context, etc...
802  */
803
804 /**
805  * RX offload capabilities of a device.
806  */
807 #define DEV_RX_OFFLOAD_VLAN_STRIP  0x00000001
808 #define DEV_RX_OFFLOAD_IPV4_CKSUM  0x00000002
809 #define DEV_RX_OFFLOAD_UDP_CKSUM   0x00000004
810 #define DEV_RX_OFFLOAD_TCP_CKSUM   0x00000008
811 #define DEV_RX_OFFLOAD_TCP_LRO     0x00000010
812 #define DEV_RX_OFFLOAD_QINQ_STRIP  0x00000020
813
814 /**
815  * TX offload capabilities of a device.
816  */
817 #define DEV_TX_OFFLOAD_VLAN_INSERT 0x00000001
818 #define DEV_TX_OFFLOAD_IPV4_CKSUM  0x00000002
819 #define DEV_TX_OFFLOAD_UDP_CKSUM   0x00000004
820 #define DEV_TX_OFFLOAD_TCP_CKSUM   0x00000008
821 #define DEV_TX_OFFLOAD_SCTP_CKSUM  0x00000010
822 #define DEV_TX_OFFLOAD_TCP_TSO     0x00000020
823 #define DEV_TX_OFFLOAD_UDP_TSO     0x00000040
824 #define DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM 0x00000080 /**< Used for tunneling packet. */
825 #define DEV_TX_OFFLOAD_QINQ_INSERT 0x00000100
826
827 struct rte_eth_dev_info {
828         struct rte_pci_device *pci_dev; /**< Device PCI information. */
829         const char *driver_name; /**< Device Driver name. */
830         unsigned int if_index; /**< Index to bound host interface, or 0 if none.
831                 Use if_indextoname() to translate into an interface name. */
832         uint32_t min_rx_bufsize; /**< Minimum size of RX buffer. */
833         uint32_t max_rx_pktlen; /**< Maximum configurable length of RX pkt. */
834         uint16_t max_rx_queues; /**< Maximum number of RX queues. */
835         uint16_t max_tx_queues; /**< Maximum number of TX queues. */
836         uint32_t max_mac_addrs; /**< Maximum number of MAC addresses. */
837         uint32_t max_hash_mac_addrs;
838         /** Maximum number of hash MAC addresses for MTA and UTA. */
839         uint16_t max_vfs; /**< Maximum number of VFs. */
840         uint16_t max_vmdq_pools; /**< Maximum number of VMDq pools. */
841         uint32_t rx_offload_capa; /**< Device RX offload capabilities. */
842         uint32_t tx_offload_capa; /**< Device TX offload capabilities. */
843         uint16_t reta_size;
844         /**< Device redirection table size, the total number of entries. */
845         uint8_t hash_key_size; /**< Hash key size in bytes */
846         /** Bit mask of RSS offloads, the bit offset also means flow type */
847         uint64_t flow_type_rss_offloads;
848         struct rte_eth_rxconf default_rxconf; /**< Default RX configuration */
849         struct rte_eth_txconf default_txconf; /**< Default TX configuration */
850         uint16_t vmdq_queue_base; /**< First queue ID for VMDQ pools. */
851         uint16_t vmdq_queue_num;  /**< Queue number for VMDQ pools. */
852         uint16_t vmdq_pool_base;  /**< First ID of VMDQ pools. */
853         struct rte_eth_desc_lim rx_desc_lim;  /**< RX descriptors limits */
854         struct rte_eth_desc_lim tx_desc_lim;  /**< TX descriptors limits */
855 };
856
857 /**
858  * Ethernet device RX queue information structure.
859  * Used to retieve information about configured queue.
860  */
861 struct rte_eth_rxq_info {
862         struct rte_mempool *mp;     /**< mempool used by that queue. */
863         struct rte_eth_rxconf conf; /**< queue config parameters. */
864         uint8_t scattered_rx;       /**< scattered packets RX supported. */
865         uint16_t nb_desc;           /**< configured number of RXDs. */
866 } __rte_cache_min_aligned;
867
868 /**
869  * Ethernet device TX queue information structure.
870  * Used to retieve information about configured queue.
871  */
872 struct rte_eth_txq_info {
873         struct rte_eth_txconf conf; /**< queue config parameters. */
874         uint16_t nb_desc;           /**< configured number of TXDs. */
875 } __rte_cache_min_aligned;
876
877 /** Maximum name length for extended statistics counters */
878 #define RTE_ETH_XSTATS_NAME_SIZE 64
879
880 /**
881  * An Ethernet device extended statistic structure
882  *
883  * This structure is used by ethdev->eth_xstats_get() to provide
884  * statistics that are not provided in the generic rte_eth_stats
885  * structure.
886  */
887 struct rte_eth_xstats {
888         char name[RTE_ETH_XSTATS_NAME_SIZE];
889         uint64_t value;
890 };
891
892 #define ETH_DCB_NUM_TCS    8
893 #define ETH_MAX_VMDQ_POOL  64
894
895 /**
896  * A structure used to get the information of queue and
897  * TC mapping on both TX and RX paths.
898  */
899 struct rte_eth_dcb_tc_queue_mapping {
900         /** rx queues assigned to tc per Pool */
901         struct {
902                 uint8_t base;
903                 uint8_t nb_queue;
904         } tc_rxq[ETH_MAX_VMDQ_POOL][ETH_DCB_NUM_TCS];
905         /** rx queues assigned to tc per Pool */
906         struct {
907                 uint8_t base;
908                 uint8_t nb_queue;
909         } tc_txq[ETH_MAX_VMDQ_POOL][ETH_DCB_NUM_TCS];
910 };
911
912 /**
913  * A structure used to get the information of DCB.
914  * It includes TC UP mapping and queue TC mapping.
915  */
916 struct rte_eth_dcb_info {
917         uint8_t nb_tcs;        /**< number of TCs */
918         uint8_t prio_tc[ETH_DCB_NUM_USER_PRIORITIES]; /**< Priority to tc */
919         uint8_t tc_bws[ETH_DCB_NUM_TCS]; /**< TX BW percentage for each TC */
920         /** rx queues assigned to tc */
921         struct rte_eth_dcb_tc_queue_mapping tc_queue;
922 };
923
924 /**
925  * RX/TX queue states
926  */
927 #define RTE_ETH_QUEUE_STATE_STOPPED 0
928 #define RTE_ETH_QUEUE_STATE_STARTED 1
929
930 struct rte_eth_dev;
931
932 struct rte_eth_dev_callback;
933 /** @internal Structure to keep track of registered callbacks */
934 TAILQ_HEAD(rte_eth_dev_cb_list, rte_eth_dev_callback);
935
936
937 #ifdef RTE_LIBRTE_ETHDEV_DEBUG
938 #define RTE_PMD_DEBUG_TRACE(...) \
939         rte_pmd_debug_trace(__func__, __VA_ARGS__)
940 #else
941 #define RTE_PMD_DEBUG_TRACE(...)
942 #endif
943
944
945 /* Macros to check for valid port */
946 #define RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, retval) do { \
947         if (!rte_eth_dev_is_valid_port(port_id)) { \
948                 RTE_PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id); \
949                 return retval; \
950         } \
951 } while (0)
952
953 #define RTE_ETH_VALID_PORTID_OR_RET(port_id) do { \
954         if (!rte_eth_dev_is_valid_port(port_id)) { \
955                 RTE_PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id); \
956                 return; \
957         } \
958 } while (0)
959
960 /*
961  * Definitions of all functions exported by an Ethernet driver through the
962  * the generic structure of type *eth_dev_ops* supplied in the *rte_eth_dev*
963  * structure associated with an Ethernet device.
964  */
965
966 typedef int  (*eth_dev_configure_t)(struct rte_eth_dev *dev);
967 /**< @internal Ethernet device configuration. */
968
969 typedef int  (*eth_dev_start_t)(struct rte_eth_dev *dev);
970 /**< @internal Function used to start a configured Ethernet device. */
971
972 typedef void (*eth_dev_stop_t)(struct rte_eth_dev *dev);
973 /**< @internal Function used to stop a configured Ethernet device. */
974
975 typedef int  (*eth_dev_set_link_up_t)(struct rte_eth_dev *dev);
976 /**< @internal Function used to link up a configured Ethernet device. */
977
978 typedef int  (*eth_dev_set_link_down_t)(struct rte_eth_dev *dev);
979 /**< @internal Function used to link down a configured Ethernet device. */
980
981 typedef void (*eth_dev_close_t)(struct rte_eth_dev *dev);
982 /**< @internal Function used to close a configured Ethernet device. */
983
984 typedef void (*eth_promiscuous_enable_t)(struct rte_eth_dev *dev);
985 /**< @internal Function used to enable the RX promiscuous mode of an Ethernet device. */
986
987 typedef void (*eth_promiscuous_disable_t)(struct rte_eth_dev *dev);
988 /**< @internal Function used to disable the RX promiscuous mode of an Ethernet device. */
989
990 typedef void (*eth_allmulticast_enable_t)(struct rte_eth_dev *dev);
991 /**< @internal Enable the receipt of all multicast packets by an Ethernet device. */
992
993 typedef void (*eth_allmulticast_disable_t)(struct rte_eth_dev *dev);
994 /**< @internal Disable the receipt of all multicast packets by an Ethernet device. */
995
996 typedef int (*eth_link_update_t)(struct rte_eth_dev *dev,
997                                 int wait_to_complete);
998 /**< @internal Get link speed, duplex mode and state (up/down) of an Ethernet device. */
999
1000 typedef void (*eth_stats_get_t)(struct rte_eth_dev *dev,
1001                                 struct rte_eth_stats *igb_stats);
1002 /**< @internal Get global I/O statistics of an Ethernet device. */
1003
1004 typedef void (*eth_stats_reset_t)(struct rte_eth_dev *dev);
1005 /**< @internal Reset global I/O statistics of an Ethernet device to 0. */
1006
1007 typedef int (*eth_xstats_get_t)(struct rte_eth_dev *dev,
1008         struct rte_eth_xstats *stats, unsigned n);
1009 /**< @internal Get extended stats of an Ethernet device. */
1010
1011 typedef void (*eth_xstats_reset_t)(struct rte_eth_dev *dev);
1012 /**< @internal Reset extended stats of an Ethernet device. */
1013
1014 typedef int (*eth_queue_stats_mapping_set_t)(struct rte_eth_dev *dev,
1015                                              uint16_t queue_id,
1016                                              uint8_t stat_idx,
1017                                              uint8_t is_rx);
1018 /**< @internal Set a queue statistics mapping for a tx/rx queue of an Ethernet device. */
1019
1020 typedef void (*eth_dev_infos_get_t)(struct rte_eth_dev *dev,
1021                                     struct rte_eth_dev_info *dev_info);
1022 /**< @internal Get specific informations of an Ethernet device. */
1023
1024 typedef int (*eth_queue_start_t)(struct rte_eth_dev *dev,
1025                                     uint16_t queue_id);
1026 /**< @internal Start rx and tx of a queue of an Ethernet device. */
1027
1028 typedef int (*eth_queue_stop_t)(struct rte_eth_dev *dev,
1029                                     uint16_t queue_id);
1030 /**< @internal Stop rx and tx of a queue of an Ethernet device. */
1031
1032 typedef int (*eth_rx_queue_setup_t)(struct rte_eth_dev *dev,
1033                                     uint16_t rx_queue_id,
1034                                     uint16_t nb_rx_desc,
1035                                     unsigned int socket_id,
1036                                     const struct rte_eth_rxconf *rx_conf,
1037                                     struct rte_mempool *mb_pool);
1038 /**< @internal Set up a receive queue of an Ethernet device. */
1039
1040 typedef int (*eth_tx_queue_setup_t)(struct rte_eth_dev *dev,
1041                                     uint16_t tx_queue_id,
1042                                     uint16_t nb_tx_desc,
1043                                     unsigned int socket_id,
1044                                     const struct rte_eth_txconf *tx_conf);
1045 /**< @internal Setup a transmit queue of an Ethernet device. */
1046
1047 typedef int (*eth_rx_enable_intr_t)(struct rte_eth_dev *dev,
1048                                     uint16_t rx_queue_id);
1049 /**< @internal Enable interrupt of a receive queue of an Ethernet device. */
1050
1051 typedef int (*eth_rx_disable_intr_t)(struct rte_eth_dev *dev,
1052                                     uint16_t rx_queue_id);
1053 /**< @internal Disable interrupt of a receive queue of an Ethernet device. */
1054
1055 typedef void (*eth_queue_release_t)(void *queue);
1056 /**< @internal Release memory resources allocated by given RX/TX queue. */
1057
1058 typedef uint32_t (*eth_rx_queue_count_t)(struct rte_eth_dev *dev,
1059                                          uint16_t rx_queue_id);
1060 /**< @internal Get number of available descriptors on a receive queue of an Ethernet device. */
1061
1062 typedef int (*eth_rx_descriptor_done_t)(void *rxq, uint16_t offset);
1063 /**< @internal Check DD bit of specific RX descriptor */
1064
1065 typedef void (*eth_rxq_info_get_t)(struct rte_eth_dev *dev,
1066         uint16_t rx_queue_id, struct rte_eth_rxq_info *qinfo);
1067
1068 typedef void (*eth_txq_info_get_t)(struct rte_eth_dev *dev,
1069         uint16_t tx_queue_id, struct rte_eth_txq_info *qinfo);
1070
1071 typedef int (*mtu_set_t)(struct rte_eth_dev *dev, uint16_t mtu);
1072 /**< @internal Set MTU. */
1073
1074 typedef int (*vlan_filter_set_t)(struct rte_eth_dev *dev,
1075                                   uint16_t vlan_id,
1076                                   int on);
1077 /**< @internal filtering of a VLAN Tag Identifier by an Ethernet device. */
1078
1079 typedef void (*vlan_tpid_set_t)(struct rte_eth_dev *dev,
1080                                   uint16_t tpid);
1081 /**< @internal set the outer VLAN-TPID by an Ethernet device. */
1082
1083 typedef void (*vlan_offload_set_t)(struct rte_eth_dev *dev, int mask);
1084 /**< @internal set VLAN offload function by an Ethernet device. */
1085
1086 typedef int (*vlan_pvid_set_t)(struct rte_eth_dev *dev,
1087                                uint16_t vlan_id,
1088                                int on);
1089 /**< @internal set port based TX VLAN insertion by an Ethernet device. */
1090
1091 typedef void (*vlan_strip_queue_set_t)(struct rte_eth_dev *dev,
1092                                   uint16_t rx_queue_id,
1093                                   int on);
1094 /**< @internal VLAN stripping enable/disable by an queue of Ethernet device. */
1095
1096 typedef uint16_t (*eth_rx_burst_t)(void *rxq,
1097                                    struct rte_mbuf **rx_pkts,
1098                                    uint16_t nb_pkts);
1099 /**< @internal Retrieve input packets from a receive queue of an Ethernet device. */
1100
1101 typedef uint16_t (*eth_tx_burst_t)(void *txq,
1102                                    struct rte_mbuf **tx_pkts,
1103                                    uint16_t nb_pkts);
1104 /**< @internal Send output packets on a transmit queue of an Ethernet device. */
1105
1106 typedef int (*flow_ctrl_get_t)(struct rte_eth_dev *dev,
1107                                struct rte_eth_fc_conf *fc_conf);
1108 /**< @internal Get current flow control parameter on an Ethernet device */
1109
1110 typedef int (*flow_ctrl_set_t)(struct rte_eth_dev *dev,
1111                                struct rte_eth_fc_conf *fc_conf);
1112 /**< @internal Setup flow control parameter on an Ethernet device */
1113
1114 typedef int (*priority_flow_ctrl_set_t)(struct rte_eth_dev *dev,
1115                                 struct rte_eth_pfc_conf *pfc_conf);
1116 /**< @internal Setup priority flow control parameter on an Ethernet device */
1117
1118 typedef int (*reta_update_t)(struct rte_eth_dev *dev,
1119                              struct rte_eth_rss_reta_entry64 *reta_conf,
1120                              uint16_t reta_size);
1121 /**< @internal Update RSS redirection table on an Ethernet device */
1122
1123 typedef int (*reta_query_t)(struct rte_eth_dev *dev,
1124                             struct rte_eth_rss_reta_entry64 *reta_conf,
1125                             uint16_t reta_size);
1126 /**< @internal Query RSS redirection table on an Ethernet device */
1127
1128 typedef int (*rss_hash_update_t)(struct rte_eth_dev *dev,
1129                                  struct rte_eth_rss_conf *rss_conf);
1130 /**< @internal Update RSS hash configuration of an Ethernet device */
1131
1132 typedef int (*rss_hash_conf_get_t)(struct rte_eth_dev *dev,
1133                                    struct rte_eth_rss_conf *rss_conf);
1134 /**< @internal Get current RSS hash configuration of an Ethernet device */
1135
1136 typedef int (*eth_dev_led_on_t)(struct rte_eth_dev *dev);
1137 /**< @internal Turn on SW controllable LED on an Ethernet device */
1138
1139 typedef int (*eth_dev_led_off_t)(struct rte_eth_dev *dev);
1140 /**< @internal Turn off SW controllable LED on an Ethernet device */
1141
1142 typedef void (*eth_mac_addr_remove_t)(struct rte_eth_dev *dev, uint32_t index);
1143 /**< @internal Remove MAC address from receive address register */
1144
1145 typedef void (*eth_mac_addr_add_t)(struct rte_eth_dev *dev,
1146                                   struct ether_addr *mac_addr,
1147                                   uint32_t index,
1148                                   uint32_t vmdq);
1149 /**< @internal Set a MAC address into Receive Address Address Register */
1150
1151 typedef void (*eth_mac_addr_set_t)(struct rte_eth_dev *dev,
1152                                   struct ether_addr *mac_addr);
1153 /**< @internal Set a MAC address into Receive Address Address Register */
1154
1155 typedef int (*eth_uc_hash_table_set_t)(struct rte_eth_dev *dev,
1156                                   struct ether_addr *mac_addr,
1157                                   uint8_t on);
1158 /**< @internal Set a Unicast Hash bitmap */
1159
1160 typedef int (*eth_uc_all_hash_table_set_t)(struct rte_eth_dev *dev,
1161                                   uint8_t on);
1162 /**< @internal Set all Unicast Hash bitmap */
1163
1164 typedef int (*eth_set_vf_rx_mode_t)(struct rte_eth_dev *dev,
1165                                   uint16_t vf,
1166                                   uint16_t rx_mode,
1167                                   uint8_t on);
1168 /**< @internal Set a VF receive mode */
1169
1170 typedef int (*eth_set_vf_rx_t)(struct rte_eth_dev *dev,
1171                                 uint16_t vf,
1172                                 uint8_t on);
1173 /**< @internal Set a VF receive  mode */
1174
1175 typedef int (*eth_set_vf_tx_t)(struct rte_eth_dev *dev,
1176                                 uint16_t vf,
1177                                 uint8_t on);
1178 /**< @internal Enable or disable a VF transmit   */
1179
1180 typedef int (*eth_set_vf_vlan_filter_t)(struct rte_eth_dev *dev,
1181                                   uint16_t vlan,
1182                                   uint64_t vf_mask,
1183                                   uint8_t vlan_on);
1184 /**< @internal Set VF VLAN pool filter */
1185
1186 typedef int (*eth_set_queue_rate_limit_t)(struct rte_eth_dev *dev,
1187                                 uint16_t queue_idx,
1188                                 uint16_t tx_rate);
1189 /**< @internal Set queue TX rate */
1190
1191 typedef int (*eth_set_vf_rate_limit_t)(struct rte_eth_dev *dev,
1192                                 uint16_t vf,
1193                                 uint16_t tx_rate,
1194                                 uint64_t q_msk);
1195 /**< @internal Set VF TX rate */
1196
1197 typedef int (*eth_mirror_rule_set_t)(struct rte_eth_dev *dev,
1198                                   struct rte_eth_mirror_conf *mirror_conf,
1199                                   uint8_t rule_id,
1200                                   uint8_t on);
1201 /**< @internal Add a traffic mirroring rule on an Ethernet device */
1202
1203 typedef int (*eth_mirror_rule_reset_t)(struct rte_eth_dev *dev,
1204                                   uint8_t rule_id);
1205 /**< @internal Remove a traffic mirroring rule on an Ethernet device */
1206
1207 typedef int (*eth_udp_tunnel_add_t)(struct rte_eth_dev *dev,
1208                                     struct rte_eth_udp_tunnel *tunnel_udp);
1209 /**< @internal Add tunneling UDP info */
1210
1211 typedef int (*eth_udp_tunnel_del_t)(struct rte_eth_dev *dev,
1212                                     struct rte_eth_udp_tunnel *tunnel_udp);
1213 /**< @internal Delete tunneling UDP info */
1214
1215 typedef int (*eth_set_mc_addr_list_t)(struct rte_eth_dev *dev,
1216                                       struct ether_addr *mc_addr_set,
1217                                       uint32_t nb_mc_addr);
1218 /**< @internal set the list of multicast addresses on an Ethernet device */
1219
1220 typedef int (*eth_timesync_enable_t)(struct rte_eth_dev *dev);
1221 /**< @internal Function used to enable IEEE1588/802.1AS timestamping. */
1222
1223 typedef int (*eth_timesync_disable_t)(struct rte_eth_dev *dev);
1224 /**< @internal Function used to disable IEEE1588/802.1AS timestamping. */
1225
1226 typedef int (*eth_timesync_read_rx_timestamp_t)(struct rte_eth_dev *dev,
1227                                                 struct timespec *timestamp,
1228                                                 uint32_t flags);
1229 /**< @internal Function used to read an RX IEEE1588/802.1AS timestamp. */
1230
1231 typedef int (*eth_timesync_read_tx_timestamp_t)(struct rte_eth_dev *dev,
1232                                                 struct timespec *timestamp);
1233 /**< @internal Function used to read a TX IEEE1588/802.1AS timestamp. */
1234
1235 typedef int (*eth_timesync_adjust_time)(struct rte_eth_dev *dev, int64_t);
1236 /**< @internal Function used to adjust the device clock */
1237
1238 typedef int (*eth_timesync_read_time)(struct rte_eth_dev *dev,
1239                                       struct timespec *timestamp);
1240 /**< @internal Function used to get time from the device clock. */
1241
1242 typedef int (*eth_timesync_write_time)(struct rte_eth_dev *dev,
1243                                        const struct timespec *timestamp);
1244 /**< @internal Function used to get time from the device clock */
1245
1246 typedef int (*eth_get_reg_length_t)(struct rte_eth_dev *dev);
1247 /**< @internal Retrieve device register count  */
1248
1249 typedef int (*eth_get_reg_t)(struct rte_eth_dev *dev,
1250                                 struct rte_dev_reg_info *info);
1251 /**< @internal Retrieve registers  */
1252
1253 typedef int (*eth_get_eeprom_length_t)(struct rte_eth_dev *dev);
1254 /**< @internal Retrieve eeprom size  */
1255
1256 typedef int (*eth_get_eeprom_t)(struct rte_eth_dev *dev,
1257                                 struct rte_dev_eeprom_info *info);
1258 /**< @internal Retrieve eeprom data  */
1259
1260 typedef int (*eth_set_eeprom_t)(struct rte_eth_dev *dev,
1261                                 struct rte_dev_eeprom_info *info);
1262 /**< @internal Program eeprom data  */
1263
1264 #ifdef RTE_NIC_BYPASS
1265
1266 enum {
1267         RTE_BYPASS_MODE_NONE,
1268         RTE_BYPASS_MODE_NORMAL,
1269         RTE_BYPASS_MODE_BYPASS,
1270         RTE_BYPASS_MODE_ISOLATE,
1271         RTE_BYPASS_MODE_NUM,
1272 };
1273
1274 #define RTE_BYPASS_MODE_VALID(x)        \
1275         ((x) > RTE_BYPASS_MODE_NONE && (x) < RTE_BYPASS_MODE_NUM)
1276
1277 enum {
1278         RTE_BYPASS_EVENT_NONE,
1279         RTE_BYPASS_EVENT_START,
1280         RTE_BYPASS_EVENT_OS_ON = RTE_BYPASS_EVENT_START,
1281         RTE_BYPASS_EVENT_POWER_ON,
1282         RTE_BYPASS_EVENT_OS_OFF,
1283         RTE_BYPASS_EVENT_POWER_OFF,
1284         RTE_BYPASS_EVENT_TIMEOUT,
1285         RTE_BYPASS_EVENT_NUM
1286 };
1287
1288 #define RTE_BYPASS_EVENT_VALID(x)       \
1289         ((x) > RTE_BYPASS_EVENT_NONE && (x) < RTE_BYPASS_MODE_NUM)
1290
1291 enum {
1292         RTE_BYPASS_TMT_OFF,     /* timeout disabled. */
1293         RTE_BYPASS_TMT_1_5_SEC, /* timeout for 1.5 seconds */
1294         RTE_BYPASS_TMT_2_SEC,   /* timeout for 2 seconds */
1295         RTE_BYPASS_TMT_3_SEC,   /* timeout for 3 seconds */
1296         RTE_BYPASS_TMT_4_SEC,   /* timeout for 4 seconds */
1297         RTE_BYPASS_TMT_8_SEC,   /* timeout for 8 seconds */
1298         RTE_BYPASS_TMT_16_SEC,  /* timeout for 16 seconds */
1299         RTE_BYPASS_TMT_32_SEC,  /* timeout for 32 seconds */
1300         RTE_BYPASS_TMT_NUM
1301 };
1302
1303 #define RTE_BYPASS_TMT_VALID(x) \
1304         ((x) == RTE_BYPASS_TMT_OFF || \
1305         ((x) > RTE_BYPASS_TMT_OFF && (x) < RTE_BYPASS_TMT_NUM))
1306
1307 typedef void (*bypass_init_t)(struct rte_eth_dev *dev);
1308 typedef int32_t (*bypass_state_set_t)(struct rte_eth_dev *dev, uint32_t *new_state);
1309 typedef int32_t (*bypass_state_show_t)(struct rte_eth_dev *dev, uint32_t *state);
1310 typedef int32_t (*bypass_event_set_t)(struct rte_eth_dev *dev, uint32_t state, uint32_t event);
1311 typedef int32_t (*bypass_event_show_t)(struct rte_eth_dev *dev, uint32_t event_shift, uint32_t *event);
1312 typedef int32_t (*bypass_wd_timeout_set_t)(struct rte_eth_dev *dev, uint32_t timeout);
1313 typedef int32_t (*bypass_wd_timeout_show_t)(struct rte_eth_dev *dev, uint32_t *wd_timeout);
1314 typedef int32_t (*bypass_ver_show_t)(struct rte_eth_dev *dev, uint32_t *ver);
1315 typedef int32_t (*bypass_wd_reset_t)(struct rte_eth_dev *dev);
1316 #endif
1317
1318 typedef int (*eth_filter_ctrl_t)(struct rte_eth_dev *dev,
1319                                  enum rte_filter_type filter_type,
1320                                  enum rte_filter_op filter_op,
1321                                  void *arg);
1322 /**< @internal Take operations to assigned filter type on an Ethernet device */
1323
1324 typedef int (*eth_get_dcb_info)(struct rte_eth_dev *dev,
1325                                  struct rte_eth_dcb_info *dcb_info);
1326 /**< @internal Get dcb information on an Ethernet device */
1327
1328 /**
1329  * @internal A structure containing the functions exported by an Ethernet driver.
1330  */
1331 struct eth_dev_ops {
1332         eth_dev_configure_t        dev_configure; /**< Configure device. */
1333         eth_dev_start_t            dev_start;     /**< Start device. */
1334         eth_dev_stop_t             dev_stop;      /**< Stop device. */
1335         eth_dev_set_link_up_t      dev_set_link_up;   /**< Device link up. */
1336         eth_dev_set_link_down_t    dev_set_link_down; /**< Device link down. */
1337         eth_dev_close_t            dev_close;     /**< Close device. */
1338         eth_promiscuous_enable_t   promiscuous_enable; /**< Promiscuous ON. */
1339         eth_promiscuous_disable_t  promiscuous_disable;/**< Promiscuous OFF. */
1340         eth_allmulticast_enable_t  allmulticast_enable;/**< RX multicast ON. */
1341         eth_allmulticast_disable_t allmulticast_disable;/**< RX multicast OF. */
1342         eth_link_update_t          link_update;   /**< Get device link state. */
1343         eth_stats_get_t            stats_get;     /**< Get generic device statistics. */
1344         eth_stats_reset_t          stats_reset;   /**< Reset generic device statistics. */
1345         eth_xstats_get_t           xstats_get;    /**< Get extended device statistics. */
1346         eth_xstats_reset_t         xstats_reset;  /**< Reset extended device statistics. */
1347         eth_queue_stats_mapping_set_t queue_stats_mapping_set;
1348         /**< Configure per queue stat counter mapping. */
1349         eth_dev_infos_get_t        dev_infos_get; /**< Get device info. */
1350         mtu_set_t                  mtu_set; /**< Set MTU. */
1351         vlan_filter_set_t          vlan_filter_set;  /**< Filter VLAN Setup. */
1352         vlan_tpid_set_t            vlan_tpid_set;      /**< Outer VLAN TPID Setup. */
1353         vlan_strip_queue_set_t     vlan_strip_queue_set; /**< VLAN Stripping on queue. */
1354         vlan_offload_set_t         vlan_offload_set; /**< Set VLAN Offload. */
1355         vlan_pvid_set_t            vlan_pvid_set; /**< Set port based TX VLAN insertion */
1356         eth_queue_start_t          rx_queue_start;/**< Start RX for a queue.*/
1357         eth_queue_stop_t           rx_queue_stop;/**< Stop RX for a queue.*/
1358         eth_queue_start_t          tx_queue_start;/**< Start TX for a queue.*/
1359         eth_queue_stop_t           tx_queue_stop;/**< Stop TX for a queue.*/
1360         eth_rx_queue_setup_t       rx_queue_setup;/**< Set up device RX queue.*/
1361         eth_queue_release_t        rx_queue_release;/**< Release RX queue.*/
1362         eth_rx_queue_count_t       rx_queue_count; /**< Get Rx queue count. */
1363         eth_rx_descriptor_done_t   rx_descriptor_done;  /**< Check rxd DD bit */
1364         /**< Enable Rx queue interrupt. */
1365         eth_rx_enable_intr_t       rx_queue_intr_enable;
1366         /**< Disable Rx queue interrupt.*/
1367         eth_rx_disable_intr_t      rx_queue_intr_disable;
1368         eth_tx_queue_setup_t       tx_queue_setup;/**< Set up device TX queue.*/
1369         eth_queue_release_t        tx_queue_release;/**< Release TX queue.*/
1370         eth_dev_led_on_t           dev_led_on;    /**< Turn on LED. */
1371         eth_dev_led_off_t          dev_led_off;   /**< Turn off LED. */
1372         flow_ctrl_get_t            flow_ctrl_get; /**< Get flow control. */
1373         flow_ctrl_set_t            flow_ctrl_set; /**< Setup flow control. */
1374         priority_flow_ctrl_set_t   priority_flow_ctrl_set; /**< Setup priority flow control.*/
1375         eth_mac_addr_remove_t      mac_addr_remove; /**< Remove MAC address */
1376         eth_mac_addr_add_t         mac_addr_add;  /**< Add a MAC address */
1377         eth_mac_addr_set_t         mac_addr_set;  /**< Set a MAC address */
1378         eth_uc_hash_table_set_t    uc_hash_table_set;  /**< Set Unicast Table Array */
1379         eth_uc_all_hash_table_set_t uc_all_hash_table_set;  /**< Set Unicast hash bitmap */
1380         eth_mirror_rule_set_t      mirror_rule_set;  /**< Add a traffic mirror rule.*/
1381         eth_mirror_rule_reset_t    mirror_rule_reset;  /**< reset a traffic mirror rule.*/
1382         eth_set_vf_rx_mode_t       set_vf_rx_mode;   /**< Set VF RX mode */
1383         eth_set_vf_rx_t            set_vf_rx;  /**< enable/disable a VF receive */
1384         eth_set_vf_tx_t            set_vf_tx;  /**< enable/disable a VF transmit */
1385         eth_set_vf_vlan_filter_t   set_vf_vlan_filter;  /**< Set VF VLAN filter */
1386         eth_udp_tunnel_add_t       udp_tunnel_add;
1387         eth_udp_tunnel_del_t       udp_tunnel_del;
1388         eth_set_queue_rate_limit_t set_queue_rate_limit;   /**< Set queue rate limit */
1389         eth_set_vf_rate_limit_t    set_vf_rate_limit;   /**< Set VF rate limit */
1390         /** Update redirection table. */
1391         reta_update_t reta_update;
1392         /** Query redirection table. */
1393         reta_query_t reta_query;
1394
1395         eth_get_reg_length_t get_reg_length;
1396         /**< Get # of registers */
1397         eth_get_reg_t get_reg;
1398         /**< Get registers */
1399         eth_get_eeprom_length_t get_eeprom_length;
1400         /**< Get eeprom length */
1401         eth_get_eeprom_t get_eeprom;
1402         /**< Get eeprom data */
1403         eth_set_eeprom_t set_eeprom;
1404         /**< Set eeprom */
1405   /* bypass control */
1406 #ifdef RTE_NIC_BYPASS
1407   bypass_init_t bypass_init;
1408   bypass_state_set_t bypass_state_set;
1409   bypass_state_show_t bypass_state_show;
1410   bypass_event_set_t bypass_event_set;
1411   bypass_event_show_t bypass_event_show;
1412   bypass_wd_timeout_set_t bypass_wd_timeout_set;
1413   bypass_wd_timeout_show_t bypass_wd_timeout_show;
1414   bypass_ver_show_t bypass_ver_show;
1415   bypass_wd_reset_t bypass_wd_reset;
1416 #endif
1417
1418         /** Configure RSS hash protocols. */
1419         rss_hash_update_t rss_hash_update;
1420         /** Get current RSS hash configuration. */
1421         rss_hash_conf_get_t rss_hash_conf_get;
1422         eth_filter_ctrl_t              filter_ctrl;
1423         /**< common filter control. */
1424         eth_set_mc_addr_list_t set_mc_addr_list; /**< set list of mcast addrs */
1425         eth_rxq_info_get_t rxq_info_get;
1426         /**< retrieve RX queue information. */
1427         eth_txq_info_get_t txq_info_get;
1428         /**< retrieve TX queue information. */
1429         /** Turn IEEE1588/802.1AS timestamping on. */
1430         eth_timesync_enable_t timesync_enable;
1431         /** Turn IEEE1588/802.1AS timestamping off. */
1432         eth_timesync_disable_t timesync_disable;
1433         /** Read the IEEE1588/802.1AS RX timestamp. */
1434         eth_timesync_read_rx_timestamp_t timesync_read_rx_timestamp;
1435         /** Read the IEEE1588/802.1AS TX timestamp. */
1436         eth_timesync_read_tx_timestamp_t timesync_read_tx_timestamp;
1437
1438         /** Get DCB information */
1439         eth_get_dcb_info get_dcb_info;
1440         /** Adjust the device clock.*/
1441         eth_timesync_adjust_time timesync_adjust_time;
1442         /** Get the device clock time. */
1443         eth_timesync_read_time timesync_read_time;
1444         /** Set the device clock time. */
1445         eth_timesync_write_time timesync_write_time;
1446 };
1447
1448 /**
1449  * Function type used for RX packet processing packet callbacks.
1450  *
1451  * The callback function is called on RX with a burst of packets that have
1452  * been received on the given port and queue.
1453  *
1454  * @param port
1455  *   The Ethernet port on which RX is being performed.
1456  * @param queue
1457  *   The queue on the Ethernet port which is being used to receive the packets.
1458  * @param pkts
1459  *   The burst of packets that have just been received.
1460  * @param nb_pkts
1461  *   The number of packets in the burst pointed to by "pkts".
1462  * @param max_pkts
1463  *   The max number of packets that can be stored in the "pkts" array.
1464  * @param user_param
1465  *   The arbitrary user parameter passed in by the application when the callback
1466  *   was originally configured.
1467  * @return
1468  *   The number of packets returned to the user.
1469  */
1470 typedef uint16_t (*rte_rx_callback_fn)(uint8_t port, uint16_t queue,
1471         struct rte_mbuf *pkts[], uint16_t nb_pkts, uint16_t max_pkts,
1472         void *user_param);
1473
1474 /**
1475  * Function type used for TX packet processing packet callbacks.
1476  *
1477  * The callback function is called on TX with a burst of packets immediately
1478  * before the packets are put onto the hardware queue for transmission.
1479  *
1480  * @param port
1481  *   The Ethernet port on which TX is being performed.
1482  * @param queue
1483  *   The queue on the Ethernet port which is being used to transmit the packets.
1484  * @param pkts
1485  *   The burst of packets that are about to be transmitted.
1486  * @param nb_pkts
1487  *   The number of packets in the burst pointed to by "pkts".
1488  * @param user_param
1489  *   The arbitrary user parameter passed in by the application when the callback
1490  *   was originally configured.
1491  * @return
1492  *   The number of packets to be written to the NIC.
1493  */
1494 typedef uint16_t (*rte_tx_callback_fn)(uint8_t port, uint16_t queue,
1495         struct rte_mbuf *pkts[], uint16_t nb_pkts, void *user_param);
1496
1497 /**
1498  * @internal
1499  * Structure used to hold information about the callbacks to be called for a
1500  * queue on RX and TX.
1501  */
1502 struct rte_eth_rxtx_callback {
1503         struct rte_eth_rxtx_callback *next;
1504         union{
1505                 rte_rx_callback_fn rx;
1506                 rte_tx_callback_fn tx;
1507         } fn;
1508         void *param;
1509 };
1510
1511 /**
1512  * The eth device type.
1513  */
1514 enum rte_eth_dev_type {
1515         RTE_ETH_DEV_UNKNOWN,    /**< unknown device type */
1516         RTE_ETH_DEV_PCI,
1517                 /**< Physical function and Virtual function of PCI devices */
1518         RTE_ETH_DEV_VIRTUAL,    /**< non hardware device */
1519         RTE_ETH_DEV_MAX         /**< max value of this enum */
1520 };
1521
1522 /**
1523  * @internal
1524  * The generic data structure associated with each ethernet device.
1525  *
1526  * Pointers to burst-oriented packet receive and transmit functions are
1527  * located at the beginning of the structure, along with the pointer to
1528  * where all the data elements for the particular device are stored in shared
1529  * memory. This split allows the function pointer and driver data to be per-
1530  * process, while the actual configuration data for the device is shared.
1531  */
1532 struct rte_eth_dev {
1533         eth_rx_burst_t rx_pkt_burst; /**< Pointer to PMD receive function. */
1534         eth_tx_burst_t tx_pkt_burst; /**< Pointer to PMD transmit function. */
1535         struct rte_eth_dev_data *data;  /**< Pointer to device data */
1536         const struct eth_driver *driver;/**< Driver for this device */
1537         const struct eth_dev_ops *dev_ops; /**< Functions exported by PMD */
1538         struct rte_pci_device *pci_dev; /**< PCI info. supplied by probing */
1539         /** User application callbacks for NIC interrupts */
1540         struct rte_eth_dev_cb_list link_intr_cbs;
1541         /**
1542          * User-supplied functions called from rx_burst to post-process
1543          * received packets before passing them to the user
1544          */
1545         struct rte_eth_rxtx_callback *post_rx_burst_cbs[RTE_MAX_QUEUES_PER_PORT];
1546         /**
1547          * User-supplied functions called from tx_burst to pre-process
1548          * received packets before passing them to the driver for transmission.
1549          */
1550         struct rte_eth_rxtx_callback *pre_tx_burst_cbs[RTE_MAX_QUEUES_PER_PORT];
1551         uint8_t attached; /**< Flag indicating the port is attached */
1552         enum rte_eth_dev_type dev_type; /**< Flag indicating the device type */
1553 };
1554
1555 struct rte_eth_dev_sriov {
1556         uint8_t active;               /**< SRIOV is active with 16, 32 or 64 pools */
1557         uint8_t nb_q_per_pool;        /**< rx queue number per pool */
1558         uint16_t def_vmdq_idx;        /**< Default pool num used for PF */
1559         uint16_t def_pool_q_idx;      /**< Default pool queue start reg index */
1560 };
1561 #define RTE_ETH_DEV_SRIOV(dev)         ((dev)->data->sriov)
1562
1563 #define RTE_ETH_NAME_MAX_LEN (32)
1564
1565 /**
1566  * @internal
1567  * The data part, with no function pointers, associated with each ethernet device.
1568  *
1569  * This structure is safe to place in shared memory to be common among different
1570  * processes in a multi-process configuration.
1571  */
1572 struct rte_eth_dev_data {
1573         char name[RTE_ETH_NAME_MAX_LEN]; /**< Unique identifier name */
1574
1575         void **rx_queues; /**< Array of pointers to RX queues. */
1576         void **tx_queues; /**< Array of pointers to TX queues. */
1577         uint16_t nb_rx_queues; /**< Number of RX queues. */
1578         uint16_t nb_tx_queues; /**< Number of TX queues. */
1579
1580         struct rte_eth_dev_sriov sriov;    /**< SRIOV data */
1581
1582         void *dev_private;              /**< PMD-specific private data */
1583
1584         struct rte_eth_link dev_link;
1585         /**< Link-level information & status */
1586
1587         struct rte_eth_conf dev_conf;   /**< Configuration applied to device. */
1588         uint16_t mtu;                   /**< Maximum Transmission Unit. */
1589
1590         uint32_t min_rx_buf_size;
1591         /**< Common rx buffer size handled by all queues */
1592
1593         uint64_t rx_mbuf_alloc_failed; /**< RX ring mbuf allocation failures. */
1594         struct ether_addr* mac_addrs;/**< Device Ethernet Link address. */
1595         uint64_t mac_pool_sel[ETH_NUM_RECEIVE_MAC_ADDR];
1596         /** bitmap array of associating Ethernet MAC addresses to pools */
1597         struct ether_addr* hash_mac_addrs;
1598         /** Device Ethernet MAC addresses of hash filtering. */
1599         uint8_t port_id;           /**< Device [external] port identifier. */
1600         uint8_t promiscuous   : 1, /**< RX promiscuous mode ON(1) / OFF(0). */
1601                 scattered_rx : 1,  /**< RX of scattered packets is ON(1) / OFF(0) */
1602                 all_multicast : 1, /**< RX all multicast mode ON(1) / OFF(0). */
1603                 dev_started : 1,   /**< Device state: STARTED(1) / STOPPED(0). */
1604                 lro         : 1;   /**< RX LRO is ON(1) / OFF(0) */
1605         uint8_t rx_queue_state[RTE_MAX_QUEUES_PER_PORT];
1606         /** Queues state: STARTED(1) / STOPPED(0) */
1607         uint8_t tx_queue_state[RTE_MAX_QUEUES_PER_PORT];
1608         /** Queues state: STARTED(1) / STOPPED(0) */
1609         uint32_t dev_flags; /**< Capabilities */
1610         enum rte_kernel_driver kdrv;    /**< Kernel driver passthrough */
1611         int numa_node;  /**< NUMA node connection */
1612         const char *drv_name;   /**< Driver name */
1613 };
1614
1615 /** Device supports hotplug detach */
1616 #define RTE_ETH_DEV_DETACHABLE   0x0001
1617 /** Device supports link state interrupt */
1618 #define RTE_ETH_DEV_INTR_LSC     0x0002
1619
1620 /**
1621  * @internal
1622  * The pool of *rte_eth_dev* structures. The size of the pool
1623  * is configured at compile-time in the <rte_ethdev.c> file.
1624  */
1625 extern struct rte_eth_dev rte_eth_devices[];
1626
1627 /**
1628  * Get the total number of Ethernet devices that have been successfully
1629  * initialized by the [matching] Ethernet driver during the PCI probing phase.
1630  * All devices whose port identifier is in the range
1631  * [0,  rte_eth_dev_count() - 1] can be operated on by network applications
1632  * immediately after invoking rte_eal_init().
1633  * If the application unplugs a port using hotplug function, The enabled port
1634  * numbers may be noncontiguous. In the case, the applications need to manage
1635  * enabled port by themselves.
1636  *
1637  * @return
1638  *   - The total number of usable Ethernet devices.
1639  */
1640 uint8_t rte_eth_dev_count(void);
1641
1642 /**
1643  * @internal
1644  * Returns a ethdev slot specified by the unique identifier name.
1645  *
1646  * @param       name
1647  *  The pointer to the Unique identifier name for each Ethernet device
1648  * @return
1649  *   - The pointer to the ethdev slot, on success. NULL on error
1650  */
1651 struct rte_eth_dev *rte_eth_dev_allocated(const char *name);
1652
1653 /**
1654  * @internal
1655  * Allocates a new ethdev slot for an ethernet device and returns the pointer
1656  * to that slot for the driver to use.
1657  *
1658  * @param       name    Unique identifier name for each Ethernet device
1659  * @param       type    Device type of this Ethernet device
1660  * @return
1661  *   - Slot in the rte_dev_devices array for a new device;
1662  */
1663 struct rte_eth_dev *rte_eth_dev_allocate(const char *name,
1664                 enum rte_eth_dev_type type);
1665
1666 /**
1667  * @internal
1668  * Release the specified ethdev port.
1669  *
1670  * @param eth_dev
1671  * The *eth_dev* pointer is the address of the *rte_eth_dev* structure.
1672  * @return
1673  *   - 0 on success, negative on error
1674  */
1675 int rte_eth_dev_release_port(struct rte_eth_dev *eth_dev);
1676
1677 /**
1678  * Attach a new Ethernet device specified by aruguments.
1679  *
1680  * @param devargs
1681  *  A pointer to a strings array describing the new device
1682  *  to be attached. The strings should be a pci address like
1683  *  '0000:01:00.0' or virtual device name like 'eth_pcap0'.
1684  * @param port_id
1685  *  A pointer to a port identifier actually attached.
1686  * @return
1687  *  0 on success and port_id is filled, negative on error
1688  */
1689 int rte_eth_dev_attach(const char *devargs, uint8_t *port_id);
1690
1691 /**
1692  * Detach a Ethernet device specified by port identifier.
1693  * This function must be called when the device is in the
1694  * closed state.
1695  *
1696  * @param port_id
1697  *   The port identifier of the device to detach.
1698  * @param devname
1699  *  A pointer to a device name actually detached.
1700  * @return
1701  *  0 on success and devname is filled, negative on error
1702  */
1703 int rte_eth_dev_detach(uint8_t port_id, char *devname);
1704
1705 struct eth_driver;
1706 /**
1707  * @internal
1708  * Initialization function of an Ethernet driver invoked for each matching
1709  * Ethernet PCI device detected during the PCI probing phase.
1710  *
1711  * @param eth_dev
1712  *   The *eth_dev* pointer is the address of the *rte_eth_dev* structure
1713  *   associated with the matching device and which have been [automatically]
1714  *   allocated in the *rte_eth_devices* array.
1715  *   The *eth_dev* structure is supplied to the driver initialization function
1716  *   with the following fields already initialized:
1717  *
1718  *   - *pci_dev*: Holds the pointers to the *rte_pci_device* structure which
1719  *     contains the generic PCI information of the matching device.
1720  *
1721  *   - *driver*: Holds the pointer to the *eth_driver* structure.
1722  *
1723  *   - *dev_private*: Holds a pointer to the device private data structure.
1724  *
1725  *   - *mtu*: Contains the default Ethernet maximum frame length (1500).
1726  *
1727  *   - *port_id*: Contains the port index of the device (actually the index
1728  *     of the *eth_dev* structure in the *rte_eth_devices* array).
1729  *
1730  * @return
1731  *   - 0: Success, the device is properly initialized by the driver.
1732  *        In particular, the driver MUST have set up the *dev_ops* pointer
1733  *        of the *eth_dev* structure.
1734  *   - <0: Error code of the device initialization failure.
1735  */
1736 typedef int (*eth_dev_init_t)(struct rte_eth_dev *eth_dev);
1737
1738 /**
1739  * @internal
1740  * Finalization function of an Ethernet driver invoked for each matching
1741  * Ethernet PCI device detected during the PCI closing phase.
1742  *
1743  * @param eth_dev
1744  *   The *eth_dev* pointer is the address of the *rte_eth_dev* structure
1745  *   associated with the matching device and which have been [automatically]
1746  *   allocated in the *rte_eth_devices* array.
1747  * @return
1748  *   - 0: Success, the device is properly finalized by the driver.
1749  *        In particular, the driver MUST free the *dev_ops* pointer
1750  *        of the *eth_dev* structure.
1751  *   - <0: Error code of the device initialization failure.
1752  */
1753 typedef int (*eth_dev_uninit_t)(struct rte_eth_dev *eth_dev);
1754
1755 /**
1756  * @internal
1757  * The structure associated with a PMD Ethernet driver.
1758  *
1759  * Each Ethernet driver acts as a PCI driver and is represented by a generic
1760  * *eth_driver* structure that holds:
1761  *
1762  * - An *rte_pci_driver* structure (which must be the first field).
1763  *
1764  * - The *eth_dev_init* function invoked for each matching PCI device.
1765  *
1766  * - The *eth_dev_uninit* function invoked for each matching PCI device.
1767  *
1768  * - The size of the private data to allocate for each matching device.
1769  */
1770 struct eth_driver {
1771         struct rte_pci_driver pci_drv;    /**< The PMD is also a PCI driver. */
1772         eth_dev_init_t eth_dev_init;      /**< Device init function. */
1773         eth_dev_uninit_t eth_dev_uninit;  /**< Device uninit function. */
1774         unsigned int dev_private_size;    /**< Size of device private data. */
1775 };
1776
1777 /**
1778  * @internal
1779  * A function invoked by the initialization function of an Ethernet driver
1780  * to simultaneously register itself as a PCI driver and as an Ethernet
1781  * Poll Mode Driver (PMD).
1782  *
1783  * @param eth_drv
1784  *   The pointer to the *eth_driver* structure associated with
1785  *   the Ethernet driver.
1786  */
1787 void rte_eth_driver_register(struct eth_driver *eth_drv);
1788
1789 /**
1790  * Configure an Ethernet device.
1791  * This function must be invoked first before any other function in the
1792  * Ethernet API. This function can also be re-invoked when a device is in the
1793  * stopped state.
1794  *
1795  * @param port_id
1796  *   The port identifier of the Ethernet device to configure.
1797  * @param nb_rx_queue
1798  *   The number of receive queues to set up for the Ethernet device.
1799  * @param nb_tx_queue
1800  *   The number of transmit queues to set up for the Ethernet device.
1801  * @param eth_conf
1802  *   The pointer to the configuration data to be used for the Ethernet device.
1803  *   The *rte_eth_conf* structure includes:
1804  *     -  the hardware offload features to activate, with dedicated fields for
1805  *        each statically configurable offload hardware feature provided by
1806  *        Ethernet devices, such as IP checksum or VLAN tag stripping for
1807  *        example.
1808  *     - the Receive Side Scaling (RSS) configuration when using multiple RX
1809  *         queues per port.
1810  *
1811  *   Embedding all configuration information in a single data structure
1812  *   is the more flexible method that allows the addition of new features
1813  *   without changing the syntax of the API.
1814  * @return
1815  *   - 0: Success, device configured.
1816  *   - <0: Error code returned by the driver configuration function.
1817  */
1818 int rte_eth_dev_configure(uint8_t port_id, uint16_t nb_rx_queue,
1819                 uint16_t nb_tx_queue, const struct rte_eth_conf *eth_conf);
1820
1821 /**
1822  * Allocate and set up a receive queue for an Ethernet device.
1823  *
1824  * The function allocates a contiguous block of memory for *nb_rx_desc*
1825  * receive descriptors from a memory zone associated with *socket_id*
1826  * and initializes each receive descriptor with a network buffer allocated
1827  * from the memory pool *mb_pool*.
1828  *
1829  * @param port_id
1830  *   The port identifier of the Ethernet device.
1831  * @param rx_queue_id
1832  *   The index of the receive queue to set up.
1833  *   The value must be in the range [0, nb_rx_queue - 1] previously supplied
1834  *   to rte_eth_dev_configure().
1835  * @param nb_rx_desc
1836  *   The number of receive descriptors to allocate for the receive ring.
1837  * @param socket_id
1838  *   The *socket_id* argument is the socket identifier in case of NUMA.
1839  *   The value can be *SOCKET_ID_ANY* if there is no NUMA constraint for
1840  *   the DMA memory allocated for the receive descriptors of the ring.
1841  * @param rx_conf
1842  *   The pointer to the configuration data to be used for the receive queue.
1843  *   NULL value is allowed, in which case default RX configuration
1844  *   will be used.
1845  *   The *rx_conf* structure contains an *rx_thresh* structure with the values
1846  *   of the Prefetch, Host, and Write-Back threshold registers of the receive
1847  *   ring.
1848  * @param mb_pool
1849  *   The pointer to the memory pool from which to allocate *rte_mbuf* network
1850  *   memory buffers to populate each descriptor of the receive ring.
1851  * @return
1852  *   - 0: Success, receive queue correctly set up.
1853  *   - -EINVAL: The size of network buffers which can be allocated from the
1854  *      memory pool does not fit the various buffer sizes allowed by the
1855  *      device controller.
1856  *   - -ENOMEM: Unable to allocate the receive ring descriptors or to
1857  *      allocate network memory buffers from the memory pool when
1858  *      initializing receive descriptors.
1859  */
1860 int rte_eth_rx_queue_setup(uint8_t port_id, uint16_t rx_queue_id,
1861                 uint16_t nb_rx_desc, unsigned int socket_id,
1862                 const struct rte_eth_rxconf *rx_conf,
1863                 struct rte_mempool *mb_pool);
1864
1865 /**
1866  * Allocate and set up a transmit queue for an Ethernet device.
1867  *
1868  * @param port_id
1869  *   The port identifier of the Ethernet device.
1870  * @param tx_queue_id
1871  *   The index of the transmit queue to set up.
1872  *   The value must be in the range [0, nb_tx_queue - 1] previously supplied
1873  *   to rte_eth_dev_configure().
1874  * @param nb_tx_desc
1875  *   The number of transmit descriptors to allocate for the transmit ring.
1876  * @param socket_id
1877  *   The *socket_id* argument is the socket identifier in case of NUMA.
1878  *   Its value can be *SOCKET_ID_ANY* if there is no NUMA constraint for
1879  *   the DMA memory allocated for the transmit descriptors of the ring.
1880  * @param tx_conf
1881  *   The pointer to the configuration data to be used for the transmit queue.
1882  *   NULL value is allowed, in which case default RX configuration
1883  *   will be used.
1884  *   The *tx_conf* structure contains the following data:
1885  *   - The *tx_thresh* structure with the values of the Prefetch, Host, and
1886  *     Write-Back threshold registers of the transmit ring.
1887  *     When setting Write-Back threshold to the value greater then zero,
1888  *     *tx_rs_thresh* value should be explicitly set to one.
1889  *   - The *tx_free_thresh* value indicates the [minimum] number of network
1890  *     buffers that must be pending in the transmit ring to trigger their
1891  *     [implicit] freeing by the driver transmit function.
1892  *   - The *tx_rs_thresh* value indicates the [minimum] number of transmit
1893  *     descriptors that must be pending in the transmit ring before setting the
1894  *     RS bit on a descriptor by the driver transmit function.
1895  *     The *tx_rs_thresh* value should be less or equal then
1896  *     *tx_free_thresh* value, and both of them should be less then
1897  *     *nb_tx_desc* - 3.
1898  *   - The *txq_flags* member contains flags to pass to the TX queue setup
1899  *     function to configure the behavior of the TX queue. This should be set
1900  *     to 0 if no special configuration is required.
1901  *
1902  *     Note that setting *tx_free_thresh* or *tx_rs_thresh* value to 0 forces
1903  *     the transmit function to use default values.
1904  * @return
1905  *   - 0: Success, the transmit queue is correctly set up.
1906  *   - -ENOMEM: Unable to allocate the transmit ring descriptors.
1907  */
1908 int rte_eth_tx_queue_setup(uint8_t port_id, uint16_t tx_queue_id,
1909                 uint16_t nb_tx_desc, unsigned int socket_id,
1910                 const struct rte_eth_txconf *tx_conf);
1911
1912 /*
1913  * Return the NUMA socket to which an Ethernet device is connected
1914  *
1915  * @param port_id
1916  *   The port identifier of the Ethernet device
1917  * @return
1918  *   The NUMA socket id to which the Ethernet device is connected or
1919  *   a default of zero if the socket could not be determined.
1920  *   -1 is returned is the port_id value is out of range.
1921  */
1922 int rte_eth_dev_socket_id(uint8_t port_id);
1923
1924 /*
1925  * Check if port_id of device is attached
1926  *
1927  * @param port_id
1928  *   The port identifier of the Ethernet device
1929  * @return
1930  *   - 0 if port is out of range or not attached
1931  *   - 1 if device is attached
1932  */
1933 int rte_eth_dev_is_valid_port(uint8_t port_id);
1934
1935 /*
1936  * Allocate mbuf from mempool, setup the DMA physical address
1937  * and then start RX for specified queue of a port. It is used
1938  * when rx_deferred_start flag of the specified queue is true.
1939  *
1940  * @param port_id
1941  *   The port identifier of the Ethernet device
1942  * @param rx_queue_id
1943  *   The index of the rx queue to update the ring.
1944  *   The value must be in the range [0, nb_rx_queue - 1] previously supplied
1945  *   to rte_eth_dev_configure().
1946  * @return
1947  *   - 0: Success, the transmit queue is correctly set up.
1948  *   - -EINVAL: The port_id or the queue_id out of range.
1949  *   - -ENOTSUP: The function not supported in PMD driver.
1950  */
1951 int rte_eth_dev_rx_queue_start(uint8_t port_id, uint16_t rx_queue_id);
1952
1953 /*
1954  * Stop specified RX queue of a port
1955  *
1956  * @param port_id
1957  *   The port identifier of the Ethernet device
1958  * @param rx_queue_id
1959  *   The index of the rx queue to update the ring.
1960  *   The value must be in the range [0, nb_rx_queue - 1] previously supplied
1961  *   to rte_eth_dev_configure().
1962  * @return
1963  *   - 0: Success, the transmit queue is correctly set up.
1964  *   - -EINVAL: The port_id or the queue_id out of range.
1965  *   - -ENOTSUP: The function not supported in PMD driver.
1966  */
1967 int rte_eth_dev_rx_queue_stop(uint8_t port_id, uint16_t rx_queue_id);
1968
1969 /*
1970  * Start TX for specified queue of a port. It is used when tx_deferred_start
1971  * flag of the specified queue is true.
1972  *
1973  * @param port_id
1974  *   The port identifier of the Ethernet device
1975  * @param tx_queue_id
1976  *   The index of the tx queue to update the ring.
1977  *   The value must be in the range [0, nb_tx_queue - 1] previously supplied
1978  *   to rte_eth_dev_configure().
1979  * @return
1980  *   - 0: Success, the transmit queue is correctly set up.
1981  *   - -EINVAL: The port_id or the queue_id out of range.
1982  *   - -ENOTSUP: The function not supported in PMD driver.
1983  */
1984 int rte_eth_dev_tx_queue_start(uint8_t port_id, uint16_t tx_queue_id);
1985
1986 /*
1987  * Stop specified TX queue of a port
1988  *
1989  * @param port_id
1990  *   The port identifier of the Ethernet device
1991  * @param tx_queue_id
1992  *   The index of the tx queue to update the ring.
1993  *   The value must be in the range [0, nb_tx_queue - 1] previously supplied
1994  *   to rte_eth_dev_configure().
1995  * @return
1996  *   - 0: Success, the transmit queue is correctly set up.
1997  *   - -EINVAL: The port_id or the queue_id out of range.
1998  *   - -ENOTSUP: The function not supported in PMD driver.
1999  */
2000 int rte_eth_dev_tx_queue_stop(uint8_t port_id, uint16_t tx_queue_id);
2001
2002
2003
2004 /**
2005  * Start an Ethernet device.
2006  *
2007  * The device start step is the last one and consists of setting the configured
2008  * offload features and in starting the transmit and the receive units of the
2009  * device.
2010  * On success, all basic functions exported by the Ethernet API (link status,
2011  * receive/transmit, and so on) can be invoked.
2012  *
2013  * @param port_id
2014  *   The port identifier of the Ethernet device.
2015  * @return
2016  *   - 0: Success, Ethernet device started.
2017  *   - <0: Error code of the driver device start function.
2018  */
2019 int rte_eth_dev_start(uint8_t port_id);
2020
2021 /**
2022  * Stop an Ethernet device. The device can be restarted with a call to
2023  * rte_eth_dev_start()
2024  *
2025  * @param port_id
2026  *   The port identifier of the Ethernet device.
2027  */
2028 void rte_eth_dev_stop(uint8_t port_id);
2029
2030
2031 /**
2032  * Link up an Ethernet device.
2033  *
2034  * Set device link up will re-enable the device rx/tx
2035  * functionality after it is previously set device linked down.
2036  *
2037  * @param port_id
2038  *   The port identifier of the Ethernet device.
2039  * @return
2040  *   - 0: Success, Ethernet device linked up.
2041  *   - <0: Error code of the driver device link up function.
2042  */
2043 int rte_eth_dev_set_link_up(uint8_t port_id);
2044
2045 /**
2046  * Link down an Ethernet device.
2047  * The device rx/tx functionality will be disabled if success,
2048  * and it can be re-enabled with a call to
2049  * rte_eth_dev_set_link_up()
2050  *
2051  * @param port_id
2052  *   The port identifier of the Ethernet device.
2053  */
2054 int rte_eth_dev_set_link_down(uint8_t port_id);
2055
2056 /**
2057  * Close a stopped Ethernet device. The device cannot be restarted!
2058  * The function frees all resources except for needed by the
2059  * closed state. To free these resources, call rte_eth_dev_detach().
2060  *
2061  * @param port_id
2062  *   The port identifier of the Ethernet device.
2063  */
2064 void rte_eth_dev_close(uint8_t port_id);
2065
2066 /**
2067  * Enable receipt in promiscuous mode for an Ethernet device.
2068  *
2069  * @param port_id
2070  *   The port identifier of the Ethernet device.
2071  */
2072 void rte_eth_promiscuous_enable(uint8_t port_id);
2073
2074 /**
2075  * Disable receipt in promiscuous mode for an Ethernet device.
2076  *
2077  * @param port_id
2078  *   The port identifier of the Ethernet device.
2079  */
2080 void rte_eth_promiscuous_disable(uint8_t port_id);
2081
2082 /**
2083  * Return the value of promiscuous mode for an Ethernet device.
2084  *
2085  * @param port_id
2086  *   The port identifier of the Ethernet device.
2087  * @return
2088  *   - (1) if promiscuous is enabled
2089  *   - (0) if promiscuous is disabled.
2090  *   - (-1) on error
2091  */
2092 int rte_eth_promiscuous_get(uint8_t port_id);
2093
2094 /**
2095  * Enable the receipt of any multicast frame by an Ethernet device.
2096  *
2097  * @param port_id
2098  *   The port identifier of the Ethernet device.
2099  */
2100 void rte_eth_allmulticast_enable(uint8_t port_id);
2101
2102 /**
2103  * Disable the receipt of all multicast frames by an Ethernet device.
2104  *
2105  * @param port_id
2106  *   The port identifier of the Ethernet device.
2107  */
2108 void rte_eth_allmulticast_disable(uint8_t port_id);
2109
2110 /**
2111  * Return the value of allmulticast mode for an Ethernet device.
2112  *
2113  * @param port_id
2114  *   The port identifier of the Ethernet device.
2115  * @return
2116  *   - (1) if allmulticast is enabled
2117  *   - (0) if allmulticast is disabled.
2118  *   - (-1) on error
2119  */
2120 int rte_eth_allmulticast_get(uint8_t port_id);
2121
2122 /**
2123  * Retrieve the status (ON/OFF), the speed (in Mbps) and the mode (HALF-DUPLEX
2124  * or FULL-DUPLEX) of the physical link of an Ethernet device. It might need
2125  * to wait up to 9 seconds in it.
2126  *
2127  * @param port_id
2128  *   The port identifier of the Ethernet device.
2129  * @param link
2130  *   A pointer to an *rte_eth_link* structure to be filled with
2131  *   the status, the speed and the mode of the Ethernet device link.
2132  */
2133 void rte_eth_link_get(uint8_t port_id, struct rte_eth_link *link);
2134
2135 /**
2136  * Retrieve the status (ON/OFF), the speed (in Mbps) and the mode (HALF-DUPLEX
2137  * or FULL-DUPLEX) of the physical link of an Ethernet device. It is a no-wait
2138  * version of rte_eth_link_get().
2139  *
2140  * @param port_id
2141  *   The port identifier of the Ethernet device.
2142  * @param link
2143  *   A pointer to an *rte_eth_link* structure to be filled with
2144  *   the status, the speed and the mode of the Ethernet device link.
2145  */
2146 void rte_eth_link_get_nowait(uint8_t port_id, struct rte_eth_link *link);
2147
2148 /**
2149  * Retrieve the general I/O statistics of an Ethernet device.
2150  *
2151  * @param port_id
2152  *   The port identifier of the Ethernet device.
2153  * @param stats
2154  *   A pointer to a structure of type *rte_eth_stats* to be filled with
2155  *   the values of device counters for the following set of statistics:
2156  *   - *ipackets* with the total of successfully received packets.
2157  *   - *opackets* with the total of successfully transmitted packets.
2158  *   - *ibytes*   with the total of successfully received bytes.
2159  *   - *obytes*   with the total of successfully transmitted bytes.
2160  *   - *ierrors*  with the total of erroneous received packets.
2161  *   - *oerrors*  with the total of failed transmitted packets.
2162  * @return
2163  *   Zero if successful. Non-zero otherwise.
2164  */
2165 int rte_eth_stats_get(uint8_t port_id, struct rte_eth_stats *stats);
2166
2167 /**
2168  * Reset the general I/O statistics of an Ethernet device.
2169  *
2170  * @param port_id
2171  *   The port identifier of the Ethernet device.
2172  */
2173 void rte_eth_stats_reset(uint8_t port_id);
2174
2175 /**
2176  * Retrieve extended statistics of an Ethernet device.
2177  *
2178  * @param port_id
2179  *   The port identifier of the Ethernet device.
2180  * @param xstats
2181  *   A pointer to a table of structure of type *rte_eth_xstats*
2182  *   to be filled with device statistics names and values.
2183  *   This parameter can be set to NULL if n is 0.
2184  * @param n
2185  *   The size of the stats table, which should be large enough to store
2186  *   all the statistics of the device.
2187  * @return
2188  *   - positive value lower or equal to n: success. The return value
2189  *     is the number of entries filled in the stats table.
2190  *   - positive value higher than n: error, the given statistics table
2191  *     is too small. The return value corresponds to the size that should
2192  *     be given to succeed. The entries in the table are not valid and
2193  *     shall not be used by the caller.
2194  *   - negative value on error (invalid port id)
2195  */
2196 int rte_eth_xstats_get(uint8_t port_id, struct rte_eth_xstats *xstats,
2197                 unsigned n);
2198
2199 /**
2200  * Reset extended statistics of an Ethernet device.
2201  *
2202  * @param port_id
2203  *   The port identifier of the Ethernet device.
2204  */
2205 void rte_eth_xstats_reset(uint8_t port_id);
2206
2207 /**
2208  *  Set a mapping for the specified transmit queue to the specified per-queue
2209  *  statistics counter.
2210  *
2211  * @param port_id
2212  *   The port identifier of the Ethernet device.
2213  * @param tx_queue_id
2214  *   The index of the transmit queue for which a queue stats mapping is required.
2215  *   The value must be in the range [0, nb_tx_queue - 1] previously supplied
2216  *   to rte_eth_dev_configure().
2217  * @param stat_idx
2218  *   The per-queue packet statistics functionality number that the transmit
2219  *   queue is to be assigned.
2220  *   The value must be in the range [0, RTE_MAX_ETHPORT_QUEUE_STATS_MAPS - 1].
2221  * @return
2222  *   Zero if successful. Non-zero otherwise.
2223  */
2224 int rte_eth_dev_set_tx_queue_stats_mapping(uint8_t port_id,
2225                 uint16_t tx_queue_id, uint8_t stat_idx);
2226
2227 /**
2228  *  Set a mapping for the specified receive queue to the specified per-queue
2229  *  statistics counter.
2230  *
2231  * @param port_id
2232  *   The port identifier of the Ethernet device.
2233  * @param rx_queue_id
2234  *   The index of the receive queue for which a queue stats mapping is required.
2235  *   The value must be in the range [0, nb_rx_queue - 1] previously supplied
2236  *   to rte_eth_dev_configure().
2237  * @param stat_idx
2238  *   The per-queue packet statistics functionality number that the receive
2239  *   queue is to be assigned.
2240  *   The value must be in the range [0, RTE_MAX_ETHPORT_QUEUE_STATS_MAPS - 1].
2241  * @return
2242  *   Zero if successful. Non-zero otherwise.
2243  */
2244 int rte_eth_dev_set_rx_queue_stats_mapping(uint8_t port_id,
2245                                            uint16_t rx_queue_id,
2246                                            uint8_t stat_idx);
2247
2248 /**
2249  * Retrieve the Ethernet address of an Ethernet device.
2250  *
2251  * @param port_id
2252  *   The port identifier of the Ethernet device.
2253  * @param mac_addr
2254  *   A pointer to a structure of type *ether_addr* to be filled with
2255  *   the Ethernet address of the Ethernet device.
2256  */
2257 void rte_eth_macaddr_get(uint8_t port_id, struct ether_addr *mac_addr);
2258
2259 /**
2260  * Retrieve the contextual information of an Ethernet device.
2261  *
2262  * @param port_id
2263  *   The port identifier of the Ethernet device.
2264  * @param dev_info
2265  *   A pointer to a structure of type *rte_eth_dev_info* to be filled with
2266  *   the contextual information of the Ethernet device.
2267  */
2268 void rte_eth_dev_info_get(uint8_t port_id, struct rte_eth_dev_info *dev_info);
2269
2270 /**
2271  * Retrieve the MTU of an Ethernet device.
2272  *
2273  * @param port_id
2274  *   The port identifier of the Ethernet device.
2275  * @param mtu
2276  *   A pointer to a uint16_t where the retrieved MTU is to be stored.
2277  * @return
2278  *   - (0) if successful.
2279  *   - (-ENODEV) if *port_id* invalid.
2280  */
2281 int rte_eth_dev_get_mtu(uint8_t port_id, uint16_t *mtu);
2282
2283 /**
2284  * Change the MTU of an Ethernet device.
2285  *
2286  * @param port_id
2287  *   The port identifier of the Ethernet device.
2288  * @param mtu
2289  *   A uint16_t for the MTU to be applied.
2290  * @return
2291  *   - (0) if successful.
2292  *   - (-ENOTSUP) if operation is not supported.
2293  *   - (-ENODEV) if *port_id* invalid.
2294  *   - (-EINVAL) if *mtu* invalid.
2295  */
2296 int rte_eth_dev_set_mtu(uint8_t port_id, uint16_t mtu);
2297
2298 /**
2299  * Enable/Disable hardware filtering by an Ethernet device of received
2300  * VLAN packets tagged with a given VLAN Tag Identifier.
2301  *
2302  * @param port_id
2303  *   The port identifier of the Ethernet device.
2304  * @param vlan_id
2305  *   The VLAN Tag Identifier whose filtering must be enabled or disabled.
2306  * @param on
2307  *   If > 0, enable VLAN filtering of VLAN packets tagged with *vlan_id*.
2308  *   Otherwise, disable VLAN filtering of VLAN packets tagged with *vlan_id*.
2309  * @return
2310  *   - (0) if successful.
2311  *   - (-ENOSUP) if hardware-assisted VLAN filtering not configured.
2312  *   - (-ENODEV) if *port_id* invalid.
2313  *   - (-ENOSYS) if VLAN filtering on *port_id* disabled.
2314  *   - (-EINVAL) if *vlan_id* > 4095.
2315  */
2316 int rte_eth_dev_vlan_filter(uint8_t port_id, uint16_t vlan_id, int on);
2317
2318 /**
2319  * Enable/Disable hardware VLAN Strip by a rx queue of an Ethernet device.
2320  * 82599/X540/X550 can support VLAN stripping at the rx queue level
2321  *
2322  * @param port_id
2323  *   The port identifier of the Ethernet device.
2324  * @param rx_queue_id
2325  *   The index of the receive queue for which a queue stats mapping is required.
2326  *   The value must be in the range [0, nb_rx_queue - 1] previously supplied
2327  *   to rte_eth_dev_configure().
2328  * @param on
2329  *   If 1, Enable VLAN Stripping of the receive queue of the Ethernet port.
2330  *   If 0, Disable VLAN Stripping of the receive queue of the Ethernet port.
2331  * @return
2332  *   - (0) if successful.
2333  *   - (-ENOSUP) if hardware-assisted VLAN stripping not configured.
2334  *   - (-ENODEV) if *port_id* invalid.
2335  *   - (-EINVAL) if *rx_queue_id* invalid.
2336  */
2337 int rte_eth_dev_set_vlan_strip_on_queue(uint8_t port_id, uint16_t rx_queue_id,
2338                 int on);
2339
2340 /**
2341  * Set the Outer VLAN Ether Type by an Ethernet device, it can be inserted to
2342  * the VLAN Header. This is a register setup available on some Intel NIC, not
2343  * but all, please check the data sheet for availability.
2344  *
2345  * @param port_id
2346  *   The port identifier of the Ethernet device.
2347  * @param tag_type
2348  *   The Tag Protocol ID
2349  * @return
2350  *   - (0) if successful.
2351  *   - (-ENOSUP) if hardware-assisted VLAN TPID setup is not supported.
2352  *   - (-ENODEV) if *port_id* invalid.
2353  */
2354 int rte_eth_dev_set_vlan_ether_type(uint8_t port_id, uint16_t tag_type);
2355
2356 /**
2357  * Set VLAN offload configuration on an Ethernet device
2358  * Enable/Disable Extended VLAN by an Ethernet device, This is a register setup
2359  * available on some Intel NIC, not but all, please check the data sheet for
2360  * availability.
2361  * Enable/Disable VLAN Strip can be done on rx queue for certain NIC, but here
2362  * the configuration is applied on the port level.
2363  *
2364  * @param port_id
2365  *   The port identifier of the Ethernet device.
2366  * @param offload_mask
2367  *   The VLAN Offload bit mask can be mixed use with "OR"
2368  *       ETH_VLAN_STRIP_OFFLOAD
2369  *       ETH_VLAN_FILTER_OFFLOAD
2370  *       ETH_VLAN_EXTEND_OFFLOAD
2371  * @return
2372  *   - (0) if successful.
2373  *   - (-ENOSUP) if hardware-assisted VLAN filtering not configured.
2374  *   - (-ENODEV) if *port_id* invalid.
2375  */
2376 int rte_eth_dev_set_vlan_offload(uint8_t port_id, int offload_mask);
2377
2378 /**
2379  * Read VLAN Offload configuration from an Ethernet device
2380  *
2381  * @param port_id
2382  *   The port identifier of the Ethernet device.
2383  * @return
2384  *   - (>0) if successful. Bit mask to indicate
2385  *       ETH_VLAN_STRIP_OFFLOAD
2386  *       ETH_VLAN_FILTER_OFFLOAD
2387  *       ETH_VLAN_EXTEND_OFFLOAD
2388  *   - (-ENODEV) if *port_id* invalid.
2389  */
2390 int rte_eth_dev_get_vlan_offload(uint8_t port_id);
2391
2392 /**
2393  * Set port based TX VLAN insersion on or off.
2394  *
2395  * @param port_id
2396  *  The port identifier of the Ethernet device.
2397  * @param pvid
2398  *  Port based TX VLAN identifier togeth with user priority.
2399  * @param on
2400  *  Turn on or off the port based TX VLAN insertion.
2401  *
2402  * @return
2403  *   - (0) if successful.
2404  *   - negative if failed.
2405  */
2406 int rte_eth_dev_set_vlan_pvid(uint8_t port_id, uint16_t pvid, int on);
2407
2408 /**
2409  *
2410  * Retrieve a burst of input packets from a receive queue of an Ethernet
2411  * device. The retrieved packets are stored in *rte_mbuf* structures whose
2412  * pointers are supplied in the *rx_pkts* array.
2413  *
2414  * The rte_eth_rx_burst() function loops, parsing the RX ring of the
2415  * receive queue, up to *nb_pkts* packets, and for each completed RX
2416  * descriptor in the ring, it performs the following operations:
2417  *
2418  * - Initialize the *rte_mbuf* data structure associated with the
2419  *   RX descriptor according to the information provided by the NIC into
2420  *   that RX descriptor.
2421  *
2422  * - Store the *rte_mbuf* data structure into the next entry of the
2423  *   *rx_pkts* array.
2424  *
2425  * - Replenish the RX descriptor with a new *rte_mbuf* buffer
2426  *   allocated from the memory pool associated with the receive queue at
2427  *   initialization time.
2428  *
2429  * When retrieving an input packet that was scattered by the controller
2430  * into multiple receive descriptors, the rte_eth_rx_burst() function
2431  * appends the associated *rte_mbuf* buffers to the first buffer of the
2432  * packet.
2433  *
2434  * The rte_eth_rx_burst() function returns the number of packets
2435  * actually retrieved, which is the number of *rte_mbuf* data structures
2436  * effectively supplied into the *rx_pkts* array.
2437  * A return value equal to *nb_pkts* indicates that the RX queue contained
2438  * at least *rx_pkts* packets, and this is likely to signify that other
2439  * received packets remain in the input queue. Applications implementing
2440  * a "retrieve as much received packets as possible" policy can check this
2441  * specific case and keep invoking the rte_eth_rx_burst() function until
2442  * a value less than *nb_pkts* is returned.
2443  *
2444  * This receive method has the following advantages:
2445  *
2446  * - It allows a run-to-completion network stack engine to retrieve and
2447  *   to immediately process received packets in a fast burst-oriented
2448  *   approach, avoiding the overhead of unnecessary intermediate packet
2449  *   queue/dequeue operations.
2450  *
2451  * - Conversely, it also allows an asynchronous-oriented processing
2452  *   method to retrieve bursts of received packets and to immediately
2453  *   queue them for further parallel processing by another logical core,
2454  *   for instance. However, instead of having received packets being
2455  *   individually queued by the driver, this approach allows the invoker
2456  *   of the rte_eth_rx_burst() function to queue a burst of retrieved
2457  *   packets at a time and therefore dramatically reduce the cost of
2458  *   enqueue/dequeue operations per packet.
2459  *
2460  * - It allows the rte_eth_rx_burst() function of the driver to take
2461  *   advantage of burst-oriented hardware features (CPU cache,
2462  *   prefetch instructions, and so on) to minimize the number of CPU
2463  *   cycles per packet.
2464  *
2465  * To summarize, the proposed receive API enables many
2466  * burst-oriented optimizations in both synchronous and asynchronous
2467  * packet processing environments with no overhead in both cases.
2468  *
2469  * The rte_eth_rx_burst() function does not provide any error
2470  * notification to avoid the corresponding overhead. As a hint, the
2471  * upper-level application might check the status of the device link once
2472  * being systematically returned a 0 value for a given number of tries.
2473  *
2474  * @param port_id
2475  *   The port identifier of the Ethernet device.
2476  * @param queue_id
2477  *   The index of the receive queue from which to retrieve input packets.
2478  *   The value must be in the range [0, nb_rx_queue - 1] previously supplied
2479  *   to rte_eth_dev_configure().
2480  * @param rx_pkts
2481  *   The address of an array of pointers to *rte_mbuf* structures that
2482  *   must be large enough to store *nb_pkts* pointers in it.
2483  * @param nb_pkts
2484  *   The maximum number of packets to retrieve.
2485  * @return
2486  *   The number of packets actually retrieved, which is the number
2487  *   of pointers to *rte_mbuf* structures effectively supplied to the
2488  *   *rx_pkts* array.
2489  */
2490 static inline uint16_t
2491 rte_eth_rx_burst(uint8_t port_id, uint16_t queue_id,
2492                  struct rte_mbuf **rx_pkts, const uint16_t nb_pkts)
2493 {
2494         struct rte_eth_dev *dev = &rte_eth_devices[port_id];
2495
2496 #ifdef RTE_LIBRTE_ETHDEV_DEBUG
2497         RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, 0);
2498         RTE_FUNC_PTR_OR_ERR_RET(*dev->rx_pkt_burst, 0);
2499
2500         if (queue_id >= dev->data->nb_rx_queues) {
2501                 RTE_PMD_DEBUG_TRACE("Invalid RX queue_id=%d\n", queue_id);
2502                 return 0;
2503         }
2504 #endif
2505         int16_t nb_rx = (*dev->rx_pkt_burst)(dev->data->rx_queues[queue_id],
2506                         rx_pkts, nb_pkts);
2507
2508 #ifdef RTE_ETHDEV_RXTX_CALLBACKS
2509         struct rte_eth_rxtx_callback *cb = dev->post_rx_burst_cbs[queue_id];
2510
2511         if (unlikely(cb != NULL)) {
2512                 do {
2513                         nb_rx = cb->fn.rx(port_id, queue_id, rx_pkts, nb_rx,
2514                                                 nb_pkts, cb->param);
2515                         cb = cb->next;
2516                 } while (cb != NULL);
2517         }
2518 #endif
2519
2520         return nb_rx;
2521 }
2522
2523 /**
2524  * Get the number of used descriptors in a specific queue
2525  *
2526  * @param port_id
2527  *  The port identifier of the Ethernet device.
2528  * @param queue_id
2529  *  The queue id on the specific port.
2530  * @return
2531  *  The number of used descriptors in the specific queue, or:
2532  *     (-EINVAL) if *port_id* is invalid
2533  *     (-ENOTSUP) if the device does not support this function
2534  */
2535 static inline int
2536 rte_eth_rx_queue_count(uint8_t port_id, uint16_t queue_id)
2537 {
2538         struct rte_eth_dev *dev = &rte_eth_devices[port_id];
2539         RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
2540         RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rx_queue_count, -ENOTSUP);
2541         return (*dev->dev_ops->rx_queue_count)(dev, queue_id);
2542 }
2543
2544 /**
2545  * Check if the DD bit of the specific RX descriptor in the queue has been set
2546  *
2547  * @param port_id
2548  *  The port identifier of the Ethernet device.
2549  * @param queue_id
2550  *  The queue id on the specific port.
2551  * @param offset
2552  *  The offset of the descriptor ID from tail.
2553  * @return
2554  *  - (1) if the specific DD bit is set.
2555  *  - (0) if the specific DD bit is not set.
2556  *  - (-ENODEV) if *port_id* invalid.
2557  *  - (-ENOTSUP) if the device does not support this function
2558  */
2559 static inline int
2560 rte_eth_rx_descriptor_done(uint8_t port_id, uint16_t queue_id, uint16_t offset)
2561 {
2562         struct rte_eth_dev *dev = &rte_eth_devices[port_id];
2563         RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
2564         RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rx_descriptor_done, -ENOTSUP);
2565         return (*dev->dev_ops->rx_descriptor_done)( \
2566                 dev->data->rx_queues[queue_id], offset);
2567 }
2568
2569 /**
2570  * Send a burst of output packets on a transmit queue of an Ethernet device.
2571  *
2572  * The rte_eth_tx_burst() function is invoked to transmit output packets
2573  * on the output queue *queue_id* of the Ethernet device designated by its
2574  * *port_id*.
2575  * The *nb_pkts* parameter is the number of packets to send which are
2576  * supplied in the *tx_pkts* array of *rte_mbuf* structures.
2577  * The rte_eth_tx_burst() function loops, sending *nb_pkts* packets,
2578  * up to the number of transmit descriptors available in the TX ring of the
2579  * transmit queue.
2580  * For each packet to send, the rte_eth_tx_burst() function performs
2581  * the following operations:
2582  *
2583  * - Pick up the next available descriptor in the transmit ring.
2584  *
2585  * - Free the network buffer previously sent with that descriptor, if any.
2586  *
2587  * - Initialize the transmit descriptor with the information provided
2588  *   in the *rte_mbuf data structure.
2589  *
2590  * In the case of a segmented packet composed of a list of *rte_mbuf* buffers,
2591  * the rte_eth_tx_burst() function uses several transmit descriptors
2592  * of the ring.
2593  *
2594  * The rte_eth_tx_burst() function returns the number of packets it
2595  * actually sent. A return value equal to *nb_pkts* means that all packets
2596  * have been sent, and this is likely to signify that other output packets
2597  * could be immediately transmitted again. Applications that implement a
2598  * "send as many packets to transmit as possible" policy can check this
2599  * specific case and keep invoking the rte_eth_tx_burst() function until
2600  * a value less than *nb_pkts* is returned.
2601  *
2602  * It is the responsibility of the rte_eth_tx_burst() function to
2603  * transparently free the memory buffers of packets previously sent.
2604  * This feature is driven by the *tx_free_thresh* value supplied to the
2605  * rte_eth_dev_configure() function at device configuration time.
2606  * When the number of free TX descriptors drops below this threshold, the
2607  * rte_eth_tx_burst() function must [attempt to] free the *rte_mbuf*  buffers
2608  * of those packets whose transmission was effectively completed.
2609  *
2610  * @param port_id
2611  *   The port identifier of the Ethernet device.
2612  * @param queue_id
2613  *   The index of the transmit queue through which output packets must be
2614  *   sent.
2615  *   The value must be in the range [0, nb_tx_queue - 1] previously supplied
2616  *   to rte_eth_dev_configure().
2617  * @param tx_pkts
2618  *   The address of an array of *nb_pkts* pointers to *rte_mbuf* structures
2619  *   which contain the output packets.
2620  * @param nb_pkts
2621  *   The maximum number of packets to transmit.
2622  * @return
2623  *   The number of output packets actually stored in transmit descriptors of
2624  *   the transmit ring. The return value can be less than the value of the
2625  *   *tx_pkts* parameter when the transmit ring is full or has been filled up.
2626  */
2627 static inline uint16_t
2628 rte_eth_tx_burst(uint8_t port_id, uint16_t queue_id,
2629                  struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
2630 {
2631         struct rte_eth_dev *dev = &rte_eth_devices[port_id];
2632
2633 #ifdef RTE_LIBRTE_ETHDEV_DEBUG
2634         RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, 0);
2635         RTE_FUNC_PTR_OR_ERR_RET(*dev->tx_pkt_burst, 0);
2636
2637         if (queue_id >= dev->data->nb_tx_queues) {
2638                 RTE_PMD_DEBUG_TRACE("Invalid TX queue_id=%d\n", queue_id);
2639                 return 0;
2640         }
2641 #endif
2642
2643 #ifdef RTE_ETHDEV_RXTX_CALLBACKS
2644         struct rte_eth_rxtx_callback *cb = dev->pre_tx_burst_cbs[queue_id];
2645
2646         if (unlikely(cb != NULL)) {
2647                 do {
2648                         nb_pkts = cb->fn.tx(port_id, queue_id, tx_pkts, nb_pkts,
2649                                         cb->param);
2650                         cb = cb->next;
2651                 } while (cb != NULL);
2652         }
2653 #endif
2654
2655         return (*dev->tx_pkt_burst)(dev->data->tx_queues[queue_id], tx_pkts, nb_pkts);
2656 }
2657
2658 /**
2659  * The eth device event type for interrupt, and maybe others in the future.
2660  */
2661 enum rte_eth_event_type {
2662         RTE_ETH_EVENT_UNKNOWN,  /**< unknown event type */
2663         RTE_ETH_EVENT_INTR_LSC, /**< lsc interrupt event */
2664         RTE_ETH_EVENT_MAX       /**< max value of this enum */
2665 };
2666
2667 typedef void (*rte_eth_dev_cb_fn)(uint8_t port_id, \
2668                 enum rte_eth_event_type event, void *cb_arg);
2669 /**< user application callback to be registered for interrupts */
2670
2671
2672
2673 /**
2674  * Register a callback function for specific port id.
2675  *
2676  * @param port_id
2677  *  Port id.
2678  * @param event
2679  *  Event interested.
2680  * @param cb_fn
2681  *  User supplied callback function to be called.
2682  * @param cb_arg
2683  *  Pointer to the parameters for the registered callback.
2684  *
2685  * @return
2686  *  - On success, zero.
2687  *  - On failure, a negative value.
2688  */
2689 int rte_eth_dev_callback_register(uint8_t port_id,
2690                         enum rte_eth_event_type event,
2691                 rte_eth_dev_cb_fn cb_fn, void *cb_arg);
2692
2693 /**
2694  * Unregister a callback function for specific port id.
2695  *
2696  * @param port_id
2697  *  Port id.
2698  * @param event
2699  *  Event interested.
2700  * @param cb_fn
2701  *  User supplied callback function to be called.
2702  * @param cb_arg
2703  *  Pointer to the parameters for the registered callback. -1 means to
2704  *  remove all for the same callback address and same event.
2705  *
2706  * @return
2707  *  - On success, zero.
2708  *  - On failure, a negative value.
2709  */
2710 int rte_eth_dev_callback_unregister(uint8_t port_id,
2711                         enum rte_eth_event_type event,
2712                 rte_eth_dev_cb_fn cb_fn, void *cb_arg);
2713
2714 /**
2715  * @internal Executes all the user application registered callbacks for
2716  * the specific device. It is for DPDK internal user only. User
2717  * application should not call it directly.
2718  *
2719  * @param dev
2720  *  Pointer to struct rte_eth_dev.
2721  * @param event
2722  *  Eth device interrupt event type.
2723  *
2724  * @return
2725  *  void
2726  */
2727 void _rte_eth_dev_callback_process(struct rte_eth_dev *dev,
2728                                 enum rte_eth_event_type event);
2729
2730 /**
2731  * When there is no rx packet coming in Rx Queue for a long time, we can
2732  * sleep lcore related to RX Queue for power saving, and enable rx interrupt
2733  * to be triggered when rx packect arrives.
2734  *
2735  * The rte_eth_dev_rx_intr_enable() function enables rx queue
2736  * interrupt on specific rx queue of a port.
2737  *
2738  * @param port_id
2739  *   The port identifier of the Ethernet device.
2740  * @param queue_id
2741  *   The index of the receive queue from which to retrieve input packets.
2742  *   The value must be in the range [0, nb_rx_queue - 1] previously supplied
2743  *   to rte_eth_dev_configure().
2744  * @return
2745  *   - (0) if successful.
2746  *   - (-ENOTSUP) if underlying hardware OR driver doesn't support
2747  *     that operation.
2748  *   - (-ENODEV) if *port_id* invalid.
2749  */
2750 int rte_eth_dev_rx_intr_enable(uint8_t port_id, uint16_t queue_id);
2751
2752 /**
2753  * When lcore wakes up from rx interrupt indicating packet coming, disable rx
2754  * interrupt and returns to polling mode.
2755  *
2756  * The rte_eth_dev_rx_intr_disable() function disables rx queue
2757  * interrupt on specific rx queue of a port.
2758  *
2759  * @param port_id
2760  *   The port identifier of the Ethernet device.
2761  * @param queue_id
2762  *   The index of the receive queue from which to retrieve input packets.
2763  *   The value must be in the range [0, nb_rx_queue - 1] previously supplied
2764  *   to rte_eth_dev_configure().
2765  * @return
2766  *   - (0) if successful.
2767  *   - (-ENOTSUP) if underlying hardware OR driver doesn't support
2768  *     that operation.
2769  *   - (-ENODEV) if *port_id* invalid.
2770  */
2771 int rte_eth_dev_rx_intr_disable(uint8_t port_id, uint16_t queue_id);
2772
2773 /**
2774  * RX Interrupt control per port.
2775  *
2776  * @param port_id
2777  *   The port identifier of the Ethernet device.
2778  * @param epfd
2779  *   Epoll instance fd which the intr vector associated to.
2780  *   Using RTE_EPOLL_PER_THREAD allows to use per thread epoll instance.
2781  * @param op
2782  *   The operation be performed for the vector.
2783  *   Operation type of {RTE_INTR_EVENT_ADD, RTE_INTR_EVENT_DEL}.
2784  * @param data
2785  *   User raw data.
2786  * @return
2787  *   - On success, zero.
2788  *   - On failure, a negative value.
2789  */
2790 int rte_eth_dev_rx_intr_ctl(uint8_t port_id, int epfd, int op, void *data);
2791
2792 /**
2793  * RX Interrupt control per queue.
2794  *
2795  * @param port_id
2796  *   The port identifier of the Ethernet device.
2797  * @param queue_id
2798  *   The index of the receive queue from which to retrieve input packets.
2799  *   The value must be in the range [0, nb_rx_queue - 1] previously supplied
2800  *   to rte_eth_dev_configure().
2801  * @param epfd
2802  *   Epoll instance fd which the intr vector associated to.
2803  *   Using RTE_EPOLL_PER_THREAD allows to use per thread epoll instance.
2804  * @param op
2805  *   The operation be performed for the vector.
2806  *   Operation type of {RTE_INTR_EVENT_ADD, RTE_INTR_EVENT_DEL}.
2807  * @param data
2808  *   User raw data.
2809  * @return
2810  *   - On success, zero.
2811  *   - On failure, a negative value.
2812  */
2813 int rte_eth_dev_rx_intr_ctl_q(uint8_t port_id, uint16_t queue_id,
2814                               int epfd, int op, void *data);
2815
2816 /**
2817  * Turn on the LED on the Ethernet device.
2818  * This function turns on the LED on the Ethernet device.
2819  *
2820  * @param port_id
2821  *   The port identifier of the Ethernet device.
2822  * @return
2823  *   - (0) if successful.
2824  *   - (-ENOTSUP) if underlying hardware OR driver doesn't support
2825  *     that operation.
2826  *   - (-ENODEV) if *port_id* invalid.
2827  */
2828 int  rte_eth_led_on(uint8_t port_id);
2829
2830 /**
2831  * Turn off the LED on the Ethernet device.
2832  * This function turns off the LED on the Ethernet device.
2833  *
2834  * @param port_id
2835  *   The port identifier of the Ethernet device.
2836  * @return
2837  *   - (0) if successful.
2838  *   - (-ENOTSUP) if underlying hardware OR driver doesn't support
2839  *     that operation.
2840  *   - (-ENODEV) if *port_id* invalid.
2841  */
2842 int  rte_eth_led_off(uint8_t port_id);
2843
2844 /**
2845  * Get current status of the Ethernet link flow control for Ethernet device
2846  *
2847  * @param port_id
2848  *   The port identifier of the Ethernet device.
2849  * @param fc_conf
2850  *   The pointer to the structure where to store the flow control parameters.
2851  * @return
2852  *   - (0) if successful.
2853  *   - (-ENOTSUP) if hardware doesn't support flow control.
2854  *   - (-ENODEV)  if *port_id* invalid.
2855  */
2856 int rte_eth_dev_flow_ctrl_get(uint8_t port_id,
2857                               struct rte_eth_fc_conf *fc_conf);
2858
2859 /**
2860  * Configure the Ethernet link flow control for Ethernet device
2861  *
2862  * @param port_id
2863  *   The port identifier of the Ethernet device.
2864  * @param fc_conf
2865  *   The pointer to the structure of the flow control parameters.
2866  * @return
2867  *   - (0) if successful.
2868  *   - (-ENOTSUP) if hardware doesn't support flow control mode.
2869  *   - (-ENODEV)  if *port_id* invalid.
2870  *   - (-EINVAL)  if bad parameter
2871  *   - (-EIO)     if flow control setup failure
2872  */
2873 int rte_eth_dev_flow_ctrl_set(uint8_t port_id,
2874                               struct rte_eth_fc_conf *fc_conf);
2875
2876 /**
2877  * Configure the Ethernet priority flow control under DCB environment
2878  * for Ethernet device.
2879  *
2880  * @param port_id
2881  * The port identifier of the Ethernet device.
2882  * @param pfc_conf
2883  * The pointer to the structure of the priority flow control parameters.
2884  * @return
2885  *   - (0) if successful.
2886  *   - (-ENOTSUP) if hardware doesn't support priority flow control mode.
2887  *   - (-ENODEV)  if *port_id* invalid.
2888  *   - (-EINVAL)  if bad parameter
2889  *   - (-EIO)     if flow control setup failure
2890  */
2891 int rte_eth_dev_priority_flow_ctrl_set(uint8_t port_id,
2892                                 struct rte_eth_pfc_conf *pfc_conf);
2893
2894 /**
2895  * Add a MAC address to an internal array of addresses used to enable whitelist
2896  * filtering to accept packets only if the destination MAC address matches.
2897  *
2898  * @param port
2899  *   The port identifier of the Ethernet device.
2900  * @param mac_addr
2901  *   The MAC address to add.
2902  * @param pool
2903  *   VMDq pool index to associate address with (if VMDq is enabled). If VMDq is
2904  *   not enabled, this should be set to 0.
2905  * @return
2906  *   - (0) if successfully added or *mac_addr" was already added.
2907  *   - (-ENOTSUP) if hardware doesn't support this feature.
2908  *   - (-ENODEV) if *port* is invalid.
2909  *   - (-ENOSPC) if no more MAC addresses can be added.
2910  *   - (-EINVAL) if MAC address is invalid.
2911  */
2912 int rte_eth_dev_mac_addr_add(uint8_t port, struct ether_addr *mac_addr,
2913                                 uint32_t pool);
2914
2915 /**
2916  * Remove a MAC address from the internal array of addresses.
2917  *
2918  * @param port
2919  *   The port identifier of the Ethernet device.
2920  * @param mac_addr
2921  *   MAC address to remove.
2922  * @return
2923  *   - (0) if successful, or *mac_addr* didn't exist.
2924  *   - (-ENOTSUP) if hardware doesn't support.
2925  *   - (-ENODEV) if *port* invalid.
2926  *   - (-EADDRINUSE) if attempting to remove the default MAC address
2927  */
2928 int rte_eth_dev_mac_addr_remove(uint8_t port, struct ether_addr *mac_addr);
2929
2930 /**
2931  * Set the default MAC address.
2932  *
2933  * @param port
2934  *   The port identifier of the Ethernet device.
2935  * @param mac_addr
2936  *   New default MAC address.
2937  * @return
2938  *   - (0) if successful, or *mac_addr* didn't exist.
2939  *   - (-ENOTSUP) if hardware doesn't support.
2940  *   - (-ENODEV) if *port* invalid.
2941  *   - (-EINVAL) if MAC address is invalid.
2942  */
2943 int rte_eth_dev_default_mac_addr_set(uint8_t port, struct ether_addr *mac_addr);
2944
2945
2946 /**
2947  * Update Redirection Table(RETA) of Receive Side Scaling of Ethernet device.
2948  *
2949  * @param port
2950  *   The port identifier of the Ethernet device.
2951  * @param reta_conf
2952  *   RETA to update.
2953  * @param reta_size
2954  *   Redirection table size. The table size can be queried by
2955  *   rte_eth_dev_info_get().
2956  * @return
2957  *   - (0) if successful.
2958  *   - (-ENOTSUP) if hardware doesn't support.
2959  *   - (-EINVAL) if bad parameter.
2960  */
2961 int rte_eth_dev_rss_reta_update(uint8_t port,
2962                                 struct rte_eth_rss_reta_entry64 *reta_conf,
2963                                 uint16_t reta_size);
2964
2965  /**
2966  * Query Redirection Table(RETA) of Receive Side Scaling of Ethernet device.
2967  *
2968  * @param port
2969  *   The port identifier of the Ethernet device.
2970  * @param reta_conf
2971  *   RETA to query.
2972  * @param reta_size
2973  *   Redirection table size. The table size can be queried by
2974  *   rte_eth_dev_info_get().
2975  * @return
2976  *   - (0) if successful.
2977  *   - (-ENOTSUP) if hardware doesn't support.
2978  *   - (-EINVAL) if bad parameter.
2979  */
2980 int rte_eth_dev_rss_reta_query(uint8_t port,
2981                                struct rte_eth_rss_reta_entry64 *reta_conf,
2982                                uint16_t reta_size);
2983
2984  /**
2985  * Updates unicast hash table for receiving packet with the given destination
2986  * MAC address, and the packet is routed to all VFs for which the RX mode is
2987  * accept packets that match the unicast hash table.
2988  *
2989  * @param port
2990  *   The port identifier of the Ethernet device.
2991  * @param addr
2992  *   Unicast MAC address.
2993  * @param on
2994  *    1 - Set an unicast hash bit for receiving packets with the MAC address.
2995  *    0 - Clear an unicast hash bit.
2996  * @return
2997  *   - (0) if successful.
2998  *   - (-ENOTSUP) if hardware doesn't support.
2999   *  - (-ENODEV) if *port_id* invalid.
3000  *   - (-EINVAL) if bad parameter.
3001  */
3002 int rte_eth_dev_uc_hash_table_set(uint8_t port,struct ether_addr *addr,
3003                                         uint8_t on);
3004
3005  /**
3006  * Updates all unicast hash bitmaps for receiving packet with any Unicast
3007  * Ethernet MAC addresses,the packet is routed to all VFs for which the RX
3008  * mode is accept packets that match the unicast hash table.
3009  *
3010  * @param port
3011  *   The port identifier of the Ethernet device.
3012  * @param on
3013  *    1 - Set all unicast hash bitmaps for receiving all the Ethernet
3014  *         MAC addresses
3015  *    0 - Clear all unicast hash bitmaps
3016  * @return
3017  *   - (0) if successful.
3018  *   - (-ENOTSUP) if hardware doesn't support.
3019   *  - (-ENODEV) if *port_id* invalid.
3020  *   - (-EINVAL) if bad parameter.
3021  */
3022 int rte_eth_dev_uc_all_hash_table_set(uint8_t port,uint8_t on);
3023
3024  /**
3025  * Set RX L2 Filtering mode of a VF of an Ethernet device.
3026  *
3027  * @param port
3028  *   The port identifier of the Ethernet device.
3029  * @param vf
3030  *   VF id.
3031  * @param rx_mode
3032  *    The RX mode mask, which  is one or more of  accepting Untagged Packets,
3033  *    packets that match the PFUTA table, Broadcast and Multicast Promiscuous.
3034  *    ETH_VMDQ_ACCEPT_UNTAG,ETH_VMDQ_ACCEPT_HASH_UC,
3035  *    ETH_VMDQ_ACCEPT_BROADCAST and ETH_VMDQ_ACCEPT_MULTICAST will be used
3036  *    in rx_mode.
3037  * @param on
3038  *    1 - Enable a VF RX mode.
3039  *    0 - Disable a VF RX mode.
3040  * @return
3041  *   - (0) if successful.
3042  *   - (-ENOTSUP) if hardware doesn't support.
3043  *   - (-ENOTSUP) if hardware doesn't support.
3044  *   - (-EINVAL) if bad parameter.
3045  */
3046 int rte_eth_dev_set_vf_rxmode(uint8_t port, uint16_t vf, uint16_t rx_mode,
3047                                 uint8_t on);
3048
3049 /**
3050 * Enable or disable a VF traffic transmit of the Ethernet device.
3051 *
3052 * @param port
3053 *   The port identifier of the Ethernet device.
3054 * @param vf
3055 *   VF id.
3056 * @param on
3057 *    1 - Enable a VF traffic transmit.
3058 *    0 - Disable a VF traffic transmit.
3059 * @return
3060 *   - (0) if successful.
3061 *   - (-ENODEV) if *port_id* invalid.
3062 *   - (-ENOTSUP) if hardware doesn't support.
3063 *   - (-EINVAL) if bad parameter.
3064 */
3065 int
3066 rte_eth_dev_set_vf_tx(uint8_t port,uint16_t vf, uint8_t on);
3067
3068 /**
3069 * Enable or disable a VF traffic receive of an Ethernet device.
3070 *
3071 * @param port
3072 *   The port identifier of the Ethernet device.
3073 * @param vf
3074 *   VF id.
3075 * @param on
3076 *    1 - Enable a VF traffic receive.
3077 *    0 - Disable a VF traffic receive.
3078 * @return
3079 *   - (0) if successful.
3080 *   - (-ENOTSUP) if hardware doesn't support.
3081 *   - (-ENODEV) if *port_id* invalid.
3082 *   - (-EINVAL) if bad parameter.
3083 */
3084 int
3085 rte_eth_dev_set_vf_rx(uint8_t port,uint16_t vf, uint8_t on);
3086
3087 /**
3088 * Enable/Disable hardware VF VLAN filtering by an Ethernet device of
3089 * received VLAN packets tagged with a given VLAN Tag Identifier.
3090 *
3091 * @param port id
3092 *   The port identifier of the Ethernet device.
3093 * @param vlan_id
3094 *   The VLAN Tag Identifier whose filtering must be enabled or disabled.
3095 * @param vf_mask
3096 *    Bitmap listing which VFs participate in the VLAN filtering.
3097 * @param vlan_on
3098 *    1 - Enable VFs VLAN filtering.
3099 *    0 - Disable VFs VLAN filtering.
3100 * @return
3101 *   - (0) if successful.
3102 *   - (-ENOTSUP) if hardware doesn't support.
3103 *   - (-ENODEV) if *port_id* invalid.
3104 *   - (-EINVAL) if bad parameter.
3105 */
3106 int
3107 rte_eth_dev_set_vf_vlan_filter(uint8_t port, uint16_t vlan_id,
3108                                 uint64_t vf_mask,
3109                                 uint8_t vlan_on);
3110
3111 /**
3112  * Set a traffic mirroring rule on an Ethernet device
3113  *
3114  * @param port_id
3115  *   The port identifier of the Ethernet device.
3116  * @param mirror_conf
3117  *   The pointer to the traffic mirroring structure describing the mirroring rule.
3118  *   The *rte_eth_vm_mirror_conf* structure includes the type of mirroring rule,
3119  *   destination pool and the value of rule if enable vlan or pool mirroring.
3120  *
3121  * @param rule_id
3122  *   The index of traffic mirroring rule, we support four separated rules.
3123  * @param on
3124  *   1 - Enable a mirroring rule.
3125  *   0 - Disable a mirroring rule.
3126  * @return
3127  *   - (0) if successful.
3128  *   - (-ENOTSUP) if hardware doesn't support this feature.
3129  *   - (-ENODEV) if *port_id* invalid.
3130  *   - (-EINVAL) if the mr_conf information is not correct.
3131  */
3132 int rte_eth_mirror_rule_set(uint8_t port_id,
3133                         struct rte_eth_mirror_conf *mirror_conf,
3134                         uint8_t rule_id,
3135                         uint8_t on);
3136
3137 /**
3138  * Reset a traffic mirroring rule on an Ethernet device.
3139  *
3140  * @param port_id
3141  *   The port identifier of the Ethernet device.
3142  * @param rule_id
3143  *   The index of traffic mirroring rule, we support four separated rules.
3144  * @return
3145  *   - (0) if successful.
3146  *   - (-ENOTSUP) if hardware doesn't support this feature.
3147  *   - (-ENODEV) if *port_id* invalid.
3148  *   - (-EINVAL) if bad parameter.
3149  */
3150 int rte_eth_mirror_rule_reset(uint8_t port_id,
3151                                          uint8_t rule_id);
3152
3153 /**
3154  * Set the rate limitation for a queue on an Ethernet device.
3155  *
3156  * @param port_id
3157  *   The port identifier of the Ethernet device.
3158  * @param queue_idx
3159  *   The queue id.
3160  * @param tx_rate
3161  *   The tx rate in Mbps. Allocated from the total port link speed.
3162  * @return
3163  *   - (0) if successful.
3164  *   - (-ENOTSUP) if hardware doesn't support this feature.
3165  *   - (-ENODEV) if *port_id* invalid.
3166  *   - (-EINVAL) if bad parameter.
3167  */
3168 int rte_eth_set_queue_rate_limit(uint8_t port_id, uint16_t queue_idx,
3169                         uint16_t tx_rate);
3170
3171 /**
3172  * Set the rate limitation for a vf on an Ethernet device.
3173  *
3174  * @param port_id
3175  *   The port identifier of the Ethernet device.
3176  * @param vf
3177  *   VF id.
3178  * @param tx_rate
3179  *   The tx rate allocated from the total link speed for this VF id.
3180  * @param q_msk
3181  *   The queue mask which need to set the rate.
3182  * @return
3183  *   - (0) if successful.
3184  *   - (-ENOTSUP) if hardware doesn't support this feature.
3185  *   - (-ENODEV) if *port_id* invalid.
3186  *   - (-EINVAL) if bad parameter.
3187  */
3188 int rte_eth_set_vf_rate_limit(uint8_t port_id, uint16_t vf,
3189                         uint16_t tx_rate, uint64_t q_msk);
3190
3191 /**
3192  * Initialize bypass logic. This function needs to be called before
3193  * executing any other bypass API.
3194  *
3195  * @param port
3196  *   The port identifier of the Ethernet device.
3197  * @return
3198  *   - (0) if successful.
3199  *   - (-ENOTSUP) if hardware doesn't support.
3200  *   - (-EINVAL) if bad parameter.
3201  */
3202 int rte_eth_dev_bypass_init(uint8_t port);
3203
3204 /**
3205  * Return bypass state.
3206  *
3207  * @param port
3208  *   The port identifier of the Ethernet device.
3209  * @param state
3210  *   The return bypass state.
3211  *   - (1) Normal mode
3212  *   - (2) Bypass mode
3213  *   - (3) Isolate mode
3214  * @return
3215  *   - (0) if successful.
3216  *   - (-ENOTSUP) if hardware doesn't support.
3217  *   - (-EINVAL) if bad parameter.
3218  */
3219 int rte_eth_dev_bypass_state_show(uint8_t port, uint32_t *state);
3220
3221 /**
3222  * Set bypass state
3223  *
3224  * @param port
3225  *   The port identifier of the Ethernet device.
3226  * @param new_state
3227  *   The current bypass state.
3228  *   - (1) Normal mode
3229  *   - (2) Bypass mode
3230  *   - (3) Isolate mode
3231  * @return
3232  *   - (0) if successful.
3233  *   - (-ENOTSUP) if hardware doesn't support.
3234  *   - (-EINVAL) if bad parameter.
3235  */
3236 int rte_eth_dev_bypass_state_set(uint8_t port, uint32_t *new_state);
3237
3238 /**
3239  * Return bypass state when given event occurs.
3240  *
3241  * @param port
3242  *   The port identifier of the Ethernet device.
3243  * @param event
3244  *   The bypass event
3245  *   - (1) Main power on (power button is pushed)
3246  *   - (2) Auxiliary power on (power supply is being plugged)
3247  *   - (3) Main power off (system shutdown and power supply is left plugged in)
3248  *   - (4) Auxiliary power off (power supply is being unplugged)
3249  *   - (5) Display or set the watchdog timer
3250  * @param state
3251  *   The bypass state when given event occurred.
3252  *   - (1) Normal mode
3253  *   - (2) Bypass mode
3254  *   - (3) Isolate mode
3255  * @return
3256  *   - (0) if successful.
3257  *   - (-ENOTSUP) if hardware doesn't support.
3258  *   - (-EINVAL) if bad parameter.
3259  */
3260 int rte_eth_dev_bypass_event_show(uint8_t port, uint32_t event, uint32_t *state);
3261
3262 /**
3263  * Set bypass state when given event occurs.
3264  *
3265  * @param port
3266  *   The port identifier of the Ethernet device.
3267  * @param event
3268  *   The bypass event
3269  *   - (1) Main power on (power button is pushed)
3270  *   - (2) Auxiliary power on (power supply is being plugged)
3271  *   - (3) Main power off (system shutdown and power supply is left plugged in)
3272  *   - (4) Auxiliary power off (power supply is being unplugged)
3273  *   - (5) Display or set the watchdog timer
3274  * @param state
3275  *   The assigned state when given event occurs.
3276  *   - (1) Normal mode
3277  *   - (2) Bypass mode
3278  *   - (3) Isolate mode
3279  * @return
3280  *   - (0) if successful.
3281  *   - (-ENOTSUP) if hardware doesn't support.
3282  *   - (-EINVAL) if bad parameter.
3283  */
3284 int rte_eth_dev_bypass_event_store(uint8_t port, uint32_t event, uint32_t state);
3285
3286 /**
3287  * Set bypass watchdog timeout count.
3288  *
3289  * @param port
3290  *   The port identifier of the Ethernet device.
3291  * @param timeout
3292  *   The timeout to be set.
3293  *   - (0) 0 seconds (timer is off)
3294  *   - (1) 1.5 seconds
3295  *   - (2) 2 seconds
3296  *   - (3) 3 seconds
3297  *   - (4) 4 seconds
3298  *   - (5) 8 seconds
3299  *   - (6) 16 seconds
3300  *   - (7) 32 seconds
3301  * @return
3302  *   - (0) if successful.
3303  *   - (-ENOTSUP) if hardware doesn't support.
3304  *   - (-EINVAL) if bad parameter.
3305  */
3306 int rte_eth_dev_wd_timeout_store(uint8_t port, uint32_t timeout);
3307
3308 /**
3309  * Get bypass firmware version.
3310  *
3311  * @param port
3312  *   The port identifier of the Ethernet device.
3313  * @param ver
3314  *   The firmware version
3315  * @return
3316  *   - (0) if successful.
3317  *   - (-ENOTSUP) if hardware doesn't support.
3318  *   - (-EINVAL) if bad parameter.
3319  */
3320 int rte_eth_dev_bypass_ver_show(uint8_t port, uint32_t *ver);
3321
3322 /**
3323  * Return bypass watchdog timeout in seconds
3324  *
3325  * @param port
3326  *   The port identifier of the Ethernet device.
3327  * @param wd_timeout
3328  *   The return watchdog timeout. "0" represents timer expired
3329  *   - (0) 0 seconds (timer is off)
3330  *   - (1) 1.5 seconds
3331  *   - (2) 2 seconds
3332  *   - (3) 3 seconds
3333  *   - (4) 4 seconds
3334  *   - (5) 8 seconds
3335  *   - (6) 16 seconds
3336  *   - (7) 32 seconds
3337  * @return
3338  *   - (0) if successful.
3339  *   - (-ENOTSUP) if hardware doesn't support.
3340  *   - (-EINVAL) if bad parameter.
3341  */
3342 int rte_eth_dev_bypass_wd_timeout_show(uint8_t port, uint32_t *wd_timeout);
3343
3344 /**
3345  * Reset bypass watchdog timer
3346  *
3347  * @param port
3348  *   The port identifier of the Ethernet device.
3349  * @return
3350  *   - (0) if successful.
3351  *   - (-ENOTSUP) if hardware doesn't support.
3352  *   - (-EINVAL) if bad parameter.
3353  */
3354 int rte_eth_dev_bypass_wd_reset(uint8_t port);
3355
3356  /**
3357  * Configuration of Receive Side Scaling hash computation of Ethernet device.
3358  *
3359  * @param port_id
3360  *   The port identifier of the Ethernet device.
3361  * @param rss_conf
3362  *   The new configuration to use for RSS hash computation on the port.
3363  * @return
3364  *   - (0) if successful.
3365  *   - (-ENODEV) if port identifier is invalid.
3366  *   - (-ENOTSUP) if hardware doesn't support.
3367  *   - (-EINVAL) if bad parameter.
3368  */
3369 int rte_eth_dev_rss_hash_update(uint8_t port_id,
3370                                 struct rte_eth_rss_conf *rss_conf);
3371
3372  /**
3373  * Retrieve current configuration of Receive Side Scaling hash computation
3374  * of Ethernet device.
3375  *
3376  * @param port_id
3377  *   The port identifier of the Ethernet device.
3378  * @param rss_conf
3379  *   Where to store the current RSS hash configuration of the Ethernet device.
3380  * @return
3381  *   - (0) if successful.
3382  *   - (-ENODEV) if port identifier is invalid.
3383  *   - (-ENOTSUP) if hardware doesn't support RSS.
3384  */
3385 int
3386 rte_eth_dev_rss_hash_conf_get(uint8_t port_id,
3387                               struct rte_eth_rss_conf *rss_conf);
3388
3389  /**
3390  * Add UDP tunneling port of an Ethernet device for filtering a specific
3391  * tunneling packet by UDP port number.
3392  *
3393  * @param port_id
3394  *   The port identifier of the Ethernet device.
3395  * @param tunnel_udp
3396  *   UDP tunneling configuration.
3397  *
3398  * @return
3399  *   - (0) if successful.
3400  *   - (-ENODEV) if port identifier is invalid.
3401  *   - (-ENOTSUP) if hardware doesn't support tunnel type.
3402  */
3403 int
3404 rte_eth_dev_udp_tunnel_add(uint8_t port_id,
3405                            struct rte_eth_udp_tunnel *tunnel_udp);
3406
3407  /**
3408  * Detete UDP tunneling port configuration of Ethernet device
3409  *
3410  * @param port_id
3411  *   The port identifier of the Ethernet device.
3412  * @param tunnel_udp
3413  *   UDP tunneling configuration.
3414  *
3415  * @return
3416  *   - (0) if successful.
3417  *   - (-ENODEV) if port identifier is invalid.
3418  *   - (-ENOTSUP) if hardware doesn't support tunnel type.
3419  */
3420 int
3421 rte_eth_dev_udp_tunnel_delete(uint8_t port_id,
3422                               struct rte_eth_udp_tunnel *tunnel_udp);
3423
3424 /**
3425  * Check whether the filter type is supported on an Ethernet device.
3426  * All the supported filter types are defined in 'rte_eth_ctrl.h'.
3427  *
3428  * @param port_id
3429  *   The port identifier of the Ethernet device.
3430  * @param filter_type
3431  *   Filter type.
3432  * @return
3433  *   - (0) if successful.
3434  *   - (-ENOTSUP) if hardware doesn't support this filter type.
3435  *   - (-ENODEV) if *port_id* invalid.
3436  */
3437 int rte_eth_dev_filter_supported(uint8_t port_id, enum rte_filter_type filter_type);
3438
3439 /**
3440  * Take operations to assigned filter type on an Ethernet device.
3441  * All the supported operations and filter types are defined in 'rte_eth_ctrl.h'.
3442  *
3443  * @param port_id
3444  *   The port identifier of the Ethernet device.
3445  * @param filter_type
3446  *   Filter type.
3447  * @param filter_op
3448  *   Type of operation.
3449  * @param arg
3450  *   A pointer to arguments defined specifically for the operation.
3451  * @return
3452  *   - (0) if successful.
3453  *   - (-ENOTSUP) if hardware doesn't support.
3454  *   - (-ENODEV) if *port_id* invalid.
3455  *   - others depends on the specific operations implementation.
3456  */
3457 int rte_eth_dev_filter_ctrl(uint8_t port_id, enum rte_filter_type filter_type,
3458                         enum rte_filter_op filter_op, void *arg);
3459
3460 /**
3461  * Get DCB information on an Ethernet device.
3462  *
3463  * @param port_id
3464  *   The port identifier of the Ethernet device.
3465  * @param dcb_info
3466  *   dcb information.
3467  * @return
3468  *   - (0) if successful.
3469  *   - (-ENODEV) if port identifier is invalid.
3470  *   - (-ENOTSUP) if hardware doesn't support.
3471  */
3472 int rte_eth_dev_get_dcb_info(uint8_t port_id,
3473                              struct rte_eth_dcb_info *dcb_info);
3474
3475 /**
3476  * Add a callback to be called on packet RX on a given port and queue.
3477  *
3478  * This API configures a function to be called for each burst of
3479  * packets received on a given NIC port queue. The return value is a pointer
3480  * that can be used to later remove the callback using
3481  * rte_eth_remove_rx_callback().
3482  *
3483  * Multiple functions are called in the order that they are added.
3484  *
3485  * @param port_id
3486  *   The port identifier of the Ethernet device.
3487  * @param queue_id
3488  *   The queue on the Ethernet device on which the callback is to be added.
3489  * @param fn
3490  *   The callback function
3491  * @param user_param
3492  *   A generic pointer parameter which will be passed to each invocation of the
3493  *   callback function on this port and queue.
3494  *
3495  * @return
3496  *   NULL on error.
3497  *   On success, a pointer value which can later be used to remove the callback.
3498  */
3499 void *rte_eth_add_rx_callback(uint8_t port_id, uint16_t queue_id,
3500                 rte_rx_callback_fn fn, void *user_param);
3501
3502 /**
3503  * Add a callback to be called on packet TX on a given port and queue.
3504  *
3505  * This API configures a function to be called for each burst of
3506  * packets sent on a given NIC port queue. The return value is a pointer
3507  * that can be used to later remove the callback using
3508  * rte_eth_remove_tx_callback().
3509  *
3510  * Multiple functions are called in the order that they are added.
3511  *
3512  * @param port_id
3513  *   The port identifier of the Ethernet device.
3514  * @param queue_id
3515  *   The queue on the Ethernet device on which the callback is to be added.
3516  * @param fn
3517  *   The callback function
3518  * @param user_param
3519  *   A generic pointer parameter which will be passed to each invocation of the
3520  *   callback function on this port and queue.
3521  *
3522  * @return
3523  *   NULL on error.
3524  *   On success, a pointer value which can later be used to remove the callback.
3525  */
3526 void *rte_eth_add_tx_callback(uint8_t port_id, uint16_t queue_id,
3527                 rte_tx_callback_fn fn, void *user_param);
3528
3529 /**
3530  * Remove an RX packet callback from a given port and queue.
3531  *
3532  * This function is used to removed callbacks that were added to a NIC port
3533  * queue using rte_eth_add_rx_callback().
3534  *
3535  * Note: the callback is removed from the callback list but it isn't freed
3536  * since the it may still be in use. The memory for the callback can be
3537  * subsequently freed back by the application by calling rte_free():
3538  *
3539  * - Immediately - if the port is stopped, or the user knows that no
3540  *   callbacks are in flight e.g. if called from the thread doing RX/TX
3541  *   on that queue.
3542  *
3543  * - After a short delay - where the delay is sufficient to allow any
3544  *   in-flight callbacks to complete.
3545  *
3546  * @param port_id
3547  *   The port identifier of the Ethernet device.
3548  * @param queue_id
3549  *   The queue on the Ethernet device from which the callback is to be removed.
3550  * @param user_cb
3551  *   User supplied callback created via rte_eth_add_rx_callback().
3552  *
3553  * @return
3554  *   - 0: Success. Callback was removed.
3555  *   - -ENOTSUP: Callback support is not available.
3556  *   - -EINVAL:  The port_id or the queue_id is out of range, or the callback
3557  *               is NULL or not found for the port/queue.
3558  */
3559 int rte_eth_remove_rx_callback(uint8_t port_id, uint16_t queue_id,
3560                 struct rte_eth_rxtx_callback *user_cb);
3561
3562 /**
3563  * Remove a TX packet callback from a given port and queue.
3564  *
3565  * This function is used to removed callbacks that were added to a NIC port
3566  * queue using rte_eth_add_tx_callback().
3567  *
3568  * Note: the callback is removed from the callback list but it isn't freed
3569  * since the it may still be in use. The memory for the callback can be
3570  * subsequently freed back by the application by calling rte_free():
3571  *
3572  * - Immediately - if the port is stopped, or the user knows that no
3573  *   callbacks are in flight e.g. if called from the thread doing RX/TX
3574  *   on that queue.
3575  *
3576  * - After a short delay - where the delay is sufficient to allow any
3577  *   in-flight callbacks to complete.
3578  *
3579  * @param port_id
3580  *   The port identifier of the Ethernet device.
3581  * @param queue_id
3582  *   The queue on the Ethernet device from which the callback is to be removed.
3583  * @param user_cb
3584  *   User supplied callback created via rte_eth_add_tx_callback().
3585  *
3586  * @return
3587  *   - 0: Success. Callback was removed.
3588  *   - -ENOTSUP: Callback support is not available.
3589  *   - -EINVAL:  The port_id or the queue_id is out of range, or the callback
3590  *               is NULL or not found for the port/queue.
3591  */
3592 int rte_eth_remove_tx_callback(uint8_t port_id, uint16_t queue_id,
3593                 struct rte_eth_rxtx_callback *user_cb);
3594
3595 /**
3596  * Retrieve information about given port's RX queue.
3597  *
3598  * @param port_id
3599  *   The port identifier of the Ethernet device.
3600  * @param queue_id
3601  *   The RX queue on the Ethernet device for which information
3602  *   will be retrieved.
3603  * @param qinfo
3604  *   A pointer to a structure of type *rte_eth_rxq_info_info* to be filled with
3605  *   the information of the Ethernet device.
3606  *
3607  * @return
3608  *   - 0: Success
3609  *   - -ENOTSUP: routine is not supported by the device PMD.
3610  *   - -EINVAL:  The port_id or the queue_id is out of range.
3611  */
3612 int rte_eth_rx_queue_info_get(uint8_t port_id, uint16_t queue_id,
3613         struct rte_eth_rxq_info *qinfo);
3614
3615 /**
3616  * Retrieve information about given port's TX queue.
3617  *
3618  * @param port_id
3619  *   The port identifier of the Ethernet device.
3620  * @param queue_id
3621  *   The TX queue on the Ethernet device for which information
3622  *   will be retrieved.
3623  * @param qinfo
3624  *   A pointer to a structure of type *rte_eth_txq_info_info* to be filled with
3625  *   the information of the Ethernet device.
3626  *
3627  * @return
3628  *   - 0: Success
3629  *   - -ENOTSUP: routine is not supported by the device PMD.
3630  *   - -EINVAL:  The port_id or the queue_id is out of range.
3631  */
3632 int rte_eth_tx_queue_info_get(uint8_t port_id, uint16_t queue_id,
3633         struct rte_eth_txq_info *qinfo);
3634
3635 /*
3636  * Retrieve number of available registers for access
3637  *
3638  * @param port_id
3639  *   The port identifier of the Ethernet device.
3640  * @return
3641  *   - (>=0) number of registers if successful.
3642  *   - (-ENOTSUP) if hardware doesn't support.
3643  *   - (-ENODEV) if *port_id* invalid.
3644  *   - others depends on the specific operations implementation.
3645  */
3646 int rte_eth_dev_get_reg_length(uint8_t port_id);
3647
3648 /**
3649  * Retrieve device registers and register attributes
3650  *
3651  * @param port_id
3652  *   The port identifier of the Ethernet device.
3653  * @param info
3654  *   The template includes buffer for register data and attribute to be filled.
3655  * @return
3656  *   - (0) if successful.
3657  *   - (-ENOTSUP) if hardware doesn't support.
3658  *   - (-ENODEV) if *port_id* invalid.
3659  *   - others depends on the specific operations implementation.
3660  */
3661 int rte_eth_dev_get_reg_info(uint8_t port_id, struct rte_dev_reg_info *info);
3662
3663 /**
3664  * Retrieve size of device EEPROM
3665  *
3666  * @param port_id
3667  *   The port identifier of the Ethernet device.
3668  * @return
3669  *   - (>=0) EEPROM size if successful.
3670  *   - (-ENOTSUP) if hardware doesn't support.
3671  *   - (-ENODEV) if *port_id* invalid.
3672  *   - others depends on the specific operations implementation.
3673  */
3674 int rte_eth_dev_get_eeprom_length(uint8_t port_id);
3675
3676 /**
3677  * Retrieve EEPROM and EEPROM attribute
3678  *
3679  * @param port_id
3680  *   The port identifier of the Ethernet device.
3681  * @param info
3682  *   The template includes buffer for return EEPROM data and
3683  *   EEPROM attributes to be filled.
3684  * @return
3685  *   - (0) if successful.
3686  *   - (-ENOTSUP) if hardware doesn't support.
3687  *   - (-ENODEV) if *port_id* invalid.
3688  *   - others depends on the specific operations implementation.
3689  */
3690 int rte_eth_dev_get_eeprom(uint8_t port_id, struct rte_dev_eeprom_info *info);
3691
3692 /**
3693  * Program EEPROM with provided data
3694  *
3695  * @param port_id
3696  *   The port identifier of the Ethernet device.
3697  * @param info
3698  *   The template includes EEPROM data for programming and
3699  *   EEPROM attributes to be filled
3700  * @return
3701  *   - (0) if successful.
3702  *   - (-ENOTSUP) if hardware doesn't support.
3703  *   - (-ENODEV) if *port_id* invalid.
3704  *   - others depends on the specific operations implementation.
3705  */
3706 int rte_eth_dev_set_eeprom(uint8_t port_id, struct rte_dev_eeprom_info *info);
3707
3708 /**
3709  * Set the list of multicast addresses to filter on an Ethernet device.
3710  *
3711  * @param port_id
3712  *   The port identifier of the Ethernet device.
3713  * @param mc_addr_set
3714  *   The array of multicast addresses to set. Equal to NULL when the function
3715  *   is invoked to flush the set of filtered addresses.
3716  * @param nb_mc_addr
3717  *   The number of multicast addresses in the *mc_addr_set* array. Equal to 0
3718  *   when the function is invoked to flush the set of filtered addresses.
3719  * @return
3720  *   - (0) if successful.
3721  *   - (-ENODEV) if *port_id* invalid.
3722  *   - (-ENOTSUP) if PMD of *port_id* doesn't support multicast filtering.
3723  *   - (-ENOSPC) if *port_id* has not enough multicast filtering resources.
3724  */
3725 int rte_eth_dev_set_mc_addr_list(uint8_t port_id,
3726                                  struct ether_addr *mc_addr_set,
3727                                  uint32_t nb_mc_addr);
3728
3729 /**
3730  * Enable IEEE1588/802.1AS timestamping for an Ethernet device.
3731  *
3732  * @param port_id
3733  *   The port identifier of the Ethernet device.
3734  *
3735  * @return
3736  *   - 0: Success.
3737  *   - -ENODEV: The port ID is invalid.
3738  *   - -ENOTSUP: The function is not supported by the Ethernet driver.
3739  */
3740 int rte_eth_timesync_enable(uint8_t port_id);
3741
3742 /**
3743  * Disable IEEE1588/802.1AS timestamping for an Ethernet device.
3744  *
3745  * @param port_id
3746  *   The port identifier of the Ethernet device.
3747  *
3748  * @return
3749  *   - 0: Success.
3750  *   - -ENODEV: The port ID is invalid.
3751  *   - -ENOTSUP: The function is not supported by the Ethernet driver.
3752  */
3753 int rte_eth_timesync_disable(uint8_t port_id);
3754
3755 /**
3756  * Read an IEEE1588/802.1AS RX timestamp from an Ethernet device.
3757  *
3758  * @param port_id
3759  *   The port identifier of the Ethernet device.
3760  * @param timestamp
3761  *   Pointer to the timestamp struct.
3762  * @param flags
3763  *   Device specific flags. Used to pass the RX timesync register index to
3764  *   i40e. Unused in igb/ixgbe, pass 0 instead.
3765  *
3766  * @return
3767  *   - 0: Success.
3768  *   - -EINVAL: No timestamp is available.
3769  *   - -ENODEV: The port ID is invalid.
3770  *   - -ENOTSUP: The function is not supported by the Ethernet driver.
3771  */
3772 int rte_eth_timesync_read_rx_timestamp(uint8_t port_id,
3773                 struct timespec *timestamp, uint32_t flags);
3774
3775 /**
3776  * Read an IEEE1588/802.1AS TX timestamp from an Ethernet device.
3777  *
3778  * @param port_id
3779  *   The port identifier of the Ethernet device.
3780  * @param timestamp
3781  *   Pointer to the timestamp struct.
3782  *
3783  * @return
3784  *   - 0: Success.
3785  *   - -EINVAL: No timestamp is available.
3786  *   - -ENODEV: The port ID is invalid.
3787  *   - -ENOTSUP: The function is not supported by the Ethernet driver.
3788  */
3789 int rte_eth_timesync_read_tx_timestamp(uint8_t port_id,
3790                 struct timespec *timestamp);
3791
3792 /**
3793  * Adjust the timesync clock on an Ethernet device.
3794  *
3795  * This is usually used in conjunction with other Ethdev timesync functions to
3796  * synchronize the device time using the IEEE1588/802.1AS protocol.
3797  *
3798  * @param port_id
3799  *   The port identifier of the Ethernet device.
3800  * @param delta
3801  *   The adjustment in nanoseconds.
3802  *
3803  * @return
3804  *   - 0: Success.
3805  *   - -ENODEV: The port ID is invalid.
3806  *   - -ENOTSUP: The function is not supported by the Ethernet driver.
3807  */
3808 int rte_eth_timesync_adjust_time(uint8_t port_id, int64_t delta);
3809
3810 /**
3811  * Read the time from the timesync clock on an Ethernet device.
3812  *
3813  * This is usually used in conjunction with other Ethdev timesync functions to
3814  * synchronize the device time using the IEEE1588/802.1AS protocol.
3815  *
3816  * @param port_id
3817  *   The port identifier of the Ethernet device.
3818  * @param time
3819  *   Pointer to the timespec struct that holds the time.
3820  *
3821  * @return
3822  *   - 0: Success.
3823  */
3824 int rte_eth_timesync_read_time(uint8_t port_id, struct timespec *time);
3825
3826 /**
3827  * Set the time of the timesync clock on an Ethernet device.
3828  *
3829  * This is usually used in conjunction with other Ethdev timesync functions to
3830  * synchronize the device time using the IEEE1588/802.1AS protocol.
3831  *
3832  * @param port_id
3833  *   The port identifier of the Ethernet device.
3834  * @param time
3835  *   Pointer to the timespec struct that holds the time.
3836  *
3837  * @return
3838  *   - 0: Success.
3839  *   - -EINVAL: No timestamp is available.
3840  *   - -ENODEV: The port ID is invalid.
3841  *   - -ENOTSUP: The function is not supported by the Ethernet driver.
3842  */
3843 int rte_eth_timesync_write_time(uint8_t port_id, const struct timespec *time);
3844
3845 /**
3846  * Copy pci device info to the Ethernet device data.
3847  *
3848  * @param eth_dev
3849  * The *eth_dev* pointer is the address of the *rte_eth_dev* structure.
3850  * @param pci_dev
3851  * The *pci_dev* pointer is the address of the *rte_pci_device* structure.
3852  *
3853  * @return
3854  *   - 0 on success, negative on error
3855  */
3856 void rte_eth_copy_pci_info(struct rte_eth_dev *eth_dev,
3857                 struct rte_pci_device *pci_dev);
3858
3859 /**
3860  * Create memzone for HW rings.
3861  * malloc can't be used as the physical address is needed.
3862  * If the memzone is already created, then this function returns a ptr
3863  * to the old one.
3864  *
3865  * @param eth_dev
3866  *   The *eth_dev* pointer is the address of the *rte_eth_dev* structure
3867  * @param name
3868  *   The name of the memory zone
3869  * @param queue_id
3870  *   The index of the queue to add to name
3871  * @param size
3872  *   The sizeof of the memory area
3873  * @param align
3874  *   Alignment for resulting memzone. Must be a power of 2.
3875  * @param socket_id
3876  *   The *socket_id* argument is the socket identifier in case of NUMA.
3877  */
3878 const struct rte_memzone *
3879 rte_eth_dma_zone_reserve(const struct rte_eth_dev *eth_dev, const char *name,
3880                          uint16_t queue_id, size_t size,
3881                          unsigned align, int socket_id);
3882
3883 #ifdef __cplusplus
3884 }
3885 #endif
3886
3887 #endif /* _RTE_ETHDEV_H_ */