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