1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2016 Cavium, Inc.
3 * Copyright(c) 2016-2018 Intel Corporation.
8 #ifndef _RTE_EVENTDEV_H_
9 #define _RTE_EVENTDEV_H_
14 * RTE Event Device API
16 * In a polling model, lcores poll ethdev ports and associated rx queues
17 * directly to look for packet. In an event driven model, by contrast, lcores
18 * call the scheduler that selects packets for them based on programmer
19 * specified criteria. Eventdev library adds support for event driven
20 * programming model, which offer applications automatic multicore scaling,
21 * dynamic load balancing, pipelining, packet ingress order maintenance and
22 * synchronization services to simplify application packet processing.
24 * The Event Device API is composed of two parts:
26 * - The application-oriented Event API that includes functions to setup
27 * an event device (configure it, setup its queues, ports and start it), to
28 * establish the link between queues to port and to receive events, and so on.
30 * - The driver-oriented Event API that exports a function allowing
31 * an event poll Mode Driver (PMD) to simultaneously register itself as
32 * an event device driver.
34 * Event device components:
38 * +-------+ | | flow 0 | |
39 * |Packet | | +-------------+ |
40 * |event | | +-------------+ |
41 * | | | | flow 1 | |port_link(port0, queue0)
42 * +-------+ | +-------------+ | | +--------+
43 * +-------+ | +-------------+ o-----v-----o |dequeue +------+
44 * |Crypto | | | flow n | | | event +------->|Core 0|
45 * |work | | +-------------+ o----+ | port 0 | | |
46 * |done ev| | event queue 0 | | +--------+ +------+
47 * +-------+ +-----------------+ |
49 * |Timer | +-----------------+ | +--------+
50 * |expiry | | +-------------+ | +------o |dequeue +------+
51 * |event | | | flow 0 | o-----------o event +------->|Core 1|
52 * +-------+ | +-------------+ | +----o port 1 | | |
53 * Event enqueue | +-------------+ | | +--------+ +------+
54 * o-------------> | | flow 1 | | |
55 * enqueue( | +-------------+ | |
56 * queue_id, | | | +--------+ +------+
57 * flow_id, | +-------------+ | | | |dequeue |Core 2|
58 * sched_type, | | flow n | o-----------o event +------->| |
59 * event_type, | +-------------+ | | | port 2 | +------+
60 * subev_type, | event queue 1 | | +--------+
61 * event) +-----------------+ | +--------+
62 * | | |dequeue +------+
63 * +-------+ +-----------------+ | | event +------->|Core n|
64 * |Core | | +-------------+ o-----------o port n | | |
65 * |(SW) | | | flow 0 | | | +--------+ +--+---+
66 * |event | | +-------------+ | | |
67 * +-------+ | +-------------+ | | |
68 * ^ | | flow 1 | | | |
69 * | | +-------------+ o------+ |
70 * | | +-------------+ | |
72 * | | +-------------+ | |
73 * | | event queue n | |
74 * | +-----------------+ |
76 * +-----------------------------------------------------------+
78 * Event device: A hardware or software-based event scheduler.
80 * Event: A unit of scheduling that encapsulates a packet or other datatype
81 * like SW generated event from the CPU, Crypto work completion notification,
82 * Timer expiry event notification etc as well as metadata.
83 * The metadata includes flow ID, scheduling type, event priority, event_type,
86 * Event queue: A queue containing events that are scheduled by the event dev.
87 * An event queue contains events of different flows associated with scheduling
88 * types, such as atomic, ordered, or parallel.
90 * Event port: An application's interface into the event dev for enqueue and
91 * dequeue operations. Each event port can be linked with one or more
92 * event queues for dequeue operations.
94 * By default, all the functions of the Event Device API exported by a PMD
95 * are lock-free functions which assume to not be invoked in parallel on
96 * different logical cores to work on the same target object. For instance,
97 * the dequeue function of a PMD cannot be invoked in parallel on two logical
98 * cores to operates on same event port. Of course, this function
99 * can be invoked in parallel by different logical cores on different ports.
100 * It is the responsibility of the upper level application to enforce this rule.
102 * In all functions of the Event API, the Event device is
103 * designated by an integer >= 0 named the device identifier *dev_id*
105 * At the Event driver level, Event devices are represented by a generic
106 * data structure of type *rte_event_dev*.
108 * Event devices are dynamically registered during the PCI/SoC device probing
109 * phase performed at EAL initialization time.
110 * When an Event device is being probed, a *rte_event_dev* structure and
111 * a new device identifier are allocated for that device. Then, the
112 * event_dev_init() function supplied by the Event driver matching the probed
113 * device is invoked to properly initialize the device.
115 * The role of the device init function consists of resetting the hardware or
116 * software event driver implementations.
118 * If the device init operation is successful, the correspondence between
119 * the device identifier assigned to the new device and its associated
120 * *rte_event_dev* structure is effectively registered.
121 * Otherwise, both the *rte_event_dev* structure and the device identifier are
124 * The functions exported by the application Event API to setup a device
125 * designated by its device identifier must be invoked in the following order:
126 * - rte_event_dev_configure()
127 * - rte_event_queue_setup()
128 * - rte_event_port_setup()
129 * - rte_event_port_link()
130 * - rte_event_dev_start()
132 * Then, the application can invoke, in any order, the functions
133 * exported by the Event API to schedule events, dequeue events, enqueue events,
134 * change event queue(s) to event port [un]link establishment and so on.
136 * Application may use rte_event_[queue/port]_default_conf_get() to get the
137 * default configuration to set up an event queue or event port by
138 * overriding few default values.
140 * If the application wants to change the configuration (i.e. call
141 * rte_event_dev_configure(), rte_event_queue_setup(), or
142 * rte_event_port_setup()), it must call rte_event_dev_stop() first to stop the
143 * device and then do the reconfiguration before calling rte_event_dev_start()
144 * again. The schedule, enqueue and dequeue functions should not be invoked
145 * when the device is stopped.
147 * Finally, an application can close an Event device by invoking the
148 * rte_event_dev_close() function.
150 * Each function of the application Event API invokes a specific function
151 * of the PMD that controls the target device designated by its device
154 * For this purpose, all device-specific functions of an Event driver are
155 * supplied through a set of pointers contained in a generic structure of type
157 * The address of the *event_dev_ops* structure is stored in the *rte_event_dev*
158 * structure by the device init function of the Event driver, which is
159 * invoked during the PCI/SoC device probing phase, as explained earlier.
161 * In other words, each function of the Event API simply retrieves the
162 * *rte_event_dev* structure associated with the device identifier and
163 * performs an indirect invocation of the corresponding driver function
164 * supplied in the *event_dev_ops* structure of the *rte_event_dev* structure.
166 * For performance reasons, the address of the fast-path functions of the
167 * Event driver is not contained in the *event_dev_ops* structure.
168 * Instead, they are directly stored at the beginning of the *rte_event_dev*
169 * structure to avoid an extra indirect memory access during their invocation.
171 * RTE event device drivers do not use interrupts for enqueue or dequeue
172 * operation. Instead, Event drivers export Poll-Mode enqueue and dequeue
173 * functions to applications.
175 * The events are injected to event device through *enqueue* operation by
176 * event producers in the system. The typical event producers are ethdev
177 * subsystem for generating packet events, CPU(SW) for generating events based
178 * on different stages of application processing, cryptodev for generating
179 * crypto work completion notification etc
181 * The *dequeue* operation gets one or more events from the event ports.
182 * The application process the events and send to downstream event queue through
183 * rte_event_enqueue_burst() if it is an intermediate stage of event processing,
184 * on the final stage, the application may use Tx adapter API for maintaining
185 * the ingress order and then send the packet/event on the wire.
187 * The point at which events are scheduled to ports depends on the device.
188 * For hardware devices, scheduling occurs asynchronously without any software
189 * intervention. Software schedulers can either be distributed
190 * (each worker thread schedules events to its own port) or centralized
191 * (a dedicated thread schedules to all ports). Distributed software schedulers
192 * perform the scheduling in rte_event_dequeue_burst(), whereas centralized
193 * scheduler logic need a dedicated service core for scheduling.
194 * The RTE_EVENT_DEV_CAP_DISTRIBUTED_SCHED capability flag is not set
195 * indicates the device is centralized and thus needs a dedicated scheduling
196 * thread that repeatedly calls software specific scheduling function.
198 * An event driven worker thread has following typical workflow on fastpath:
201 * rte_event_dequeue_burst(...);
203 * rte_event_enqueue_burst(...);
213 #include <rte_common.h>
214 #include <rte_config.h>
215 #include <rte_memory.h>
216 #include <rte_errno.h>
218 #include "rte_eventdev_trace_fp.h"
220 struct rte_mbuf; /* we just use mbuf pointers; no need to include rte_mbuf.h */
223 /* Event device capability bitmap flags */
224 #define RTE_EVENT_DEV_CAP_QUEUE_QOS (1ULL << 0)
225 /**< Event scheduling prioritization is based on the priority associated with
228 * @see rte_event_queue_setup()
230 #define RTE_EVENT_DEV_CAP_EVENT_QOS (1ULL << 1)
231 /**< Event scheduling prioritization is based on the priority associated with
232 * each event. Priority of each event is supplied in *rte_event* structure
233 * on each enqueue operation.
235 * @see rte_event_enqueue_burst()
237 #define RTE_EVENT_DEV_CAP_DISTRIBUTED_SCHED (1ULL << 2)
238 /**< Event device operates in distributed scheduling mode.
239 * In distributed scheduling mode, event scheduling happens in HW or
240 * rte_event_dequeue_burst() or the combination of these two.
241 * If the flag is not set then eventdev is centralized and thus needs a
242 * dedicated service core that acts as a scheduling thread .
244 * @see rte_event_dequeue_burst()
246 #define RTE_EVENT_DEV_CAP_QUEUE_ALL_TYPES (1ULL << 3)
247 /**< Event device is capable of enqueuing events of any type to any queue.
248 * If this capability is not set, the queue only supports events of the
249 * *RTE_SCHED_TYPE_* type that it was created with.
251 * @see RTE_SCHED_TYPE_* values
253 #define RTE_EVENT_DEV_CAP_BURST_MODE (1ULL << 4)
254 /**< Event device is capable of operating in burst mode for enqueue(forward,
255 * release) and dequeue operation. If this capability is not set, application
256 * still uses the rte_event_dequeue_burst() and rte_event_enqueue_burst() but
257 * PMD accepts only one event at a time.
259 * @see rte_event_dequeue_burst() rte_event_enqueue_burst()
261 #define RTE_EVENT_DEV_CAP_IMPLICIT_RELEASE_DISABLE (1ULL << 5)
262 /**< Event device ports support disabling the implicit release feature, in
263 * which the port will release all unreleased events in its dequeue operation.
264 * If this capability is set and the port is configured with implicit release
265 * disabled, the application is responsible for explicitly releasing events
266 * using either the RTE_EVENT_OP_FORWARD or the RTE_EVENT_OP_RELEASE event
267 * enqueue operations.
269 * @see rte_event_dequeue_burst() rte_event_enqueue_burst()
272 #define RTE_EVENT_DEV_CAP_NONSEQ_MODE (1ULL << 6)
273 /**< Event device is capable of operating in none sequential mode. The path
274 * of the event is not necessary to be sequential. Application can change
275 * the path of event at runtime. If the flag is not set, then event each event
276 * will follow a path from queue 0 to queue 1 to queue 2 etc. If the flag is
277 * set, events may be sent to queues in any order. If the flag is not set, the
278 * eventdev will return an error when the application enqueues an event for a
279 * qid which is not the next in the sequence.
282 #define RTE_EVENT_DEV_CAP_RUNTIME_PORT_LINK (1ULL << 7)
283 /**< Event device is capable of configuring the queue/port link at runtime.
284 * If the flag is not set, the eventdev queue/port link is only can be
285 * configured during initialization.
288 #define RTE_EVENT_DEV_CAP_MULTIPLE_QUEUE_PORT (1ULL << 8)
289 /**< Event device is capable of setting up the link between multiple queue
290 * with single port. If the flag is not set, the eventdev can only map a
291 * single queue to each port or map a single queue to many port.
294 /* Event device priority levels */
295 #define RTE_EVENT_DEV_PRIORITY_HIGHEST 0
296 /**< Highest priority expressed across eventdev subsystem
297 * @see rte_event_queue_setup(), rte_event_enqueue_burst()
298 * @see rte_event_port_link()
300 #define RTE_EVENT_DEV_PRIORITY_NORMAL 128
301 /**< Normal priority expressed across eventdev subsystem
302 * @see rte_event_queue_setup(), rte_event_enqueue_burst()
303 * @see rte_event_port_link()
305 #define RTE_EVENT_DEV_PRIORITY_LOWEST 255
306 /**< Lowest priority expressed across eventdev subsystem
307 * @see rte_event_queue_setup(), rte_event_enqueue_burst()
308 * @see rte_event_port_link()
312 * Get the total number of event devices that have been successfully
316 * The total number of usable event devices.
319 rte_event_dev_count(void);
322 * Get the device identifier for the named event device.
325 * Event device name to select the event device identifier.
328 * Returns event device identifier on success.
329 * - <0: Failure to find named event device.
332 rte_event_dev_get_dev_id(const char *name);
335 * Return the NUMA socket to which a device is connected.
338 * The identifier of the device.
340 * The NUMA socket id to which the device is connected or
341 * a default of zero if the socket could not be determined.
342 * -(-EINVAL) dev_id value is out of range.
345 rte_event_dev_socket_id(uint8_t dev_id);
348 * Event device information
350 struct rte_event_dev_info {
351 const char *driver_name; /**< Event driver name */
352 struct rte_device *dev; /**< Device information */
353 uint32_t min_dequeue_timeout_ns;
354 /**< Minimum supported global dequeue timeout(ns) by this device */
355 uint32_t max_dequeue_timeout_ns;
356 /**< Maximum supported global dequeue timeout(ns) by this device */
357 uint32_t dequeue_timeout_ns;
358 /**< Configured global dequeue timeout(ns) for this device */
359 uint8_t max_event_queues;
360 /**< Maximum event_queues supported by this device */
361 uint32_t max_event_queue_flows;
362 /**< Maximum supported flows in an event queue by this device*/
363 uint8_t max_event_queue_priority_levels;
364 /**< Maximum number of event queue priority levels by this device.
365 * Valid when the device has RTE_EVENT_DEV_CAP_QUEUE_QOS capability
367 uint8_t max_event_priority_levels;
368 /**< Maximum number of event priority levels by this device.
369 * Valid when the device has RTE_EVENT_DEV_CAP_EVENT_QOS capability
371 uint8_t max_event_ports;
372 /**< Maximum number of event ports supported by this device */
373 uint8_t max_event_port_dequeue_depth;
374 /**< Maximum number of events can be dequeued at a time from an
375 * event port by this device.
376 * A device that does not support bulk dequeue will set this as 1.
378 uint32_t max_event_port_enqueue_depth;
379 /**< Maximum number of events can be enqueued at a time from an
380 * event port by this device.
381 * A device that does not support bulk enqueue will set this as 1.
383 int32_t max_num_events;
384 /**< A *closed system* event dev has a limit on the number of events it
385 * can manage at a time. An *open system* event dev does not have a
386 * limit and will specify this as -1.
388 uint32_t event_dev_cap;
389 /**< Event device capabilities(RTE_EVENT_DEV_CAP_)*/
393 * Retrieve the contextual information of an event device.
396 * The identifier of the device.
398 * @param[out] dev_info
399 * A pointer to a structure of type *rte_event_dev_info* to be filled with the
400 * contextual information of the device.
403 * - 0: Success, driver updates the contextual information of the event device
404 * - <0: Error code returned by the driver info get function.
408 rte_event_dev_info_get(uint8_t dev_id, struct rte_event_dev_info *dev_info);
411 * The count of ports.
413 #define RTE_EVENT_DEV_ATTR_PORT_COUNT 0
415 * The count of queues.
417 #define RTE_EVENT_DEV_ATTR_QUEUE_COUNT 1
419 * The status of the device, zero for stopped, non-zero for started.
421 #define RTE_EVENT_DEV_ATTR_STARTED 2
424 * Get an attribute from a device.
426 * @param dev_id Eventdev id
427 * @param attr_id The attribute ID to retrieve
428 * @param[out] attr_value A pointer that will be filled in with the attribute
429 * value if successful.
432 * - 0: Successfully retrieved attribute value
433 * - -EINVAL: Invalid device or *attr_id* provided, or *attr_value* is NULL
436 rte_event_dev_attr_get(uint8_t dev_id, uint32_t attr_id,
437 uint32_t *attr_value);
440 /* Event device configuration bitmap flags */
441 #define RTE_EVENT_DEV_CFG_PER_DEQUEUE_TIMEOUT (1ULL << 0)
442 /**< Override the global *dequeue_timeout_ns* and use per dequeue timeout in ns.
443 * @see rte_event_dequeue_timeout_ticks(), rte_event_dequeue_burst()
446 /** Event device configuration structure */
447 struct rte_event_dev_config {
448 uint32_t dequeue_timeout_ns;
449 /**< rte_event_dequeue_burst() timeout on this device.
450 * This value should be in the range of *min_dequeue_timeout_ns* and
451 * *max_dequeue_timeout_ns* which previously provided in
452 * rte_event_dev_info_get()
453 * The value 0 is allowed, in which case, default dequeue timeout used.
454 * @see RTE_EVENT_DEV_CFG_PER_DEQUEUE_TIMEOUT
456 int32_t nb_events_limit;
457 /**< In a *closed system* this field is the limit on maximum number of
458 * events that can be inflight in the eventdev at a given time. The
459 * limit is required to ensure that the finite space in a closed system
460 * is not overwhelmed. The value cannot exceed the *max_num_events*
461 * as provided by rte_event_dev_info_get().
462 * This value should be set to -1 for *open system*.
464 uint8_t nb_event_queues;
465 /**< Number of event queues to configure on this device.
466 * This value cannot exceed the *max_event_queues* which previously
467 * provided in rte_event_dev_info_get()
469 uint8_t nb_event_ports;
470 /**< Number of event ports to configure on this device.
471 * This value cannot exceed the *max_event_ports* which previously
472 * provided in rte_event_dev_info_get()
474 uint32_t nb_event_queue_flows;
475 /**< Number of flows for any event queue on this device.
476 * This value cannot exceed the *max_event_queue_flows* which previously
477 * provided in rte_event_dev_info_get()
479 uint32_t nb_event_port_dequeue_depth;
480 /**< Maximum number of events can be dequeued at a time from an
481 * event port by this device.
482 * This value cannot exceed the *max_event_port_dequeue_depth*
483 * which previously provided in rte_event_dev_info_get().
484 * Ignored when device is not RTE_EVENT_DEV_CAP_BURST_MODE capable.
485 * @see rte_event_port_setup()
487 uint32_t nb_event_port_enqueue_depth;
488 /**< Maximum number of events can be enqueued at a time from an
489 * event port by this device.
490 * This value cannot exceed the *max_event_port_enqueue_depth*
491 * which previously provided in rte_event_dev_info_get().
492 * Ignored when device is not RTE_EVENT_DEV_CAP_BURST_MODE capable.
493 * @see rte_event_port_setup()
495 uint32_t event_dev_cfg;
496 /**< Event device config flags(RTE_EVENT_DEV_CFG_)*/
500 * Configure an event device.
502 * This function must be invoked first before any other function in the
503 * API. This function can also be re-invoked when a device is in the
506 * The caller may use rte_event_dev_info_get() to get the capability of each
507 * resources available for this event device.
510 * The identifier of the device to configure.
512 * The event device configuration structure.
515 * - 0: Success, device configured.
516 * - <0: Error code returned by the driver configuration function.
519 rte_event_dev_configure(uint8_t dev_id,
520 const struct rte_event_dev_config *dev_conf);
523 /* Event queue specific APIs */
525 /* Event queue configuration bitmap flags */
526 #define RTE_EVENT_QUEUE_CFG_ALL_TYPES (1ULL << 0)
527 /**< Allow ATOMIC,ORDERED,PARALLEL schedule type enqueue
529 * @see RTE_SCHED_TYPE_ORDERED, RTE_SCHED_TYPE_ATOMIC, RTE_SCHED_TYPE_PARALLEL
530 * @see rte_event_enqueue_burst()
532 #define RTE_EVENT_QUEUE_CFG_SINGLE_LINK (1ULL << 1)
533 /**< This event queue links only to a single event port.
535 * @see rte_event_port_setup(), rte_event_port_link()
538 /** Event queue configuration structure */
539 struct rte_event_queue_conf {
540 uint32_t nb_atomic_flows;
541 /**< The maximum number of active flows this queue can track at any
542 * given time. If the queue is configured for atomic scheduling (by
543 * applying the RTE_EVENT_QUEUE_CFG_ALL_TYPES flag to event_queue_cfg
544 * or RTE_SCHED_TYPE_ATOMIC flag to schedule_type), then the
545 * value must be in the range of [1, nb_event_queue_flows], which was
546 * previously provided in rte_event_dev_configure().
548 uint32_t nb_atomic_order_sequences;
549 /**< The maximum number of outstanding events waiting to be
550 * reordered by this queue. In other words, the number of entries in
551 * this queue’s reorder buffer.When the number of events in the
552 * reorder buffer reaches to *nb_atomic_order_sequences* then the
553 * scheduler cannot schedule the events from this queue and invalid
554 * event will be returned from dequeue until one or more entries are
556 * If the queue is configured for ordered scheduling (by applying the
557 * RTE_EVENT_QUEUE_CFG_ALL_TYPES flag to event_queue_cfg or
558 * RTE_SCHED_TYPE_ORDERED flag to schedule_type), then the value must
559 * be in the range of [1, nb_event_queue_flows], which was
560 * previously supplied to rte_event_dev_configure().
562 uint32_t event_queue_cfg;
563 /**< Queue cfg flags(EVENT_QUEUE_CFG_) */
564 uint8_t schedule_type;
565 /**< Queue schedule type(RTE_SCHED_TYPE_*).
566 * Valid when RTE_EVENT_QUEUE_CFG_ALL_TYPES bit is not set in
570 /**< Priority for this event queue relative to other event queues.
571 * The requested priority should in the range of
572 * [RTE_EVENT_DEV_PRIORITY_HIGHEST, RTE_EVENT_DEV_PRIORITY_LOWEST].
573 * The implementation shall normalize the requested priority to
574 * event device supported priority value.
575 * Valid when the device has RTE_EVENT_DEV_CAP_QUEUE_QOS capability
580 * Retrieve the default configuration information of an event queue designated
581 * by its *queue_id* from the event driver for an event device.
583 * This function intended to be used in conjunction with rte_event_queue_setup()
584 * where caller needs to set up the queue by overriding few default values.
587 * The identifier of the device.
589 * The index of the event queue to get the configuration information.
590 * The value must be in the range [0, nb_event_queues - 1]
591 * previously supplied to rte_event_dev_configure().
592 * @param[out] queue_conf
593 * The pointer to the default event queue configuration data.
595 * - 0: Success, driver updates the default event queue configuration data.
596 * - <0: Error code returned by the driver info get function.
598 * @see rte_event_queue_setup()
602 rte_event_queue_default_conf_get(uint8_t dev_id, uint8_t queue_id,
603 struct rte_event_queue_conf *queue_conf);
606 * Allocate and set up an event queue for an event device.
609 * The identifier of the device.
611 * The index of the event queue to setup. The value must be in the range
612 * [0, nb_event_queues - 1] previously supplied to rte_event_dev_configure().
614 * The pointer to the configuration data to be used for the event queue.
615 * NULL value is allowed, in which case default configuration used.
617 * @see rte_event_queue_default_conf_get()
620 * - 0: Success, event queue correctly set up.
621 * - <0: event queue configuration failed
624 rte_event_queue_setup(uint8_t dev_id, uint8_t queue_id,
625 const struct rte_event_queue_conf *queue_conf);
628 * The priority of the queue.
630 #define RTE_EVENT_QUEUE_ATTR_PRIORITY 0
632 * The number of atomic flows configured for the queue.
634 #define RTE_EVENT_QUEUE_ATTR_NB_ATOMIC_FLOWS 1
636 * The number of atomic order sequences configured for the queue.
638 #define RTE_EVENT_QUEUE_ATTR_NB_ATOMIC_ORDER_SEQUENCES 2
640 * The cfg flags for the queue.
642 #define RTE_EVENT_QUEUE_ATTR_EVENT_QUEUE_CFG 3
644 * The schedule type of the queue.
646 #define RTE_EVENT_QUEUE_ATTR_SCHEDULE_TYPE 4
649 * Get an attribute from a queue.
656 * The attribute ID to retrieve
657 * @param[out] attr_value
658 * A pointer that will be filled in with the attribute value if successful
661 * - 0: Successfully returned value
662 * - -EINVAL: invalid device, queue or attr_id provided, or attr_value was
664 * - -EOVERFLOW: returned when attr_id is set to
665 * RTE_EVENT_QUEUE_ATTR_SCHEDULE_TYPE and event_queue_cfg is set to
666 * RTE_EVENT_QUEUE_CFG_ALL_TYPES
669 rte_event_queue_attr_get(uint8_t dev_id, uint8_t queue_id, uint32_t attr_id,
670 uint32_t *attr_value);
672 /* Event port specific APIs */
674 /** Event port configuration structure */
675 struct rte_event_port_conf {
676 int32_t new_event_threshold;
677 /**< A backpressure threshold for new event enqueues on this port.
678 * Use for *closed system* event dev where event capacity is limited,
679 * and cannot exceed the capacity of the event dev.
680 * Configuring ports with different thresholds can make higher priority
681 * traffic less likely to be backpressured.
682 * For example, a port used to inject NIC Rx packets into the event dev
683 * can have a lower threshold so as not to overwhelm the device,
684 * while ports used for worker pools can have a higher threshold.
685 * This value cannot exceed the *nb_events_limit*
686 * which was previously supplied to rte_event_dev_configure().
687 * This should be set to '-1' for *open system*.
689 uint16_t dequeue_depth;
690 /**< Configure number of bulk dequeues for this event port.
691 * This value cannot exceed the *nb_event_port_dequeue_depth*
692 * which previously supplied to rte_event_dev_configure().
693 * Ignored when device is not RTE_EVENT_DEV_CAP_BURST_MODE capable.
695 uint16_t enqueue_depth;
696 /**< Configure number of bulk enqueues for this event port.
697 * This value cannot exceed the *nb_event_port_enqueue_depth*
698 * which previously supplied to rte_event_dev_configure().
699 * Ignored when device is not RTE_EVENT_DEV_CAP_BURST_MODE capable.
701 uint8_t disable_implicit_release;
702 /**< Configure the port not to release outstanding events in
703 * rte_event_dev_dequeue_burst(). If true, all events received through
704 * the port must be explicitly released with RTE_EVENT_OP_RELEASE or
705 * RTE_EVENT_OP_FORWARD. Must be false when the device is not
706 * RTE_EVENT_DEV_CAP_IMPLICIT_RELEASE_DISABLE capable.
711 * Retrieve the default configuration information of an event port designated
712 * by its *port_id* from the event driver for an event device.
714 * This function intended to be used in conjunction with rte_event_port_setup()
715 * where caller needs to set up the port by overriding few default values.
718 * The identifier of the device.
720 * The index of the event port to get the configuration information.
721 * The value must be in the range [0, nb_event_ports - 1]
722 * previously supplied to rte_event_dev_configure().
723 * @param[out] port_conf
724 * The pointer to the default event port configuration data
726 * - 0: Success, driver updates the default event port configuration data.
727 * - <0: Error code returned by the driver info get function.
729 * @see rte_event_port_setup()
733 rte_event_port_default_conf_get(uint8_t dev_id, uint8_t port_id,
734 struct rte_event_port_conf *port_conf);
737 * Allocate and set up an event port for an event device.
740 * The identifier of the device.
742 * The index of the event port to setup. The value must be in the range
743 * [0, nb_event_ports - 1] previously supplied to rte_event_dev_configure().
745 * The pointer to the configuration data to be used for the queue.
746 * NULL value is allowed, in which case default configuration used.
748 * @see rte_event_port_default_conf_get()
751 * - 0: Success, event port correctly set up.
752 * - <0: Port configuration failed
753 * - (-EDQUOT) Quota exceeded(Application tried to link the queue configured
754 * with RTE_EVENT_QUEUE_CFG_SINGLE_LINK to more than one event ports)
757 rte_event_port_setup(uint8_t dev_id, uint8_t port_id,
758 const struct rte_event_port_conf *port_conf);
761 * The queue depth of the port on the enqueue side
763 #define RTE_EVENT_PORT_ATTR_ENQ_DEPTH 0
765 * The queue depth of the port on the dequeue side
767 #define RTE_EVENT_PORT_ATTR_DEQ_DEPTH 1
769 * The new event threshold of the port
771 #define RTE_EVENT_PORT_ATTR_NEW_EVENT_THRESHOLD 2
774 * Get an attribute from a port.
781 * The attribute ID to retrieve
782 * @param[out] attr_value
783 * A pointer that will be filled in with the attribute value if successful
786 * - 0: Successfully returned value
787 * - (-EINVAL) Invalid device, port or attr_id, or attr_value was NULL
790 rte_event_port_attr_get(uint8_t dev_id, uint8_t port_id, uint32_t attr_id,
791 uint32_t *attr_value);
794 * Start an event device.
796 * The device start step is the last one and consists of setting the event
797 * queues to start accepting the events and schedules to event ports.
799 * On success, all basic functions exported by the API (event enqueue,
800 * event dequeue and so on) can be invoked.
803 * Event device identifier
805 * - 0: Success, device started.
806 * - -ESTALE : Not all ports of the device are configured
807 * - -ENOLINK: Not all queues are linked, which could lead to deadlock.
810 rte_event_dev_start(uint8_t dev_id);
813 * Stop an event device.
815 * This function causes all queued events to be drained, including those
816 * residing in event ports. While draining events out of the device, this
817 * function calls the user-provided flush callback (if one was registered) once
820 * The device can be restarted with a call to rte_event_dev_start(). Threads
821 * that continue to enqueue/dequeue while the device is stopped, or being
822 * stopped, will result in undefined behavior. This includes event adapters,
823 * which must be stopped prior to stopping the eventdev.
826 * Event device identifier.
828 * @see rte_event_dev_stop_flush_callback_register()
831 rte_event_dev_stop(uint8_t dev_id);
833 typedef void (*eventdev_stop_flush_t)(uint8_t dev_id, struct rte_event event,
835 /**< Callback function called during rte_event_dev_stop(), invoked once per
840 * Registers a callback function to be invoked during rte_event_dev_stop() for
841 * each flushed event. This function can be used to properly dispose of queued
842 * events, for example events containing memory pointers.
844 * The callback function is only registered for the calling process. The
845 * callback function must be registered in every process that can call
846 * rte_event_dev_stop().
848 * To unregister a callback, call this function with a NULL callback pointer.
851 * The identifier of the device.
853 * Callback function invoked once per flushed event.
855 * Argument supplied to callback.
859 * - -EINVAL if *dev_id* is invalid
861 * @see rte_event_dev_stop()
864 rte_event_dev_stop_flush_callback_register(uint8_t dev_id,
865 eventdev_stop_flush_t callback, void *userdata);
868 * Close an event device. The device cannot be restarted!
871 * Event device identifier
874 * - 0 on successfully closing device
875 * - <0 on failure to close device
876 * - (-EAGAIN) if device is busy
879 rte_event_dev_close(uint8_t dev_id);
881 /* Scheduler type definitions */
882 #define RTE_SCHED_TYPE_ORDERED 0
883 /**< Ordered scheduling
885 * Events from an ordered flow of an event queue can be scheduled to multiple
886 * ports for concurrent processing while maintaining the original event order.
887 * This scheme enables the user to achieve high single flow throughput by
888 * avoiding SW synchronization for ordering between ports which bound to cores.
890 * The source flow ordering from an event queue is maintained when events are
891 * enqueued to their destination queue within the same ordered flow context.
892 * An event port holds the context until application call
893 * rte_event_dequeue_burst() from the same port, which implicitly releases
895 * User may allow the scheduler to release the context earlier than that
896 * by invoking rte_event_enqueue_burst() with RTE_EVENT_OP_RELEASE operation.
898 * Events from the source queue appear in their original order when dequeued
899 * from a destination queue.
900 * Event ordering is based on the received event(s), but also other
901 * (newly allocated or stored) events are ordered when enqueued within the same
902 * ordered context. Events not enqueued (e.g. released or stored) within the
903 * context are considered missing from reordering and are skipped at this time
904 * (but can be ordered again within another context).
906 * @see rte_event_queue_setup(), rte_event_dequeue_burst(), RTE_EVENT_OP_RELEASE
909 #define RTE_SCHED_TYPE_ATOMIC 1
910 /**< Atomic scheduling
912 * Events from an atomic flow of an event queue can be scheduled only to a
913 * single port at a time. The port is guaranteed to have exclusive (atomic)
914 * access to the associated flow context, which enables the user to avoid SW
915 * synchronization. Atomic flows also help to maintain event ordering
916 * since only one port at a time can process events from a flow of an
919 * The atomic queue synchronization context is dedicated to the port until
920 * application call rte_event_dequeue_burst() from the same port,
921 * which implicitly releases the context. User may allow the scheduler to
922 * release the context earlier than that by invoking rte_event_enqueue_burst()
923 * with RTE_EVENT_OP_RELEASE operation.
925 * @see rte_event_queue_setup(), rte_event_dequeue_burst(), RTE_EVENT_OP_RELEASE
928 #define RTE_SCHED_TYPE_PARALLEL 2
929 /**< Parallel scheduling
931 * The scheduler performs priority scheduling, load balancing, etc. functions
932 * but does not provide additional event synchronization or ordering.
933 * It is free to schedule events from a single parallel flow of an event queue
934 * to multiple events ports for concurrent processing.
935 * The application is responsible for flow context synchronization and
936 * event ordering (SW synchronization).
938 * @see rte_event_queue_setup(), rte_event_dequeue_burst()
941 /* Event types to classify the event source */
942 #define RTE_EVENT_TYPE_ETHDEV 0x0
943 /**< The event generated from ethdev subsystem */
944 #define RTE_EVENT_TYPE_CRYPTODEV 0x1
945 /**< The event generated from crypodev subsystem */
946 #define RTE_EVENT_TYPE_TIMER 0x2
947 /**< The event generated from event timer adapter */
948 #define RTE_EVENT_TYPE_CPU 0x3
949 /**< The event generated from cpu for pipelining.
950 * Application may use *sub_event_type* to further classify the event
952 #define RTE_EVENT_TYPE_ETH_RX_ADAPTER 0x4
953 /**< The event generated from event eth Rx adapter */
954 #define RTE_EVENT_TYPE_MAX 0x10
955 /**< Maximum number of event types */
957 /* Event enqueue operations */
958 #define RTE_EVENT_OP_NEW 0
959 /**< The event producers use this operation to inject a new event to the
962 #define RTE_EVENT_OP_FORWARD 1
963 /**< The CPU use this operation to forward the event to different event queue or
964 * change to new application specific flow or schedule type to enable
967 * This operation must only be enqueued to the same port that the
968 * event to be forwarded was dequeued from.
970 #define RTE_EVENT_OP_RELEASE 2
971 /**< Release the flow context associated with the schedule type.
973 * If current flow's scheduler type method is *RTE_SCHED_TYPE_ATOMIC*
974 * then this function hints the scheduler that the user has completed critical
975 * section processing in the current atomic context.
976 * The scheduler is now allowed to schedule events from the same flow from
977 * an event queue to another port. However, the context may be still held
978 * until the next rte_event_dequeue_burst() call, this call allows but does not
979 * force the scheduler to release the context early.
981 * Early atomic context release may increase parallelism and thus system
982 * performance, but the user needs to design carefully the split into critical
983 * vs non-critical sections.
985 * If current flow's scheduler type method is *RTE_SCHED_TYPE_ORDERED*
986 * then this function hints the scheduler that the user has done all that need
987 * to maintain event order in the current ordered context.
988 * The scheduler is allowed to release the ordered context of this port and
989 * avoid reordering any following enqueues.
991 * Early ordered context release may increase parallelism and thus system
994 * If current flow's scheduler type method is *RTE_SCHED_TYPE_PARALLEL*
995 * or no scheduling context is held then this function may be an NOOP,
996 * depending on the implementation.
998 * This operation must only be enqueued to the same port that the
999 * event to be released was dequeued from.
1004 * The generic *rte_event* structure to hold the event attributes
1005 * for dequeue and enqueue operation
1012 /** Event attributes for dequeue or enqueue operation */
1014 uint32_t flow_id:20;
1015 /**< Targeted flow identifier for the enqueue and
1016 * dequeue operation.
1017 * The value must be in the range of
1018 * [0, nb_event_queue_flows - 1] which
1019 * previously supplied to rte_event_dev_configure().
1021 uint32_t sub_event_type:8;
1022 /**< Sub-event types based on the event source.
1023 * @see RTE_EVENT_TYPE_CPU
1025 uint32_t event_type:4;
1026 /**< Event type to classify the event source.
1027 * @see RTE_EVENT_TYPE_ETHDEV, (RTE_EVENT_TYPE_*)
1030 /**< The type of event enqueue operation - new/forward/
1031 * etc.This field is not preserved across an instance
1032 * and is undefined on dequeue.
1033 * @see RTE_EVENT_OP_NEW, (RTE_EVENT_OP_*)
1036 /**< Reserved for future use */
1037 uint8_t sched_type:2;
1038 /**< Scheduler synchronization type (RTE_SCHED_TYPE_*)
1039 * associated with flow id on a given event queue
1040 * for the enqueue and dequeue operation.
1043 /**< Targeted event queue identifier for the enqueue or
1044 * dequeue operation.
1045 * The value must be in the range of
1046 * [0, nb_event_queues - 1] which previously supplied to
1047 * rte_event_dev_configure().
1050 /**< Event priority relative to other events in the
1051 * event queue. The requested priority should in the
1052 * range of [RTE_EVENT_DEV_PRIORITY_HIGHEST,
1053 * RTE_EVENT_DEV_PRIORITY_LOWEST].
1054 * The implementation shall normalize the requested
1055 * priority to supported priority value.
1056 * Valid when the device has
1057 * RTE_EVENT_DEV_CAP_EVENT_QOS capability.
1059 uint8_t impl_opaque;
1060 /**< Implementation specific opaque value.
1061 * An implementation may use this field to hold
1062 * implementation specific value to share between
1063 * dequeue and enqueue operation.
1064 * The application should not modify this field.
1071 /**< Opaque 64-bit value */
1073 /**< Opaque event pointer */
1074 struct rte_mbuf *mbuf;
1075 /**< mbuf pointer if dequeued event is associated with mbuf */
1079 /* Ethdev Rx adapter capability bitmap flags */
1080 #define RTE_EVENT_ETH_RX_ADAPTER_CAP_INTERNAL_PORT 0x1
1081 /**< This flag is sent when the packet transfer mechanism is in HW.
1082 * Ethdev can send packets to the event device using internal event port.
1084 #define RTE_EVENT_ETH_RX_ADAPTER_CAP_MULTI_EVENTQ 0x2
1085 /**< Adapter supports multiple event queues per ethdev. Every ethdev
1086 * Rx queue can be connected to a unique event queue.
1088 #define RTE_EVENT_ETH_RX_ADAPTER_CAP_OVERRIDE_FLOW_ID 0x4
1089 /**< The application can override the adapter generated flow ID in the
1090 * event. This flow ID can be specified when adding an ethdev Rx queue
1091 * to the adapter using the ev member of struct rte_event_eth_rx_adapter
1092 * @see struct rte_event_eth_rx_adapter_queue_conf::ev
1093 * @see struct rte_event_eth_rx_adapter_queue_conf::rx_queue_flags
1097 * Retrieve the event device's ethdev Rx adapter capabilities for the
1098 * specified ethernet port
1101 * The identifier of the device.
1103 * @param eth_port_id
1104 * The identifier of the ethernet device.
1107 * A pointer to memory filled with Rx event adapter capabilities.
1110 * - 0: Success, driver provides Rx event adapter capabilities for the
1112 * - <0: Error code returned by the driver function.
1116 rte_event_eth_rx_adapter_caps_get(uint8_t dev_id, uint16_t eth_port_id,
1119 #define RTE_EVENT_TIMER_ADAPTER_CAP_INTERNAL_PORT (1ULL << 0)
1120 /**< This flag is set when the timer mechanism is in HW. */
1123 * Retrieve the event device's timer adapter capabilities.
1126 * The identifier of the device.
1129 * A pointer to memory to be filled with event timer adapter capabilities.
1132 * - 0: Success, driver provided event timer adapter capabilities.
1133 * - <0: Error code returned by the driver function.
1136 rte_event_timer_adapter_caps_get(uint8_t dev_id, uint32_t *caps);
1138 /* Crypto adapter capability bitmap flag */
1139 #define RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_NEW 0x1
1140 /**< Flag indicates HW is capable of generating events in
1141 * RTE_EVENT_OP_NEW enqueue operation. Cryptodev will send
1142 * packets to the event device as new events using an internal
1146 #define RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_FWD 0x2
1147 /**< Flag indicates HW is capable of generating events in
1148 * RTE_EVENT_OP_FORWARD enqueue operation. Cryptodev will send
1149 * packets to the event device as forwarded event using an
1150 * internal event port.
1153 #define RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_QP_EV_BIND 0x4
1154 /**< Flag indicates HW is capable of mapping crypto queue pair to
1158 #define RTE_EVENT_CRYPTO_ADAPTER_CAP_SESSION_PRIVATE_DATA 0x8
1159 /**< Flag indicates HW/SW supports a mechanism to store and retrieve
1160 * the private data information along with the crypto session.
1164 * Retrieve the event device's crypto adapter capabilities for the
1165 * specified cryptodev device
1168 * The identifier of the device.
1171 * The identifier of the cryptodev device.
1174 * A pointer to memory filled with event adapter capabilities.
1175 * It is expected to be pre-allocated & initialized by caller.
1178 * - 0: Success, driver provides event adapter capabilities for the
1180 * - <0: Error code returned by the driver function.
1184 rte_event_crypto_adapter_caps_get(uint8_t dev_id, uint8_t cdev_id,
1187 /* Ethdev Tx adapter capability bitmap flags */
1188 #define RTE_EVENT_ETH_TX_ADAPTER_CAP_INTERNAL_PORT 0x1
1189 /**< This flag is sent when the PMD supports a packet transmit callback
1193 * Retrieve the event device's eth Tx adapter capabilities
1196 * The identifier of the device.
1198 * @param eth_port_id
1199 * The identifier of the ethernet device.
1202 * A pointer to memory filled with eth Tx adapter capabilities.
1205 * - 0: Success, driver provides eth Tx adapter capabilities.
1206 * - <0: Error code returned by the driver function.
1210 rte_event_eth_tx_adapter_caps_get(uint8_t dev_id, uint16_t eth_port_id,
1213 struct rte_eventdev_ops;
1214 struct rte_eventdev;
1216 typedef uint16_t (*event_enqueue_t)(void *port, const struct rte_event *ev);
1217 /**< @internal Enqueue event on port of a device */
1219 typedef uint16_t (*event_enqueue_burst_t)(void *port,
1220 const struct rte_event ev[], uint16_t nb_events);
1221 /**< @internal Enqueue burst of events on port of a device */
1223 typedef uint16_t (*event_dequeue_t)(void *port, struct rte_event *ev,
1224 uint64_t timeout_ticks);
1225 /**< @internal Dequeue event from port of a device */
1227 typedef uint16_t (*event_dequeue_burst_t)(void *port, struct rte_event ev[],
1228 uint16_t nb_events, uint64_t timeout_ticks);
1229 /**< @internal Dequeue burst of events from port of a device */
1231 typedef uint16_t (*event_tx_adapter_enqueue)(void *port,
1232 struct rte_event ev[], uint16_t nb_events);
1233 /**< @internal Enqueue burst of events on port of a device */
1235 typedef uint16_t (*event_tx_adapter_enqueue_same_dest)(void *port,
1236 struct rte_event ev[], uint16_t nb_events);
1237 /**< @internal Enqueue burst of events on port of a device supporting
1238 * burst having same destination Ethernet port & Tx queue.
1241 #define RTE_EVENTDEV_NAME_MAX_LEN (64)
1242 /**< @internal Max length of name of event PMD */
1246 * The data part, with no function pointers, associated with each device.
1248 * This structure is safe to place in shared memory to be common among
1249 * different processes in a multi-process configuration.
1251 struct rte_eventdev_data {
1253 /**< Socket ID where memory is allocated */
1255 /**< Device ID for this instance */
1257 /**< Number of event queues. */
1259 /**< Number of event ports. */
1261 /**< Array of pointers to ports. */
1262 struct rte_event_port_conf *ports_cfg;
1263 /**< Array of port configuration structures. */
1264 struct rte_event_queue_conf *queues_cfg;
1265 /**< Array of queue configuration structures. */
1266 uint16_t *links_map;
1267 /**< Memory to store queues to port connections. */
1269 /**< PMD-specific private data */
1270 uint32_t event_dev_cap;
1271 /**< Event device capabilities(RTE_EVENT_DEV_CAP_)*/
1272 struct rte_event_dev_config dev_conf;
1273 /**< Configuration applied to device. */
1274 uint8_t service_inited;
1275 /* Service initialization state */
1276 uint32_t service_id;
1278 void *dev_stop_flush_arg;
1279 /**< User-provided argument for event flush function */
1282 uint8_t dev_started : 1;
1283 /**< Device state: STARTED(1)/STOPPED(0) */
1285 char name[RTE_EVENTDEV_NAME_MAX_LEN];
1286 /**< Unique identifier name */
1288 uint64_t reserved_64s[4]; /**< Reserved for future fields */
1289 void *reserved_ptrs[4]; /**< Reserved for future fields */
1290 } __rte_cache_aligned;
1292 /** @internal The data structure associated with each event device. */
1293 struct rte_eventdev {
1294 event_enqueue_t enqueue;
1295 /**< Pointer to PMD enqueue function. */
1296 event_enqueue_burst_t enqueue_burst;
1297 /**< Pointer to PMD enqueue burst function. */
1298 event_enqueue_burst_t enqueue_new_burst;
1299 /**< Pointer to PMD enqueue burst function(op new variant) */
1300 event_enqueue_burst_t enqueue_forward_burst;
1301 /**< Pointer to PMD enqueue burst function(op forward variant) */
1302 event_dequeue_t dequeue;
1303 /**< Pointer to PMD dequeue function. */
1304 event_dequeue_burst_t dequeue_burst;
1305 /**< Pointer to PMD dequeue burst function. */
1306 event_tx_adapter_enqueue_same_dest txa_enqueue_same_dest;
1307 /**< Pointer to PMD eth Tx adapter burst enqueue function with
1308 * events destined to same Eth port & Tx queue.
1310 event_tx_adapter_enqueue txa_enqueue;
1311 /**< Pointer to PMD eth Tx adapter enqueue function. */
1312 struct rte_eventdev_data *data;
1313 /**< Pointer to device data */
1314 struct rte_eventdev_ops *dev_ops;
1315 /**< Functions exported by PMD */
1316 struct rte_device *dev;
1317 /**< Device info. supplied by probing */
1320 uint8_t attached : 1;
1321 /**< Flag indicating the device is attached */
1323 uint64_t reserved_64s[4]; /**< Reserved for future fields */
1324 void *reserved_ptrs[4]; /**< Reserved for future fields */
1325 } __rte_cache_aligned;
1327 extern struct rte_eventdev *rte_eventdevs;
1328 /** @internal The pool of rte_eventdev structures. */
1330 static __rte_always_inline uint16_t
1331 __rte_event_enqueue_burst(uint8_t dev_id, uint8_t port_id,
1332 const struct rte_event ev[], uint16_t nb_events,
1333 const event_enqueue_burst_t fn)
1335 const struct rte_eventdev *dev = &rte_eventdevs[dev_id];
1337 #ifdef RTE_LIBRTE_EVENTDEV_DEBUG
1338 if (dev_id >= RTE_EVENT_MAX_DEVS || !rte_eventdevs[dev_id].attached) {
1343 if (port_id >= dev->data->nb_ports) {
1348 rte_eventdev_trace_enq_burst(dev_id, port_id, ev, nb_events, fn);
1350 * Allow zero cost non burst mode routine invocation if application
1351 * requests nb_events as const one
1354 return (*dev->enqueue)(dev->data->ports[port_id], ev);
1356 return fn(dev->data->ports[port_id], ev, nb_events);
1360 * Enqueue a burst of events objects or an event object supplied in *rte_event*
1361 * structure on an event device designated by its *dev_id* through the event
1362 * port specified by *port_id*. Each event object specifies the event queue on
1363 * which it will be enqueued.
1365 * The *nb_events* parameter is the number of event objects to enqueue which are
1366 * supplied in the *ev* array of *rte_event* structure.
1368 * Event operations RTE_EVENT_OP_FORWARD and RTE_EVENT_OP_RELEASE must only be
1369 * enqueued to the same port that their associated events were dequeued from.
1371 * The rte_event_enqueue_burst() function returns the number of
1372 * events objects it actually enqueued. A return value equal to *nb_events*
1373 * means that all event objects have been enqueued.
1376 * The identifier of the device.
1378 * The identifier of the event port.
1380 * Points to an array of *nb_events* objects of type *rte_event* structure
1381 * which contain the event object enqueue operations to be processed.
1383 * The number of event objects to enqueue, typically number of
1384 * rte_event_port_attr_get(...RTE_EVENT_PORT_ATTR_ENQ_DEPTH...)
1385 * available for this port.
1388 * The number of event objects actually enqueued on the event device. The
1389 * return value can be less than the value of the *nb_events* parameter when
1390 * the event devices queue is full or if invalid parameters are specified in a
1391 * *rte_event*. If the return value is less than *nb_events*, the remaining
1392 * events at the end of ev[] are not consumed and the caller has to take care
1393 * of them, and rte_errno is set accordingly. Possible errno values include:
1394 * - EINVAL The port ID is invalid, device ID is invalid, an event's queue
1395 * ID is invalid, or an event's sched type doesn't match the
1396 * capabilities of the destination queue.
1397 * - ENOSPC The event port was backpressured and unable to enqueue
1398 * one or more events. This error code is only applicable to
1400 * @see rte_event_port_attr_get(), RTE_EVENT_PORT_ATTR_ENQ_DEPTH
1402 static inline uint16_t
1403 rte_event_enqueue_burst(uint8_t dev_id, uint8_t port_id,
1404 const struct rte_event ev[], uint16_t nb_events)
1406 const struct rte_eventdev *dev = &rte_eventdevs[dev_id];
1408 return __rte_event_enqueue_burst(dev_id, port_id, ev, nb_events,
1409 dev->enqueue_burst);
1413 * Enqueue a burst of events objects of operation type *RTE_EVENT_OP_NEW* on
1414 * an event device designated by its *dev_id* through the event port specified
1417 * Provides the same functionality as rte_event_enqueue_burst(), expect that
1418 * application can use this API when the all objects in the burst contains
1419 * the enqueue operation of the type *RTE_EVENT_OP_NEW*. This specialized
1420 * function can provide the additional hint to the PMD and optimize if possible.
1422 * The rte_event_enqueue_new_burst() result is undefined if the enqueue burst
1423 * has event object of operation type != RTE_EVENT_OP_NEW.
1426 * The identifier of the device.
1428 * The identifier of the event port.
1430 * Points to an array of *nb_events* objects of type *rte_event* structure
1431 * which contain the event object enqueue operations to be processed.
1433 * The number of event objects to enqueue, typically number of
1434 * rte_event_port_attr_get(...RTE_EVENT_PORT_ATTR_ENQ_DEPTH...)
1435 * available for this port.
1438 * The number of event objects actually enqueued on the event device. The
1439 * return value can be less than the value of the *nb_events* parameter when
1440 * the event devices queue is full or if invalid parameters are specified in a
1441 * *rte_event*. If the return value is less than *nb_events*, the remaining
1442 * events at the end of ev[] are not consumed and the caller has to take care
1443 * of them, and rte_errno is set accordingly. Possible errno values include:
1444 * - EINVAL The port ID is invalid, device ID is invalid, an event's queue
1445 * ID is invalid, or an event's sched type doesn't match the
1446 * capabilities of the destination queue.
1447 * - ENOSPC The event port was backpressured and unable to enqueue
1448 * one or more events. This error code is only applicable to
1450 * @see rte_event_port_attr_get(), RTE_EVENT_PORT_ATTR_ENQ_DEPTH
1451 * @see rte_event_enqueue_burst()
1453 static inline uint16_t
1454 rte_event_enqueue_new_burst(uint8_t dev_id, uint8_t port_id,
1455 const struct rte_event ev[], uint16_t nb_events)
1457 const struct rte_eventdev *dev = &rte_eventdevs[dev_id];
1459 return __rte_event_enqueue_burst(dev_id, port_id, ev, nb_events,
1460 dev->enqueue_new_burst);
1464 * Enqueue a burst of events objects of operation type *RTE_EVENT_OP_FORWARD*
1465 * on an event device designated by its *dev_id* through the event port
1466 * specified by *port_id*.
1468 * Provides the same functionality as rte_event_enqueue_burst(), expect that
1469 * application can use this API when the all objects in the burst contains
1470 * the enqueue operation of the type *RTE_EVENT_OP_FORWARD*. This specialized
1471 * function can provide the additional hint to the PMD and optimize if possible.
1473 * The rte_event_enqueue_new_burst() result is undefined if the enqueue burst
1474 * has event object of operation type != RTE_EVENT_OP_FORWARD.
1477 * The identifier of the device.
1479 * The identifier of the event port.
1481 * Points to an array of *nb_events* objects of type *rte_event* structure
1482 * which contain the event object enqueue operations to be processed.
1484 * The number of event objects to enqueue, typically number of
1485 * rte_event_port_attr_get(...RTE_EVENT_PORT_ATTR_ENQ_DEPTH...)
1486 * available for this port.
1489 * The number of event objects actually enqueued on the event device. The
1490 * return value can be less than the value of the *nb_events* parameter when
1491 * the event devices queue is full or if invalid parameters are specified in a
1492 * *rte_event*. If the return value is less than *nb_events*, the remaining
1493 * events at the end of ev[] are not consumed and the caller has to take care
1494 * of them, and rte_errno is set accordingly. Possible errno values include:
1495 * - EINVAL The port ID is invalid, device ID is invalid, an event's queue
1496 * ID is invalid, or an event's sched type doesn't match the
1497 * capabilities of the destination queue.
1498 * - ENOSPC The event port was backpressured and unable to enqueue
1499 * one or more events. This error code is only applicable to
1501 * @see rte_event_port_attr_get(), RTE_EVENT_PORT_ATTR_ENQ_DEPTH
1502 * @see rte_event_enqueue_burst()
1504 static inline uint16_t
1505 rte_event_enqueue_forward_burst(uint8_t dev_id, uint8_t port_id,
1506 const struct rte_event ev[], uint16_t nb_events)
1508 const struct rte_eventdev *dev = &rte_eventdevs[dev_id];
1510 return __rte_event_enqueue_burst(dev_id, port_id, ev, nb_events,
1511 dev->enqueue_forward_burst);
1515 * Converts nanoseconds to *timeout_ticks* value for rte_event_dequeue_burst()
1517 * If the device is configured with RTE_EVENT_DEV_CFG_PER_DEQUEUE_TIMEOUT flag
1518 * then application can use this function to convert timeout value in
1519 * nanoseconds to implementations specific timeout value supplied in
1520 * rte_event_dequeue_burst()
1523 * The identifier of the device.
1525 * Wait time in nanosecond
1526 * @param[out] timeout_ticks
1527 * Value for the *timeout_ticks* parameter in rte_event_dequeue_burst()
1531 * - -ENOTSUP if the device doesn't support timeouts
1532 * - -EINVAL if *dev_id* is invalid or *timeout_ticks* is NULL
1533 * - other values < 0 on failure.
1535 * @see rte_event_dequeue_burst(), RTE_EVENT_DEV_CFG_PER_DEQUEUE_TIMEOUT
1536 * @see rte_event_dev_configure()
1540 rte_event_dequeue_timeout_ticks(uint8_t dev_id, uint64_t ns,
1541 uint64_t *timeout_ticks);
1544 * Dequeue a burst of events objects or an event object from the event port
1545 * designated by its *event_port_id*, on an event device designated
1548 * rte_event_dequeue_burst() does not dictate the specifics of scheduling
1549 * algorithm as each eventdev driver may have different criteria to schedule
1550 * an event. However, in general, from an application perspective scheduler may
1551 * use the following scheme to dispatch an event to the port.
1553 * 1) Selection of event queue based on
1554 * a) The list of event queues are linked to the event port.
1555 * b) If the device has RTE_EVENT_DEV_CAP_QUEUE_QOS capability then event
1556 * queue selection from list is based on event queue priority relative to
1557 * other event queue supplied as *priority* in rte_event_queue_setup()
1558 * c) If the device has RTE_EVENT_DEV_CAP_EVENT_QOS capability then event
1559 * queue selection from the list is based on event priority supplied as
1560 * *priority* in rte_event_enqueue_burst()
1561 * 2) Selection of event
1562 * a) The number of flows available in selected event queue.
1563 * b) Schedule type method associated with the event
1565 * The *nb_events* parameter is the maximum number of event objects to dequeue
1566 * which are returned in the *ev* array of *rte_event* structure.
1568 * The rte_event_dequeue_burst() function returns the number of events objects
1569 * it actually dequeued. A return value equal to *nb_events* means that all
1570 * event objects have been dequeued.
1572 * The number of events dequeued is the number of scheduler contexts held by
1573 * this port. These contexts are automatically released in the next
1574 * rte_event_dequeue_burst() invocation if the port supports implicit
1575 * releases, or invoking rte_event_enqueue_burst() with RTE_EVENT_OP_RELEASE
1576 * operation can be used to release the contexts early.
1578 * Event operations RTE_EVENT_OP_FORWARD and RTE_EVENT_OP_RELEASE must only be
1579 * enqueued to the same port that their associated events were dequeued from.
1582 * The identifier of the device.
1584 * The identifier of the event port.
1586 * Points to an array of *nb_events* objects of type *rte_event* structure
1587 * for output to be populated with the dequeued event objects.
1589 * The maximum number of event objects to dequeue, typically number of
1590 * rte_event_port_dequeue_depth() available for this port.
1592 * @param timeout_ticks
1593 * - 0 no-wait, returns immediately if there is no event.
1594 * - >0 wait for the event, if the device is configured with
1595 * RTE_EVENT_DEV_CFG_PER_DEQUEUE_TIMEOUT then this function will wait until
1596 * at least one event is available or *timeout_ticks* time.
1597 * if the device is not configured with RTE_EVENT_DEV_CFG_PER_DEQUEUE_TIMEOUT
1598 * then this function will wait until the event available or
1599 * *dequeue_timeout_ns* ns which was previously supplied to
1600 * rte_event_dev_configure()
1603 * The number of event objects actually dequeued from the port. The return
1604 * value can be less than the value of the *nb_events* parameter when the
1605 * event port's queue is not full.
1607 * @see rte_event_port_dequeue_depth()
1609 static inline uint16_t
1610 rte_event_dequeue_burst(uint8_t dev_id, uint8_t port_id, struct rte_event ev[],
1611 uint16_t nb_events, uint64_t timeout_ticks)
1613 struct rte_eventdev *dev = &rte_eventdevs[dev_id];
1615 #ifdef RTE_LIBRTE_EVENTDEV_DEBUG
1616 if (dev_id >= RTE_EVENT_MAX_DEVS || !rte_eventdevs[dev_id].attached) {
1621 if (port_id >= dev->data->nb_ports) {
1626 rte_eventdev_trace_deq_burst(dev_id, port_id, ev, nb_events);
1628 * Allow zero cost non burst mode routine invocation if application
1629 * requests nb_events as const one
1632 return (*dev->dequeue)(
1633 dev->data->ports[port_id], ev, timeout_ticks);
1635 return (*dev->dequeue_burst)(
1636 dev->data->ports[port_id], ev, nb_events,
1641 * Link multiple source event queues supplied in *queues* to the destination
1642 * event port designated by its *port_id* with associated service priority
1643 * supplied in *priorities* on the event device designated by its *dev_id*.
1645 * The link establishment shall enable the event port *port_id* from
1646 * receiving events from the specified event queue(s) supplied in *queues*
1648 * An event queue may link to one or more event ports.
1649 * The number of links can be established from an event queue to event port is
1650 * implementation defined.
1652 * Event queue(s) to event port link establishment can be changed at runtime
1653 * without re-configuring the device to support scaling and to reduce the
1654 * latency of critical work by establishing the link with more event ports
1658 * The identifier of the device.
1661 * Event port identifier to select the destination port to link.
1664 * Points to an array of *nb_links* event queues to be linked
1665 * to the event port.
1666 * NULL value is allowed, in which case this function links all the configured
1667 * event queues *nb_event_queues* which previously supplied to
1668 * rte_event_dev_configure() to the event port *port_id*
1671 * Points to an array of *nb_links* service priorities associated with each
1672 * event queue link to event port.
1673 * The priority defines the event port's servicing priority for
1674 * event queue, which may be ignored by an implementation.
1675 * The requested priority should in the range of
1676 * [RTE_EVENT_DEV_PRIORITY_HIGHEST, RTE_EVENT_DEV_PRIORITY_LOWEST].
1677 * The implementation shall normalize the requested priority to
1678 * implementation supported priority value.
1679 * NULL value is allowed, in which case this function links the event queues
1680 * with RTE_EVENT_DEV_PRIORITY_NORMAL servicing priority
1683 * The number of links to establish. This parameter is ignored if queues is
1687 * The number of links actually established. The return value can be less than
1688 * the value of the *nb_links* parameter when the implementation has the
1689 * limitation on specific queue to port link establishment or if invalid
1690 * parameters are specified in *queues*
1691 * If the return value is less than *nb_links*, the remaining links at the end
1692 * of link[] are not established, and the caller has to take care of them.
1693 * If return value is less than *nb_links* then implementation shall update the
1694 * rte_errno accordingly, Possible rte_errno values are
1695 * (EDQUOT) Quota exceeded(Application tried to link the queue configured with
1696 * RTE_EVENT_QUEUE_CFG_SINGLE_LINK to more than one event ports)
1697 * (EINVAL) Invalid parameter
1701 rte_event_port_link(uint8_t dev_id, uint8_t port_id,
1702 const uint8_t queues[], const uint8_t priorities[],
1706 * Unlink multiple source event queues supplied in *queues* from the destination
1707 * event port designated by its *port_id* on the event device designated
1710 * The unlink call issues an async request to disable the event port *port_id*
1711 * from receiving events from the specified event queue *queue_id*.
1712 * Event queue(s) to event port unlink establishment can be changed at runtime
1713 * without re-configuring the device.
1715 * @see rte_event_port_unlinks_in_progress() to poll for completed unlinks.
1718 * The identifier of the device.
1721 * Event port identifier to select the destination port to unlink.
1724 * Points to an array of *nb_unlinks* event queues to be unlinked
1725 * from the event port.
1726 * NULL value is allowed, in which case this function unlinks all the
1727 * event queue(s) from the event port *port_id*.
1730 * The number of unlinks to establish. This parameter is ignored if queues is
1734 * The number of unlinks successfully requested. The return value can be less
1735 * than the value of the *nb_unlinks* parameter when the implementation has the
1736 * limitation on specific queue to port unlink establishment or
1737 * if invalid parameters are specified.
1738 * If the return value is less than *nb_unlinks*, the remaining queues at the
1739 * end of queues[] are not unlinked, and the caller has to take care of them.
1740 * If return value is less than *nb_unlinks* then implementation shall update
1741 * the rte_errno accordingly, Possible rte_errno values are
1742 * (EINVAL) Invalid parameter
1745 rte_event_port_unlink(uint8_t dev_id, uint8_t port_id,
1746 uint8_t queues[], uint16_t nb_unlinks);
1749 * Returns the number of unlinks in progress.
1751 * This function provides the application with a method to detect when an
1752 * unlink has been completed by the implementation.
1754 * @see rte_event_port_unlink() to issue unlink requests.
1757 * The identifier of the device.
1760 * Event port identifier to select port to check for unlinks in progress.
1763 * The number of unlinks that are in progress. A return of zero indicates that
1764 * there are no outstanding unlink requests. A positive return value indicates
1765 * the number of unlinks that are in progress, but are not yet complete.
1766 * A negative return value indicates an error, -EINVAL indicates an invalid
1767 * parameter passed for *dev_id* or *port_id*.
1770 rte_event_port_unlinks_in_progress(uint8_t dev_id, uint8_t port_id);
1773 * Retrieve the list of source event queues and its associated service priority
1774 * linked to the destination event port designated by its *port_id*
1775 * on the event device designated by its *dev_id*.
1778 * The identifier of the device.
1781 * Event port identifier.
1783 * @param[out] queues
1784 * Points to an array of *queues* for output.
1785 * The caller has to allocate *RTE_EVENT_MAX_QUEUES_PER_DEV* bytes to
1786 * store the event queue(s) linked with event port *port_id*
1788 * @param[out] priorities
1789 * Points to an array of *priorities* for output.
1790 * The caller has to allocate *RTE_EVENT_MAX_QUEUES_PER_DEV* bytes to
1791 * store the service priority associated with each event queue linked
1794 * The number of links established on the event port designated by its
1800 rte_event_port_links_get(uint8_t dev_id, uint8_t port_id,
1801 uint8_t queues[], uint8_t priorities[]);
1804 * Retrieve the service ID of the event dev. If the adapter doesn't use
1805 * a rte_service function, this function returns -ESRCH.
1808 * The identifier of the device.
1810 * @param [out] service_id
1811 * A pointer to a uint32_t, to be filled in with the service id.
1815 * - <0: Error code on failure, if the event dev doesn't use a rte_service
1816 * function, this function returns -ESRCH.
1819 rte_event_dev_service_id_get(uint8_t dev_id, uint32_t *service_id);
1822 * Dump internal information about *dev_id* to the FILE* provided in *f*.
1825 * The identifier of the device.
1828 * A pointer to a file for output
1835 rte_event_dev_dump(uint8_t dev_id, FILE *f);
1837 /** Maximum name length for extended statistics counters */
1838 #define RTE_EVENT_DEV_XSTATS_NAME_SIZE 64
1841 * Selects the component of the eventdev to retrieve statistics from.
1843 enum rte_event_dev_xstats_mode {
1844 RTE_EVENT_DEV_XSTATS_DEVICE,
1845 RTE_EVENT_DEV_XSTATS_PORT,
1846 RTE_EVENT_DEV_XSTATS_QUEUE,
1850 * A name-key lookup element for extended statistics.
1852 * This structure is used to map between names and ID numbers
1853 * for extended ethdev statistics.
1855 struct rte_event_dev_xstats_name {
1856 char name[RTE_EVENT_DEV_XSTATS_NAME_SIZE];
1860 * Retrieve names of extended statistics of an event device.
1863 * The identifier of the event device.
1865 * The mode of statistics to retrieve. Choices include the device statistics,
1866 * port statistics or queue statistics.
1867 * @param queue_port_id
1868 * Used to specify the port or queue number in queue or port mode, and is
1869 * ignored in device mode.
1870 * @param[out] xstats_names
1871 * Block of memory to insert names into. Must be at least size in capacity.
1872 * If set to NULL, function returns required capacity.
1874 * Block of memory to insert ids into. Must be at least size in capacity.
1875 * If set to NULL, function returns required capacity. The id values returned
1876 * can be passed to *rte_event_dev_xstats_get* to select statistics.
1878 * Capacity of xstats_names (number of names).
1880 * - positive value lower or equal to size: success. The return value
1881 * is the number of entries filled in the stats table.
1882 * - positive value higher than size: error, the given statistics table
1883 * is too small. The return value corresponds to the size that should
1884 * be given to succeed. The entries in the table are not valid and
1885 * shall not be used by the caller.
1886 * - negative value on error:
1887 * -ENODEV for invalid *dev_id*
1888 * -EINVAL for invalid mode, queue port or id parameters
1889 * -ENOTSUP if the device doesn't support this function.
1892 rte_event_dev_xstats_names_get(uint8_t dev_id,
1893 enum rte_event_dev_xstats_mode mode,
1894 uint8_t queue_port_id,
1895 struct rte_event_dev_xstats_name *xstats_names,
1900 * Retrieve extended statistics of an event device.
1903 * The identifier of the device.
1905 * The mode of statistics to retrieve. Choices include the device statistics,
1906 * port statistics or queue statistics.
1907 * @param queue_port_id
1908 * Used to specify the port or queue number in queue or port mode, and is
1909 * ignored in device mode.
1911 * The id numbers of the stats to get. The ids can be got from the stat
1912 * position in the stat list from rte_event_dev_get_xstats_names(), or
1913 * by using rte_event_dev_xstats_by_name_get().
1914 * @param[out] values
1915 * The values for each stats request by ID.
1917 * The number of stats requested
1919 * - positive value: number of stat entries filled into the values array
1920 * - negative value on error:
1921 * -ENODEV for invalid *dev_id*
1922 * -EINVAL for invalid mode, queue port or id parameters
1923 * -ENOTSUP if the device doesn't support this function.
1926 rte_event_dev_xstats_get(uint8_t dev_id,
1927 enum rte_event_dev_xstats_mode mode,
1928 uint8_t queue_port_id,
1929 const unsigned int ids[],
1930 uint64_t values[], unsigned int n);
1933 * Retrieve the value of a single stat by requesting it by name.
1936 * The identifier of the device
1938 * The stat name to retrieve
1940 * If non-NULL, the numerical id of the stat will be returned, so that further
1941 * requests for the stat can be got using rte_event_dev_xstats_get, which will
1942 * be faster as it doesn't need to scan a list of names for the stat.
1943 * If the stat cannot be found, the id returned will be (unsigned)-1.
1945 * - positive value or zero: the stat value
1946 * - negative value: -EINVAL if stat not found, -ENOTSUP if not supported.
1949 rte_event_dev_xstats_by_name_get(uint8_t dev_id, const char *name,
1953 * Reset the values of the xstats of the selected component in the device.
1956 * The identifier of the device
1958 * The mode of the statistics to reset. Choose from device, queue or port.
1959 * @param queue_port_id
1960 * The queue or port to reset. 0 and positive values select ports and queues,
1961 * while -1 indicates all ports or queues.
1963 * Selects specific statistics to be reset. When NULL, all statistics selected
1964 * by *mode* will be reset. If non-NULL, must point to array of at least
1967 * The number of ids available from the *ids* array. Ignored when ids is NULL.
1969 * - zero: successfully reset the statistics to zero
1970 * - negative value: -EINVAL invalid parameters, -ENOTSUP if not supported.
1973 rte_event_dev_xstats_reset(uint8_t dev_id,
1974 enum rte_event_dev_xstats_mode mode,
1975 int16_t queue_port_id,
1976 const uint32_t ids[],
1980 * Trigger the eventdev self test.
1983 * The identifier of the device
1985 * - 0: Selftest successful
1986 * - -ENOTSUP if the device doesn't support selftest
1987 * - other values < 0 on failure.
1989 int rte_event_dev_selftest(uint8_t dev_id);
1995 #endif /* _RTE_EVENTDEV_H_ */