eventdev: remove unneeded dependencies
[dpdk.git] / lib / librte_eventdev / rte_eventdev.h
1 /*
2  *   BSD LICENSE
3  *
4  *   Copyright 2016 Cavium.
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 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  * An event driven based application has following typical workflow on fastpath:
203  * \code{.c}
204  *      while (1) {
205  *
206  *              rte_event_schedule(dev_id);
207  *
208  *              rte_event_dequeue(...);
209  *
210  *              (event processing)
211  *
212  *              rte_event_enqueue(...);
213  *      }
214  * \endcode
215  *
216  * The events are injected to event device through *enqueue* operation by
217  * event producers in the system. The typical event producers are ethdev
218  * subsystem for generating packet events, CPU(SW) for generating events based
219  * on different stages of application processing, cryptodev for generating
220  * crypto work completion notification etc
221  *
222  * The *dequeue* operation gets one or more events from the event ports.
223  * The application process the events and send to downstream event queue through
224  * rte_event_enqueue_burst() if it is an intermediate stage of event processing,
225  * on the final stage, the application may send to different subsystem like
226  * ethdev to send the packet/event on the wire using ethdev
227  * rte_eth_tx_burst() API.
228  *
229  * The point at which events are scheduled to ports depends on the device.
230  * For hardware devices, scheduling occurs asynchronously without any software
231  * intervention. Software schedulers can either be distributed
232  * (each worker thread schedules events to its own port) or centralized
233  * (a dedicated thread schedules to all ports). Distributed software schedulers
234  * perform the scheduling in rte_event_dequeue_burst(), whereas centralized
235  * scheduler logic is located in rte_event_schedule().
236  * The RTE_EVENT_DEV_CAP_DISTRIBUTED_SCHED capability flag is not set
237  * indicates the device is centralized and thus needs a dedicated scheduling
238  * thread that repeatedly calls rte_event_schedule().
239  *
240  */
241
242 #ifdef __cplusplus
243 extern "C" {
244 #endif
245
246 #include <rte_common.h>
247 #include <rte_memory.h>
248
249 struct rte_mbuf; /* we just use mbuf pointers; no need to include rte_mbuf.h */
250
251 /* Event device capability bitmap flags */
252 #define RTE_EVENT_DEV_CAP_QUEUE_QOS           (1ULL << 0)
253 /**< Event scheduling prioritization is based on the priority associated with
254  *  each event queue.
255  *
256  *  @see rte_event_queue_setup()
257  */
258 #define RTE_EVENT_DEV_CAP_EVENT_QOS           (1ULL << 1)
259 /**< Event scheduling prioritization is based on the priority associated with
260  *  each event. Priority of each event is supplied in *rte_event* structure
261  *  on each enqueue operation.
262  *
263  *  @see rte_event_enqueue_burst()
264  */
265 #define RTE_EVENT_DEV_CAP_DISTRIBUTED_SCHED   (1ULL << 2)
266 /**< Event device operates in distributed scheduling mode.
267  * In distributed scheduling mode, event scheduling happens in HW or
268  * rte_event_dequeue_burst() or the combination of these two.
269  * If the flag is not set then eventdev is centralized and thus needs a
270  * dedicated scheduling thread that repeatedly calls rte_event_schedule().
271  *
272  * @see rte_event_schedule(), rte_event_dequeue_burst()
273  */
274
275 /* Event device priority levels */
276 #define RTE_EVENT_DEV_PRIORITY_HIGHEST   0
277 /**< Highest priority expressed across eventdev subsystem
278  * @see rte_event_queue_setup(), rte_event_enqueue_burst()
279  * @see rte_event_port_link()
280  */
281 #define RTE_EVENT_DEV_PRIORITY_NORMAL    128
282 /**< Normal priority expressed across eventdev subsystem
283  * @see rte_event_queue_setup(), rte_event_enqueue_burst()
284  * @see rte_event_port_link()
285  */
286 #define RTE_EVENT_DEV_PRIORITY_LOWEST    255
287 /**< Lowest priority expressed across eventdev subsystem
288  * @see rte_event_queue_setup(), rte_event_enqueue_burst()
289  * @see rte_event_port_link()
290  */
291
292 /**
293  * Get the total number of event devices that have been successfully
294  * initialised.
295  *
296  * @return
297  *   The total number of usable event devices.
298  */
299 uint8_t
300 rte_event_dev_count(void);
301
302 /**
303  * Get the device identifier for the named event device.
304  *
305  * @param name
306  *   Event device name to select the event device identifier.
307  *
308  * @return
309  *   Returns event device identifier on success.
310  *   - <0: Failure to find named event device.
311  */
312 int
313 rte_event_dev_get_dev_id(const char *name);
314
315 /**
316  * Return the NUMA socket to which a device is connected.
317  *
318  * @param dev_id
319  *   The identifier of the device.
320  * @return
321  *   The NUMA socket id to which the device is connected or
322  *   a default of zero if the socket could not be determined.
323  *   -(-EINVAL)  dev_id value is out of range.
324  */
325 int
326 rte_event_dev_socket_id(uint8_t dev_id);
327
328 /**
329  * Event device information
330  */
331 struct rte_event_dev_info {
332         const char *driver_name;        /**< Event driver name */
333         struct rte_pci_device *pci_dev; /**< PCI information */
334         uint32_t min_dequeue_timeout_ns;
335         /**< Minimum supported global dequeue timeout(ns) by this device */
336         uint32_t max_dequeue_timeout_ns;
337         /**< Maximum supported global dequeue timeout(ns) by this device */
338         uint32_t dequeue_timeout_ns;
339         /**< Configured global dequeue timeout(ns) for this device */
340         uint8_t max_event_queues;
341         /**< Maximum event_queues supported by this device */
342         uint32_t max_event_queue_flows;
343         /**< Maximum supported flows in an event queue by this device*/
344         uint8_t max_event_queue_priority_levels;
345         /**< Maximum number of event queue priority levels by this device.
346          * Valid when the device has RTE_EVENT_DEV_CAP_QUEUE_QOS capability
347          */
348         uint8_t max_event_priority_levels;
349         /**< Maximum number of event priority levels by this device.
350          * Valid when the device has RTE_EVENT_DEV_CAP_EVENT_QOS capability
351          */
352         uint8_t max_event_ports;
353         /**< Maximum number of event ports supported by this device */
354         uint8_t max_event_port_dequeue_depth;
355         /**< Maximum number of events can be dequeued at a time from an
356          * event port by this device.
357          * A device that does not support bulk dequeue will set this as 1.
358          */
359         uint32_t max_event_port_enqueue_depth;
360         /**< Maximum number of events can be enqueued at a time from an
361          * event port by this device.
362          * A device that does not support bulk enqueue will set this as 1.
363          */
364         int32_t max_num_events;
365         /**< A *closed system* event dev has a limit on the number of events it
366          * can manage at a time. An *open system* event dev does not have a
367          * limit and will specify this as -1.
368          */
369         uint32_t event_dev_cap;
370         /**< Event device capabilities(RTE_EVENT_DEV_CAP_)*/
371 };
372
373 /**
374  * Retrieve the contextual information of an event device.
375  *
376  * @param dev_id
377  *   The identifier of the device.
378  *
379  * @param[out] dev_info
380  *   A pointer to a structure of type *rte_event_dev_info* to be filled with the
381  *   contextual information of the device.
382  *
383  * @return
384  *   - 0: Success, driver updates the contextual information of the event device
385  *   - <0: Error code returned by the driver info get function.
386  *
387  */
388 int
389 rte_event_dev_info_get(uint8_t dev_id, struct rte_event_dev_info *dev_info);
390
391 /* Event device configuration bitmap flags */
392 #define RTE_EVENT_DEV_CFG_PER_DEQUEUE_TIMEOUT (1ULL << 0)
393 /**< Override the global *dequeue_timeout_ns* and use per dequeue timeout in ns.
394  *  @see rte_event_dequeue_timeout_ticks(), rte_event_dequeue_burst()
395  */
396
397 /** Event device configuration structure */
398 struct rte_event_dev_config {
399         uint32_t dequeue_timeout_ns;
400         /**< rte_event_dequeue_burst() timeout on this device.
401          * This value should be in the range of *min_dequeue_timeout_ns* and
402          * *max_dequeue_timeout_ns* which previously provided in
403          * rte_event_dev_info_get()
404          * @see RTE_EVENT_DEV_CFG_PER_DEQUEUE_TIMEOUT
405          */
406         int32_t nb_events_limit;
407         /**< Applies to *closed system* event dev only. This field indicates a
408          * limit to ethdev-like devices to limit the number of events injected
409          * into the system to not overwhelm core-to-core events.
410          * This value cannot exceed the *max_num_events* which previously
411          * provided in rte_event_dev_info_get()
412          */
413         uint8_t nb_event_queues;
414         /**< Number of event queues to configure on this device.
415          * This value cannot exceed the *max_event_queues* which previously
416          * provided in rte_event_dev_info_get()
417          */
418         uint8_t nb_event_ports;
419         /**< Number of event ports to configure on this device.
420          * This value cannot exceed the *max_event_ports* which previously
421          * provided in rte_event_dev_info_get()
422          */
423         uint32_t nb_event_queue_flows;
424         /**< Number of flows for any event queue on this device.
425          * This value cannot exceed the *max_event_queue_flows* which previously
426          * provided in rte_event_dev_info_get()
427          */
428         uint8_t nb_event_port_dequeue_depth;
429         /**< Maximum number of events can be dequeued at a time from an
430          * event port by this device.
431          * This value cannot exceed the *max_event_port_dequeue_depth*
432          * which previously provided in rte_event_dev_info_get()
433          * @see rte_event_port_setup()
434          */
435         uint32_t nb_event_port_enqueue_depth;
436         /**< Maximum number of events can be enqueued at a time from an
437          * event port by this device.
438          * This value cannot exceed the *max_event_port_enqueue_depth*
439          * which previously provided in rte_event_dev_info_get()
440          * @see rte_event_port_setup()
441          */
442         uint32_t event_dev_cfg;
443         /**< Event device config flags(RTE_EVENT_DEV_CFG_)*/
444 };
445
446 /**
447  * Configure an event device.
448  *
449  * This function must be invoked first before any other function in the
450  * API. This function can also be re-invoked when a device is in the
451  * stopped state.
452  *
453  * The caller may use rte_event_dev_info_get() to get the capability of each
454  * resources available for this event device.
455  *
456  * @param dev_id
457  *   The identifier of the device to configure.
458  * @param dev_conf
459  *   The event device configuration structure.
460  *
461  * @return
462  *   - 0: Success, device configured.
463  *   - <0: Error code returned by the driver configuration function.
464  */
465 int
466 rte_event_dev_configure(uint8_t dev_id,
467                         const struct rte_event_dev_config *dev_conf);
468
469
470 /* Event queue specific APIs */
471
472 /* Event queue configuration bitmap flags */
473 #define RTE_EVENT_QUEUE_CFG_DEFAULT            (0)
474 /**< Default value of *event_queue_cfg* when rte_event_queue_setup() invoked
475  * with queue_conf == NULL
476  *
477  * @see rte_event_queue_setup()
478  */
479 #define RTE_EVENT_QUEUE_CFG_TYPE_MASK          (3ULL << 0)
480 /**< Mask for event queue schedule type configuration request */
481 #define RTE_EVENT_QUEUE_CFG_ALL_TYPES          (0ULL << 0)
482 /**< Allow ATOMIC,ORDERED,PARALLEL schedule type enqueue
483  *
484  * @see RTE_SCHED_TYPE_ORDERED, RTE_SCHED_TYPE_ATOMIC, RTE_SCHED_TYPE_PARALLEL
485  * @see rte_event_enqueue_burst()
486  */
487 #define RTE_EVENT_QUEUE_CFG_ATOMIC_ONLY        (1ULL << 0)
488 /**< Allow only ATOMIC schedule type enqueue
489  *
490  * The rte_event_enqueue_burst() result is undefined if the queue configured
491  * with ATOMIC only and sched_type != RTE_SCHED_TYPE_ATOMIC
492  *
493  * @see RTE_SCHED_TYPE_ATOMIC, rte_event_enqueue_burst()
494  */
495 #define RTE_EVENT_QUEUE_CFG_ORDERED_ONLY       (2ULL << 0)
496 /**< Allow only ORDERED schedule type enqueue
497  *
498  * The rte_event_enqueue_burst() result is undefined if the queue configured
499  * with ORDERED only and sched_type != RTE_SCHED_TYPE_ORDERED
500  *
501  * @see RTE_SCHED_TYPE_ORDERED, rte_event_enqueue_burst()
502  */
503 #define RTE_EVENT_QUEUE_CFG_PARALLEL_ONLY      (3ULL << 0)
504 /**< Allow only PARALLEL schedule type enqueue
505  *
506  * The rte_event_enqueue_burst() result is undefined if the queue configured
507  * with PARALLEL only and sched_type != RTE_SCHED_TYPE_PARALLEL
508  *
509  * @see RTE_SCHED_TYPE_PARALLEL, rte_event_enqueue_burst()
510  */
511 #define RTE_EVENT_QUEUE_CFG_SINGLE_LINK        (1ULL << 2)
512 /**< This event queue links only to a single event port.
513  *
514  *  @see rte_event_port_setup(), rte_event_port_link()
515  */
516
517 /** Event queue configuration structure */
518 struct rte_event_queue_conf {
519         uint32_t nb_atomic_flows;
520         /**< The maximum number of active flows this queue can track at any
521          * given time. The value must be in the range of
522          * [1 - nb_event_queue_flows)] which previously provided in
523          * rte_event_dev_info_get().
524          */
525         uint32_t nb_atomic_order_sequences;
526         /**< The maximum number of outstanding events waiting to be
527          * reordered by this queue. In other words, the number of entries in
528          * this queue’s reorder buffer.When the number of events in the
529          * reorder buffer reaches to *nb_atomic_order_sequences* then the
530          * scheduler cannot schedule the events from this queue and invalid
531          * event will be returned from dequeue until one or more entries are
532          * freed up/released.
533          * The value must be in the range of [1 - nb_event_queue_flows)]
534          * which previously supplied to rte_event_dev_configure().
535          */
536         uint32_t event_queue_cfg; /**< Queue cfg flags(EVENT_QUEUE_CFG_) */
537         uint8_t priority;
538         /**< Priority for this event queue relative to other event queues.
539          * The requested priority should in the range of
540          * [RTE_EVENT_DEV_PRIORITY_HIGHEST, RTE_EVENT_DEV_PRIORITY_LOWEST].
541          * The implementation shall normalize the requested priority to
542          * event device supported priority value.
543          * Valid when the device has RTE_EVENT_DEV_CAP_QUEUE_QOS capability
544          */
545 };
546
547 /**
548  * Retrieve the default configuration information of an event queue designated
549  * by its *queue_id* from the event driver for an event device.
550  *
551  * This function intended to be used in conjunction with rte_event_queue_setup()
552  * where caller needs to set up the queue by overriding few default values.
553  *
554  * @param dev_id
555  *   The identifier of the device.
556  * @param queue_id
557  *   The index of the event queue to get the configuration information.
558  *   The value must be in the range [0, nb_event_queues - 1]
559  *   previously supplied to rte_event_dev_configure().
560  * @param[out] queue_conf
561  *   The pointer to the default event queue configuration data.
562  * @return
563  *   - 0: Success, driver updates the default event queue configuration data.
564  *   - <0: Error code returned by the driver info get function.
565  *
566  * @see rte_event_queue_setup()
567  *
568  */
569 int
570 rte_event_queue_default_conf_get(uint8_t dev_id, uint8_t queue_id,
571                                  struct rte_event_queue_conf *queue_conf);
572
573 /**
574  * Allocate and set up an event queue for an event device.
575  *
576  * @param dev_id
577  *   The identifier of the device.
578  * @param queue_id
579  *   The index of the event queue to setup. The value must be in the range
580  *   [0, nb_event_queues - 1] previously supplied to rte_event_dev_configure().
581  * @param queue_conf
582  *   The pointer to the configuration data to be used for the event queue.
583  *   NULL value is allowed, in which case default configuration used.
584  *
585  * @see rte_event_queue_default_conf_get()
586  *
587  * @return
588  *   - 0: Success, event queue correctly set up.
589  *   - <0: event queue configuration failed
590  */
591 int
592 rte_event_queue_setup(uint8_t dev_id, uint8_t queue_id,
593                       const struct rte_event_queue_conf *queue_conf);
594
595 /**
596  * Get the number of event queues on a specific event device
597  *
598  * @param dev_id
599  *   Event device identifier.
600  * @return
601  *   - The number of configured event queues
602  */
603 uint8_t
604 rte_event_queue_count(uint8_t dev_id);
605
606 /**
607  * Get the priority of the event queue on a specific event device
608  *
609  * @param dev_id
610  *   Event device identifier.
611  * @param queue_id
612  *   Event queue identifier.
613  * @return
614  *   - If the device has RTE_EVENT_DEV_CAP_QUEUE_QOS capability then the
615  *    configured priority of the event queue in
616  *    [RTE_EVENT_DEV_PRIORITY_HIGHEST, RTE_EVENT_DEV_PRIORITY_LOWEST] range
617  *    else the value RTE_EVENT_DEV_PRIORITY_NORMAL
618  */
619 uint8_t
620 rte_event_queue_priority(uint8_t dev_id, uint8_t queue_id);
621
622 /* Event port specific APIs */
623
624 /** Event port configuration structure */
625 struct rte_event_port_conf {
626         int32_t new_event_threshold;
627         /**< A backpressure threshold for new event enqueues on this port.
628          * Use for *closed system* event dev where event capacity is limited,
629          * and cannot exceed the capacity of the event dev.
630          * Configuring ports with different thresholds can make higher priority
631          * traffic less likely to  be backpressured.
632          * For example, a port used to inject NIC Rx packets into the event dev
633          * can have a lower threshold so as not to overwhelm the device,
634          * while ports used for worker pools can have a higher threshold.
635          * This value cannot exceed the *nb_events_limit*
636          * which previously supplied to rte_event_dev_configure()
637          */
638         uint8_t dequeue_depth;
639         /**< Configure number of bulk dequeues for this event port.
640          * This value cannot exceed the *nb_event_port_dequeue_depth*
641          * which previously supplied to rte_event_dev_configure()
642          */
643         uint8_t enqueue_depth;
644         /**< Configure number of bulk enqueues for this event port.
645          * This value cannot exceed the *nb_event_port_enqueue_depth*
646          * which previously supplied to rte_event_dev_configure()
647          */
648 };
649
650 /**
651  * Retrieve the default configuration information of an event port designated
652  * by its *port_id* from the event driver for an event device.
653  *
654  * This function intended to be used in conjunction with rte_event_port_setup()
655  * where caller needs to set up the port by overriding few default values.
656  *
657  * @param dev_id
658  *   The identifier of the device.
659  * @param port_id
660  *   The index of the event port to get the configuration information.
661  *   The value must be in the range [0, nb_event_ports - 1]
662  *   previously supplied to rte_event_dev_configure().
663  * @param[out] port_conf
664  *   The pointer to the default event port configuration data
665  * @return
666  *   - 0: Success, driver updates the default event port configuration data.
667  *   - <0: Error code returned by the driver info get function.
668  *
669  * @see rte_event_port_setup()
670  *
671  */
672 int
673 rte_event_port_default_conf_get(uint8_t dev_id, uint8_t port_id,
674                                 struct rte_event_port_conf *port_conf);
675
676 /**
677  * Allocate and set up an event port for an event device.
678  *
679  * @param dev_id
680  *   The identifier of the device.
681  * @param port_id
682  *   The index of the event port to setup. The value must be in the range
683  *   [0, nb_event_ports - 1] previously supplied to rte_event_dev_configure().
684  * @param port_conf
685  *   The pointer to the configuration data to be used for the queue.
686  *   NULL value is allowed, in which case default configuration used.
687  *
688  * @see rte_event_port_default_conf_get()
689  *
690  * @return
691  *   - 0: Success, event port correctly set up.
692  *   - <0: Port configuration failed
693  *   - (-EDQUOT) Quota exceeded(Application tried to link the queue configured
694  *   with RTE_EVENT_QUEUE_CFG_SINGLE_LINK to more than one event ports)
695  */
696 int
697 rte_event_port_setup(uint8_t dev_id, uint8_t port_id,
698                      const struct rte_event_port_conf *port_conf);
699
700 /**
701  * Get the number of dequeue queue depth configured for event port designated
702  * by its *port_id* on a specific event device
703  *
704  * @param dev_id
705  *   Event device identifier.
706  * @param port_id
707  *   Event port identifier.
708  * @return
709  *   - The number of configured dequeue queue depth
710  *
711  * @see rte_event_dequeue_burst()
712  */
713 uint8_t
714 rte_event_port_dequeue_depth(uint8_t dev_id, uint8_t port_id);
715
716 /**
717  * Get the number of enqueue queue depth configured for event port designated
718  * by its *port_id* on a specific event device
719  *
720  * @param dev_id
721  *   Event device identifier.
722  * @param port_id
723  *   Event port identifier.
724  * @return
725  *   - The number of configured enqueue queue depth
726  *
727  * @see rte_event_enqueue_burst()
728  */
729 uint8_t
730 rte_event_port_enqueue_depth(uint8_t dev_id, uint8_t port_id);
731
732 /**
733  * Get the number of ports on a specific event device
734  *
735  * @param dev_id
736  *   Event device identifier.
737  * @return
738  *   - The number of configured ports
739  */
740 uint8_t
741 rte_event_port_count(uint8_t dev_id);
742
743 /**
744  * Start an event device.
745  *
746  * The device start step is the last one and consists of setting the event
747  * queues to start accepting the events and schedules to event ports.
748  *
749  * On success, all basic functions exported by the API (event enqueue,
750  * event dequeue and so on) can be invoked.
751  *
752  * @param dev_id
753  *   Event device identifier
754  * @return
755  *   - 0: Success, device started.
756  *   - <0: Error code of the driver device start function.
757  */
758 int
759 rte_event_dev_start(uint8_t dev_id);
760
761 /**
762  * Stop an event device. The device can be restarted with a call to
763  * rte_event_dev_start()
764  *
765  * @param dev_id
766  *   Event device identifier.
767  */
768 void
769 rte_event_dev_stop(uint8_t dev_id);
770
771 /**
772  * Close an event device. The device cannot be restarted!
773  *
774  * @param dev_id
775  *   Event device identifier
776  *
777  * @return
778  *  - 0 on successfully closing device
779  *  - <0 on failure to close device
780  *  - (-EAGAIN) if device is busy
781  */
782 int
783 rte_event_dev_close(uint8_t dev_id);
784
785 /* Scheduler type definitions */
786 #define RTE_SCHED_TYPE_ORDERED          0
787 /**< Ordered scheduling
788  *
789  * Events from an ordered flow of an event queue can be scheduled to multiple
790  * ports for concurrent processing while maintaining the original event order.
791  * This scheme enables the user to achieve high single flow throughput by
792  * avoiding SW synchronization for ordering between ports which bound to cores.
793  *
794  * The source flow ordering from an event queue is maintained when events are
795  * enqueued to their destination queue within the same ordered flow context.
796  * An event port holds the context until application call
797  * rte_event_dequeue_burst() from the same port, which implicitly releases
798  * the context.
799  * User may allow the scheduler to release the context earlier than that
800  * by invoking rte_event_enqueue_burst() with RTE_EVENT_OP_RELEASE operation.
801  *
802  * Events from the source queue appear in their original order when dequeued
803  * from a destination queue.
804  * Event ordering is based on the received event(s), but also other
805  * (newly allocated or stored) events are ordered when enqueued within the same
806  * ordered context. Events not enqueued (e.g. released or stored) within the
807  * context are  considered missing from reordering and are skipped at this time
808  * (but can be ordered again within another context).
809  *
810  * @see rte_event_queue_setup(), rte_event_dequeue_burst(), RTE_EVENT_OP_RELEASE
811  */
812
813 #define RTE_SCHED_TYPE_ATOMIC           1
814 /**< Atomic scheduling
815  *
816  * Events from an atomic flow of an event queue can be scheduled only to a
817  * single port at a time. The port is guaranteed to have exclusive (atomic)
818  * access to the associated flow context, which enables the user to avoid SW
819  * synchronization. Atomic flows also help to maintain event ordering
820  * since only one port at a time can process events from a flow of an
821  * event queue.
822  *
823  * The atomic queue synchronization context is dedicated to the port until
824  * application call rte_event_dequeue_burst() from the same port,
825  * which implicitly releases the context. User may allow the scheduler to
826  * release the context earlier than that by invoking rte_event_enqueue_burst()
827  * with RTE_EVENT_OP_RELEASE operation.
828  *
829  * @see rte_event_queue_setup(), rte_event_dequeue_burst(), RTE_EVENT_OP_RELEASE
830  */
831
832 #define RTE_SCHED_TYPE_PARALLEL         2
833 /**< Parallel scheduling
834  *
835  * The scheduler performs priority scheduling, load balancing, etc. functions
836  * but does not provide additional event synchronization or ordering.
837  * It is free to schedule events from a single parallel flow of an event queue
838  * to multiple events ports for concurrent processing.
839  * The application is responsible for flow context synchronization and
840  * event ordering (SW synchronization).
841  *
842  * @see rte_event_queue_setup(), rte_event_dequeue_burst()
843  */
844
845 /* Event types to classify the event source */
846 #define RTE_EVENT_TYPE_ETHDEV           0x0
847 /**< The event generated from ethdev subsystem */
848 #define RTE_EVENT_TYPE_CRYPTODEV        0x1
849 /**< The event generated from crypodev subsystem */
850 #define RTE_EVENT_TYPE_TIMERDEV         0x2
851 /**< The event generated from timerdev subsystem */
852 #define RTE_EVENT_TYPE_CPU              0x3
853 /**< The event generated from cpu for pipelining.
854  * Application may use *sub_event_type* to further classify the event
855  */
856 #define RTE_EVENT_TYPE_MAX              0x10
857 /**< Maximum number of event types */
858
859 /* Event enqueue operations */
860 #define RTE_EVENT_OP_NEW                0
861 /**< The event producers use this operation to inject a new event to the
862  * event device.
863  */
864 #define RTE_EVENT_OP_FORWARD            1
865 /**< The CPU use this operation to forward the event to different event queue or
866  * change to new application specific flow or schedule type to enable
867  * pipelining
868  */
869 #define RTE_EVENT_OP_RELEASE            2
870 /**< Release the flow context associated with the schedule type.
871  *
872  * If current flow's scheduler type method is *RTE_SCHED_TYPE_ATOMIC*
873  * then this function hints the scheduler that the user has completed critical
874  * section processing in the current atomic context.
875  * The scheduler is now allowed to schedule events from the same flow from
876  * an event queue to another port. However, the context may be still held
877  * until the next rte_event_dequeue_burst() call, this call allows but does not
878  * force the scheduler to release the context early.
879  *
880  * Early atomic context release may increase parallelism and thus system
881  * performance, but the user needs to design carefully the split into critical
882  * vs non-critical sections.
883  *
884  * If current flow's scheduler type method is *RTE_SCHED_TYPE_ORDERED*
885  * then this function hints the scheduler that the user has done all that need
886  * to maintain event order in the current ordered context.
887  * The scheduler is allowed to release the ordered context of this port and
888  * avoid reordering any following enqueues.
889  *
890  * Early ordered context release may increase parallelism and thus system
891  * performance.
892  *
893  * If current flow's scheduler type method is *RTE_SCHED_TYPE_PARALLEL*
894  * or no scheduling context is held then this function may be an NOOP,
895  * depending on the implementation.
896  *
897  */
898
899 /**
900  * The generic *rte_event* structure to hold the event attributes
901  * for dequeue and enqueue operation
902  */
903 struct rte_event {
904         /** WORD0 */
905         RTE_STD_C11
906         union {
907                 uint64_t event;
908                 /** Event attributes for dequeue or enqueue operation */
909                 struct {
910                         uint32_t flow_id:20;
911                         /**< Targeted flow identifier for the enqueue and
912                          * dequeue operation.
913                          * The value must be in the range of
914                          * [0, nb_event_queue_flows - 1] which
915                          * previously supplied to rte_event_dev_configure().
916                          */
917                         uint32_t sub_event_type:8;
918                         /**< Sub-event types based on the event source.
919                          * @see RTE_EVENT_TYPE_CPU
920                          */
921                         uint32_t event_type:4;
922                         /**< Event type to classify the event source.
923                          * @see RTE_EVENT_TYPE_ETHDEV, (RTE_EVENT_TYPE_*)
924                          */
925                         uint8_t op:2;
926                         /**< The type of event enqueue operation - new/forward/
927                          * etc.This field is not preserved across an instance
928                          * and is undefined on dequeue.
929                          * @see RTE_EVENT_OP_NEW, (RTE_EVENT_OP_*)
930                          */
931                         uint8_t rsvd:4;
932                         /**< Reserved for future use */
933                         uint8_t sched_type:2;
934                         /**< Scheduler synchronization type (RTE_SCHED_TYPE_*)
935                          * associated with flow id on a given event queue
936                          * for the enqueue and dequeue operation.
937                          */
938                         uint8_t queue_id;
939                         /**< Targeted event queue identifier for the enqueue or
940                          * dequeue operation.
941                          * The value must be in the range of
942                          * [0, nb_event_queues - 1] which previously supplied to
943                          * rte_event_dev_configure().
944                          */
945                         uint8_t priority;
946                         /**< Event priority relative to other events in the
947                          * event queue. The requested priority should in the
948                          * range of  [RTE_EVENT_DEV_PRIORITY_HIGHEST,
949                          * RTE_EVENT_DEV_PRIORITY_LOWEST].
950                          * The implementation shall normalize the requested
951                          * priority to supported priority value.
952                          * Valid when the device has
953                          * RTE_EVENT_DEV_CAP_EVENT_QOS capability.
954                          */
955                         uint8_t impl_opaque;
956                         /**< Implementation specific opaque value.
957                          * An implementation may use this field to hold
958                          * implementation specific value to share between
959                          * dequeue and enqueue operation.
960                          * The application should not modify this field.
961                          */
962                 };
963         };
964         /** WORD1 */
965         RTE_STD_C11
966         union {
967                 uint64_t u64;
968                 /**< Opaque 64-bit value */
969                 void *event_ptr;
970                 /**< Opaque event pointer */
971                 struct rte_mbuf *mbuf;
972                 /**< mbuf pointer if dequeued event is associated with mbuf */
973         };
974 };
975
976
977 struct rte_eventdev_driver;
978 struct rte_eventdev_ops;
979 struct rte_eventdev;
980
981 typedef void (*event_schedule_t)(struct rte_eventdev *dev);
982 /**< @internal Schedule one or more events in the event dev. */
983
984 typedef uint16_t (*event_enqueue_t)(void *port, const struct rte_event *ev);
985 /**< @internal Enqueue event on port of a device */
986
987 typedef uint16_t (*event_enqueue_burst_t)(void *port,
988                         const struct rte_event ev[], uint16_t nb_events);
989 /**< @internal Enqueue burst of events on port of a device */
990
991 typedef uint16_t (*event_dequeue_t)(void *port, struct rte_event *ev,
992                 uint64_t timeout_ticks);
993 /**< @internal Dequeue event from port of a device */
994
995 typedef uint16_t (*event_dequeue_burst_t)(void *port, struct rte_event ev[],
996                 uint16_t nb_events, uint64_t timeout_ticks);
997 /**< @internal Dequeue burst of events from port of a device */
998
999 #define RTE_EVENTDEV_NAME_MAX_LEN       (64)
1000 /**< @internal Max length of name of event PMD */
1001
1002 /**
1003  * @internal
1004  * The data part, with no function pointers, associated with each device.
1005  *
1006  * This structure is safe to place in shared memory to be common among
1007  * different processes in a multi-process configuration.
1008  */
1009 struct rte_eventdev_data {
1010         int socket_id;
1011         /**< Socket ID where memory is allocated */
1012         uint8_t dev_id;
1013         /**< Device ID for this instance */
1014         uint8_t nb_queues;
1015         /**< Number of event queues. */
1016         uint8_t nb_ports;
1017         /**< Number of event ports. */
1018         void **ports;
1019         /**< Array of pointers to ports. */
1020         uint8_t *ports_dequeue_depth;
1021         /**< Array of port dequeue depth. */
1022         uint8_t *ports_enqueue_depth;
1023         /**< Array of port enqueue depth. */
1024         uint8_t *queues_prio;
1025         /**< Array of queue priority. */
1026         uint16_t *links_map;
1027         /**< Memory to store queues to port connections. */
1028         void *dev_private;
1029         /**< PMD-specific private data */
1030         uint32_t event_dev_cap;
1031         /**< Event device capabilities(RTE_EVENT_DEV_CAP_)*/
1032         struct rte_event_dev_config dev_conf;
1033         /**< Configuration applied to device. */
1034
1035         RTE_STD_C11
1036         uint8_t dev_started : 1;
1037         /**< Device state: STARTED(1)/STOPPED(0) */
1038
1039         char name[RTE_EVENTDEV_NAME_MAX_LEN];
1040         /**< Unique identifier name */
1041 } __rte_cache_aligned;
1042
1043 /** @internal The data structure associated with each event device. */
1044 struct rte_eventdev {
1045         event_schedule_t schedule;
1046         /**< Pointer to PMD schedule function. */
1047         event_enqueue_t enqueue;
1048         /**< Pointer to PMD enqueue function. */
1049         event_enqueue_burst_t enqueue_burst;
1050         /**< Pointer to PMD enqueue burst function. */
1051         event_dequeue_t dequeue;
1052         /**< Pointer to PMD dequeue function. */
1053         event_dequeue_burst_t dequeue_burst;
1054         /**< Pointer to PMD dequeue burst function. */
1055
1056         struct rte_eventdev_data *data;
1057         /**< Pointer to device data */
1058         const struct rte_eventdev_ops *dev_ops;
1059         /**< Functions exported by PMD */
1060         struct rte_pci_device *pci_dev;
1061         /**< PCI info. supplied by probing */
1062         const struct rte_eventdev_driver *driver;
1063         /**< Driver for this device */
1064
1065         RTE_STD_C11
1066         uint8_t attached : 1;
1067         /**< Flag indicating the device is attached */
1068 } __rte_cache_aligned;
1069
1070 extern struct rte_eventdev *rte_eventdevs;
1071 /** @internal The pool of rte_eventdev structures. */
1072
1073
1074 /**
1075  * Schedule one or more events in the event dev.
1076  *
1077  * An event dev implementation may define this is a NOOP, for instance if
1078  * the event dev performs its scheduling in hardware.
1079  *
1080  * @param dev_id
1081  *   The identifier of the device.
1082  */
1083 static inline void
1084 rte_event_schedule(uint8_t dev_id)
1085 {
1086         struct rte_eventdev *dev = &rte_eventdevs[dev_id];
1087         if (*dev->schedule)
1088                 (*dev->schedule)(dev);
1089 }
1090
1091 /**
1092  * Enqueue a burst of events objects or an event object supplied in *rte_event*
1093  * structure on an  event device designated by its *dev_id* through the event
1094  * port specified by *port_id*. Each event object specifies the event queue on
1095  * which it will be enqueued.
1096  *
1097  * The *nb_events* parameter is the number of event objects to enqueue which are
1098  * supplied in the *ev* array of *rte_event* structure.
1099  *
1100  * The rte_event_enqueue_burst() function returns the number of
1101  * events objects it actually enqueued. A return value equal to *nb_events*
1102  * means that all event objects have been enqueued.
1103  *
1104  * @param dev_id
1105  *   The identifier of the device.
1106  * @param port_id
1107  *   The identifier of the event port.
1108  * @param ev
1109  *   Points to an array of *nb_events* objects of type *rte_event* structure
1110  *   which contain the event object enqueue operations to be processed.
1111  * @param nb_events
1112  *   The number of event objects to enqueue, typically number of
1113  *   rte_event_port_enqueue_depth() available for this port.
1114  *
1115  * @return
1116  *   The number of event objects actually enqueued on the event device. The
1117  *   return value can be less than the value of the *nb_events* parameter when
1118  *   the event devices queue is full or if invalid parameters are specified in a
1119  *   *rte_event*. If return value is less than *nb_events*, the remaining events
1120  *   at the end of ev[] are not consumed,and the caller has to take care of them
1121  *
1122  * @see rte_event_port_enqueue_depth()
1123  */
1124 static inline uint16_t
1125 rte_event_enqueue_burst(uint8_t dev_id, uint8_t port_id,
1126                         const struct rte_event ev[], uint16_t nb_events)
1127 {
1128         struct rte_eventdev *dev = &rte_eventdevs[dev_id];
1129
1130         /*
1131          * Allow zero cost non burst mode routine invocation if application
1132          * requests nb_events as const one
1133          */
1134         if (nb_events == 1)
1135                 return (*dev->enqueue)(
1136                         dev->data->ports[port_id], ev);
1137         else
1138                 return (*dev->enqueue_burst)(
1139                         dev->data->ports[port_id], ev, nb_events);
1140 }
1141
1142 /**
1143  * Converts nanoseconds to *timeout_ticks* value for rte_event_dequeue_burst()
1144  *
1145  * If the device is configured with RTE_EVENT_DEV_CFG_PER_DEQUEUE_TIMEOUT flag
1146  * then application can use this function to convert timeout value in
1147  * nanoseconds to implementations specific timeout value supplied in
1148  * rte_event_dequeue_burst()
1149  *
1150  * @param dev_id
1151  *   The identifier of the device.
1152  * @param ns
1153  *   Wait time in nanosecond
1154  * @param[out] timeout_ticks
1155  *   Value for the *timeout_ticks* parameter in rte_event_dequeue_burst()
1156  *
1157  * @return
1158  *  - 0 on success.
1159  *  - <0 on failure.
1160  *
1161  * @see rte_event_dequeue_burst(), RTE_EVENT_DEV_CFG_PER_DEQUEUE_TIMEOUT
1162  * @see rte_event_dev_configure()
1163  *
1164  */
1165 int
1166 rte_event_dequeue_timeout_ticks(uint8_t dev_id, uint64_t ns,
1167                                         uint64_t *timeout_ticks);
1168
1169 /**
1170  * Dequeue a burst of events objects or an event object from the event port
1171  * designated by its *event_port_id*, on an event device designated
1172  * by its *dev_id*.
1173  *
1174  * rte_event_dequeue_burst() does not dictate the specifics of scheduling
1175  * algorithm as each eventdev driver may have different criteria to schedule
1176  * an event. However, in general, from an application perspective scheduler may
1177  * use the following scheme to dispatch an event to the port.
1178  *
1179  * 1) Selection of event queue based on
1180  *   a) The list of event queues are linked to the event port.
1181  *   b) If the device has RTE_EVENT_DEV_CAP_QUEUE_QOS capability then event
1182  *   queue selection from list is based on event queue priority relative to
1183  *   other event queue supplied as *priority* in rte_event_queue_setup()
1184  *   c) If the device has RTE_EVENT_DEV_CAP_EVENT_QOS capability then event
1185  *   queue selection from the list is based on event priority supplied as
1186  *   *priority* in rte_event_enqueue_burst()
1187  * 2) Selection of event
1188  *   a) The number of flows available in selected event queue.
1189  *   b) Schedule type method associated with the event
1190  *
1191  * The *nb_events* parameter is the maximum number of event objects to dequeue
1192  * which are returned in the *ev* array of *rte_event* structure.
1193  *
1194  * The rte_event_dequeue_burst() function returns the number of events objects
1195  * it actually dequeued. A return value equal to *nb_events* means that all
1196  * event objects have been dequeued.
1197  *
1198  * The number of events dequeued is the number of scheduler contexts held by
1199  * this port. These contexts are automatically released in the next
1200  * rte_event_dequeue_burst() invocation, or invoking rte_event_enqueue_burst()
1201  * with RTE_EVENT_OP_RELEASE operation can be used to release the
1202  * contexts early.
1203  *
1204  * @param dev_id
1205  *   The identifier of the device.
1206  * @param port_id
1207  *   The identifier of the event port.
1208  * @param[out] ev
1209  *   Points to an array of *nb_events* objects of type *rte_event* structure
1210  *   for output to be populated with the dequeued event objects.
1211  * @param nb_events
1212  *   The maximum number of event objects to dequeue, typically number of
1213  *   rte_event_port_dequeue_depth() available for this port.
1214  *
1215  * @param timeout_ticks
1216  *   - 0 no-wait, returns immediately if there is no event.
1217  *   - >0 wait for the event, if the device is configured with
1218  *   RTE_EVENT_DEV_CFG_PER_DEQUEUE_TIMEOUT then this function will wait until
1219  *   the event available or *timeout_ticks* time.
1220  *   if the device is not configured with RTE_EVENT_DEV_CFG_PER_DEQUEUE_TIMEOUT
1221  *   then this function will wait until the event available or
1222  *   *dequeue_timeout_ns* ns which was previously supplied to
1223  *   rte_event_dev_configure()
1224  *
1225  * @return
1226  * The number of event objects actually dequeued from the port. The return
1227  * value can be less than the value of the *nb_events* parameter when the
1228  * event port's queue is not full.
1229  *
1230  * @see rte_event_port_dequeue_depth()
1231  */
1232 static inline uint16_t
1233 rte_event_dequeue_burst(uint8_t dev_id, uint8_t port_id, struct rte_event ev[],
1234                         uint16_t nb_events, uint64_t timeout_ticks)
1235 {
1236         struct rte_eventdev *dev = &rte_eventdevs[dev_id];
1237
1238         /*
1239          * Allow zero cost non burst mode routine invocation if application
1240          * requests nb_events as const one
1241          */
1242         if (nb_events == 1)
1243                 return (*dev->dequeue)(
1244                         dev->data->ports[port_id], ev, timeout_ticks);
1245         else
1246                 return (*dev->dequeue_burst)(
1247                         dev->data->ports[port_id], ev, nb_events,
1248                                 timeout_ticks);
1249 }
1250
1251 /**
1252  * Link multiple source event queues supplied in *queues* to the destination
1253  * event port designated by its *port_id* with associated service priority
1254  * supplied in *priorities* on the event device designated by its *dev_id*.
1255  *
1256  * The link establishment shall enable the event port *port_id* from
1257  * receiving events from the specified event queue(s) supplied in *queues*
1258  *
1259  * An event queue may link to one or more event ports.
1260  * The number of links can be established from an event queue to event port is
1261  * implementation defined.
1262  *
1263  * Event queue(s) to event port link establishment can be changed at runtime
1264  * without re-configuring the device to support scaling and to reduce the
1265  * latency of critical work by establishing the link with more event ports
1266  * at runtime.
1267  *
1268  * @param dev_id
1269  *   The identifier of the device.
1270  *
1271  * @param port_id
1272  *   Event port identifier to select the destination port to link.
1273  *
1274  * @param queues
1275  *   Points to an array of *nb_links* event queues to be linked
1276  *   to the event port.
1277  *   NULL value is allowed, in which case this function links all the configured
1278  *   event queues *nb_event_queues* which previously supplied to
1279  *   rte_event_dev_configure() to the event port *port_id*
1280  *
1281  * @param priorities
1282  *   Points to an array of *nb_links* service priorities associated with each
1283  *   event queue link to event port.
1284  *   The priority defines the event port's servicing priority for
1285  *   event queue, which may be ignored by an implementation.
1286  *   The requested priority should in the range of
1287  *   [RTE_EVENT_DEV_PRIORITY_HIGHEST, RTE_EVENT_DEV_PRIORITY_LOWEST].
1288  *   The implementation shall normalize the requested priority to
1289  *   implementation supported priority value.
1290  *   NULL value is allowed, in which case this function links the event queues
1291  *   with RTE_EVENT_DEV_PRIORITY_NORMAL servicing priority
1292  *
1293  * @param nb_links
1294  *   The number of links to establish
1295  *
1296  * @return
1297  * The number of links actually established. The return value can be less than
1298  * the value of the *nb_links* parameter when the implementation has the
1299  * limitation on specific queue to port link establishment or if invalid
1300  * parameters are specified in *queues*
1301  * If the return value is less than *nb_links*, the remaining links at the end
1302  * of link[] are not established, and the caller has to take care of them.
1303  * If return value is less than *nb_links* then implementation shall update the
1304  * rte_errno accordingly, Possible rte_errno values are
1305  * (-EDQUOT) Quota exceeded(Application tried to link the queue configured with
1306  *  RTE_EVENT_QUEUE_CFG_SINGLE_LINK to more than one event ports)
1307  * (-EINVAL) Invalid parameter
1308  *
1309  */
1310 int
1311 rte_event_port_link(uint8_t dev_id, uint8_t port_id,
1312                     const uint8_t queues[], const uint8_t priorities[],
1313                     uint16_t nb_links);
1314
1315 /**
1316  * Unlink multiple source event queues supplied in *queues* from the destination
1317  * event port designated by its *port_id* on the event device designated
1318  * by its *dev_id*.
1319  *
1320  * The unlink establishment shall disable the event port *port_id* from
1321  * receiving events from the specified event queue *queue_id*
1322  *
1323  * Event queue(s) to event port unlink establishment can be changed at runtime
1324  * without re-configuring the device.
1325  *
1326  * @param dev_id
1327  *   The identifier of the device.
1328  *
1329  * @param port_id
1330  *   Event port identifier to select the destination port to unlink.
1331  *
1332  * @param queues
1333  *   Points to an array of *nb_unlinks* event queues to be unlinked
1334  *   from the event port.
1335  *   NULL value is allowed, in which case this function unlinks all the
1336  *   event queue(s) from the event port *port_id*.
1337  *
1338  * @param nb_unlinks
1339  *   The number of unlinks to establish
1340  *
1341  * @return
1342  * The number of unlinks actually established. The return value can be less
1343  * than the value of the *nb_unlinks* parameter when the implementation has the
1344  * limitation on specific queue to port unlink establishment or
1345  * if invalid parameters are specified.
1346  * If the return value is less than *nb_unlinks*, the remaining queues at the
1347  * end of queues[] are not established, and the caller has to take care of them.
1348  * If return value is less than *nb_unlinks* then implementation shall update
1349  * the rte_errno accordingly, Possible rte_errno values are
1350  * (-EINVAL) Invalid parameter
1351  *
1352  */
1353 int
1354 rte_event_port_unlink(uint8_t dev_id, uint8_t port_id,
1355                       uint8_t queues[], uint16_t nb_unlinks);
1356
1357 /**
1358  * Retrieve the list of source event queues and its associated service priority
1359  * linked to the destination event port designated by its *port_id*
1360  * on the event device designated by its *dev_id*.
1361  *
1362  * @param dev_id
1363  *   The identifier of the device.
1364  *
1365  * @param port_id
1366  *   Event port identifier.
1367  *
1368  * @param[out] queues
1369  *   Points to an array of *queues* for output.
1370  *   The caller has to allocate *RTE_EVENT_MAX_QUEUES_PER_DEV* bytes to
1371  *   store the event queue(s) linked with event port *port_id*
1372  *
1373  * @param[out] priorities
1374  *   Points to an array of *priorities* for output.
1375  *   The caller has to allocate *RTE_EVENT_MAX_QUEUES_PER_DEV* bytes to
1376  *   store the service priority associated with each event queue linked
1377  *
1378  * @return
1379  * The number of links established on the event port designated by its
1380  *  *port_id*.
1381  * - <0 on failure.
1382  *
1383  */
1384 int
1385 rte_event_port_links_get(uint8_t dev_id, uint8_t port_id,
1386                          uint8_t queues[], uint8_t priorities[]);
1387
1388 /**
1389  * Dump internal information about *dev_id* to the FILE* provided in *f*.
1390  *
1391  * @param dev_id
1392  *   The identifier of the device.
1393  *
1394  * @param f
1395  *   A pointer to a file for output
1396  *
1397  * @return
1398  *   - 0: on success
1399  *   - <0: on failure.
1400  */
1401 int
1402 rte_event_dev_dump(uint8_t dev_id, FILE *f);
1403
1404 #ifdef __cplusplus
1405 }
1406 #endif
1407
1408 #endif /* _RTE_EVENTDEV_H_ */