New upstream version 17.11-rc3
[deb_dpdk.git] / lib / librte_eventdev / rte_eventdev.h
1 /*
2  *   BSD LICENSE
3  *
4  *   Copyright 2016 Cavium, Inc.
5  *   Copyright 2016 Intel Corporation.
6  *   Copyright 2016 NXP.
7  *
8  *   Redistribution and use in source and binary forms, with or without
9  *   modification, are permitted provided that the following conditions
10  *   are met:
11  *
12  *     * Redistributions of source code must retain the above copyright
13  *       notice, this list of conditions and the following disclaimer.
14  *     * Redistributions in binary form must reproduce the above copyright
15  *       notice, this list of conditions and the following disclaimer in
16  *       the documentation and/or other materials provided with the
17  *       distribution.
18  *     * Neither the name of Cavium, Inc nor the names of its
19  *       contributors may be used to endorse or promote products derived
20  *       from this software without specific prior written permission.
21  *
22  *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23  *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24  *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25  *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26  *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27  *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28  *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29  *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30  *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31  *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32  *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33  */
34
35 #ifndef _RTE_EVENTDEV_H_
36 #define _RTE_EVENTDEV_H_
37
38 /**
39  * @file
40  *
41  * RTE Event Device API
42  *
43  * In a polling model, lcores poll ethdev ports and associated rx queues
44  * directly to look for packet. In an event driven model, by contrast, lcores
45  * call the scheduler that selects packets for them based on programmer
46  * specified criteria. Eventdev library adds support for event driven
47  * programming model, which offer applications automatic multicore scaling,
48  * dynamic load balancing, pipelining, packet ingress order maintenance and
49  * synchronization services to simplify application packet processing.
50  *
51  * The Event Device API is composed of two parts:
52  *
53  * - The application-oriented Event API that includes functions to setup
54  *   an event device (configure it, setup its queues, ports and start it), to
55  *   establish the link between queues to port and to receive events, and so on.
56  *
57  * - The driver-oriented Event API that exports a function allowing
58  *   an event poll Mode Driver (PMD) to simultaneously register itself as
59  *   an event device driver.
60  *
61  * Event device components:
62  *
63  *                     +-----------------+
64  *                     | +-------------+ |
65  *        +-------+    | |    flow 0   | |
66  *        |Packet |    | +-------------+ |
67  *        |event  |    | +-------------+ |
68  *        |       |    | |    flow 1   | |port_link(port0, queue0)
69  *        +-------+    | +-------------+ |     |     +--------+
70  *        +-------+    | +-------------+ o-----v-----o        |dequeue +------+
71  *        |Crypto |    | |    flow n   | |           | event  +------->|Core 0|
72  *        |work   |    | +-------------+ o----+      | port 0 |        |      |
73  *        |done ev|    |  event queue 0  |    |      +--------+        +------+
74  *        +-------+    +-----------------+    |
75  *        +-------+                           |
76  *        |Timer  |    +-----------------+    |      +--------+
77  *        |expiry |    | +-------------+ |    +------o        |dequeue +------+
78  *        |event  |    | |    flow 0   | o-----------o event  +------->|Core 1|
79  *        +-------+    | +-------------+ |      +----o port 1 |        |      |
80  *       Event enqueue | +-------------+ |      |    +--------+        +------+
81  *     o-------------> | |    flow 1   | |      |
82  *        enqueue(     | +-------------+ |      |
83  *        queue_id,    |                 |      |    +--------+        +------+
84  *        flow_id,     | +-------------+ |      |    |        |dequeue |Core 2|
85  *        sched_type,  | |    flow n   | o-----------o event  +------->|      |
86  *        event_type,  | +-------------+ |      |    | port 2 |        +------+
87  *        subev_type,  |  event queue 1  |      |    +--------+
88  *        event)       +-----------------+      |    +--------+
89  *                                              |    |        |dequeue +------+
90  *        +-------+    +-----------------+      |    | event  +------->|Core n|
91  *        |Core   |    | +-------------+ o-----------o port n |        |      |
92  *        |(SW)   |    | |    flow 0   | |      |    +--------+        +--+---+
93  *        |event  |    | +-------------+ |      |                         |
94  *        +-------+    | +-------------+ |      |                         |
95  *            ^        | |    flow 1   | |      |                         |
96  *            |        | +-------------+ o------+                         |
97  *            |        | +-------------+ |                                |
98  *            |        | |    flow n   | |                                |
99  *            |        | +-------------+ |                                |
100  *            |        |  event queue n  |                                |
101  *            |        +-----------------+                                |
102  *            |                                                           |
103  *            +-----------------------------------------------------------+
104  *
105  * Event device: A hardware or software-based event scheduler.
106  *
107  * Event: A unit of scheduling that encapsulates a packet or other datatype
108  * like SW generated event from the CPU, Crypto work completion notification,
109  * Timer expiry event notification etc as well as metadata.
110  * The metadata includes flow ID, scheduling type, event priority, event_type,
111  * sub_event_type etc.
112  *
113  * Event queue: A queue containing events that are scheduled by the event dev.
114  * An event queue contains events of different flows associated with scheduling
115  * types, such as atomic, ordered, or parallel.
116  *
117  * Event port: An application's interface into the event dev for enqueue and
118  * dequeue operations. Each event port can be linked with one or more
119  * event queues for dequeue operations.
120  *
121  * By default, all the functions of the Event Device API exported by a PMD
122  * are lock-free functions which assume to not be invoked in parallel on
123  * different logical cores to work on the same target object. For instance,
124  * the dequeue function of a PMD cannot be invoked in parallel on two logical
125  * cores to operates on same  event port. Of course, this function
126  * can be invoked in parallel by different logical cores on different ports.
127  * It is the responsibility of the upper level application to enforce this rule.
128  *
129  * In all functions of the Event API, the Event device is
130  * designated by an integer >= 0 named the device identifier *dev_id*
131  *
132  * At the Event driver level, Event devices are represented by a generic
133  * data structure of type *rte_event_dev*.
134  *
135  * Event devices are dynamically registered during the PCI/SoC device probing
136  * phase performed at EAL initialization time.
137  * When an Event device is being probed, a *rte_event_dev* structure and
138  * a new device identifier are allocated for that device. Then, the
139  * event_dev_init() function supplied by the Event driver matching the probed
140  * device is invoked to properly initialize the device.
141  *
142  * The role of the device init function consists of resetting the hardware or
143  * software event driver implementations.
144  *
145  * If the device init operation is successful, the correspondence between
146  * the device identifier assigned to the new device and its associated
147  * *rte_event_dev* structure is effectively registered.
148  * Otherwise, both the *rte_event_dev* structure and the device identifier are
149  * freed.
150  *
151  * The functions exported by the application Event API to setup a device
152  * designated by its device identifier must be invoked in the following order:
153  *     - rte_event_dev_configure()
154  *     - rte_event_queue_setup()
155  *     - rte_event_port_setup()
156  *     - rte_event_port_link()
157  *     - rte_event_dev_start()
158  *
159  * Then, the application can invoke, in any order, the functions
160  * exported by the Event API to schedule events, dequeue events, enqueue events,
161  * change event queue(s) to event port [un]link establishment and so on.
162  *
163  * Application may use rte_event_[queue/port]_default_conf_get() to get the
164  * default configuration to set up an event queue or event port by
165  * overriding few default values.
166  *
167  * If the application wants to change the configuration (i.e. call
168  * rte_event_dev_configure(), rte_event_queue_setup(), or
169  * rte_event_port_setup()), it must call rte_event_dev_stop() first to stop the
170  * device and then do the reconfiguration before calling rte_event_dev_start()
171  * again. The schedule, enqueue and dequeue functions should not be invoked
172  * when the device is stopped.
173  *
174  * Finally, an application can close an Event device by invoking the
175  * rte_event_dev_close() function.
176  *
177  * Each function of the application Event API invokes a specific function
178  * of the PMD that controls the target device designated by its device
179  * identifier.
180  *
181  * For this purpose, all device-specific functions of an Event driver are
182  * supplied through a set of pointers contained in a generic structure of type
183  * *event_dev_ops*.
184  * The address of the *event_dev_ops* structure is stored in the *rte_event_dev*
185  * structure by the device init function of the Event driver, which is
186  * invoked during the PCI/SoC device probing phase, as explained earlier.
187  *
188  * In other words, each function of the Event API simply retrieves the
189  * *rte_event_dev* structure associated with the device identifier and
190  * performs an indirect invocation of the corresponding driver function
191  * supplied in the *event_dev_ops* structure of the *rte_event_dev* structure.
192  *
193  * For performance reasons, the address of the fast-path functions of the
194  * Event driver is not contained in the *event_dev_ops* structure.
195  * Instead, they are directly stored at the beginning of the *rte_event_dev*
196  * structure to avoid an extra indirect memory access during their invocation.
197  *
198  * RTE event device drivers do not use interrupts for enqueue or dequeue
199  * operation. Instead, Event drivers export Poll-Mode enqueue and dequeue
200  * functions to applications.
201  *
202  * The events are injected to event device through *enqueue* operation by
203  * event producers in the system. The typical event producers are ethdev
204  * subsystem for generating packet events, CPU(SW) for generating events based
205  * on different stages of application processing, cryptodev for generating
206  * crypto work completion notification etc
207  *
208  * The *dequeue* operation gets one or more events from the event ports.
209  * The application process the events and send to downstream event queue through
210  * rte_event_enqueue_burst() if it is an intermediate stage of event processing,
211  * on the final stage, the application may send to different subsystem like
212  * ethdev to send the packet/event on the wire using ethdev
213  * rte_eth_tx_burst() API.
214  *
215  * The point at which events are scheduled to ports depends on the device.
216  * For hardware devices, scheduling occurs asynchronously without any software
217  * intervention. Software schedulers can either be distributed
218  * (each worker thread schedules events to its own port) or centralized
219  * (a dedicated thread schedules to all ports). Distributed software schedulers
220  * perform the scheduling in rte_event_dequeue_burst(), whereas centralized
221  * scheduler logic need a dedicated service core for scheduling.
222  * The RTE_EVENT_DEV_CAP_DISTRIBUTED_SCHED capability flag is not set
223  * indicates the device is centralized and thus needs a dedicated scheduling
224  * thread that repeatedly calls software specific scheduling function.
225  *
226  * An event driven worker thread has following typical workflow on fastpath:
227  * \code{.c}
228  *      while (1) {
229  *              rte_event_dequeue_burst(...);
230  *              (event processing)
231  *              rte_event_enqueue_burst(...);
232  *      }
233  * \endcode
234  *
235  */
236
237 #ifdef __cplusplus
238 extern "C" {
239 #endif
240
241 #include <rte_common.h>
242 #include <rte_memory.h>
243 #include <rte_errno.h>
244
245 struct rte_mbuf; /* we just use mbuf pointers; no need to include rte_mbuf.h */
246
247 /* Event device capability bitmap flags */
248 #define RTE_EVENT_DEV_CAP_QUEUE_QOS           (1ULL << 0)
249 /**< Event scheduling prioritization is based on the priority associated with
250  *  each event queue.
251  *
252  *  @see rte_event_queue_setup()
253  */
254 #define RTE_EVENT_DEV_CAP_EVENT_QOS           (1ULL << 1)
255 /**< Event scheduling prioritization is based on the priority associated with
256  *  each event. Priority of each event is supplied in *rte_event* structure
257  *  on each enqueue operation.
258  *
259  *  @see rte_event_enqueue_burst()
260  */
261 #define RTE_EVENT_DEV_CAP_DISTRIBUTED_SCHED   (1ULL << 2)
262 /**< Event device operates in distributed scheduling mode.
263  * In distributed scheduling mode, event scheduling happens in HW or
264  * rte_event_dequeue_burst() or the combination of these two.
265  * If the flag is not set then eventdev is centralized and thus needs a
266  * dedicated service core that acts as a scheduling thread .
267  *
268  * @see rte_event_dequeue_burst()
269  */
270 #define RTE_EVENT_DEV_CAP_QUEUE_ALL_TYPES     (1ULL << 3)
271 /**< Event device is capable of enqueuing events of any type to any queue.
272  * If this capability is not set, the queue only supports events of the
273  *  *RTE_SCHED_TYPE_* type that it was created with.
274  *
275  * @see RTE_SCHED_TYPE_* values
276  */
277 #define RTE_EVENT_DEV_CAP_BURST_MODE          (1ULL << 4)
278 /**< Event device is capable of operating in burst mode for enqueue(forward,
279  * release) and dequeue operation. If this capability is not set, application
280  * still uses the rte_event_dequeue_burst() and rte_event_enqueue_burst() but
281  * PMD accepts only one event at a time.
282  *
283  * @see rte_event_dequeue_burst() rte_event_enqueue_burst()
284  */
285
286 /* Event device priority levels */
287 #define RTE_EVENT_DEV_PRIORITY_HIGHEST   0
288 /**< Highest priority expressed across eventdev subsystem
289  * @see rte_event_queue_setup(), rte_event_enqueue_burst()
290  * @see rte_event_port_link()
291  */
292 #define RTE_EVENT_DEV_PRIORITY_NORMAL    128
293 /**< Normal priority expressed across eventdev subsystem
294  * @see rte_event_queue_setup(), rte_event_enqueue_burst()
295  * @see rte_event_port_link()
296  */
297 #define RTE_EVENT_DEV_PRIORITY_LOWEST    255
298 /**< Lowest priority expressed across eventdev subsystem
299  * @see rte_event_queue_setup(), rte_event_enqueue_burst()
300  * @see rte_event_port_link()
301  */
302
303 /**
304  * Get the total number of event devices that have been successfully
305  * initialised.
306  *
307  * @return
308  *   The total number of usable event devices.
309  */
310 uint8_t
311 rte_event_dev_count(void);
312
313 /**
314  * Get the device identifier for the named event device.
315  *
316  * @param name
317  *   Event device name to select the event device identifier.
318  *
319  * @return
320  *   Returns event device identifier on success.
321  *   - <0: Failure to find named event device.
322  */
323 int
324 rte_event_dev_get_dev_id(const char *name);
325
326 /**
327  * Return the NUMA socket to which a device is connected.
328  *
329  * @param dev_id
330  *   The identifier of the device.
331  * @return
332  *   The NUMA socket id to which the device is connected or
333  *   a default of zero if the socket could not be determined.
334  *   -(-EINVAL)  dev_id value is out of range.
335  */
336 int
337 rte_event_dev_socket_id(uint8_t dev_id);
338
339 /**
340  * Event device information
341  */
342 struct rte_event_dev_info {
343         const char *driver_name;        /**< Event driver name */
344         struct rte_device *dev; /**< Device information */
345         uint32_t min_dequeue_timeout_ns;
346         /**< Minimum supported global dequeue timeout(ns) by this device */
347         uint32_t max_dequeue_timeout_ns;
348         /**< Maximum supported global dequeue timeout(ns) by this device */
349         uint32_t dequeue_timeout_ns;
350         /**< Configured global dequeue timeout(ns) for this device */
351         uint8_t max_event_queues;
352         /**< Maximum event_queues supported by this device */
353         uint32_t max_event_queue_flows;
354         /**< Maximum supported flows in an event queue by this device*/
355         uint8_t max_event_queue_priority_levels;
356         /**< Maximum number of event queue priority levels by this device.
357          * Valid when the device has RTE_EVENT_DEV_CAP_QUEUE_QOS capability
358          */
359         uint8_t max_event_priority_levels;
360         /**< Maximum number of event priority levels by this device.
361          * Valid when the device has RTE_EVENT_DEV_CAP_EVENT_QOS capability
362          */
363         uint8_t max_event_ports;
364         /**< Maximum number of event ports supported by this device */
365         uint8_t max_event_port_dequeue_depth;
366         /**< Maximum number of events can be dequeued at a time from an
367          * event port by this device.
368          * A device that does not support bulk dequeue will set this as 1.
369          */
370         uint32_t max_event_port_enqueue_depth;
371         /**< Maximum number of events can be enqueued at a time from an
372          * event port by this device.
373          * A device that does not support bulk enqueue will set this as 1.
374          */
375         int32_t max_num_events;
376         /**< A *closed system* event dev has a limit on the number of events it
377          * can manage at a time. An *open system* event dev does not have a
378          * limit and will specify this as -1.
379          */
380         uint32_t event_dev_cap;
381         /**< Event device capabilities(RTE_EVENT_DEV_CAP_)*/
382 };
383
384 /**
385  * Retrieve the contextual information of an event device.
386  *
387  * @param dev_id
388  *   The identifier of the device.
389  *
390  * @param[out] dev_info
391  *   A pointer to a structure of type *rte_event_dev_info* to be filled with the
392  *   contextual information of the device.
393  *
394  * @return
395  *   - 0: Success, driver updates the contextual information of the event device
396  *   - <0: Error code returned by the driver info get function.
397  *
398  */
399 int
400 rte_event_dev_info_get(uint8_t dev_id, struct rte_event_dev_info *dev_info);
401
402 /**
403  * The count of ports.
404  */
405 #define RTE_EVENT_DEV_ATTR_PORT_COUNT 0
406 /**
407  * The count of queues.
408  */
409 #define RTE_EVENT_DEV_ATTR_QUEUE_COUNT 1
410 /**
411  * The status of the device, zero for stopped, non-zero for started.
412  */
413 #define RTE_EVENT_DEV_ATTR_STARTED 2
414
415 /**
416  * Get an attribute from a device.
417  *
418  * @param dev_id Eventdev id
419  * @param attr_id The attribute ID to retrieve
420  * @param[out] attr_value A pointer that will be filled in with the attribute
421  *             value if successful.
422  *
423  * @retval 0 Successfully retrieved attribute value
424  *         -EINVAL Invalid device or  *attr_id* provided, or *attr_value*
425  *         is NULL
426  */
427 int
428 rte_event_dev_attr_get(uint8_t dev_id, uint32_t attr_id,
429                        uint32_t *attr_value);
430
431
432 /* Event device configuration bitmap flags */
433 #define RTE_EVENT_DEV_CFG_PER_DEQUEUE_TIMEOUT (1ULL << 0)
434 /**< Override the global *dequeue_timeout_ns* and use per dequeue timeout in ns.
435  *  @see rte_event_dequeue_timeout_ticks(), rte_event_dequeue_burst()
436  */
437
438 /** Event device configuration structure */
439 struct rte_event_dev_config {
440         uint32_t dequeue_timeout_ns;
441         /**< rte_event_dequeue_burst() timeout on this device.
442          * This value should be in the range of *min_dequeue_timeout_ns* and
443          * *max_dequeue_timeout_ns* which previously provided in
444          * rte_event_dev_info_get()
445          * The value 0 is allowed, in which case, default dequeue timeout used.
446          * @see RTE_EVENT_DEV_CFG_PER_DEQUEUE_TIMEOUT
447          */
448         int32_t nb_events_limit;
449         /**< In a *closed system* this field is the limit on maximum number of
450          * events that can be inflight in the eventdev at a given time. The
451          * limit is required to ensure that the finite space in a closed system
452          * is not overwhelmed. The value cannot exceed the *max_num_events*
453          * as provided by rte_event_dev_info_get().
454          * This value should be set to -1 for *open system*.
455          */
456         uint8_t nb_event_queues;
457         /**< Number of event queues to configure on this device.
458          * This value cannot exceed the *max_event_queues* which previously
459          * provided in rte_event_dev_info_get()
460          */
461         uint8_t nb_event_ports;
462         /**< Number of event ports to configure on this device.
463          * This value cannot exceed the *max_event_ports* which previously
464          * provided in rte_event_dev_info_get()
465          */
466         uint32_t nb_event_queue_flows;
467         /**< Number of flows for any event queue on this device.
468          * This value cannot exceed the *max_event_queue_flows* which previously
469          * provided in rte_event_dev_info_get()
470          */
471         uint32_t nb_event_port_dequeue_depth;
472         /**< Maximum number of events can be dequeued at a time from an
473          * event port by this device.
474          * This value cannot exceed the *max_event_port_dequeue_depth*
475          * which previously provided in rte_event_dev_info_get().
476          * Ignored when device is not RTE_EVENT_DEV_CAP_BURST_MODE capable.
477          * @see rte_event_port_setup()
478          */
479         uint32_t nb_event_port_enqueue_depth;
480         /**< Maximum number of events can be enqueued at a time from an
481          * event port by this device.
482          * This value cannot exceed the *max_event_port_enqueue_depth*
483          * which previously provided in rte_event_dev_info_get().
484          * Ignored when device is not RTE_EVENT_DEV_CAP_BURST_MODE capable.
485          * @see rte_event_port_setup()
486          */
487         uint32_t event_dev_cfg;
488         /**< Event device config flags(RTE_EVENT_DEV_CFG_)*/
489 };
490
491 /**
492  * Configure an event device.
493  *
494  * This function must be invoked first before any other function in the
495  * API. This function can also be re-invoked when a device is in the
496  * stopped state.
497  *
498  * The caller may use rte_event_dev_info_get() to get the capability of each
499  * resources available for this event device.
500  *
501  * @param dev_id
502  *   The identifier of the device to configure.
503  * @param dev_conf
504  *   The event device configuration structure.
505  *
506  * @return
507  *   - 0: Success, device configured.
508  *   - <0: Error code returned by the driver configuration function.
509  */
510 int
511 rte_event_dev_configure(uint8_t dev_id,
512                         const struct rte_event_dev_config *dev_conf);
513
514
515 /* Event queue specific APIs */
516
517 /* Event queue configuration bitmap flags */
518 #define RTE_EVENT_QUEUE_CFG_ALL_TYPES          (1ULL << 0)
519 /**< Allow ATOMIC,ORDERED,PARALLEL schedule type enqueue
520  *
521  * @see RTE_SCHED_TYPE_ORDERED, RTE_SCHED_TYPE_ATOMIC, RTE_SCHED_TYPE_PARALLEL
522  * @see rte_event_enqueue_burst()
523  */
524 #define RTE_EVENT_QUEUE_CFG_SINGLE_LINK        (1ULL << 1)
525 /**< This event queue links only to a single event port.
526  *
527  *  @see rte_event_port_setup(), rte_event_port_link()
528  */
529
530 /** Event queue configuration structure */
531 struct rte_event_queue_conf {
532         uint32_t nb_atomic_flows;
533         /**< The maximum number of active flows this queue can track at any
534          * given time. If the queue is configured for atomic scheduling (by
535          * applying the RTE_EVENT_QUEUE_CFG_ALL_TYPES flag to event_queue_cfg
536          * or RTE_SCHED_TYPE_ATOMIC flag to schedule_type), then the
537          * value must be in the range of [1, nb_event_queue_flows], which was
538          * previously provided in rte_event_dev_configure().
539          */
540         uint32_t nb_atomic_order_sequences;
541         /**< The maximum number of outstanding events waiting to be
542          * reordered by this queue. In other words, the number of entries in
543          * this queue’s reorder buffer.When the number of events in the
544          * reorder buffer reaches to *nb_atomic_order_sequences* then the
545          * scheduler cannot schedule the events from this queue and invalid
546          * event will be returned from dequeue until one or more entries are
547          * freed up/released.
548          * If the queue is configured for ordered scheduling (by applying the
549          * RTE_EVENT_QUEUE_CFG_ALL_TYPES flag to event_queue_cfg or
550          * RTE_SCHED_TYPE_ORDERED flag to schedule_type), then the value must
551          * be in the range of [1, nb_event_queue_flows], which was
552          * previously supplied to rte_event_dev_configure().
553          */
554         uint32_t event_queue_cfg;
555         /**< Queue cfg flags(EVENT_QUEUE_CFG_) */
556         uint8_t schedule_type;
557         /**< Queue schedule type(RTE_SCHED_TYPE_*).
558          * Valid when RTE_EVENT_QUEUE_CFG_ALL_TYPES bit is not set in
559          * event_queue_cfg.
560          */
561         uint8_t priority;
562         /**< Priority for this event queue relative to other event queues.
563          * The requested priority should in the range of
564          * [RTE_EVENT_DEV_PRIORITY_HIGHEST, RTE_EVENT_DEV_PRIORITY_LOWEST].
565          * The implementation shall normalize the requested priority to
566          * event device supported priority value.
567          * Valid when the device has RTE_EVENT_DEV_CAP_QUEUE_QOS capability
568          */
569 };
570
571 /**
572  * Retrieve the default configuration information of an event queue designated
573  * by its *queue_id* from the event driver for an event device.
574  *
575  * This function intended to be used in conjunction with rte_event_queue_setup()
576  * where caller needs to set up the queue by overriding few default values.
577  *
578  * @param dev_id
579  *   The identifier of the device.
580  * @param queue_id
581  *   The index of the event queue to get the configuration information.
582  *   The value must be in the range [0, nb_event_queues - 1]
583  *   previously supplied to rte_event_dev_configure().
584  * @param[out] queue_conf
585  *   The pointer to the default event queue configuration data.
586  * @return
587  *   - 0: Success, driver updates the default event queue configuration data.
588  *   - <0: Error code returned by the driver info get function.
589  *
590  * @see rte_event_queue_setup()
591  *
592  */
593 int
594 rte_event_queue_default_conf_get(uint8_t dev_id, uint8_t queue_id,
595                                  struct rte_event_queue_conf *queue_conf);
596
597 /**
598  * Allocate and set up an event queue for an event device.
599  *
600  * @param dev_id
601  *   The identifier of the device.
602  * @param queue_id
603  *   The index of the event queue to setup. The value must be in the range
604  *   [0, nb_event_queues - 1] previously supplied to rte_event_dev_configure().
605  * @param queue_conf
606  *   The pointer to the configuration data to be used for the event queue.
607  *   NULL value is allowed, in which case default configuration used.
608  *
609  * @see rte_event_queue_default_conf_get()
610  *
611  * @return
612  *   - 0: Success, event queue correctly set up.
613  *   - <0: event queue configuration failed
614  */
615 int
616 rte_event_queue_setup(uint8_t dev_id, uint8_t queue_id,
617                       const struct rte_event_queue_conf *queue_conf);
618
619 /**
620  * The priority of the queue.
621  */
622 #define RTE_EVENT_QUEUE_ATTR_PRIORITY 0
623 /**
624  * The number of atomic flows configured for the queue.
625  */
626 #define RTE_EVENT_QUEUE_ATTR_NB_ATOMIC_FLOWS 1
627 /**
628  * The number of atomic order sequences configured for the queue.
629  */
630 #define RTE_EVENT_QUEUE_ATTR_NB_ATOMIC_ORDER_SEQUENCES 2
631 /**
632  * The cfg flags for the queue.
633  */
634 #define RTE_EVENT_QUEUE_ATTR_EVENT_QUEUE_CFG 3
635 /**
636  * The schedule type of the queue.
637  */
638 #define RTE_EVENT_QUEUE_ATTR_SCHEDULE_TYPE 4
639
640 /**
641  * Get an attribute from a queue.
642  *
643  * @param dev_id Eventdev id
644  * @param queue_id Eventdev queue id
645  * @param attr_id The attribute ID to retrieve
646  * @param[out] attr_value A pointer that will be filled in with the attribute
647  *             value if successful
648  *
649  * @retval 0 Successfully returned value
650  *         -EINVAL invalid device, queue or attr_id provided, or attr_value
651  *         was NULL
652  *         -EOVERFLOW returned when attr_id is set to
653  *         RTE_EVENT_QUEUE_ATTR_SCHEDULE_TYPE and event_queue_cfg is set to
654  *         RTE_EVENT_QUEUE_CFG_ALL_TYPES
655  */
656 int
657 rte_event_queue_attr_get(uint8_t dev_id, uint8_t queue_id, uint32_t attr_id,
658                         uint32_t *attr_value);
659
660 /* Event port specific APIs */
661
662 /** Event port configuration structure */
663 struct rte_event_port_conf {
664         int32_t new_event_threshold;
665         /**< A backpressure threshold for new event enqueues on this port.
666          * Use for *closed system* event dev where event capacity is limited,
667          * and cannot exceed the capacity of the event dev.
668          * Configuring ports with different thresholds can make higher priority
669          * traffic less likely to  be backpressured.
670          * For example, a port used to inject NIC Rx packets into the event dev
671          * can have a lower threshold so as not to overwhelm the device,
672          * while ports used for worker pools can have a higher threshold.
673          * This value cannot exceed the *nb_events_limit*
674          * which was previously supplied to rte_event_dev_configure().
675          * This should be set to '-1' for *open system*.
676          */
677         uint16_t dequeue_depth;
678         /**< Configure number of bulk dequeues for this event port.
679          * This value cannot exceed the *nb_event_port_dequeue_depth*
680          * which previously supplied to rte_event_dev_configure().
681          * Ignored when device is not RTE_EVENT_DEV_CAP_BURST_MODE capable.
682          */
683         uint16_t enqueue_depth;
684         /**< Configure number of bulk enqueues for this event port.
685          * This value cannot exceed the *nb_event_port_enqueue_depth*
686          * which previously supplied to rte_event_dev_configure().
687          * Ignored when device is not RTE_EVENT_DEV_CAP_BURST_MODE capable.
688          */
689 };
690
691 /**
692  * Retrieve the default configuration information of an event port designated
693  * by its *port_id* from the event driver for an event device.
694  *
695  * This function intended to be used in conjunction with rte_event_port_setup()
696  * where caller needs to set up the port by overriding few default values.
697  *
698  * @param dev_id
699  *   The identifier of the device.
700  * @param port_id
701  *   The index of the event port to get the configuration information.
702  *   The value must be in the range [0, nb_event_ports - 1]
703  *   previously supplied to rte_event_dev_configure().
704  * @param[out] port_conf
705  *   The pointer to the default event port configuration data
706  * @return
707  *   - 0: Success, driver updates the default event port configuration data.
708  *   - <0: Error code returned by the driver info get function.
709  *
710  * @see rte_event_port_setup()
711  *
712  */
713 int
714 rte_event_port_default_conf_get(uint8_t dev_id, uint8_t port_id,
715                                 struct rte_event_port_conf *port_conf);
716
717 /**
718  * Allocate and set up an event port for an event device.
719  *
720  * @param dev_id
721  *   The identifier of the device.
722  * @param port_id
723  *   The index of the event port to setup. The value must be in the range
724  *   [0, nb_event_ports - 1] previously supplied to rte_event_dev_configure().
725  * @param port_conf
726  *   The pointer to the configuration data to be used for the queue.
727  *   NULL value is allowed, in which case default configuration used.
728  *
729  * @see rte_event_port_default_conf_get()
730  *
731  * @return
732  *   - 0: Success, event port correctly set up.
733  *   - <0: Port configuration failed
734  *   - (-EDQUOT) Quota exceeded(Application tried to link the queue configured
735  *   with RTE_EVENT_QUEUE_CFG_SINGLE_LINK to more than one event ports)
736  */
737 int
738 rte_event_port_setup(uint8_t dev_id, uint8_t port_id,
739                      const struct rte_event_port_conf *port_conf);
740
741 /**
742  * The queue depth of the port on the enqueue side
743  */
744 #define RTE_EVENT_PORT_ATTR_ENQ_DEPTH 0
745 /**
746  * The queue depth of the port on the dequeue side
747  */
748 #define RTE_EVENT_PORT_ATTR_DEQ_DEPTH 1
749 /**
750  * The new event threshold of the port
751  */
752 #define RTE_EVENT_PORT_ATTR_NEW_EVENT_THRESHOLD 2
753
754 /**
755  * Get an attribute from a port.
756  *
757  * @param dev_id Eventdev id
758  * @param port_id Eventdev port id
759  * @param attr_id The attribute ID to retrieve
760  * @param[out] attr_value A pointer that will be filled in with the attribute
761  *             value if successful
762  *
763  * @retval 0 Successfully returned value
764  *         -EINVAL Invalid device, port or attr_id, or attr_value was NULL
765  */
766 int
767 rte_event_port_attr_get(uint8_t dev_id, uint8_t port_id, uint32_t attr_id,
768                         uint32_t *attr_value);
769
770 /**
771  * Start an event device.
772  *
773  * The device start step is the last one and consists of setting the event
774  * queues to start accepting the events and schedules to event ports.
775  *
776  * On success, all basic functions exported by the API (event enqueue,
777  * event dequeue and so on) can be invoked.
778  *
779  * @param dev_id
780  *   Event device identifier
781  * @return
782  *   - 0: Success, device started.
783  *   - -ESTALE : Not all ports of the device are configured
784  *   - -ENOLINK: Not all queues are linked, which could lead to deadlock.
785  */
786 int
787 rte_event_dev_start(uint8_t dev_id);
788
789 /**
790  * Stop an event device. The device can be restarted with a call to
791  * rte_event_dev_start()
792  *
793  * @param dev_id
794  *   Event device identifier.
795  */
796 void
797 rte_event_dev_stop(uint8_t dev_id);
798
799 /**
800  * Close an event device. The device cannot be restarted!
801  *
802  * @param dev_id
803  *   Event device identifier
804  *
805  * @return
806  *  - 0 on successfully closing device
807  *  - <0 on failure to close device
808  *  - (-EAGAIN) if device is busy
809  */
810 int
811 rte_event_dev_close(uint8_t dev_id);
812
813 /* Scheduler type definitions */
814 #define RTE_SCHED_TYPE_ORDERED          0
815 /**< Ordered scheduling
816  *
817  * Events from an ordered flow of an event queue can be scheduled to multiple
818  * ports for concurrent processing while maintaining the original event order.
819  * This scheme enables the user to achieve high single flow throughput by
820  * avoiding SW synchronization for ordering between ports which bound to cores.
821  *
822  * The source flow ordering from an event queue is maintained when events are
823  * enqueued to their destination queue within the same ordered flow context.
824  * An event port holds the context until application call
825  * rte_event_dequeue_burst() from the same port, which implicitly releases
826  * the context.
827  * User may allow the scheduler to release the context earlier than that
828  * by invoking rte_event_enqueue_burst() with RTE_EVENT_OP_RELEASE operation.
829  *
830  * Events from the source queue appear in their original order when dequeued
831  * from a destination queue.
832  * Event ordering is based on the received event(s), but also other
833  * (newly allocated or stored) events are ordered when enqueued within the same
834  * ordered context. Events not enqueued (e.g. released or stored) within the
835  * context are  considered missing from reordering and are skipped at this time
836  * (but can be ordered again within another context).
837  *
838  * @see rte_event_queue_setup(), rte_event_dequeue_burst(), RTE_EVENT_OP_RELEASE
839  */
840
841 #define RTE_SCHED_TYPE_ATOMIC           1
842 /**< Atomic scheduling
843  *
844  * Events from an atomic flow of an event queue can be scheduled only to a
845  * single port at a time. The port is guaranteed to have exclusive (atomic)
846  * access to the associated flow context, which enables the user to avoid SW
847  * synchronization. Atomic flows also help to maintain event ordering
848  * since only one port at a time can process events from a flow of an
849  * event queue.
850  *
851  * The atomic queue synchronization context is dedicated to the port until
852  * application call rte_event_dequeue_burst() from the same port,
853  * which implicitly releases the context. User may allow the scheduler to
854  * release the context earlier than that by invoking rte_event_enqueue_burst()
855  * with RTE_EVENT_OP_RELEASE operation.
856  *
857  * @see rte_event_queue_setup(), rte_event_dequeue_burst(), RTE_EVENT_OP_RELEASE
858  */
859
860 #define RTE_SCHED_TYPE_PARALLEL         2
861 /**< Parallel scheduling
862  *
863  * The scheduler performs priority scheduling, load balancing, etc. functions
864  * but does not provide additional event synchronization or ordering.
865  * It is free to schedule events from a single parallel flow of an event queue
866  * to multiple events ports for concurrent processing.
867  * The application is responsible for flow context synchronization and
868  * event ordering (SW synchronization).
869  *
870  * @see rte_event_queue_setup(), rte_event_dequeue_burst()
871  */
872
873 /* Event types to classify the event source */
874 #define RTE_EVENT_TYPE_ETHDEV           0x0
875 /**< The event generated from ethdev subsystem */
876 #define RTE_EVENT_TYPE_CRYPTODEV        0x1
877 /**< The event generated from crypodev subsystem */
878 #define RTE_EVENT_TYPE_TIMERDEV         0x2
879 /**< The event generated from timerdev subsystem */
880 #define RTE_EVENT_TYPE_CPU              0x3
881 /**< The event generated from cpu for pipelining.
882  * Application may use *sub_event_type* to further classify the event
883  */
884 #define RTE_EVENT_TYPE_ETH_RX_ADAPTER   0x4
885 /**< The event generated from event eth Rx adapter */
886 #define RTE_EVENT_TYPE_MAX              0x10
887 /**< Maximum number of event types */
888
889 /* Event enqueue operations */
890 #define RTE_EVENT_OP_NEW                0
891 /**< The event producers use this operation to inject a new event to the
892  * event device.
893  */
894 #define RTE_EVENT_OP_FORWARD            1
895 /**< The CPU use this operation to forward the event to different event queue or
896  * change to new application specific flow or schedule type to enable
897  * pipelining.
898  *
899  * This operation must only be enqueued to the same port that the
900  * event to be forwarded was dequeued from.
901  */
902 #define RTE_EVENT_OP_RELEASE            2
903 /**< Release the flow context associated with the schedule type.
904  *
905  * If current flow's scheduler type method is *RTE_SCHED_TYPE_ATOMIC*
906  * then this function hints the scheduler that the user has completed critical
907  * section processing in the current atomic context.
908  * The scheduler is now allowed to schedule events from the same flow from
909  * an event queue to another port. However, the context may be still held
910  * until the next rte_event_dequeue_burst() call, this call allows but does not
911  * force the scheduler to release the context early.
912  *
913  * Early atomic context release may increase parallelism and thus system
914  * performance, but the user needs to design carefully the split into critical
915  * vs non-critical sections.
916  *
917  * If current flow's scheduler type method is *RTE_SCHED_TYPE_ORDERED*
918  * then this function hints the scheduler that the user has done all that need
919  * to maintain event order in the current ordered context.
920  * The scheduler is allowed to release the ordered context of this port and
921  * avoid reordering any following enqueues.
922  *
923  * Early ordered context release may increase parallelism and thus system
924  * performance.
925  *
926  * If current flow's scheduler type method is *RTE_SCHED_TYPE_PARALLEL*
927  * or no scheduling context is held then this function may be an NOOP,
928  * depending on the implementation.
929  *
930  * This operation must only be enqueued to the same port that the
931  * event to be released was dequeued from.
932  *
933  */
934
935 /**
936  * The generic *rte_event* structure to hold the event attributes
937  * for dequeue and enqueue operation
938  */
939 RTE_STD_C11
940 struct rte_event {
941         /** WORD0 */
942         union {
943                 uint64_t event;
944                 /** Event attributes for dequeue or enqueue operation */
945                 struct {
946                         uint32_t flow_id:20;
947                         /**< Targeted flow identifier for the enqueue and
948                          * dequeue operation.
949                          * The value must be in the range of
950                          * [0, nb_event_queue_flows - 1] which
951                          * previously supplied to rte_event_dev_configure().
952                          */
953                         uint32_t sub_event_type:8;
954                         /**< Sub-event types based on the event source.
955                          * @see RTE_EVENT_TYPE_CPU
956                          */
957                         uint32_t event_type:4;
958                         /**< Event type to classify the event source.
959                          * @see RTE_EVENT_TYPE_ETHDEV, (RTE_EVENT_TYPE_*)
960                          */
961                         uint8_t op:2;
962                         /**< The type of event enqueue operation - new/forward/
963                          * etc.This field is not preserved across an instance
964                          * and is undefined on dequeue.
965                          * @see RTE_EVENT_OP_NEW, (RTE_EVENT_OP_*)
966                          */
967                         uint8_t rsvd:4;
968                         /**< Reserved for future use */
969                         uint8_t sched_type:2;
970                         /**< Scheduler synchronization type (RTE_SCHED_TYPE_*)
971                          * associated with flow id on a given event queue
972                          * for the enqueue and dequeue operation.
973                          */
974                         uint8_t queue_id;
975                         /**< Targeted event queue identifier for the enqueue or
976                          * dequeue operation.
977                          * The value must be in the range of
978                          * [0, nb_event_queues - 1] which previously supplied to
979                          * rte_event_dev_configure().
980                          */
981                         uint8_t priority;
982                         /**< Event priority relative to other events in the
983                          * event queue. The requested priority should in the
984                          * range of  [RTE_EVENT_DEV_PRIORITY_HIGHEST,
985                          * RTE_EVENT_DEV_PRIORITY_LOWEST].
986                          * The implementation shall normalize the requested
987                          * priority to supported priority value.
988                          * Valid when the device has
989                          * RTE_EVENT_DEV_CAP_EVENT_QOS capability.
990                          */
991                         uint8_t impl_opaque;
992                         /**< Implementation specific opaque value.
993                          * An implementation may use this field to hold
994                          * implementation specific value to share between
995                          * dequeue and enqueue operation.
996                          * The application should not modify this field.
997                          */
998                 };
999         };
1000         /** WORD1 */
1001         union {
1002                 uint64_t u64;
1003                 /**< Opaque 64-bit value */
1004                 void *event_ptr;
1005                 /**< Opaque event pointer */
1006                 struct rte_mbuf *mbuf;
1007                 /**< mbuf pointer if dequeued event is associated with mbuf */
1008         };
1009 };
1010
1011 /* Ethdev Rx adapter capability bitmap flags */
1012 #define RTE_EVENT_ETH_RX_ADAPTER_CAP_INTERNAL_PORT      0x1
1013 /**< This flag is sent when the packet transfer mechanism is in HW.
1014  * Ethdev can send packets to the event device using internal event port.
1015  */
1016 #define RTE_EVENT_ETH_RX_ADAPTER_CAP_MULTI_EVENTQ       0x2
1017 /**< Adapter supports multiple event queues per ethdev. Every ethdev
1018  * Rx queue can be connected to a unique event queue.
1019  */
1020 #define RTE_EVENT_ETH_RX_ADAPTER_CAP_OVERRIDE_FLOW_ID   0x4
1021 /**< The application can override the adapter generated flow ID in the
1022  * event. This flow ID can be specified when adding an ethdev Rx queue
1023  * to the adapter using the ev member of struct rte_event_eth_rx_adapter
1024  * @see struct rte_event_eth_rx_adapter_queue_conf::ev
1025  * @see struct rte_event_eth_rx_adapter_queue_conf::rx_queue_flags
1026  */
1027
1028 /**
1029  * Retrieve the event device's ethdev Rx adapter capabilities for the
1030  * specified ethernet port
1031  *
1032  * @param dev_id
1033  *   The identifier of the device.
1034  *
1035  * @param eth_port_id
1036  *   The identifier of the ethernet device.
1037  *
1038  * @param[out] caps
1039  *   A pointer to memory filled with Rx event adapter capabilities.
1040  *
1041  * @return
1042  *   - 0: Success, driver provides Rx event adapter capabilities for the
1043  *      ethernet device.
1044  *   - <0: Error code returned by the driver function.
1045  *
1046  */
1047 int
1048 rte_event_eth_rx_adapter_caps_get(uint8_t dev_id, uint8_t eth_port_id,
1049                                 uint32_t *caps);
1050
1051 struct rte_eventdev_driver;
1052 struct rte_eventdev_ops;
1053 struct rte_eventdev;
1054
1055 typedef uint16_t (*event_enqueue_t)(void *port, const struct rte_event *ev);
1056 /**< @internal Enqueue event on port of a device */
1057
1058 typedef uint16_t (*event_enqueue_burst_t)(void *port,
1059                         const struct rte_event ev[], uint16_t nb_events);
1060 /**< @internal Enqueue burst of events on port of a device */
1061
1062 typedef uint16_t (*event_dequeue_t)(void *port, struct rte_event *ev,
1063                 uint64_t timeout_ticks);
1064 /**< @internal Dequeue event from port of a device */
1065
1066 typedef uint16_t (*event_dequeue_burst_t)(void *port, struct rte_event ev[],
1067                 uint16_t nb_events, uint64_t timeout_ticks);
1068 /**< @internal Dequeue burst of events from port of a device */
1069
1070 #define RTE_EVENTDEV_NAME_MAX_LEN       (64)
1071 /**< @internal Max length of name of event PMD */
1072
1073 /**
1074  * @internal
1075  * The data part, with no function pointers, associated with each device.
1076  *
1077  * This structure is safe to place in shared memory to be common among
1078  * different processes in a multi-process configuration.
1079  */
1080 struct rte_eventdev_data {
1081         int socket_id;
1082         /**< Socket ID where memory is allocated */
1083         uint8_t dev_id;
1084         /**< Device ID for this instance */
1085         uint8_t nb_queues;
1086         /**< Number of event queues. */
1087         uint8_t nb_ports;
1088         /**< Number of event ports. */
1089         void **ports;
1090         /**< Array of pointers to ports. */
1091         struct rte_event_port_conf *ports_cfg;
1092         /**< Array of port configuration structures. */
1093         struct rte_event_queue_conf *queues_cfg;
1094         /**< Array of queue configuration structures. */
1095         uint16_t *links_map;
1096         /**< Memory to store queues to port connections. */
1097         void *dev_private;
1098         /**< PMD-specific private data */
1099         uint32_t event_dev_cap;
1100         /**< Event device capabilities(RTE_EVENT_DEV_CAP_)*/
1101         struct rte_event_dev_config dev_conf;
1102         /**< Configuration applied to device. */
1103         uint8_t service_inited;
1104         /* Service initialization state */
1105         uint32_t service_id;
1106         /* Service ID*/
1107
1108         RTE_STD_C11
1109         uint8_t dev_started : 1;
1110         /**< Device state: STARTED(1)/STOPPED(0) */
1111
1112         char name[RTE_EVENTDEV_NAME_MAX_LEN];
1113         /**< Unique identifier name */
1114 } __rte_cache_aligned;
1115
1116 /** @internal The data structure associated with each event device. */
1117 struct rte_eventdev {
1118         event_enqueue_t enqueue;
1119         /**< Pointer to PMD enqueue function. */
1120         event_enqueue_burst_t enqueue_burst;
1121         /**< Pointer to PMD enqueue burst function. */
1122         event_enqueue_burst_t enqueue_new_burst;
1123         /**< Pointer to PMD enqueue burst function(op new variant) */
1124         event_enqueue_burst_t enqueue_forward_burst;
1125         /**< Pointer to PMD enqueue burst function(op forward variant) */
1126         event_dequeue_t dequeue;
1127         /**< Pointer to PMD dequeue function. */
1128         event_dequeue_burst_t dequeue_burst;
1129         /**< Pointer to PMD dequeue burst function. */
1130
1131         struct rte_eventdev_data *data;
1132         /**< Pointer to device data */
1133         const struct rte_eventdev_ops *dev_ops;
1134         /**< Functions exported by PMD */
1135         struct rte_device *dev;
1136         /**< Device info. supplied by probing */
1137
1138         RTE_STD_C11
1139         uint8_t attached : 1;
1140         /**< Flag indicating the device is attached */
1141 } __rte_cache_aligned;
1142
1143 extern struct rte_eventdev *rte_eventdevs;
1144 /** @internal The pool of rte_eventdev structures. */
1145
1146 static __rte_always_inline uint16_t
1147 __rte_event_enqueue_burst(uint8_t dev_id, uint8_t port_id,
1148                         const struct rte_event ev[], uint16_t nb_events,
1149                         const event_enqueue_burst_t fn)
1150 {
1151         const struct rte_eventdev *dev = &rte_eventdevs[dev_id];
1152
1153 #ifdef RTE_LIBRTE_EVENTDEV_DEBUG
1154         if (dev_id >= RTE_EVENT_MAX_DEVS || !rte_eventdevs[dev_id].attached) {
1155                 rte_errno = -EINVAL;
1156                 return 0;
1157         }
1158
1159         if (port_id >= dev->data->nb_ports) {
1160                 rte_errno = -EINVAL;
1161                 return 0;
1162         }
1163 #endif
1164         /*
1165          * Allow zero cost non burst mode routine invocation if application
1166          * requests nb_events as const one
1167          */
1168         if (nb_events == 1)
1169                 return (*dev->enqueue)(dev->data->ports[port_id], ev);
1170         else
1171                 return fn(dev->data->ports[port_id], ev, nb_events);
1172 }
1173
1174 /**
1175  * Enqueue a burst of events objects or an event object supplied in *rte_event*
1176  * structure on an  event device designated by its *dev_id* through the event
1177  * port specified by *port_id*. Each event object specifies the event queue on
1178  * which it will be enqueued.
1179  *
1180  * The *nb_events* parameter is the number of event objects to enqueue which are
1181  * supplied in the *ev* array of *rte_event* structure.
1182  *
1183  * Event operations RTE_EVENT_OP_FORWARD and RTE_EVENT_OP_RELEASE must only be
1184  * enqueued to the same port that their associated events were dequeued from.
1185  *
1186  * The rte_event_enqueue_burst() function returns the number of
1187  * events objects it actually enqueued. A return value equal to *nb_events*
1188  * means that all event objects have been enqueued.
1189  *
1190  * @param dev_id
1191  *   The identifier of the device.
1192  * @param port_id
1193  *   The identifier of the event port.
1194  * @param ev
1195  *   Points to an array of *nb_events* objects of type *rte_event* structure
1196  *   which contain the event object enqueue operations to be processed.
1197  * @param nb_events
1198  *   The number of event objects to enqueue, typically number of
1199  *   rte_event_port_enqueue_depth() available for this port.
1200  *
1201  * @return
1202  *   The number of event objects actually enqueued on the event device. The
1203  *   return value can be less than the value of the *nb_events* parameter when
1204  *   the event devices queue is full or if invalid parameters are specified in a
1205  *   *rte_event*. If the return value is less than *nb_events*, the remaining
1206  *   events at the end of ev[] are not consumed and the caller has to take care
1207  *   of them, and rte_errno is set accordingly. Possible errno values include:
1208  *   - -EINVAL  The port ID is invalid, device ID is invalid, an event's queue
1209  *              ID is invalid, or an event's sched type doesn't match the
1210  *              capabilities of the destination queue.
1211  *   - -ENOSPC  The event port was backpressured and unable to enqueue
1212  *              one or more events. This error code is only applicable to
1213  *              closed systems.
1214  * @see rte_event_port_enqueue_depth()
1215  */
1216 static inline uint16_t
1217 rte_event_enqueue_burst(uint8_t dev_id, uint8_t port_id,
1218                         const struct rte_event ev[], uint16_t nb_events)
1219 {
1220         const struct rte_eventdev *dev = &rte_eventdevs[dev_id];
1221
1222         return __rte_event_enqueue_burst(dev_id, port_id, ev, nb_events,
1223                         dev->enqueue_burst);
1224 }
1225
1226 /**
1227  * Enqueue a burst of events objects of operation type *RTE_EVENT_OP_NEW* on
1228  * an event device designated by its *dev_id* through the event port specified
1229  * by *port_id*.
1230  *
1231  * Provides the same functionality as rte_event_enqueue_burst(), expect that
1232  * application can use this API when the all objects in the burst contains
1233  * the enqueue operation of the type *RTE_EVENT_OP_NEW*. This specialized
1234  * function can provide the additional hint to the PMD and optimize if possible.
1235  *
1236  * The rte_event_enqueue_new_burst() result is undefined if the enqueue burst
1237  * has event object of operation type != RTE_EVENT_OP_NEW.
1238  *
1239  * @param dev_id
1240  *   The identifier of the device.
1241  * @param port_id
1242  *   The identifier of the event port.
1243  * @param ev
1244  *   Points to an array of *nb_events* objects of type *rte_event* structure
1245  *   which contain the event object enqueue operations to be processed.
1246  * @param nb_events
1247  *   The number of event objects to enqueue, typically number of
1248  *   rte_event_port_enqueue_depth() available for this port.
1249  *
1250  * @return
1251  *   The number of event objects actually enqueued on the event device. The
1252  *   return value can be less than the value of the *nb_events* parameter when
1253  *   the event devices queue is full or if invalid parameters are specified in a
1254  *   *rte_event*. If the return value is less than *nb_events*, the remaining
1255  *   events at the end of ev[] are not consumed and the caller has to take care
1256  *   of them, and rte_errno is set accordingly. Possible errno values include:
1257  *   - -EINVAL  The port ID is invalid, device ID is invalid, an event's queue
1258  *              ID is invalid, or an event's sched type doesn't match the
1259  *              capabilities of the destination queue.
1260  *   - -ENOSPC  The event port was backpressured and unable to enqueue
1261  *              one or more events. This error code is only applicable to
1262  *              closed systems.
1263  * @see rte_event_port_enqueue_depth() rte_event_enqueue_burst()
1264  */
1265 static inline uint16_t
1266 rte_event_enqueue_new_burst(uint8_t dev_id, uint8_t port_id,
1267                         const struct rte_event ev[], uint16_t nb_events)
1268 {
1269         const struct rte_eventdev *dev = &rte_eventdevs[dev_id];
1270
1271         return __rte_event_enqueue_burst(dev_id, port_id, ev, nb_events,
1272                         dev->enqueue_new_burst);
1273 }
1274
1275 /**
1276  * Enqueue a burst of events objects of operation type *RTE_EVENT_OP_FORWARD*
1277  * on an event device designated by its *dev_id* through the event port
1278  * specified by *port_id*.
1279  *
1280  * Provides the same functionality as rte_event_enqueue_burst(), expect that
1281  * application can use this API when the all objects in the burst contains
1282  * the enqueue operation of the type *RTE_EVENT_OP_FORWARD*. This specialized
1283  * function can provide the additional hint to the PMD and optimize if possible.
1284  *
1285  * The rte_event_enqueue_new_burst() result is undefined if the enqueue burst
1286  * has event object of operation type != RTE_EVENT_OP_FORWARD.
1287  *
1288  * @param dev_id
1289  *   The identifier of the device.
1290  * @param port_id
1291  *   The identifier of the event port.
1292  * @param ev
1293  *   Points to an array of *nb_events* objects of type *rte_event* structure
1294  *   which contain the event object enqueue operations to be processed.
1295  * @param nb_events
1296  *   The number of event objects to enqueue, typically number of
1297  *   rte_event_port_enqueue_depth() available for this port.
1298  *
1299  * @return
1300  *   The number of event objects actually enqueued on the event device. The
1301  *   return value can be less than the value of the *nb_events* parameter when
1302  *   the event devices queue is full or if invalid parameters are specified in a
1303  *   *rte_event*. If the return value is less than *nb_events*, the remaining
1304  *   events at the end of ev[] are not consumed and the caller has to take care
1305  *   of them, and rte_errno is set accordingly. Possible errno values include:
1306  *   - -EINVAL  The port ID is invalid, device ID is invalid, an event's queue
1307  *              ID is invalid, or an event's sched type doesn't match the
1308  *              capabilities of the destination queue.
1309  *   - -ENOSPC  The event port was backpressured and unable to enqueue
1310  *              one or more events. This error code is only applicable to
1311  *              closed systems.
1312  * @see rte_event_port_enqueue_depth() rte_event_enqueue_burst()
1313  */
1314 static inline uint16_t
1315 rte_event_enqueue_forward_burst(uint8_t dev_id, uint8_t port_id,
1316                         const struct rte_event ev[], uint16_t nb_events)
1317 {
1318         const struct rte_eventdev *dev = &rte_eventdevs[dev_id];
1319
1320         return __rte_event_enqueue_burst(dev_id, port_id, ev, nb_events,
1321                         dev->enqueue_forward_burst);
1322 }
1323
1324 /**
1325  * Converts nanoseconds to *timeout_ticks* value for rte_event_dequeue_burst()
1326  *
1327  * If the device is configured with RTE_EVENT_DEV_CFG_PER_DEQUEUE_TIMEOUT flag
1328  * then application can use this function to convert timeout value in
1329  * nanoseconds to implementations specific timeout value supplied in
1330  * rte_event_dequeue_burst()
1331  *
1332  * @param dev_id
1333  *   The identifier of the device.
1334  * @param ns
1335  *   Wait time in nanosecond
1336  * @param[out] timeout_ticks
1337  *   Value for the *timeout_ticks* parameter in rte_event_dequeue_burst()
1338  *
1339  * @return
1340  *  - 0 on success.
1341  *  - -ENOTSUP if the device doesn't support timeouts
1342  *  - -EINVAL if *dev_id* is invalid or *timeout_ticks* is NULL
1343  *  - other values < 0 on failure.
1344  *
1345  * @see rte_event_dequeue_burst(), RTE_EVENT_DEV_CFG_PER_DEQUEUE_TIMEOUT
1346  * @see rte_event_dev_configure()
1347  *
1348  */
1349 int
1350 rte_event_dequeue_timeout_ticks(uint8_t dev_id, uint64_t ns,
1351                                         uint64_t *timeout_ticks);
1352
1353 /**
1354  * Dequeue a burst of events objects or an event object from the event port
1355  * designated by its *event_port_id*, on an event device designated
1356  * by its *dev_id*.
1357  *
1358  * rte_event_dequeue_burst() does not dictate the specifics of scheduling
1359  * algorithm as each eventdev driver may have different criteria to schedule
1360  * an event. However, in general, from an application perspective scheduler may
1361  * use the following scheme to dispatch an event to the port.
1362  *
1363  * 1) Selection of event queue based on
1364  *   a) The list of event queues are linked to the event port.
1365  *   b) If the device has RTE_EVENT_DEV_CAP_QUEUE_QOS capability then event
1366  *   queue selection from list is based on event queue priority relative to
1367  *   other event queue supplied as *priority* in rte_event_queue_setup()
1368  *   c) If the device has RTE_EVENT_DEV_CAP_EVENT_QOS capability then event
1369  *   queue selection from the list is based on event priority supplied as
1370  *   *priority* in rte_event_enqueue_burst()
1371  * 2) Selection of event
1372  *   a) The number of flows available in selected event queue.
1373  *   b) Schedule type method associated with the event
1374  *
1375  * The *nb_events* parameter is the maximum number of event objects to dequeue
1376  * which are returned in the *ev* array of *rte_event* structure.
1377  *
1378  * The rte_event_dequeue_burst() function returns the number of events objects
1379  * it actually dequeued. A return value equal to *nb_events* means that all
1380  * event objects have been dequeued.
1381  *
1382  * The number of events dequeued is the number of scheduler contexts held by
1383  * this port. These contexts are automatically released in the next
1384  * rte_event_dequeue_burst() invocation, or invoking rte_event_enqueue_burst()
1385  * with RTE_EVENT_OP_RELEASE operation can be used to release the
1386  * contexts early.
1387  *
1388  * Event operations RTE_EVENT_OP_FORWARD and RTE_EVENT_OP_RELEASE must only be
1389  * enqueued to the same port that their associated events were dequeued from.
1390  *
1391  * @param dev_id
1392  *   The identifier of the device.
1393  * @param port_id
1394  *   The identifier of the event port.
1395  * @param[out] ev
1396  *   Points to an array of *nb_events* objects of type *rte_event* structure
1397  *   for output to be populated with the dequeued event objects.
1398  * @param nb_events
1399  *   The maximum number of event objects to dequeue, typically number of
1400  *   rte_event_port_dequeue_depth() available for this port.
1401  *
1402  * @param timeout_ticks
1403  *   - 0 no-wait, returns immediately if there is no event.
1404  *   - >0 wait for the event, if the device is configured with
1405  *   RTE_EVENT_DEV_CFG_PER_DEQUEUE_TIMEOUT then this function will wait until
1406  *   at least one event is available or *timeout_ticks* time.
1407  *   if the device is not configured with RTE_EVENT_DEV_CFG_PER_DEQUEUE_TIMEOUT
1408  *   then this function will wait until the event available or
1409  *   *dequeue_timeout_ns* ns which was previously supplied to
1410  *   rte_event_dev_configure()
1411  *
1412  * @return
1413  * The number of event objects actually dequeued from the port. The return
1414  * value can be less than the value of the *nb_events* parameter when the
1415  * event port's queue is not full.
1416  *
1417  * @see rte_event_port_dequeue_depth()
1418  */
1419 static inline uint16_t
1420 rte_event_dequeue_burst(uint8_t dev_id, uint8_t port_id, struct rte_event ev[],
1421                         uint16_t nb_events, uint64_t timeout_ticks)
1422 {
1423         struct rte_eventdev *dev = &rte_eventdevs[dev_id];
1424
1425 #ifdef RTE_LIBRTE_EVENTDEV_DEBUG
1426         if (dev_id >= RTE_EVENT_MAX_DEVS || !rte_eventdevs[dev_id].attached) {
1427                 rte_errno = -EINVAL;
1428                 return 0;
1429         }
1430
1431         if (port_id >= dev->data->nb_ports) {
1432                 rte_errno = -EINVAL;
1433                 return 0;
1434         }
1435 #endif
1436
1437         /*
1438          * Allow zero cost non burst mode routine invocation if application
1439          * requests nb_events as const one
1440          */
1441         if (nb_events == 1)
1442                 return (*dev->dequeue)(
1443                         dev->data->ports[port_id], ev, timeout_ticks);
1444         else
1445                 return (*dev->dequeue_burst)(
1446                         dev->data->ports[port_id], ev, nb_events,
1447                                 timeout_ticks);
1448 }
1449
1450 /**
1451  * Link multiple source event queues supplied in *queues* to the destination
1452  * event port designated by its *port_id* with associated service priority
1453  * supplied in *priorities* on the event device designated by its *dev_id*.
1454  *
1455  * The link establishment shall enable the event port *port_id* from
1456  * receiving events from the specified event queue(s) supplied in *queues*
1457  *
1458  * An event queue may link to one or more event ports.
1459  * The number of links can be established from an event queue to event port is
1460  * implementation defined.
1461  *
1462  * Event queue(s) to event port link establishment can be changed at runtime
1463  * without re-configuring the device to support scaling and to reduce the
1464  * latency of critical work by establishing the link with more event ports
1465  * at runtime.
1466  *
1467  * @param dev_id
1468  *   The identifier of the device.
1469  *
1470  * @param port_id
1471  *   Event port identifier to select the destination port to link.
1472  *
1473  * @param queues
1474  *   Points to an array of *nb_links* event queues to be linked
1475  *   to the event port.
1476  *   NULL value is allowed, in which case this function links all the configured
1477  *   event queues *nb_event_queues* which previously supplied to
1478  *   rte_event_dev_configure() to the event port *port_id*
1479  *
1480  * @param priorities
1481  *   Points to an array of *nb_links* service priorities associated with each
1482  *   event queue link to event port.
1483  *   The priority defines the event port's servicing priority for
1484  *   event queue, which may be ignored by an implementation.
1485  *   The requested priority should in the range of
1486  *   [RTE_EVENT_DEV_PRIORITY_HIGHEST, RTE_EVENT_DEV_PRIORITY_LOWEST].
1487  *   The implementation shall normalize the requested priority to
1488  *   implementation supported priority value.
1489  *   NULL value is allowed, in which case this function links the event queues
1490  *   with RTE_EVENT_DEV_PRIORITY_NORMAL servicing priority
1491  *
1492  * @param nb_links
1493  *   The number of links to establish. This parameter is ignored if queues is
1494  *   NULL.
1495  *
1496  * @return
1497  * The number of links actually established. The return value can be less than
1498  * the value of the *nb_links* parameter when the implementation has the
1499  * limitation on specific queue to port link establishment or if invalid
1500  * parameters are specified in *queues*
1501  * If the return value is less than *nb_links*, the remaining links at the end
1502  * of link[] are not established, and the caller has to take care of them.
1503  * If return value is less than *nb_links* then implementation shall update the
1504  * rte_errno accordingly, Possible rte_errno values are
1505  * (-EDQUOT) Quota exceeded(Application tried to link the queue configured with
1506  *  RTE_EVENT_QUEUE_CFG_SINGLE_LINK to more than one event ports)
1507  * (-EINVAL) Invalid parameter
1508  *
1509  */
1510 int
1511 rte_event_port_link(uint8_t dev_id, uint8_t port_id,
1512                     const uint8_t queues[], const uint8_t priorities[],
1513                     uint16_t nb_links);
1514
1515 /**
1516  * Unlink multiple source event queues supplied in *queues* from the destination
1517  * event port designated by its *port_id* on the event device designated
1518  * by its *dev_id*.
1519  *
1520  * The unlink establishment shall disable the event port *port_id* from
1521  * receiving events from the specified event queue *queue_id*
1522  *
1523  * Event queue(s) to event port unlink establishment can be changed at runtime
1524  * without re-configuring the device.
1525  *
1526  * @param dev_id
1527  *   The identifier of the device.
1528  *
1529  * @param port_id
1530  *   Event port identifier to select the destination port to unlink.
1531  *
1532  * @param queues
1533  *   Points to an array of *nb_unlinks* event queues to be unlinked
1534  *   from the event port.
1535  *   NULL value is allowed, in which case this function unlinks all the
1536  *   event queue(s) from the event port *port_id*.
1537  *
1538  * @param nb_unlinks
1539  *   The number of unlinks to establish. This parameter is ignored if queues is
1540  *   NULL.
1541  *
1542  * @return
1543  * The number of unlinks actually established. The return value can be less
1544  * than the value of the *nb_unlinks* parameter when the implementation has the
1545  * limitation on specific queue to port unlink establishment or
1546  * if invalid parameters are specified.
1547  * If the return value is less than *nb_unlinks*, the remaining queues at the
1548  * end of queues[] are not established, and the caller has to take care of them.
1549  * If return value is less than *nb_unlinks* then implementation shall update
1550  * the rte_errno accordingly, Possible rte_errno values are
1551  * (-EINVAL) Invalid parameter
1552  *
1553  */
1554 int
1555 rte_event_port_unlink(uint8_t dev_id, uint8_t port_id,
1556                       uint8_t queues[], uint16_t nb_unlinks);
1557
1558 /**
1559  * Retrieve the list of source event queues and its associated service priority
1560  * linked to the destination event port designated by its *port_id*
1561  * on the event device designated by its *dev_id*.
1562  *
1563  * @param dev_id
1564  *   The identifier of the device.
1565  *
1566  * @param port_id
1567  *   Event port identifier.
1568  *
1569  * @param[out] queues
1570  *   Points to an array of *queues* for output.
1571  *   The caller has to allocate *RTE_EVENT_MAX_QUEUES_PER_DEV* bytes to
1572  *   store the event queue(s) linked with event port *port_id*
1573  *
1574  * @param[out] priorities
1575  *   Points to an array of *priorities* for output.
1576  *   The caller has to allocate *RTE_EVENT_MAX_QUEUES_PER_DEV* bytes to
1577  *   store the service priority associated with each event queue linked
1578  *
1579  * @return
1580  * The number of links established on the event port designated by its
1581  *  *port_id*.
1582  * - <0 on failure.
1583  *
1584  */
1585 int
1586 rte_event_port_links_get(uint8_t dev_id, uint8_t port_id,
1587                          uint8_t queues[], uint8_t priorities[]);
1588
1589 /**
1590  * Retrieve the service ID of the event dev. If the adapter doesn't use
1591  * a rte_service function, this function returns -ESRCH.
1592  *
1593  * @param dev_id
1594  *   The identifier of the device.
1595  *
1596  * @param [out] service_id
1597  *   A pointer to a uint32_t, to be filled in with the service id.
1598  *
1599  * @return
1600  *   - 0: Success
1601  *   - <0: Error code on failure, if the event dev doesn't use a rte_service
1602  *   function, this function returns -ESRCH.
1603  */
1604 int
1605 rte_event_dev_service_id_get(uint8_t dev_id, uint32_t *service_id);
1606
1607 /**
1608  * Dump internal information about *dev_id* to the FILE* provided in *f*.
1609  *
1610  * @param dev_id
1611  *   The identifier of the device.
1612  *
1613  * @param f
1614  *   A pointer to a file for output
1615  *
1616  * @return
1617  *   - 0: on success
1618  *   - <0: on failure.
1619  */
1620 int
1621 rte_event_dev_dump(uint8_t dev_id, FILE *f);
1622
1623 /** Maximum name length for extended statistics counters */
1624 #define RTE_EVENT_DEV_XSTATS_NAME_SIZE 64
1625
1626 /**
1627  * Selects the component of the eventdev to retrieve statistics from.
1628  */
1629 enum rte_event_dev_xstats_mode {
1630         RTE_EVENT_DEV_XSTATS_DEVICE,
1631         RTE_EVENT_DEV_XSTATS_PORT,
1632         RTE_EVENT_DEV_XSTATS_QUEUE,
1633 };
1634
1635 /**
1636  * A name-key lookup element for extended statistics.
1637  *
1638  * This structure is used to map between names and ID numbers
1639  * for extended ethdev statistics.
1640  */
1641 struct rte_event_dev_xstats_name {
1642         char name[RTE_EVENT_DEV_XSTATS_NAME_SIZE];
1643 };
1644
1645 /**
1646  * Retrieve names of extended statistics of an event device.
1647  *
1648  * @param dev_id
1649  *   The identifier of the event device.
1650  * @param mode
1651  *   The mode of statistics to retrieve. Choices include the device statistics,
1652  *   port statistics or queue statistics.
1653  * @param queue_port_id
1654  *   Used to specify the port or queue number in queue or port mode, and is
1655  *   ignored in device mode.
1656  * @param[out] xstats_names
1657  *   Block of memory to insert names into. Must be at least size in capacity.
1658  *   If set to NULL, function returns required capacity.
1659  * @param[out] ids
1660  *   Block of memory to insert ids into. Must be at least size in capacity.
1661  *   If set to NULL, function returns required capacity. The id values returned
1662  *   can be passed to *rte_event_dev_xstats_get* to select statistics.
1663  * @param size
1664  *   Capacity of xstats_names (number of names).
1665  * @return
1666  *   - positive value lower or equal to size: success. The return value
1667  *     is the number of entries filled in the stats table.
1668  *   - positive value higher than size: error, the given statistics table
1669  *     is too small. The return value corresponds to the size that should
1670  *     be given to succeed. The entries in the table are not valid and
1671  *     shall not be used by the caller.
1672  *   - negative value on error:
1673  *        -ENODEV for invalid *dev_id*
1674  *        -EINVAL for invalid mode, queue port or id parameters
1675  *        -ENOTSUP if the device doesn't support this function.
1676  */
1677 int
1678 rte_event_dev_xstats_names_get(uint8_t dev_id,
1679                                enum rte_event_dev_xstats_mode mode,
1680                                uint8_t queue_port_id,
1681                                struct rte_event_dev_xstats_name *xstats_names,
1682                                unsigned int *ids,
1683                                unsigned int size);
1684
1685 /**
1686  * Retrieve extended statistics of an event device.
1687  *
1688  * @param dev_id
1689  *   The identifier of the device.
1690  * @param mode
1691  *  The mode of statistics to retrieve. Choices include the device statistics,
1692  *  port statistics or queue statistics.
1693  * @param queue_port_id
1694  *   Used to specify the port or queue number in queue or port mode, and is
1695  *   ignored in device mode.
1696  * @param ids
1697  *   The id numbers of the stats to get. The ids can be got from the stat
1698  *   position in the stat list from rte_event_dev_get_xstats_names(), or
1699  *   by using rte_eventdev_get_xstats_by_name()
1700  * @param[out] values
1701  *   The values for each stats request by ID.
1702  * @param n
1703  *   The number of stats requested
1704  * @return
1705  *   - positive value: number of stat entries filled into the values array
1706  *   - negative value on error:
1707  *        -ENODEV for invalid *dev_id*
1708  *        -EINVAL for invalid mode, queue port or id parameters
1709  *        -ENOTSUP if the device doesn't support this function.
1710  */
1711 int
1712 rte_event_dev_xstats_get(uint8_t dev_id,
1713                          enum rte_event_dev_xstats_mode mode,
1714                          uint8_t queue_port_id,
1715                          const unsigned int ids[],
1716                          uint64_t values[], unsigned int n);
1717
1718 /**
1719  * Retrieve the value of a single stat by requesting it by name.
1720  *
1721  * @param dev_id
1722  *   The identifier of the device
1723  * @param name
1724  *   The stat name to retrieve
1725  * @param[out] id
1726  *   If non-NULL, the numerical id of the stat will be returned, so that further
1727  *   requests for the stat can be got using rte_eventdev_xstats_get, which will
1728  *   be faster as it doesn't need to scan a list of names for the stat.
1729  *   If the stat cannot be found, the id returned will be (unsigned)-1.
1730  * @return
1731  *   - positive value or zero: the stat value
1732  *   - negative value: -EINVAL if stat not found, -ENOTSUP if not supported.
1733  */
1734 uint64_t
1735 rte_event_dev_xstats_by_name_get(uint8_t dev_id, const char *name,
1736                                  unsigned int *id);
1737
1738 /**
1739  * Reset the values of the xstats of the selected component in the device.
1740  *
1741  * @param dev_id
1742  *   The identifier of the device
1743  * @param mode
1744  *   The mode of the statistics to reset. Choose from device, queue or port.
1745  * @param queue_port_id
1746  *   The queue or port to reset. 0 and positive values select ports and queues,
1747  *   while -1 indicates all ports or queues.
1748  * @param ids
1749  *   Selects specific statistics to be reset. When NULL, all statistics selected
1750  *   by *mode* will be reset. If non-NULL, must point to array of at least
1751  *   *nb_ids* size.
1752  * @param nb_ids
1753  *   The number of ids available from the *ids* array. Ignored when ids is NULL.
1754  * @return
1755  *   - zero: successfully reset the statistics to zero
1756  *   - negative value: -EINVAL invalid parameters, -ENOTSUP if not supported.
1757  */
1758 int
1759 rte_event_dev_xstats_reset(uint8_t dev_id,
1760                            enum rte_event_dev_xstats_mode mode,
1761                            int16_t queue_port_id,
1762                            const uint32_t ids[],
1763                            uint32_t nb_ids);
1764
1765 #ifdef __cplusplus
1766 }
1767 #endif
1768
1769 #endif /* _RTE_EVENTDEV_H_ */