ethdev: add sanity checks to functions
[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         uint8_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_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_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(fmt, args...)
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 extern 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 extern 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 extern 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 extern int rte_eth_dev_configure(uint8_t port_id,
1819                                  uint16_t nb_rx_queue,
1820                                  uint16_t nb_tx_queue,
1821                                  const struct rte_eth_conf *eth_conf);
1822
1823 /**
1824  * Allocate and set up a receive queue for an Ethernet device.
1825  *
1826  * The function allocates a contiguous block of memory for *nb_rx_desc*
1827  * receive descriptors from a memory zone associated with *socket_id*
1828  * and initializes each receive descriptor with a network buffer allocated
1829  * from the memory pool *mb_pool*.
1830  *
1831  * @param port_id
1832  *   The port identifier of the Ethernet device.
1833  * @param rx_queue_id
1834  *   The index of the receive queue to set up.
1835  *   The value must be in the range [0, nb_rx_queue - 1] previously supplied
1836  *   to rte_eth_dev_configure().
1837  * @param nb_rx_desc
1838  *   The number of receive descriptors to allocate for the receive ring.
1839  * @param socket_id
1840  *   The *socket_id* argument is the socket identifier in case of NUMA.
1841  *   The value can be *SOCKET_ID_ANY* if there is no NUMA constraint for
1842  *   the DMA memory allocated for the receive descriptors of the ring.
1843  * @param rx_conf
1844  *   The pointer to the configuration data to be used for the receive queue.
1845  *   NULL value is allowed, in which case default RX configuration
1846  *   will be used.
1847  *   The *rx_conf* structure contains an *rx_thresh* structure with the values
1848  *   of the Prefetch, Host, and Write-Back threshold registers of the receive
1849  *   ring.
1850  * @param mb_pool
1851  *   The pointer to the memory pool from which to allocate *rte_mbuf* network
1852  *   memory buffers to populate each descriptor of the receive ring.
1853  * @return
1854  *   - 0: Success, receive queue correctly set up.
1855  *   - -EINVAL: The size of network buffers which can be allocated from the
1856  *      memory pool does not fit the various buffer sizes allowed by the
1857  *      device controller.
1858  *   - -ENOMEM: Unable to allocate the receive ring descriptors or to
1859  *      allocate network memory buffers from the memory pool when
1860  *      initializing receive descriptors.
1861  */
1862 extern int rte_eth_rx_queue_setup(uint8_t port_id, uint16_t rx_queue_id,
1863                                   uint16_t nb_rx_desc, unsigned int socket_id,
1864                                   const struct rte_eth_rxconf *rx_conf,
1865                                   struct rte_mempool *mb_pool);
1866
1867 /**
1868  * Allocate and set up a transmit queue for an Ethernet device.
1869  *
1870  * @param port_id
1871  *   The port identifier of the Ethernet device.
1872  * @param tx_queue_id
1873  *   The index of the transmit queue to set up.
1874  *   The value must be in the range [0, nb_tx_queue - 1] previously supplied
1875  *   to rte_eth_dev_configure().
1876  * @param nb_tx_desc
1877  *   The number of transmit descriptors to allocate for the transmit ring.
1878  * @param socket_id
1879  *   The *socket_id* argument is the socket identifier in case of NUMA.
1880  *   Its value can be *SOCKET_ID_ANY* if there is no NUMA constraint for
1881  *   the DMA memory allocated for the transmit descriptors of the ring.
1882  * @param tx_conf
1883  *   The pointer to the configuration data to be used for the transmit queue.
1884  *   NULL value is allowed, in which case default RX configuration
1885  *   will be used.
1886  *   The *tx_conf* structure contains the following data:
1887  *   - The *tx_thresh* structure with the values of the Prefetch, Host, and
1888  *     Write-Back threshold registers of the transmit ring.
1889  *     When setting Write-Back threshold to the value greater then zero,
1890  *     *tx_rs_thresh* value should be explicitly set to one.
1891  *   - The *tx_free_thresh* value indicates the [minimum] number of network
1892  *     buffers that must be pending in the transmit ring to trigger their
1893  *     [implicit] freeing by the driver transmit function.
1894  *   - The *tx_rs_thresh* value indicates the [minimum] number of transmit
1895  *     descriptors that must be pending in the transmit ring before setting the
1896  *     RS bit on a descriptor by the driver transmit function.
1897  *     The *tx_rs_thresh* value should be less or equal then
1898  *     *tx_free_thresh* value, and both of them should be less then
1899  *     *nb_tx_desc* - 3.
1900  *   - The *txq_flags* member contains flags to pass to the TX queue setup
1901  *     function to configure the behavior of the TX queue. This should be set
1902  *     to 0 if no special configuration is required.
1903  *
1904  *     Note that setting *tx_free_thresh* or *tx_rs_thresh* value to 0 forces
1905  *     the transmit function to use default values.
1906  * @return
1907  *   - 0: Success, the transmit queue is correctly set up.
1908  *   - -ENOMEM: Unable to allocate the transmit ring descriptors.
1909  */
1910 extern int rte_eth_tx_queue_setup(uint8_t port_id, uint16_t tx_queue_id,
1911                                   uint16_t nb_tx_desc, unsigned int socket_id,
1912                                   const struct rte_eth_txconf *tx_conf);
1913
1914 /*
1915  * Return the NUMA socket to which an Ethernet device is connected
1916  *
1917  * @param port_id
1918  *   The port identifier of the Ethernet device
1919  * @return
1920  *   The NUMA socket id to which the Ethernet device is connected or
1921  *   a default of zero if the socket could not be determined.
1922  *   -1 is returned is the port_id value is out of range.
1923  */
1924 extern int rte_eth_dev_socket_id(uint8_t port_id);
1925
1926 /*
1927  * Check if port_id of device is attached
1928  *
1929  * @param port_id
1930  *   The port identifier of the Ethernet device
1931  * @return
1932  *   - 0 if port is out of range or not attached
1933  *   - 1 if device is attached
1934  */
1935 extern int rte_eth_dev_is_valid_port(uint8_t port_id);
1936
1937 /*
1938  * Allocate mbuf from mempool, setup the DMA physical address
1939  * and then start RX for specified queue of a port. It is used
1940  * when rx_deferred_start flag of the specified queue is true.
1941  *
1942  * @param port_id
1943  *   The port identifier of the Ethernet device
1944  * @param rx_queue_id
1945  *   The index of the rx queue to update the ring.
1946  *   The value must be in the range [0, nb_rx_queue - 1] previously supplied
1947  *   to rte_eth_dev_configure().
1948  * @return
1949  *   - 0: Success, the transmit queue is correctly set up.
1950  *   - -EINVAL: The port_id or the queue_id out of range.
1951  *   - -ENOTSUP: The function not supported in PMD driver.
1952  */
1953 extern int rte_eth_dev_rx_queue_start(uint8_t port_id, uint16_t rx_queue_id);
1954
1955 /*
1956  * Stop specified RX queue of a port
1957  *
1958  * @param port_id
1959  *   The port identifier of the Ethernet device
1960  * @param rx_queue_id
1961  *   The index of the rx queue to update the ring.
1962  *   The value must be in the range [0, nb_rx_queue - 1] previously supplied
1963  *   to rte_eth_dev_configure().
1964  * @return
1965  *   - 0: Success, the transmit queue is correctly set up.
1966  *   - -EINVAL: The port_id or the queue_id out of range.
1967  *   - -ENOTSUP: The function not supported in PMD driver.
1968  */
1969 extern int rte_eth_dev_rx_queue_stop(uint8_t port_id, uint16_t rx_queue_id);
1970
1971 /*
1972  * Start TX for specified queue of a port. It is used when tx_deferred_start
1973  * flag of the specified queue is true.
1974  *
1975  * @param port_id
1976  *   The port identifier of the Ethernet device
1977  * @param tx_queue_id
1978  *   The index of the tx queue to update the ring.
1979  *   The value must be in the range [0, nb_tx_queue - 1] previously supplied
1980  *   to rte_eth_dev_configure().
1981  * @return
1982  *   - 0: Success, the transmit queue is correctly set up.
1983  *   - -EINVAL: The port_id or the queue_id out of range.
1984  *   - -ENOTSUP: The function not supported in PMD driver.
1985  */
1986 extern int rte_eth_dev_tx_queue_start(uint8_t port_id, uint16_t tx_queue_id);
1987
1988 /*
1989  * Stop specified TX queue of a port
1990  *
1991  * @param port_id
1992  *   The port identifier of the Ethernet device
1993  * @param tx_queue_id
1994  *   The index of the tx queue to update the ring.
1995  *   The value must be in the range [0, nb_tx_queue - 1] previously supplied
1996  *   to rte_eth_dev_configure().
1997  * @return
1998  *   - 0: Success, the transmit queue is correctly set up.
1999  *   - -EINVAL: The port_id or the queue_id out of range.
2000  *   - -ENOTSUP: The function not supported in PMD driver.
2001  */
2002 extern int rte_eth_dev_tx_queue_stop(uint8_t port_id, uint16_t tx_queue_id);
2003
2004
2005
2006 /**
2007  * Start an Ethernet device.
2008  *
2009  * The device start step is the last one and consists of setting the configured
2010  * offload features and in starting the transmit and the receive units of the
2011  * device.
2012  * On success, all basic functions exported by the Ethernet API (link status,
2013  * receive/transmit, and so on) can be invoked.
2014  *
2015  * @param port_id
2016  *   The port identifier of the Ethernet device.
2017  * @return
2018  *   - 0: Success, Ethernet device started.
2019  *   - <0: Error code of the driver device start function.
2020  */
2021 extern int rte_eth_dev_start(uint8_t port_id);
2022
2023 /**
2024  * Stop an Ethernet device. The device can be restarted with a call to
2025  * rte_eth_dev_start()
2026  *
2027  * @param port_id
2028  *   The port identifier of the Ethernet device.
2029  */
2030 extern void rte_eth_dev_stop(uint8_t port_id);
2031
2032
2033 /**
2034  * Link up an Ethernet device.
2035  *
2036  * Set device link up will re-enable the device rx/tx
2037  * functionality after it is previously set device linked down.
2038  *
2039  * @param port_id
2040  *   The port identifier of the Ethernet device.
2041  * @return
2042  *   - 0: Success, Ethernet device linked up.
2043  *   - <0: Error code of the driver device link up function.
2044  */
2045 extern int rte_eth_dev_set_link_up(uint8_t port_id);
2046
2047 /**
2048  * Link down an Ethernet device.
2049  * The device rx/tx functionality will be disabled if success,
2050  * and it can be re-enabled with a call to
2051  * rte_eth_dev_set_link_up()
2052  *
2053  * @param port_id
2054  *   The port identifier of the Ethernet device.
2055  */
2056 extern int rte_eth_dev_set_link_down(uint8_t port_id);
2057
2058 /**
2059  * Close a stopped Ethernet device. The device cannot be restarted!
2060  * The function frees all resources except for needed by the
2061  * closed state. To free these resources, call rte_eth_dev_detach().
2062  *
2063  * @param port_id
2064  *   The port identifier of the Ethernet device.
2065  */
2066 extern void rte_eth_dev_close(uint8_t port_id);
2067
2068 /**
2069  * Enable receipt in promiscuous mode for an Ethernet device.
2070  *
2071  * @param port_id
2072  *   The port identifier of the Ethernet device.
2073  */
2074 extern void rte_eth_promiscuous_enable(uint8_t port_id);
2075
2076 /**
2077  * Disable receipt in promiscuous mode for an Ethernet device.
2078  *
2079  * @param port_id
2080  *   The port identifier of the Ethernet device.
2081  */
2082 extern void rte_eth_promiscuous_disable(uint8_t port_id);
2083
2084 /**
2085  * Return the value of promiscuous mode for an Ethernet device.
2086  *
2087  * @param port_id
2088  *   The port identifier of the Ethernet device.
2089  * @return
2090  *   - (1) if promiscuous is enabled
2091  *   - (0) if promiscuous is disabled.
2092  *   - (-1) on error
2093  */
2094 extern int rte_eth_promiscuous_get(uint8_t port_id);
2095
2096 /**
2097  * Enable the receipt of any multicast frame by an Ethernet device.
2098  *
2099  * @param port_id
2100  *   The port identifier of the Ethernet device.
2101  */
2102 extern void rte_eth_allmulticast_enable(uint8_t port_id);
2103
2104 /**
2105  * Disable the receipt of all multicast frames by an Ethernet device.
2106  *
2107  * @param port_id
2108  *   The port identifier of the Ethernet device.
2109  */
2110 extern void rte_eth_allmulticast_disable(uint8_t port_id);
2111
2112 /**
2113  * Return the value of allmulticast mode for an Ethernet device.
2114  *
2115  * @param port_id
2116  *   The port identifier of the Ethernet device.
2117  * @return
2118  *   - (1) if allmulticast is enabled
2119  *   - (0) if allmulticast is disabled.
2120  *   - (-1) on error
2121  */
2122 extern int rte_eth_allmulticast_get(uint8_t port_id);
2123
2124 /**
2125  * Retrieve the status (ON/OFF), the speed (in Mbps) and the mode (HALF-DUPLEX
2126  * or FULL-DUPLEX) of the physical link of an Ethernet device. It might need
2127  * to wait up to 9 seconds in it.
2128  *
2129  * @param port_id
2130  *   The port identifier of the Ethernet device.
2131  * @param link
2132  *   A pointer to an *rte_eth_link* structure to be filled with
2133  *   the status, the speed and the mode of the Ethernet device link.
2134  */
2135 extern void rte_eth_link_get(uint8_t port_id, struct rte_eth_link *link);
2136
2137 /**
2138  * Retrieve the status (ON/OFF), the speed (in Mbps) and the mode (HALF-DUPLEX
2139  * or FULL-DUPLEX) of the physical link of an Ethernet device. It is a no-wait
2140  * version of rte_eth_link_get().
2141  *
2142  * @param port_id
2143  *   The port identifier of the Ethernet device.
2144  * @param link
2145  *   A pointer to an *rte_eth_link* structure to be filled with
2146  *   the status, the speed and the mode of the Ethernet device link.
2147  */
2148 extern void rte_eth_link_get_nowait(uint8_t port_id,
2149                                 struct rte_eth_link *link);
2150
2151 /**
2152  * Retrieve the general I/O statistics of an Ethernet device.
2153  *
2154  * @param port_id
2155  *   The port identifier of the Ethernet device.
2156  * @param stats
2157  *   A pointer to a structure of type *rte_eth_stats* to be filled with
2158  *   the values of device counters for the following set of statistics:
2159  *   - *ipackets* with the total of successfully received packets.
2160  *   - *opackets* with the total of successfully transmitted packets.
2161  *   - *ibytes*   with the total of successfully received bytes.
2162  *   - *obytes*   with the total of successfully transmitted bytes.
2163  *   - *ierrors*  with the total of erroneous received packets.
2164  *   - *oerrors*  with the total of failed transmitted packets.
2165  * @return
2166  *   Zero if successful. Non-zero otherwise.
2167  */
2168 extern int rte_eth_stats_get(uint8_t port_id, struct rte_eth_stats *stats);
2169
2170 /**
2171  * Reset the general I/O statistics of an Ethernet device.
2172  *
2173  * @param port_id
2174  *   The port identifier of the Ethernet device.
2175  */
2176 extern void rte_eth_stats_reset(uint8_t port_id);
2177
2178 /**
2179  * Retrieve extended statistics of an Ethernet device.
2180  *
2181  * @param port_id
2182  *   The port identifier of the Ethernet device.
2183  * @param xstats
2184  *   A pointer to a table of structure of type *rte_eth_xstats*
2185  *   to be filled with device statistics names and values.
2186  *   This parameter can be set to NULL if n is 0.
2187  * @param n
2188  *   The size of the stats table, which should be large enough to store
2189  *   all the statistics of the device.
2190  * @return
2191  *   - positive value lower or equal to n: success. The return value
2192  *     is the number of entries filled in the stats table.
2193  *   - positive value higher than n: error, the given statistics table
2194  *     is too small. The return value corresponds to the size that should
2195  *     be given to succeed. The entries in the table are not valid and
2196  *     shall not be used by the caller.
2197  *   - negative value on error (invalid port id)
2198  */
2199 extern int rte_eth_xstats_get(uint8_t port_id,
2200         struct rte_eth_xstats *xstats, unsigned n);
2201
2202 /**
2203  * Reset extended statistics of an Ethernet device.
2204  *
2205  * @param port_id
2206  *   The port identifier of the Ethernet device.
2207  */
2208 extern void rte_eth_xstats_reset(uint8_t port_id);
2209
2210 /**
2211  *  Set a mapping for the specified transmit queue to the specified per-queue
2212  *  statistics counter.
2213  *
2214  * @param port_id
2215  *   The port identifier of the Ethernet device.
2216  * @param tx_queue_id
2217  *   The index of the transmit queue for which a queue stats mapping is required.
2218  *   The value must be in the range [0, nb_tx_queue - 1] previously supplied
2219  *   to rte_eth_dev_configure().
2220  * @param stat_idx
2221  *   The per-queue packet statistics functionality number that the transmit
2222  *   queue is to be assigned.
2223  *   The value must be in the range [0, RTE_MAX_ETHPORT_QUEUE_STATS_MAPS - 1].
2224  * @return
2225  *   Zero if successful. Non-zero otherwise.
2226  */
2227 extern int rte_eth_dev_set_tx_queue_stats_mapping(uint8_t port_id,
2228                                                   uint16_t tx_queue_id,
2229                                                   uint8_t stat_idx);
2230
2231 /**
2232  *  Set a mapping for the specified receive queue to the specified per-queue
2233  *  statistics counter.
2234  *
2235  * @param port_id
2236  *   The port identifier of the Ethernet device.
2237  * @param rx_queue_id
2238  *   The index of the receive queue for which a queue stats mapping is required.
2239  *   The value must be in the range [0, nb_rx_queue - 1] previously supplied
2240  *   to rte_eth_dev_configure().
2241  * @param stat_idx
2242  *   The per-queue packet statistics functionality number that the receive
2243  *   queue is to be assigned.
2244  *   The value must be in the range [0, RTE_MAX_ETHPORT_QUEUE_STATS_MAPS - 1].
2245  * @return
2246  *   Zero if successful. Non-zero otherwise.
2247  */
2248 extern int rte_eth_dev_set_rx_queue_stats_mapping(uint8_t port_id,
2249                                                   uint16_t rx_queue_id,
2250                                                   uint8_t stat_idx);
2251
2252 /**
2253  * Retrieve the Ethernet address of an Ethernet device.
2254  *
2255  * @param port_id
2256  *   The port identifier of the Ethernet device.
2257  * @param mac_addr
2258  *   A pointer to a structure of type *ether_addr* to be filled with
2259  *   the Ethernet address of the Ethernet device.
2260  */
2261 extern void rte_eth_macaddr_get(uint8_t port_id, struct ether_addr *mac_addr);
2262
2263 /**
2264  * Retrieve the contextual information of an Ethernet device.
2265  *
2266  * @param port_id
2267  *   The port identifier of the Ethernet device.
2268  * @param dev_info
2269  *   A pointer to a structure of type *rte_eth_dev_info* to be filled with
2270  *   the contextual information of the Ethernet device.
2271  */
2272 extern void rte_eth_dev_info_get(uint8_t port_id,
2273                                  struct rte_eth_dev_info *dev_info);
2274
2275 /**
2276  * Retrieve the MTU of an Ethernet device.
2277  *
2278  * @param port_id
2279  *   The port identifier of the Ethernet device.
2280  * @param mtu
2281  *   A pointer to a uint16_t where the retrieved MTU is to be stored.
2282  * @return
2283  *   - (0) if successful.
2284  *   - (-ENODEV) if *port_id* invalid.
2285  */
2286 extern int rte_eth_dev_get_mtu(uint8_t port_id, uint16_t *mtu);
2287
2288 /**
2289  * Change the MTU of an Ethernet device.
2290  *
2291  * @param port_id
2292  *   The port identifier of the Ethernet device.
2293  * @param mtu
2294  *   A uint16_t for the MTU to be applied.
2295  * @return
2296  *   - (0) if successful.
2297  *   - (-ENOTSUP) if operation is not supported.
2298  *   - (-ENODEV) if *port_id* invalid.
2299  *   - (-EINVAL) if *mtu* invalid.
2300  */
2301 extern int rte_eth_dev_set_mtu(uint8_t port_id, uint16_t mtu);
2302
2303 /**
2304  * Enable/Disable hardware filtering by an Ethernet device of received
2305  * VLAN packets tagged with a given VLAN Tag Identifier.
2306  *
2307  * @param port_id
2308  *   The port identifier of the Ethernet device.
2309  * @param vlan_id
2310  *   The VLAN Tag Identifier whose filtering must be enabled or disabled.
2311  * @param on
2312  *   If > 0, enable VLAN filtering of VLAN packets tagged with *vlan_id*.
2313  *   Otherwise, disable VLAN filtering of VLAN packets tagged with *vlan_id*.
2314  * @return
2315  *   - (0) if successful.
2316  *   - (-ENOSUP) if hardware-assisted VLAN filtering not configured.
2317  *   - (-ENODEV) if *port_id* invalid.
2318  *   - (-ENOSYS) if VLAN filtering on *port_id* disabled.
2319  *   - (-EINVAL) if *vlan_id* > 4095.
2320  */
2321 extern int rte_eth_dev_vlan_filter(uint8_t port_id, uint16_t vlan_id , int on);
2322
2323 /**
2324  * Enable/Disable hardware VLAN Strip by a rx queue of an Ethernet device.
2325  * 82599/X540/X550 can support VLAN stripping at the rx queue level
2326  *
2327  * @param port_id
2328  *   The port identifier of the Ethernet device.
2329  * @param rx_queue_id
2330  *   The index of the receive queue for which a queue stats mapping is required.
2331  *   The value must be in the range [0, nb_rx_queue - 1] previously supplied
2332  *   to rte_eth_dev_configure().
2333  * @param on
2334  *   If 1, Enable VLAN Stripping of the receive queue of the Ethernet port.
2335  *   If 0, Disable VLAN Stripping of the receive queue of the Ethernet port.
2336  * @return
2337  *   - (0) if successful.
2338  *   - (-ENOSUP) if hardware-assisted VLAN stripping not configured.
2339  *   - (-ENODEV) if *port_id* invalid.
2340  *   - (-EINVAL) if *rx_queue_id* invalid.
2341  */
2342 extern int rte_eth_dev_set_vlan_strip_on_queue(uint8_t port_id,
2343                 uint16_t rx_queue_id, int on);
2344
2345 /**
2346  * Set the Outer VLAN Ether Type by an Ethernet device, it can be inserted to
2347  * the VLAN Header. This is a register setup available on some Intel NIC, not
2348  * but all, please check the data sheet for availability.
2349  *
2350  * @param port_id
2351  *   The port identifier of the Ethernet device.
2352  * @param tag_type
2353  *   The Tag Protocol ID
2354  * @return
2355  *   - (0) if successful.
2356  *   - (-ENOSUP) if hardware-assisted VLAN TPID setup is not supported.
2357  *   - (-ENODEV) if *port_id* invalid.
2358  */
2359 extern int rte_eth_dev_set_vlan_ether_type(uint8_t port_id, uint16_t tag_type);
2360
2361 /**
2362  * Set VLAN offload configuration on an Ethernet device
2363  * Enable/Disable Extended VLAN by an Ethernet device, This is a register setup
2364  * available on some Intel NIC, not but all, please check the data sheet for
2365  * availability.
2366  * Enable/Disable VLAN Strip can be done on rx queue for certain NIC, but here
2367  * the configuration is applied on the port level.
2368  *
2369  * @param port_id
2370  *   The port identifier of the Ethernet device.
2371  * @param offload_mask
2372  *   The VLAN Offload bit mask can be mixed use with "OR"
2373  *       ETH_VLAN_STRIP_OFFLOAD
2374  *       ETH_VLAN_FILTER_OFFLOAD
2375  *       ETH_VLAN_EXTEND_OFFLOAD
2376  * @return
2377  *   - (0) if successful.
2378  *   - (-ENOSUP) if hardware-assisted VLAN filtering not configured.
2379  *   - (-ENODEV) if *port_id* invalid.
2380  */
2381 extern int rte_eth_dev_set_vlan_offload(uint8_t port_id, int offload_mask);
2382
2383 /**
2384  * Read VLAN Offload configuration from an Ethernet device
2385  *
2386  * @param port_id
2387  *   The port identifier of the Ethernet device.
2388  * @return
2389  *   - (>0) if successful. Bit mask to indicate
2390  *       ETH_VLAN_STRIP_OFFLOAD
2391  *       ETH_VLAN_FILTER_OFFLOAD
2392  *       ETH_VLAN_EXTEND_OFFLOAD
2393  *   - (-ENODEV) if *port_id* invalid.
2394  */
2395 extern int rte_eth_dev_get_vlan_offload(uint8_t port_id);
2396
2397 /**
2398  * Set port based TX VLAN insersion on or off.
2399  *
2400  * @param port_id
2401  *  The port identifier of the Ethernet device.
2402  * @param pvid
2403  *  Port based TX VLAN identifier togeth with user priority.
2404  * @param on
2405  *  Turn on or off the port based TX VLAN insertion.
2406  *
2407  * @return
2408  *   - (0) if successful.
2409  *   - negative if failed.
2410  */
2411 extern int rte_eth_dev_set_vlan_pvid(uint8_t port_id, uint16_t pvid, int on);
2412
2413 /**
2414  *
2415  * Retrieve a burst of input packets from a receive queue of an Ethernet
2416  * device. The retrieved packets are stored in *rte_mbuf* structures whose
2417  * pointers are supplied in the *rx_pkts* array.
2418  *
2419  * The rte_eth_rx_burst() function loops, parsing the RX ring of the
2420  * receive queue, up to *nb_pkts* packets, and for each completed RX
2421  * descriptor in the ring, it performs the following operations:
2422  *
2423  * - Initialize the *rte_mbuf* data structure associated with the
2424  *   RX descriptor according to the information provided by the NIC into
2425  *   that RX descriptor.
2426  *
2427  * - Store the *rte_mbuf* data structure into the next entry of the
2428  *   *rx_pkts* array.
2429  *
2430  * - Replenish the RX descriptor with a new *rte_mbuf* buffer
2431  *   allocated from the memory pool associated with the receive queue at
2432  *   initialization time.
2433  *
2434  * When retrieving an input packet that was scattered by the controller
2435  * into multiple receive descriptors, the rte_eth_rx_burst() function
2436  * appends the associated *rte_mbuf* buffers to the first buffer of the
2437  * packet.
2438  *
2439  * The rte_eth_rx_burst() function returns the number of packets
2440  * actually retrieved, which is the number of *rte_mbuf* data structures
2441  * effectively supplied into the *rx_pkts* array.
2442  * A return value equal to *nb_pkts* indicates that the RX queue contained
2443  * at least *rx_pkts* packets, and this is likely to signify that other
2444  * received packets remain in the input queue. Applications implementing
2445  * a "retrieve as much received packets as possible" policy can check this
2446  * specific case and keep invoking the rte_eth_rx_burst() function until
2447  * a value less than *nb_pkts* is returned.
2448  *
2449  * This receive method has the following advantages:
2450  *
2451  * - It allows a run-to-completion network stack engine to retrieve and
2452  *   to immediately process received packets in a fast burst-oriented
2453  *   approach, avoiding the overhead of unnecessary intermediate packet
2454  *   queue/dequeue operations.
2455  *
2456  * - Conversely, it also allows an asynchronous-oriented processing
2457  *   method to retrieve bursts of received packets and to immediately
2458  *   queue them for further parallel processing by another logical core,
2459  *   for instance. However, instead of having received packets being
2460  *   individually queued by the driver, this approach allows the invoker
2461  *   of the rte_eth_rx_burst() function to queue a burst of retrieved
2462  *   packets at a time and therefore dramatically reduce the cost of
2463  *   enqueue/dequeue operations per packet.
2464  *
2465  * - It allows the rte_eth_rx_burst() function of the driver to take
2466  *   advantage of burst-oriented hardware features (CPU cache,
2467  *   prefetch instructions, and so on) to minimize the number of CPU
2468  *   cycles per packet.
2469  *
2470  * To summarize, the proposed receive API enables many
2471  * burst-oriented optimizations in both synchronous and asynchronous
2472  * packet processing environments with no overhead in both cases.
2473  *
2474  * The rte_eth_rx_burst() function does not provide any error
2475  * notification to avoid the corresponding overhead. As a hint, the
2476  * upper-level application might check the status of the device link once
2477  * being systematically returned a 0 value for a given number of tries.
2478  *
2479  * @param port_id
2480  *   The port identifier of the Ethernet device.
2481  * @param queue_id
2482  *   The index of the receive queue from which to retrieve input packets.
2483  *   The value must be in the range [0, nb_rx_queue - 1] previously supplied
2484  *   to rte_eth_dev_configure().
2485  * @param rx_pkts
2486  *   The address of an array of pointers to *rte_mbuf* structures that
2487  *   must be large enough to store *nb_pkts* pointers in it.
2488  * @param nb_pkts
2489  *   The maximum number of packets to retrieve.
2490  * @return
2491  *   The number of packets actually retrieved, which is the number
2492  *   of pointers to *rte_mbuf* structures effectively supplied to the
2493  *   *rx_pkts* array.
2494  */
2495 static inline uint16_t
2496 rte_eth_rx_burst(uint8_t port_id, uint16_t queue_id,
2497                  struct rte_mbuf **rx_pkts, const uint16_t nb_pkts)
2498 {
2499         struct rte_eth_dev *dev = &rte_eth_devices[port_id];
2500
2501 #ifdef RTE_LIBRTE_ETHDEV_DEBUG
2502         RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, 0);
2503         RTE_FUNC_PTR_OR_ERR_RET(*dev->rx_pkt_burst, 0);
2504
2505         if (queue_id >= dev->data->nb_rx_queues) {
2506                 RTE_PMD_DEBUG_TRACE("Invalid RX queue_id=%d\n", queue_id);
2507                 return 0;
2508         }
2509 #endif
2510         int16_t nb_rx = (*dev->rx_pkt_burst)(dev->data->rx_queues[queue_id],
2511                         rx_pkts, nb_pkts);
2512
2513 #ifdef RTE_ETHDEV_RXTX_CALLBACKS
2514         struct rte_eth_rxtx_callback *cb = dev->post_rx_burst_cbs[queue_id];
2515
2516         if (unlikely(cb != NULL)) {
2517                 do {
2518                         nb_rx = cb->fn.rx(port_id, queue_id, rx_pkts, nb_rx,
2519                                                 nb_pkts, cb->param);
2520                         cb = cb->next;
2521                 } while (cb != NULL);
2522         }
2523 #endif
2524
2525         return nb_rx;
2526 }
2527
2528 /**
2529  * Get the number of used descriptors in a specific queue
2530  *
2531  * @param port_id
2532  *  The port identifier of the Ethernet device.
2533  * @param queue_id
2534  *  The queue id on the specific port.
2535  * @return
2536  *  The number of used descriptors in the specific queue, or:
2537  *     (-EINVAL) if *port_id* is invalid
2538  *     (-ENOTSUP) if the device does not support this function
2539  */
2540 static inline int
2541 rte_eth_rx_queue_count(uint8_t port_id, uint16_t queue_id)
2542 {
2543         struct rte_eth_dev *dev = &rte_eth_devices[port_id];
2544         RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
2545         RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rx_queue_count, -ENOTSUP);
2546         return (*dev->dev_ops->rx_queue_count)(dev, queue_id);
2547 }
2548
2549 /**
2550  * Check if the DD bit of the specific RX descriptor in the queue has been set
2551  *
2552  * @param port_id
2553  *  The port identifier of the Ethernet device.
2554  * @param queue_id
2555  *  The queue id on the specific port.
2556  * @param offset
2557  *  The offset of the descriptor ID from tail.
2558  * @return
2559  *  - (1) if the specific DD bit is set.
2560  *  - (0) if the specific DD bit is not set.
2561  *  - (-ENODEV) if *port_id* invalid.
2562  *  - (-ENOTSUP) if the device does not support this function
2563  */
2564 static inline int
2565 rte_eth_rx_descriptor_done(uint8_t port_id, uint16_t queue_id, uint16_t offset)
2566 {
2567         struct rte_eth_dev *dev = &rte_eth_devices[port_id];
2568         RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
2569         RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rx_descriptor_done, -ENOTSUP);
2570         return (*dev->dev_ops->rx_descriptor_done)( \
2571                 dev->data->rx_queues[queue_id], offset);
2572 }
2573
2574 /**
2575  * Send a burst of output packets on a transmit queue of an Ethernet device.
2576  *
2577  * The rte_eth_tx_burst() function is invoked to transmit output packets
2578  * on the output queue *queue_id* of the Ethernet device designated by its
2579  * *port_id*.
2580  * The *nb_pkts* parameter is the number of packets to send which are
2581  * supplied in the *tx_pkts* array of *rte_mbuf* structures.
2582  * The rte_eth_tx_burst() function loops, sending *nb_pkts* packets,
2583  * up to the number of transmit descriptors available in the TX ring of the
2584  * transmit queue.
2585  * For each packet to send, the rte_eth_tx_burst() function performs
2586  * the following operations:
2587  *
2588  * - Pick up the next available descriptor in the transmit ring.
2589  *
2590  * - Free the network buffer previously sent with that descriptor, if any.
2591  *
2592  * - Initialize the transmit descriptor with the information provided
2593  *   in the *rte_mbuf data structure.
2594  *
2595  * In the case of a segmented packet composed of a list of *rte_mbuf* buffers,
2596  * the rte_eth_tx_burst() function uses several transmit descriptors
2597  * of the ring.
2598  *
2599  * The rte_eth_tx_burst() function returns the number of packets it
2600  * actually sent. A return value equal to *nb_pkts* means that all packets
2601  * have been sent, and this is likely to signify that other output packets
2602  * could be immediately transmitted again. Applications that implement a
2603  * "send as many packets to transmit as possible" policy can check this
2604  * specific case and keep invoking the rte_eth_tx_burst() function until
2605  * a value less than *nb_pkts* is returned.
2606  *
2607  * It is the responsibility of the rte_eth_tx_burst() function to
2608  * transparently free the memory buffers of packets previously sent.
2609  * This feature is driven by the *tx_free_thresh* value supplied to the
2610  * rte_eth_dev_configure() function at device configuration time.
2611  * When the number of free TX descriptors drops below this threshold, the
2612  * rte_eth_tx_burst() function must [attempt to] free the *rte_mbuf*  buffers
2613  * of those packets whose transmission was effectively completed.
2614  *
2615  * @param port_id
2616  *   The port identifier of the Ethernet device.
2617  * @param queue_id
2618  *   The index of the transmit queue through which output packets must be
2619  *   sent.
2620  *   The value must be in the range [0, nb_tx_queue - 1] previously supplied
2621  *   to rte_eth_dev_configure().
2622  * @param tx_pkts
2623  *   The address of an array of *nb_pkts* pointers to *rte_mbuf* structures
2624  *   which contain the output packets.
2625  * @param nb_pkts
2626  *   The maximum number of packets to transmit.
2627  * @return
2628  *   The number of output packets actually stored in transmit descriptors of
2629  *   the transmit ring. The return value can be less than the value of the
2630  *   *tx_pkts* parameter when the transmit ring is full or has been filled up.
2631  */
2632 static inline uint16_t
2633 rte_eth_tx_burst(uint8_t port_id, uint16_t queue_id,
2634                  struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
2635 {
2636         struct rte_eth_dev *dev = &rte_eth_devices[port_id];
2637
2638 #ifdef RTE_LIBRTE_ETHDEV_DEBUG
2639         RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, 0);
2640         RTE_FUNC_PTR_OR_ERR_RET(*dev->tx_pkt_burst, 0);
2641
2642         if (queue_id >= dev->data->nb_tx_queues) {
2643                 RTE_PMD_DEBUG_TRACE("Invalid TX queue_id=%d\n", queue_id);
2644                 return 0;
2645         }
2646 #endif
2647
2648 #ifdef RTE_ETHDEV_RXTX_CALLBACKS
2649         struct rte_eth_rxtx_callback *cb = dev->pre_tx_burst_cbs[queue_id];
2650
2651         if (unlikely(cb != NULL)) {
2652                 do {
2653                         nb_pkts = cb->fn.tx(port_id, queue_id, tx_pkts, nb_pkts,
2654                                         cb->param);
2655                         cb = cb->next;
2656                 } while (cb != NULL);
2657         }
2658 #endif
2659
2660         return (*dev->tx_pkt_burst)(dev->data->tx_queues[queue_id], tx_pkts, nb_pkts);
2661 }
2662
2663 /**
2664  * The eth device event type for interrupt, and maybe others in the future.
2665  */
2666 enum rte_eth_event_type {
2667         RTE_ETH_EVENT_UNKNOWN,  /**< unknown event type */
2668         RTE_ETH_EVENT_INTR_LSC, /**< lsc interrupt event */
2669         RTE_ETH_EVENT_MAX       /**< max value of this enum */
2670 };
2671
2672 typedef void (*rte_eth_dev_cb_fn)(uint8_t port_id, \
2673                 enum rte_eth_event_type event, void *cb_arg);
2674 /**< user application callback to be registered for interrupts */
2675
2676
2677
2678 /**
2679  * Register a callback function for specific port id.
2680  *
2681  * @param port_id
2682  *  Port id.
2683  * @param event
2684  *  Event interested.
2685  * @param cb_fn
2686  *  User supplied callback function to be called.
2687  * @param cb_arg
2688  *  Pointer to the parameters for the registered callback.
2689  *
2690  * @return
2691  *  - On success, zero.
2692  *  - On failure, a negative value.
2693  */
2694 int rte_eth_dev_callback_register(uint8_t port_id,
2695                         enum rte_eth_event_type event,
2696                 rte_eth_dev_cb_fn cb_fn, void *cb_arg);
2697
2698 /**
2699  * Unregister a callback function for specific port id.
2700  *
2701  * @param port_id
2702  *  Port id.
2703  * @param event
2704  *  Event interested.
2705  * @param cb_fn
2706  *  User supplied callback function to be called.
2707  * @param cb_arg
2708  *  Pointer to the parameters for the registered callback. -1 means to
2709  *  remove all for the same callback address and same event.
2710  *
2711  * @return
2712  *  - On success, zero.
2713  *  - On failure, a negative value.
2714  */
2715 int rte_eth_dev_callback_unregister(uint8_t port_id,
2716                         enum rte_eth_event_type event,
2717                 rte_eth_dev_cb_fn cb_fn, void *cb_arg);
2718
2719 /**
2720  * @internal Executes all the user application registered callbacks for
2721  * the specific device. It is for DPDK internal user only. User
2722  * application should not call it directly.
2723  *
2724  * @param dev
2725  *  Pointer to struct rte_eth_dev.
2726  * @param event
2727  *  Eth device interrupt event type.
2728  *
2729  * @return
2730  *  void
2731  */
2732 void _rte_eth_dev_callback_process(struct rte_eth_dev *dev,
2733                                 enum rte_eth_event_type event);
2734
2735 /**
2736  * When there is no rx packet coming in Rx Queue for a long time, we can
2737  * sleep lcore related to RX Queue for power saving, and enable rx interrupt
2738  * to be triggered when rx packect arrives.
2739  *
2740  * The rte_eth_dev_rx_intr_enable() function enables rx queue
2741  * interrupt on specific rx queue of a port.
2742  *
2743  * @param port_id
2744  *   The port identifier of the Ethernet device.
2745  * @param queue_id
2746  *   The index of the receive queue from which to retrieve input packets.
2747  *   The value must be in the range [0, nb_rx_queue - 1] previously supplied
2748  *   to rte_eth_dev_configure().
2749  * @return
2750  *   - (0) if successful.
2751  *   - (-ENOTSUP) if underlying hardware OR driver doesn't support
2752  *     that operation.
2753  *   - (-ENODEV) if *port_id* invalid.
2754  */
2755 int rte_eth_dev_rx_intr_enable(uint8_t port_id, uint16_t queue_id);
2756
2757 /**
2758  * When lcore wakes up from rx interrupt indicating packet coming, disable rx
2759  * interrupt and returns to polling mode.
2760  *
2761  * The rte_eth_dev_rx_intr_disable() function disables rx queue
2762  * interrupt on specific rx queue of a port.
2763  *
2764  * @param port_id
2765  *   The port identifier of the Ethernet device.
2766  * @param queue_id
2767  *   The index of the receive queue from which to retrieve input packets.
2768  *   The value must be in the range [0, nb_rx_queue - 1] previously supplied
2769  *   to rte_eth_dev_configure().
2770  * @return
2771  *   - (0) if successful.
2772  *   - (-ENOTSUP) if underlying hardware OR driver doesn't support
2773  *     that operation.
2774  *   - (-ENODEV) if *port_id* invalid.
2775  */
2776 int rte_eth_dev_rx_intr_disable(uint8_t port_id, uint16_t queue_id);
2777
2778 /**
2779  * RX Interrupt control per port.
2780  *
2781  * @param port_id
2782  *   The port identifier of the Ethernet device.
2783  * @param epfd
2784  *   Epoll instance fd which the intr vector associated to.
2785  *   Using RTE_EPOLL_PER_THREAD allows to use per thread epoll instance.
2786  * @param op
2787  *   The operation be performed for the vector.
2788  *   Operation type of {RTE_INTR_EVENT_ADD, RTE_INTR_EVENT_DEL}.
2789  * @param data
2790  *   User raw data.
2791  * @return
2792  *   - On success, zero.
2793  *   - On failure, a negative value.
2794  */
2795 int rte_eth_dev_rx_intr_ctl(uint8_t port_id, int epfd, int op, void *data);
2796
2797 /**
2798  * RX Interrupt control per queue.
2799  *
2800  * @param port_id
2801  *   The port identifier of the Ethernet device.
2802  * @param queue_id
2803  *   The index of the receive queue from which to retrieve input packets.
2804  *   The value must be in the range [0, nb_rx_queue - 1] previously supplied
2805  *   to rte_eth_dev_configure().
2806  * @param epfd
2807  *   Epoll instance fd which the intr vector associated to.
2808  *   Using RTE_EPOLL_PER_THREAD allows to use per thread epoll instance.
2809  * @param op
2810  *   The operation be performed for the vector.
2811  *   Operation type of {RTE_INTR_EVENT_ADD, RTE_INTR_EVENT_DEL}.
2812  * @param data
2813  *   User raw data.
2814  * @return
2815  *   - On success, zero.
2816  *   - On failure, a negative value.
2817  */
2818 int rte_eth_dev_rx_intr_ctl_q(uint8_t port_id, uint16_t queue_id,
2819                               int epfd, int op, void *data);
2820
2821 /**
2822  * Turn on the LED on the Ethernet device.
2823  * This function turns on the LED on the Ethernet device.
2824  *
2825  * @param port_id
2826  *   The port identifier of the Ethernet device.
2827  * @return
2828  *   - (0) if successful.
2829  *   - (-ENOTSUP) if underlying hardware OR driver doesn't support
2830  *     that operation.
2831  *   - (-ENODEV) if *port_id* invalid.
2832  */
2833 int  rte_eth_led_on(uint8_t port_id);
2834
2835 /**
2836  * Turn off the LED on the Ethernet device.
2837  * This function turns off the LED on the Ethernet device.
2838  *
2839  * @param port_id
2840  *   The port identifier of the Ethernet device.
2841  * @return
2842  *   - (0) if successful.
2843  *   - (-ENOTSUP) if underlying hardware OR driver doesn't support
2844  *     that operation.
2845  *   - (-ENODEV) if *port_id* invalid.
2846  */
2847 int  rte_eth_led_off(uint8_t port_id);
2848
2849 /**
2850  * Get current status of the Ethernet link flow control for Ethernet device
2851  *
2852  * @param port_id
2853  *   The port identifier of the Ethernet device.
2854  * @param fc_conf
2855  *   The pointer to the structure where to store the flow control parameters.
2856  * @return
2857  *   - (0) if successful.
2858  *   - (-ENOTSUP) if hardware doesn't support flow control.
2859  *   - (-ENODEV)  if *port_id* invalid.
2860  */
2861 int rte_eth_dev_flow_ctrl_get(uint8_t port_id,
2862                               struct rte_eth_fc_conf *fc_conf);
2863
2864 /**
2865  * Configure the Ethernet link flow control for Ethernet device
2866  *
2867  * @param port_id
2868  *   The port identifier of the Ethernet device.
2869  * @param fc_conf
2870  *   The pointer to the structure of the flow control parameters.
2871  * @return
2872  *   - (0) if successful.
2873  *   - (-ENOTSUP) if hardware doesn't support flow control mode.
2874  *   - (-ENODEV)  if *port_id* invalid.
2875  *   - (-EINVAL)  if bad parameter
2876  *   - (-EIO)     if flow control setup failure
2877  */
2878 int rte_eth_dev_flow_ctrl_set(uint8_t port_id,
2879                               struct rte_eth_fc_conf *fc_conf);
2880
2881 /**
2882  * Configure the Ethernet priority flow control under DCB environment
2883  * for Ethernet device.
2884  *
2885  * @param port_id
2886  * The port identifier of the Ethernet device.
2887  * @param pfc_conf
2888  * The pointer to the structure of the priority flow control parameters.
2889  * @return
2890  *   - (0) if successful.
2891  *   - (-ENOTSUP) if hardware doesn't support priority flow control mode.
2892  *   - (-ENODEV)  if *port_id* invalid.
2893  *   - (-EINVAL)  if bad parameter
2894  *   - (-EIO)     if flow control setup failure
2895  */
2896 int rte_eth_dev_priority_flow_ctrl_set(uint8_t port_id,
2897                                 struct rte_eth_pfc_conf *pfc_conf);
2898
2899 /**
2900  * Add a MAC address to an internal array of addresses used to enable whitelist
2901  * filtering to accept packets only if the destination MAC address matches.
2902  *
2903  * @param port
2904  *   The port identifier of the Ethernet device.
2905  * @param mac_addr
2906  *   The MAC address to add.
2907  * @param pool
2908  *   VMDq pool index to associate address with (if VMDq is enabled). If VMDq is
2909  *   not enabled, this should be set to 0.
2910  * @return
2911  *   - (0) if successfully added or *mac_addr" was already added.
2912  *   - (-ENOTSUP) if hardware doesn't support this feature.
2913  *   - (-ENODEV) if *port* is invalid.
2914  *   - (-ENOSPC) if no more MAC addresses can be added.
2915  *   - (-EINVAL) if MAC address is invalid.
2916  */
2917 int rte_eth_dev_mac_addr_add(uint8_t port, struct ether_addr *mac_addr,
2918                                 uint32_t pool);
2919
2920 /**
2921  * Remove a MAC address from the internal array of addresses.
2922  *
2923  * @param port
2924  *   The port identifier of the Ethernet device.
2925  * @param mac_addr
2926  *   MAC address to remove.
2927  * @return
2928  *   - (0) if successful, or *mac_addr* didn't exist.
2929  *   - (-ENOTSUP) if hardware doesn't support.
2930  *   - (-ENODEV) if *port* invalid.
2931  *   - (-EADDRINUSE) if attempting to remove the default MAC address
2932  */
2933 int rte_eth_dev_mac_addr_remove(uint8_t port, struct ether_addr *mac_addr);
2934
2935 /**
2936  * Set the default MAC address.
2937  *
2938  * @param port
2939  *   The port identifier of the Ethernet device.
2940  * @param mac_addr
2941  *   New default MAC address.
2942  * @return
2943  *   - (0) if successful, or *mac_addr* didn't exist.
2944  *   - (-ENOTSUP) if hardware doesn't support.
2945  *   - (-ENODEV) if *port* invalid.
2946  *   - (-EINVAL) if MAC address is invalid.
2947  */
2948 int rte_eth_dev_default_mac_addr_set(uint8_t port, struct ether_addr *mac_addr);
2949
2950
2951 /**
2952  * Update Redirection Table(RETA) of Receive Side Scaling of Ethernet device.
2953  *
2954  * @param port
2955  *   The port identifier of the Ethernet device.
2956  * @param reta_conf
2957  *   RETA to update.
2958  * @param reta_size
2959  *   Redirection table size. The table size can be queried by
2960  *   rte_eth_dev_info_get().
2961  * @return
2962  *   - (0) if successful.
2963  *   - (-ENOTSUP) if hardware doesn't support.
2964  *   - (-EINVAL) if bad parameter.
2965  */
2966 int rte_eth_dev_rss_reta_update(uint8_t port,
2967                                 struct rte_eth_rss_reta_entry64 *reta_conf,
2968                                 uint16_t reta_size);
2969
2970  /**
2971  * Query Redirection Table(RETA) of Receive Side Scaling of Ethernet device.
2972  *
2973  * @param port
2974  *   The port identifier of the Ethernet device.
2975  * @param reta_conf
2976  *   RETA to query.
2977  * @param reta_size
2978  *   Redirection table size. The table size can be queried by
2979  *   rte_eth_dev_info_get().
2980  * @return
2981  *   - (0) if successful.
2982  *   - (-ENOTSUP) if hardware doesn't support.
2983  *   - (-EINVAL) if bad parameter.
2984  */
2985 int rte_eth_dev_rss_reta_query(uint8_t port,
2986                                struct rte_eth_rss_reta_entry64 *reta_conf,
2987                                uint16_t reta_size);
2988
2989  /**
2990  * Updates unicast hash table for receiving packet with the given destination
2991  * MAC address, and the packet is routed to all VFs for which the RX mode is
2992  * accept packets that match the unicast hash table.
2993  *
2994  * @param port
2995  *   The port identifier of the Ethernet device.
2996  * @param addr
2997  *   Unicast MAC address.
2998  * @param on
2999  *    1 - Set an unicast hash bit for receiving packets with the MAC address.
3000  *    0 - Clear an unicast hash bit.
3001  * @return
3002  *   - (0) if successful.
3003  *   - (-ENOTSUP) if hardware doesn't support.
3004   *  - (-ENODEV) if *port_id* invalid.
3005  *   - (-EINVAL) if bad parameter.
3006  */
3007 int rte_eth_dev_uc_hash_table_set(uint8_t port,struct ether_addr *addr,
3008                                         uint8_t on);
3009
3010  /**
3011  * Updates all unicast hash bitmaps for receiving packet with any Unicast
3012  * Ethernet MAC addresses,the packet is routed to all VFs for which the RX
3013  * mode is accept packets that match the unicast hash table.
3014  *
3015  * @param port
3016  *   The port identifier of the Ethernet device.
3017  * @param on
3018  *    1 - Set all unicast hash bitmaps for receiving all the Ethernet
3019  *         MAC addresses
3020  *    0 - Clear all unicast hash bitmaps
3021  * @return
3022  *   - (0) if successful.
3023  *   - (-ENOTSUP) if hardware doesn't support.
3024   *  - (-ENODEV) if *port_id* invalid.
3025  *   - (-EINVAL) if bad parameter.
3026  */
3027 int rte_eth_dev_uc_all_hash_table_set(uint8_t port,uint8_t on);
3028
3029  /**
3030  * Set RX L2 Filtering mode of a VF of an Ethernet device.
3031  *
3032  * @param port
3033  *   The port identifier of the Ethernet device.
3034  * @param vf
3035  *   VF id.
3036  * @param rx_mode
3037  *    The RX mode mask, which  is one or more of  accepting Untagged Packets,
3038  *    packets that match the PFUTA table, Broadcast and Multicast Promiscuous.
3039  *    ETH_VMDQ_ACCEPT_UNTAG,ETH_VMDQ_ACCEPT_HASH_UC,
3040  *    ETH_VMDQ_ACCEPT_BROADCAST and ETH_VMDQ_ACCEPT_MULTICAST will be used
3041  *    in rx_mode.
3042  * @param on
3043  *    1 - Enable a VF RX mode.
3044  *    0 - Disable a VF RX mode.
3045  * @return
3046  *   - (0) if successful.
3047  *   - (-ENOTSUP) if hardware doesn't support.
3048  *   - (-ENOTSUP) if hardware doesn't support.
3049  *   - (-EINVAL) if bad parameter.
3050  */
3051 int rte_eth_dev_set_vf_rxmode(uint8_t port, uint16_t vf, uint16_t rx_mode,
3052                                 uint8_t on);
3053
3054 /**
3055 * Enable or disable a VF traffic transmit of the Ethernet device.
3056 *
3057 * @param port
3058 *   The port identifier of the Ethernet device.
3059 * @param vf
3060 *   VF id.
3061 * @param on
3062 *    1 - Enable a VF traffic transmit.
3063 *    0 - Disable a VF traffic transmit.
3064 * @return
3065 *   - (0) if successful.
3066 *   - (-ENODEV) if *port_id* invalid.
3067 *   - (-ENOTSUP) if hardware doesn't support.
3068 *   - (-EINVAL) if bad parameter.
3069 */
3070 int
3071 rte_eth_dev_set_vf_tx(uint8_t port,uint16_t vf, uint8_t on);
3072
3073 /**
3074 * Enable or disable a VF traffic receive of an Ethernet device.
3075 *
3076 * @param port
3077 *   The port identifier of the Ethernet device.
3078 * @param vf
3079 *   VF id.
3080 * @param on
3081 *    1 - Enable a VF traffic receive.
3082 *    0 - Disable a VF traffic receive.
3083 * @return
3084 *   - (0) if successful.
3085 *   - (-ENOTSUP) if hardware doesn't support.
3086 *   - (-ENODEV) if *port_id* invalid.
3087 *   - (-EINVAL) if bad parameter.
3088 */
3089 int
3090 rte_eth_dev_set_vf_rx(uint8_t port,uint16_t vf, uint8_t on);
3091
3092 /**
3093 * Enable/Disable hardware VF VLAN filtering by an Ethernet device of
3094 * received VLAN packets tagged with a given VLAN Tag Identifier.
3095 *
3096 * @param port id
3097 *   The port identifier of the Ethernet device.
3098 * @param vlan_id
3099 *   The VLAN Tag Identifier whose filtering must be enabled or disabled.
3100 * @param vf_mask
3101 *    Bitmap listing which VFs participate in the VLAN filtering.
3102 * @param vlan_on
3103 *    1 - Enable VFs VLAN filtering.
3104 *    0 - Disable VFs VLAN filtering.
3105 * @return
3106 *   - (0) if successful.
3107 *   - (-ENOTSUP) if hardware doesn't support.
3108 *   - (-ENODEV) if *port_id* invalid.
3109 *   - (-EINVAL) if bad parameter.
3110 */
3111 int
3112 rte_eth_dev_set_vf_vlan_filter(uint8_t port, uint16_t vlan_id,
3113                                 uint64_t vf_mask,
3114                                 uint8_t vlan_on);
3115
3116 /**
3117  * Set a traffic mirroring rule on an Ethernet device
3118  *
3119  * @param port_id
3120  *   The port identifier of the Ethernet device.
3121  * @param mirror_conf
3122  *   The pointer to the traffic mirroring structure describing the mirroring rule.
3123  *   The *rte_eth_vm_mirror_conf* structure includes the type of mirroring rule,
3124  *   destination pool and the value of rule if enable vlan or pool mirroring.
3125  *
3126  * @param rule_id
3127  *   The index of traffic mirroring rule, we support four separated rules.
3128  * @param on
3129  *   1 - Enable a mirroring rule.
3130  *   0 - Disable a mirroring rule.
3131  * @return
3132  *   - (0) if successful.
3133  *   - (-ENOTSUP) if hardware doesn't support this feature.
3134  *   - (-ENODEV) if *port_id* invalid.
3135  *   - (-EINVAL) if the mr_conf information is not correct.
3136  */
3137 int rte_eth_mirror_rule_set(uint8_t port_id,
3138                         struct rte_eth_mirror_conf *mirror_conf,
3139                         uint8_t rule_id,
3140                         uint8_t on);
3141
3142 /**
3143  * Reset a traffic mirroring rule on an Ethernet device.
3144  *
3145  * @param port_id
3146  *   The port identifier of the Ethernet device.
3147  * @param rule_id
3148  *   The index of traffic mirroring rule, we support four separated rules.
3149  * @return
3150  *   - (0) if successful.
3151  *   - (-ENOTSUP) if hardware doesn't support this feature.
3152  *   - (-ENODEV) if *port_id* invalid.
3153  *   - (-EINVAL) if bad parameter.
3154  */
3155 int rte_eth_mirror_rule_reset(uint8_t port_id,
3156                                          uint8_t rule_id);
3157
3158 /**
3159  * Set the rate limitation for a queue on an Ethernet device.
3160  *
3161  * @param port_id
3162  *   The port identifier of the Ethernet device.
3163  * @param queue_idx
3164  *   The queue id.
3165  * @param tx_rate
3166  *   The tx rate in Mbps. Allocated from the total port link speed.
3167  * @return
3168  *   - (0) if successful.
3169  *   - (-ENOTSUP) if hardware doesn't support this feature.
3170  *   - (-ENODEV) if *port_id* invalid.
3171  *   - (-EINVAL) if bad parameter.
3172  */
3173 int rte_eth_set_queue_rate_limit(uint8_t port_id, uint16_t queue_idx,
3174                         uint16_t tx_rate);
3175
3176 /**
3177  * Set the rate limitation for a vf on an Ethernet device.
3178  *
3179  * @param port_id
3180  *   The port identifier of the Ethernet device.
3181  * @param vf
3182  *   VF id.
3183  * @param tx_rate
3184  *   The tx rate allocated from the total link speed for this VF id.
3185  * @param q_msk
3186  *   The queue mask which need to set the rate.
3187  * @return
3188  *   - (0) if successful.
3189  *   - (-ENOTSUP) if hardware doesn't support this feature.
3190  *   - (-ENODEV) if *port_id* invalid.
3191  *   - (-EINVAL) if bad parameter.
3192  */
3193 int rte_eth_set_vf_rate_limit(uint8_t port_id, uint16_t vf,
3194                         uint16_t tx_rate, uint64_t q_msk);
3195
3196 /**
3197  * Initialize bypass logic. This function needs to be called before
3198  * executing any other bypass API.
3199  *
3200  * @param port
3201  *   The port identifier of the Ethernet device.
3202  * @return
3203  *   - (0) if successful.
3204  *   - (-ENOTSUP) if hardware doesn't support.
3205  *   - (-EINVAL) if bad parameter.
3206  */
3207 int rte_eth_dev_bypass_init(uint8_t port);
3208
3209 /**
3210  * Return bypass state.
3211  *
3212  * @param port
3213  *   The port identifier of the Ethernet device.
3214  * @param state
3215  *   The return bypass state.
3216  *   - (1) Normal mode
3217  *   - (2) Bypass mode
3218  *   - (3) Isolate mode
3219  * @return
3220  *   - (0) if successful.
3221  *   - (-ENOTSUP) if hardware doesn't support.
3222  *   - (-EINVAL) if bad parameter.
3223  */
3224 int rte_eth_dev_bypass_state_show(uint8_t port, uint32_t *state);
3225
3226 /**
3227  * Set bypass state
3228  *
3229  * @param port
3230  *   The port identifier of the Ethernet device.
3231  * @param new_state
3232  *   The current bypass state.
3233  *   - (1) Normal mode
3234  *   - (2) Bypass mode
3235  *   - (3) Isolate mode
3236  * @return
3237  *   - (0) if successful.
3238  *   - (-ENOTSUP) if hardware doesn't support.
3239  *   - (-EINVAL) if bad parameter.
3240  */
3241 int rte_eth_dev_bypass_state_set(uint8_t port, uint32_t *new_state);
3242
3243 /**
3244  * Return bypass state when given event occurs.
3245  *
3246  * @param port
3247  *   The port identifier of the Ethernet device.
3248  * @param event
3249  *   The bypass event
3250  *   - (1) Main power on (power button is pushed)
3251  *   - (2) Auxiliary power on (power supply is being plugged)
3252  *   - (3) Main power off (system shutdown and power supply is left plugged in)
3253  *   - (4) Auxiliary power off (power supply is being unplugged)
3254  *   - (5) Display or set the watchdog timer
3255  * @param state
3256  *   The bypass state when given event occurred.
3257  *   - (1) Normal mode
3258  *   - (2) Bypass mode
3259  *   - (3) Isolate mode
3260  * @return
3261  *   - (0) if successful.
3262  *   - (-ENOTSUP) if hardware doesn't support.
3263  *   - (-EINVAL) if bad parameter.
3264  */
3265 int rte_eth_dev_bypass_event_show(uint8_t port, uint32_t event, uint32_t *state);
3266
3267 /**
3268  * Set bypass state when given event occurs.
3269  *
3270  * @param port
3271  *   The port identifier of the Ethernet device.
3272  * @param event
3273  *   The bypass event
3274  *   - (1) Main power on (power button is pushed)
3275  *   - (2) Auxiliary power on (power supply is being plugged)
3276  *   - (3) Main power off (system shutdown and power supply is left plugged in)
3277  *   - (4) Auxiliary power off (power supply is being unplugged)
3278  *   - (5) Display or set the watchdog timer
3279  * @param state
3280  *   The assigned state when given event occurs.
3281  *   - (1) Normal mode
3282  *   - (2) Bypass mode
3283  *   - (3) Isolate mode
3284  * @return
3285  *   - (0) if successful.
3286  *   - (-ENOTSUP) if hardware doesn't support.
3287  *   - (-EINVAL) if bad parameter.
3288  */
3289 int rte_eth_dev_bypass_event_store(uint8_t port, uint32_t event, uint32_t state);
3290
3291 /**
3292  * Set bypass watchdog timeout count.
3293  *
3294  * @param port
3295  *   The port identifier of the Ethernet device.
3296  * @param timeout
3297  *   The timeout to be set.
3298  *   - (0) 0 seconds (timer is off)
3299  *   - (1) 1.5 seconds
3300  *   - (2) 2 seconds
3301  *   - (3) 3 seconds
3302  *   - (4) 4 seconds
3303  *   - (5) 8 seconds
3304  *   - (6) 16 seconds
3305  *   - (7) 32 seconds
3306  * @return
3307  *   - (0) if successful.
3308  *   - (-ENOTSUP) if hardware doesn't support.
3309  *   - (-EINVAL) if bad parameter.
3310  */
3311 int rte_eth_dev_wd_timeout_store(uint8_t port, uint32_t timeout);
3312
3313 /**
3314  * Get bypass firmware version.
3315  *
3316  * @param port
3317  *   The port identifier of the Ethernet device.
3318  * @param ver
3319  *   The firmware version
3320  * @return
3321  *   - (0) if successful.
3322  *   - (-ENOTSUP) if hardware doesn't support.
3323  *   - (-EINVAL) if bad parameter.
3324  */
3325 int rte_eth_dev_bypass_ver_show(uint8_t port, uint32_t *ver);
3326
3327 /**
3328  * Return bypass watchdog timeout in seconds
3329  *
3330  * @param port
3331  *   The port identifier of the Ethernet device.
3332  * @param wd_timeout
3333  *   The return watchdog timeout. "0" represents timer expired
3334  *   - (0) 0 seconds (timer is off)
3335  *   - (1) 1.5 seconds
3336  *   - (2) 2 seconds
3337  *   - (3) 3 seconds
3338  *   - (4) 4 seconds
3339  *   - (5) 8 seconds
3340  *   - (6) 16 seconds
3341  *   - (7) 32 seconds
3342  * @return
3343  *   - (0) if successful.
3344  *   - (-ENOTSUP) if hardware doesn't support.
3345  *   - (-EINVAL) if bad parameter.
3346  */
3347 int rte_eth_dev_bypass_wd_timeout_show(uint8_t port, uint32_t *wd_timeout);
3348
3349 /**
3350  * Reset bypass watchdog timer
3351  *
3352  * @param port
3353  *   The port identifier of the Ethernet device.
3354  * @return
3355  *   - (0) if successful.
3356  *   - (-ENOTSUP) if hardware doesn't support.
3357  *   - (-EINVAL) if bad parameter.
3358  */
3359 int rte_eth_dev_bypass_wd_reset(uint8_t port);
3360
3361  /**
3362  * Configuration of Receive Side Scaling hash computation of Ethernet device.
3363  *
3364  * @param port_id
3365  *   The port identifier of the Ethernet device.
3366  * @param rss_conf
3367  *   The new configuration to use for RSS hash computation on the port.
3368  * @return
3369  *   - (0) if successful.
3370  *   - (-ENODEV) if port identifier is invalid.
3371  *   - (-ENOTSUP) if hardware doesn't support.
3372  *   - (-EINVAL) if bad parameter.
3373  */
3374 int rte_eth_dev_rss_hash_update(uint8_t port_id,
3375                                 struct rte_eth_rss_conf *rss_conf);
3376
3377  /**
3378  * Retrieve current configuration of Receive Side Scaling hash computation
3379  * of Ethernet device.
3380  *
3381  * @param port_id
3382  *   The port identifier of the Ethernet device.
3383  * @param rss_conf
3384  *   Where to store the current RSS hash configuration of the Ethernet device.
3385  * @return
3386  *   - (0) if successful.
3387  *   - (-ENODEV) if port identifier is invalid.
3388  *   - (-ENOTSUP) if hardware doesn't support RSS.
3389  */
3390 int
3391 rte_eth_dev_rss_hash_conf_get(uint8_t port_id,
3392                               struct rte_eth_rss_conf *rss_conf);
3393
3394  /**
3395  * Add UDP tunneling port of an Ethernet device for filtering a specific
3396  * tunneling packet by UDP port number.
3397  *
3398  * @param port_id
3399  *   The port identifier of the Ethernet device.
3400  * @param tunnel_udp
3401  *   UDP tunneling configuration.
3402  *
3403  * @return
3404  *   - (0) if successful.
3405  *   - (-ENODEV) if port identifier is invalid.
3406  *   - (-ENOTSUP) if hardware doesn't support tunnel type.
3407  */
3408 int
3409 rte_eth_dev_udp_tunnel_add(uint8_t port_id,
3410                            struct rte_eth_udp_tunnel *tunnel_udp);
3411
3412  /**
3413  * Detete UDP tunneling port configuration of Ethernet device
3414  *
3415  * @param port_id
3416  *   The port identifier of the Ethernet device.
3417  * @param tunnel_udp
3418  *   UDP tunneling configuration.
3419  *
3420  * @return
3421  *   - (0) if successful.
3422  *   - (-ENODEV) if port identifier is invalid.
3423  *   - (-ENOTSUP) if hardware doesn't support tunnel type.
3424  */
3425 int
3426 rte_eth_dev_udp_tunnel_delete(uint8_t port_id,
3427                               struct rte_eth_udp_tunnel *tunnel_udp);
3428
3429 /**
3430  * Check whether the filter type is supported on an Ethernet device.
3431  * All the supported filter types are defined in 'rte_eth_ctrl.h'.
3432  *
3433  * @param port_id
3434  *   The port identifier of the Ethernet device.
3435  * @param filter_type
3436  *   Filter type.
3437  * @return
3438  *   - (0) if successful.
3439  *   - (-ENOTSUP) if hardware doesn't support this filter type.
3440  *   - (-ENODEV) if *port_id* invalid.
3441  */
3442 int rte_eth_dev_filter_supported(uint8_t port_id, enum rte_filter_type filter_type);
3443
3444 /**
3445  * Take operations to assigned filter type on an Ethernet device.
3446  * All the supported operations and filter types are defined in 'rte_eth_ctrl.h'.
3447  *
3448  * @param port_id
3449  *   The port identifier of the Ethernet device.
3450  * @param filter_type
3451  *   Filter type.
3452  * @param filter_op
3453  *   Type of operation.
3454  * @param arg
3455  *   A pointer to arguments defined specifically for the operation.
3456  * @return
3457  *   - (0) if successful.
3458  *   - (-ENOTSUP) if hardware doesn't support.
3459  *   - (-ENODEV) if *port_id* invalid.
3460  *   - others depends on the specific operations implementation.
3461  */
3462 int rte_eth_dev_filter_ctrl(uint8_t port_id, enum rte_filter_type filter_type,
3463                         enum rte_filter_op filter_op, void *arg);
3464
3465 /**
3466  * Get DCB information on an Ethernet device.
3467  *
3468  * @param port_id
3469  *   The port identifier of the Ethernet device.
3470  * @param dcb_info
3471  *   dcb information.
3472  * @return
3473  *   - (0) if successful.
3474  *   - (-ENODEV) if port identifier is invalid.
3475  *   - (-ENOTSUP) if hardware doesn't support.
3476  */
3477 int rte_eth_dev_get_dcb_info(uint8_t port_id,
3478                              struct rte_eth_dcb_info *dcb_info);
3479
3480 /**
3481  * Add a callback to be called on packet RX on a given port and queue.
3482  *
3483  * This API configures a function to be called for each burst of
3484  * packets received on a given NIC port queue. The return value is a pointer
3485  * that can be used to later remove the callback using
3486  * rte_eth_remove_rx_callback().
3487  *
3488  * Multiple functions are called in the order that they are added.
3489  *
3490  * @param port_id
3491  *   The port identifier of the Ethernet device.
3492  * @param queue_id
3493  *   The queue on the Ethernet device on which the callback is to be added.
3494  * @param fn
3495  *   The callback function
3496  * @param user_param
3497  *   A generic pointer parameter which will be passed to each invocation of the
3498  *   callback function on this port and queue.
3499  *
3500  * @return
3501  *   NULL on error.
3502  *   On success, a pointer value which can later be used to remove the callback.
3503  */
3504 void *rte_eth_add_rx_callback(uint8_t port_id, uint16_t queue_id,
3505                 rte_rx_callback_fn fn, void *user_param);
3506
3507 /**
3508  * Add a callback to be called on packet TX on a given port and queue.
3509  *
3510  * This API configures a function to be called for each burst of
3511  * packets sent on a given NIC port queue. The return value is a pointer
3512  * that can be used to later remove the callback using
3513  * rte_eth_remove_tx_callback().
3514  *
3515  * Multiple functions are called in the order that they are added.
3516  *
3517  * @param port_id
3518  *   The port identifier of the Ethernet device.
3519  * @param queue_id
3520  *   The queue on the Ethernet device on which the callback is to be added.
3521  * @param fn
3522  *   The callback function
3523  * @param user_param
3524  *   A generic pointer parameter which will be passed to each invocation of the
3525  *   callback function on this port and queue.
3526  *
3527  * @return
3528  *   NULL on error.
3529  *   On success, a pointer value which can later be used to remove the callback.
3530  */
3531 void *rte_eth_add_tx_callback(uint8_t port_id, uint16_t queue_id,
3532                 rte_tx_callback_fn fn, void *user_param);
3533
3534 /**
3535  * Remove an RX packet callback from a given port and queue.
3536  *
3537  * This function is used to removed callbacks that were added to a NIC port
3538  * queue using rte_eth_add_rx_callback().
3539  *
3540  * Note: the callback is removed from the callback list but it isn't freed
3541  * since the it may still be in use. The memory for the callback can be
3542  * subsequently freed back by the application by calling rte_free():
3543  *
3544  * - Immediately - if the port is stopped, or the user knows that no
3545  *   callbacks are in flight e.g. if called from the thread doing RX/TX
3546  *   on that queue.
3547  *
3548  * - After a short delay - where the delay is sufficient to allow any
3549  *   in-flight callbacks to complete.
3550  *
3551  * @param port_id
3552  *   The port identifier of the Ethernet device.
3553  * @param queue_id
3554  *   The queue on the Ethernet device from which the callback is to be removed.
3555  * @param user_cb
3556  *   User supplied callback created via rte_eth_add_rx_callback().
3557  *
3558  * @return
3559  *   - 0: Success. Callback was removed.
3560  *   - -ENOTSUP: Callback support is not available.
3561  *   - -EINVAL:  The port_id or the queue_id is out of range, or the callback
3562  *               is NULL or not found for the port/queue.
3563  */
3564 int rte_eth_remove_rx_callback(uint8_t port_id, uint16_t queue_id,
3565                 struct rte_eth_rxtx_callback *user_cb);
3566
3567 /**
3568  * Remove a TX packet callback from a given port and queue.
3569  *
3570  * This function is used to removed callbacks that were added to a NIC port
3571  * queue using rte_eth_add_tx_callback().
3572  *
3573  * Note: the callback is removed from the callback list but it isn't freed
3574  * since the it may still be in use. The memory for the callback can be
3575  * subsequently freed back by the application by calling rte_free():
3576  *
3577  * - Immediately - if the port is stopped, or the user knows that no
3578  *   callbacks are in flight e.g. if called from the thread doing RX/TX
3579  *   on that queue.
3580  *
3581  * - After a short delay - where the delay is sufficient to allow any
3582  *   in-flight callbacks to complete.
3583  *
3584  * @param port_id
3585  *   The port identifier of the Ethernet device.
3586  * @param queue_id
3587  *   The queue on the Ethernet device from which the callback is to be removed.
3588  * @param user_cb
3589  *   User supplied callback created via rte_eth_add_tx_callback().
3590  *
3591  * @return
3592  *   - 0: Success. Callback was removed.
3593  *   - -ENOTSUP: Callback support is not available.
3594  *   - -EINVAL:  The port_id or the queue_id is out of range, or the callback
3595  *               is NULL or not found for the port/queue.
3596  */
3597 int rte_eth_remove_tx_callback(uint8_t port_id, uint16_t queue_id,
3598                 struct rte_eth_rxtx_callback *user_cb);
3599
3600 /**
3601  * Retrieve information about given port's RX queue.
3602  *
3603  * @param port_id
3604  *   The port identifier of the Ethernet device.
3605  * @param queue_id
3606  *   The RX queue on the Ethernet device for which information
3607  *   will be retrieved.
3608  * @param qinfo
3609  *   A pointer to a structure of type *rte_eth_rxq_info_info* to be filled with
3610  *   the information of the Ethernet device.
3611  *
3612  * @return
3613  *   - 0: Success
3614  *   - -ENOTSUP: routine is not supported by the device PMD.
3615  *   - -EINVAL:  The port_id or the queue_id is out of range.
3616  */
3617 int rte_eth_rx_queue_info_get(uint8_t port_id, uint16_t queue_id,
3618         struct rte_eth_rxq_info *qinfo);
3619
3620 /**
3621  * Retrieve information about given port's TX queue.
3622  *
3623  * @param port_id
3624  *   The port identifier of the Ethernet device.
3625  * @param queue_id
3626  *   The TX queue on the Ethernet device for which information
3627  *   will be retrieved.
3628  * @param qinfo
3629  *   A pointer to a structure of type *rte_eth_txq_info_info* to be filled with
3630  *   the information of the Ethernet device.
3631  *
3632  * @return
3633  *   - 0: Success
3634  *   - -ENOTSUP: routine is not supported by the device PMD.
3635  *   - -EINVAL:  The port_id or the queue_id is out of range.
3636  */
3637 int rte_eth_tx_queue_info_get(uint8_t port_id, uint16_t queue_id,
3638         struct rte_eth_txq_info *qinfo);
3639
3640 /*
3641  * Retrieve number of available registers for access
3642  *
3643  * @param port_id
3644  *   The port identifier of the Ethernet device.
3645  * @return
3646  *   - (>=0) number of registers if successful.
3647  *   - (-ENOTSUP) if hardware doesn't support.
3648  *   - (-ENODEV) if *port_id* invalid.
3649  *   - others depends on the specific operations implementation.
3650  */
3651 int rte_eth_dev_get_reg_length(uint8_t port_id);
3652
3653 /**
3654  * Retrieve device registers and register attributes
3655  *
3656  * @param port_id
3657  *   The port identifier of the Ethernet device.
3658  * @param info
3659  *   The template includes buffer for register data and attribute to be filled.
3660  * @return
3661  *   - (0) if successful.
3662  *   - (-ENOTSUP) if hardware doesn't support.
3663  *   - (-ENODEV) if *port_id* invalid.
3664  *   - others depends on the specific operations implementation.
3665  */
3666 int rte_eth_dev_get_reg_info(uint8_t port_id, struct rte_dev_reg_info *info);
3667
3668 /**
3669  * Retrieve size of device EEPROM
3670  *
3671  * @param port_id
3672  *   The port identifier of the Ethernet device.
3673  * @return
3674  *   - (>=0) EEPROM size if successful.
3675  *   - (-ENOTSUP) if hardware doesn't support.
3676  *   - (-ENODEV) if *port_id* invalid.
3677  *   - others depends on the specific operations implementation.
3678  */
3679 int rte_eth_dev_get_eeprom_length(uint8_t port_id);
3680
3681 /**
3682  * Retrieve EEPROM and EEPROM attribute
3683  *
3684  * @param port_id
3685  *   The port identifier of the Ethernet device.
3686  * @param info
3687  *   The template includes buffer for return EEPROM data and
3688  *   EEPROM attributes to be filled.
3689  * @return
3690  *   - (0) if successful.
3691  *   - (-ENOTSUP) if hardware doesn't support.
3692  *   - (-ENODEV) if *port_id* invalid.
3693  *   - others depends on the specific operations implementation.
3694  */
3695 int rte_eth_dev_get_eeprom(uint8_t port_id, struct rte_dev_eeprom_info *info);
3696
3697 /**
3698  * Program EEPROM with provided data
3699  *
3700  * @param port_id
3701  *   The port identifier of the Ethernet device.
3702  * @param info
3703  *   The template includes EEPROM data for programming and
3704  *   EEPROM attributes to be filled
3705  * @return
3706  *   - (0) if successful.
3707  *   - (-ENOTSUP) if hardware doesn't support.
3708  *   - (-ENODEV) if *port_id* invalid.
3709  *   - others depends on the specific operations implementation.
3710  */
3711 int rte_eth_dev_set_eeprom(uint8_t port_id, struct rte_dev_eeprom_info *info);
3712
3713 /**
3714  * Set the list of multicast addresses to filter on an Ethernet device.
3715  *
3716  * @param port_id
3717  *   The port identifier of the Ethernet device.
3718  * @param mc_addr_set
3719  *   The array of multicast addresses to set. Equal to NULL when the function
3720  *   is invoked to flush the set of filtered addresses.
3721  * @param nb_mc_addr
3722  *   The number of multicast addresses in the *mc_addr_set* array. Equal to 0
3723  *   when the function is invoked to flush the set of filtered addresses.
3724  * @return
3725  *   - (0) if successful.
3726  *   - (-ENODEV) if *port_id* invalid.
3727  *   - (-ENOTSUP) if PMD of *port_id* doesn't support multicast filtering.
3728  *   - (-ENOSPC) if *port_id* has not enough multicast filtering resources.
3729  */
3730 int rte_eth_dev_set_mc_addr_list(uint8_t port_id,
3731                                  struct ether_addr *mc_addr_set,
3732                                  uint32_t nb_mc_addr);
3733
3734 /**
3735  * Enable IEEE1588/802.1AS timestamping for an Ethernet device.
3736  *
3737  * @param port_id
3738  *   The port identifier of the Ethernet device.
3739  *
3740  * @return
3741  *   - 0: Success.
3742  *   - -ENODEV: The port ID is invalid.
3743  *   - -ENOTSUP: The function is not supported by the Ethernet driver.
3744  */
3745 extern int rte_eth_timesync_enable(uint8_t port_id);
3746
3747 /**
3748  * Disable IEEE1588/802.1AS timestamping for an Ethernet device.
3749  *
3750  * @param port_id
3751  *   The port identifier of the Ethernet device.
3752  *
3753  * @return
3754  *   - 0: Success.
3755  *   - -ENODEV: The port ID is invalid.
3756  *   - -ENOTSUP: The function is not supported by the Ethernet driver.
3757  */
3758 extern int rte_eth_timesync_disable(uint8_t port_id);
3759
3760 /**
3761  * Read an IEEE1588/802.1AS RX timestamp from an Ethernet device.
3762  *
3763  * @param port_id
3764  *   The port identifier of the Ethernet device.
3765  * @param timestamp
3766  *   Pointer to the timestamp struct.
3767  * @param flags
3768  *   Device specific flags. Used to pass the RX timesync register index to
3769  *   i40e. Unused in igb/ixgbe, pass 0 instead.
3770  *
3771  * @return
3772  *   - 0: Success.
3773  *   - -EINVAL: No timestamp is available.
3774  *   - -ENODEV: The port ID is invalid.
3775  *   - -ENOTSUP: The function is not supported by the Ethernet driver.
3776  */
3777 extern int rte_eth_timesync_read_rx_timestamp(uint8_t port_id,
3778                                               struct timespec *timestamp,
3779                                               uint32_t flags);
3780
3781 /**
3782  * Read an IEEE1588/802.1AS TX timestamp from an Ethernet device.
3783  *
3784  * @param port_id
3785  *   The port identifier of the Ethernet device.
3786  * @param timestamp
3787  *   Pointer to the timestamp struct.
3788  *
3789  * @return
3790  *   - 0: Success.
3791  *   - -EINVAL: No timestamp is available.
3792  *   - -ENODEV: The port ID is invalid.
3793  *   - -ENOTSUP: The function is not supported by the Ethernet driver.
3794  */
3795 extern int rte_eth_timesync_read_tx_timestamp(uint8_t port_id,
3796                                               struct timespec *timestamp);
3797
3798 /**
3799  * Adjust the timesync clock on an Ethernet device.
3800  *
3801  * This is usually used in conjunction with other Ethdev timesync functions to
3802  * synchronize the device time using the IEEE1588/802.1AS protocol.
3803  *
3804  * @param port_id
3805  *   The port identifier of the Ethernet device.
3806  * @param delta
3807  *   The adjustment in nanoseconds.
3808  *
3809  * @return
3810  *   - 0: Success.
3811  *   - -ENODEV: The port ID is invalid.
3812  *   - -ENOTSUP: The function is not supported by the Ethernet driver.
3813  */
3814 extern int rte_eth_timesync_adjust_time(uint8_t port_id, int64_t delta);
3815
3816 /**
3817  * Read the time from the timesync clock on an Ethernet device.
3818  *
3819  * This is usually used in conjunction with other Ethdev timesync functions to
3820  * synchronize the device time using the IEEE1588/802.1AS protocol.
3821  *
3822  * @param port_id
3823  *   The port identifier of the Ethernet device.
3824  * @param time
3825  *   Pointer to the timespec struct that holds the time.
3826  *
3827  * @return
3828  *   - 0: Success.
3829  */
3830 extern int rte_eth_timesync_read_time(uint8_t port_id, struct timespec *time);
3831
3832 /**
3833  * Set the time of the timesync clock on an Ethernet device.
3834  *
3835  * This is usually used in conjunction with other Ethdev timesync functions to
3836  * synchronize the device time using the IEEE1588/802.1AS protocol.
3837  *
3838  * @param port_id
3839  *   The port identifier of the Ethernet device.
3840  * @param time
3841  *   Pointer to the timespec struct that holds the time.
3842  *
3843  * @return
3844  *   - 0: Success.
3845  *   - -EINVAL: No timestamp is available.
3846  *   - -ENODEV: The port ID is invalid.
3847  *   - -ENOTSUP: The function is not supported by the Ethernet driver.
3848  */
3849 extern int rte_eth_timesync_write_time(uint8_t port_id,
3850                                        const struct timespec *time);
3851
3852 /**
3853  * Copy pci device info to the Ethernet device data.
3854  *
3855  * @param eth_dev
3856  * The *eth_dev* pointer is the address of the *rte_eth_dev* structure.
3857  * @param pci_dev
3858  * The *pci_dev* pointer is the address of the *rte_pci_device* structure.
3859  *
3860  * @return
3861  *   - 0 on success, negative on error
3862  */
3863 extern void rte_eth_copy_pci_info(struct rte_eth_dev *eth_dev, struct rte_pci_device *pci_dev);
3864
3865
3866 /**
3867  * Create memzone for HW rings.
3868  * malloc can't be used as the physical address is needed.
3869  * If the memzone is already created, then this function returns a ptr
3870  * to the old one.
3871  *
3872  * @param eth_dev
3873  *   The *eth_dev* pointer is the address of the *rte_eth_dev* structure
3874  * @param name
3875  *   The name of the memory zone
3876  * @param queue_id
3877  *   The index of the queue to add to name
3878  * @param size
3879  *   The sizeof of the memory area
3880  * @param align
3881  *   Alignment for resulting memzone. Must be a power of 2.
3882  * @param socket_id
3883  *   The *socket_id* argument is the socket identifier in case of NUMA.
3884  */
3885 const struct rte_memzone *
3886 rte_eth_dma_zone_reserve(const struct rte_eth_dev *eth_dev, const char *name,
3887                          uint16_t queue_id, size_t size,
3888                          unsigned align, int socket_id);
3889
3890 #ifdef __cplusplus
3891 }
3892 #endif
3893
3894 #endif /* _RTE_ETHDEV_H_ */