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