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_errno.h>
215 #include <rte_mbuf_pool_ops.h>
216 #include <rte_mempool.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 and weight
226 * associated with each event queue. Events from a queue with highest priority
227 * is scheduled first. If the queues are of same priority, weight of the queues
228 * are considered to select a queue in a weighted round robin fashion.
229 * Subsequent dequeue calls from an event port could see events from the same
230 * event queue, if the queue is configured with an affinity count. Affinity
231 * count is the number of subsequent dequeue calls, in which an event port
232 * should use the same event queue if the queue is non-empty
234 * @see rte_event_queue_setup(), rte_event_queue_attr_set()
236 #define RTE_EVENT_DEV_CAP_EVENT_QOS (1ULL << 1)
237 /**< Event scheduling prioritization is based on the priority associated with
238 * each event. Priority of each event is supplied in *rte_event* structure
239 * on each enqueue operation.
241 * @see rte_event_enqueue_burst()
243 #define RTE_EVENT_DEV_CAP_DISTRIBUTED_SCHED (1ULL << 2)
244 /**< Event device operates in distributed scheduling mode.
245 * In distributed scheduling mode, event scheduling happens in HW or
246 * rte_event_dequeue_burst() or the combination of these two.
247 * If the flag is not set then eventdev is centralized and thus needs a
248 * dedicated service core that acts as a scheduling thread .
250 * @see rte_event_dequeue_burst()
252 #define RTE_EVENT_DEV_CAP_QUEUE_ALL_TYPES (1ULL << 3)
253 /**< Event device is capable of enqueuing events of any type to any queue.
254 * If this capability is not set, the queue only supports events of the
255 * *RTE_SCHED_TYPE_* type that it was created with.
257 * @see RTE_SCHED_TYPE_* values
259 #define RTE_EVENT_DEV_CAP_BURST_MODE (1ULL << 4)
260 /**< Event device is capable of operating in burst mode for enqueue(forward,
261 * release) and dequeue operation. If this capability is not set, application
262 * still uses the rte_event_dequeue_burst() and rte_event_enqueue_burst() but
263 * PMD accepts only one event at a time.
265 * @see rte_event_dequeue_burst() rte_event_enqueue_burst()
267 #define RTE_EVENT_DEV_CAP_IMPLICIT_RELEASE_DISABLE (1ULL << 5)
268 /**< Event device ports support disabling the implicit release feature, in
269 * which the port will release all unreleased events in its dequeue operation.
270 * If this capability is set and the port is configured with implicit release
271 * disabled, the application is responsible for explicitly releasing events
272 * using either the RTE_EVENT_OP_FORWARD or the RTE_EVENT_OP_RELEASE event
273 * enqueue operations.
275 * @see rte_event_dequeue_burst() rte_event_enqueue_burst()
278 #define RTE_EVENT_DEV_CAP_NONSEQ_MODE (1ULL << 6)
279 /**< Event device is capable of operating in none sequential mode. The path
280 * of the event is not necessary to be sequential. Application can change
281 * the path of event at runtime. If the flag is not set, then event each event
282 * will follow a path from queue 0 to queue 1 to queue 2 etc. If the flag is
283 * set, events may be sent to queues in any order. If the flag is not set, the
284 * eventdev will return an error when the application enqueues an event for a
285 * qid which is not the next in the sequence.
288 #define RTE_EVENT_DEV_CAP_RUNTIME_PORT_LINK (1ULL << 7)
289 /**< Event device is capable of configuring the queue/port link at runtime.
290 * If the flag is not set, the eventdev queue/port link is only can be
291 * configured during initialization.
294 #define RTE_EVENT_DEV_CAP_MULTIPLE_QUEUE_PORT (1ULL << 8)
295 /**< Event device is capable of setting up the link between multiple queue
296 * with single port. If the flag is not set, the eventdev can only map a
297 * single queue to each port or map a single queue to many port.
300 #define RTE_EVENT_DEV_CAP_CARRY_FLOW_ID (1ULL << 9)
301 /**< Event device preserves the flow ID from the enqueued
302 * event to the dequeued event if the flag is set. Otherwise,
303 * the content of this field is implementation dependent.
306 #define RTE_EVENT_DEV_CAP_MAINTENANCE_FREE (1ULL << 10)
307 /**< Event device *does not* require calls to rte_event_maintain().
308 * An event device that does not set this flag requires calls to
309 * rte_event_maintain() during periods when neither
310 * rte_event_dequeue_burst() nor rte_event_enqueue_burst() are called
311 * on a port. This will allow the event device to perform internal
312 * processing, such as flushing buffered events, return credits to a
313 * global pool, or process signaling related to load balancing.
316 #define RTE_EVENT_DEV_CAP_RUNTIME_QUEUE_ATTR (1ULL << 11)
317 /**< Event device is capable of changing the queue attributes at runtime i.e
318 * after rte_event_queue_setup() or rte_event_start() call sequence. If this
319 * flag is not set, eventdev queue attributes can only be configured during
320 * rte_event_queue_setup().
323 /* Event device priority levels */
324 #define RTE_EVENT_DEV_PRIORITY_HIGHEST 0
325 /**< Highest priority expressed across eventdev subsystem
326 * @see rte_event_queue_setup(), rte_event_enqueue_burst()
327 * @see rte_event_port_link()
329 #define RTE_EVENT_DEV_PRIORITY_NORMAL 128
330 /**< Normal priority expressed across eventdev subsystem
331 * @see rte_event_queue_setup(), rte_event_enqueue_burst()
332 * @see rte_event_port_link()
334 #define RTE_EVENT_DEV_PRIORITY_LOWEST 255
335 /**< Lowest priority expressed across eventdev subsystem
336 * @see rte_event_queue_setup(), rte_event_enqueue_burst()
337 * @see rte_event_port_link()
340 /* Event queue scheduling weights */
341 #define RTE_EVENT_QUEUE_WEIGHT_HIGHEST 255
342 /**< Highest weight of an event queue
343 * @see rte_event_queue_attr_get(), rte_event_queue_attr_set()
345 #define RTE_EVENT_QUEUE_WEIGHT_LOWEST 0
346 /**< Lowest weight of an event queue
347 * @see rte_event_queue_attr_get(), rte_event_queue_attr_set()
350 /* Event queue scheduling affinity */
351 #define RTE_EVENT_QUEUE_AFFINITY_HIGHEST 255
352 /**< Highest scheduling affinity of an event queue
353 * @see rte_event_queue_attr_get(), rte_event_queue_attr_set()
355 #define RTE_EVENT_QUEUE_AFFINITY_LOWEST 0
356 /**< Lowest scheduling affinity of an event queue
357 * @see rte_event_queue_attr_get(), rte_event_queue_attr_set()
361 * Get the total number of event devices that have been successfully
365 * The total number of usable event devices.
368 rte_event_dev_count(void);
371 * Get the device identifier for the named event device.
374 * Event device name to select the event device identifier.
377 * Returns event device identifier on success.
378 * - <0: Failure to find named event device.
381 rte_event_dev_get_dev_id(const char *name);
384 * Return the NUMA socket to which a device is connected.
387 * The identifier of the device.
389 * The NUMA socket id to which the device is connected or
390 * a default of zero if the socket could not be determined.
391 * -(-EINVAL) dev_id value is out of range.
394 rte_event_dev_socket_id(uint8_t dev_id);
397 * Event device information
399 struct rte_event_dev_info {
400 const char *driver_name; /**< Event driver name */
401 struct rte_device *dev; /**< Device information */
402 uint32_t min_dequeue_timeout_ns;
403 /**< Minimum supported global dequeue timeout(ns) by this device */
404 uint32_t max_dequeue_timeout_ns;
405 /**< Maximum supported global dequeue timeout(ns) by this device */
406 uint32_t dequeue_timeout_ns;
407 /**< Configured global dequeue timeout(ns) for this device */
408 uint8_t max_event_queues;
409 /**< Maximum event_queues supported by this device */
410 uint32_t max_event_queue_flows;
411 /**< Maximum supported flows in an event queue by this device*/
412 uint8_t max_event_queue_priority_levels;
413 /**< Maximum number of event queue priority levels by this device.
414 * Valid when the device has RTE_EVENT_DEV_CAP_QUEUE_QOS capability
416 uint8_t max_event_priority_levels;
417 /**< Maximum number of event priority levels by this device.
418 * Valid when the device has RTE_EVENT_DEV_CAP_EVENT_QOS capability
420 uint8_t max_event_ports;
421 /**< Maximum number of event ports supported by this device */
422 uint8_t max_event_port_dequeue_depth;
423 /**< Maximum number of events can be dequeued at a time from an
424 * event port by this device.
425 * A device that does not support bulk dequeue will set this as 1.
427 uint32_t max_event_port_enqueue_depth;
428 /**< Maximum number of events can be enqueued at a time from an
429 * event port by this device.
430 * A device that does not support bulk enqueue will set this as 1.
432 uint8_t max_event_port_links;
433 /**< Maximum number of queues that can be linked to a single event
434 * port by this device.
436 int32_t max_num_events;
437 /**< A *closed system* event dev has a limit on the number of events it
438 * can manage at a time. An *open system* event dev does not have a
439 * limit and will specify this as -1.
441 uint32_t event_dev_cap;
442 /**< Event device capabilities(RTE_EVENT_DEV_CAP_)*/
443 uint8_t max_single_link_event_port_queue_pairs;
444 /**< Maximum number of event ports and queues that are optimized for
445 * (and only capable of) single-link configurations supported by this
446 * device. These ports and queues are not accounted for in
447 * max_event_ports or max_event_queues.
452 * Retrieve the contextual information of an event device.
455 * The identifier of the device.
457 * @param[out] dev_info
458 * A pointer to a structure of type *rte_event_dev_info* to be filled with the
459 * contextual information of the device.
462 * - 0: Success, driver updates the contextual information of the event device
463 * - <0: Error code returned by the driver info get function.
467 rte_event_dev_info_get(uint8_t dev_id, struct rte_event_dev_info *dev_info);
470 * The count of ports.
472 #define RTE_EVENT_DEV_ATTR_PORT_COUNT 0
474 * The count of queues.
476 #define RTE_EVENT_DEV_ATTR_QUEUE_COUNT 1
478 * The status of the device, zero for stopped, non-zero for started.
480 #define RTE_EVENT_DEV_ATTR_STARTED 2
483 * Get an attribute from a device.
485 * @param dev_id Eventdev id
486 * @param attr_id The attribute ID to retrieve
487 * @param[out] attr_value A pointer that will be filled in with the attribute
488 * value if successful.
491 * - 0: Successfully retrieved attribute value
492 * - -EINVAL: Invalid device or *attr_id* provided, or *attr_value* is NULL
495 rte_event_dev_attr_get(uint8_t dev_id, uint32_t attr_id,
496 uint32_t *attr_value);
499 /* Event device configuration bitmap flags */
500 #define RTE_EVENT_DEV_CFG_PER_DEQUEUE_TIMEOUT (1ULL << 0)
501 /**< Override the global *dequeue_timeout_ns* and use per dequeue timeout in ns.
502 * @see rte_event_dequeue_timeout_ticks(), rte_event_dequeue_burst()
505 /** Event device configuration structure */
506 struct rte_event_dev_config {
507 uint32_t dequeue_timeout_ns;
508 /**< rte_event_dequeue_burst() timeout on this device.
509 * This value should be in the range of *min_dequeue_timeout_ns* and
510 * *max_dequeue_timeout_ns* which previously provided in
511 * rte_event_dev_info_get()
512 * The value 0 is allowed, in which case, default dequeue timeout used.
513 * @see RTE_EVENT_DEV_CFG_PER_DEQUEUE_TIMEOUT
515 int32_t nb_events_limit;
516 /**< In a *closed system* this field is the limit on maximum number of
517 * events that can be inflight in the eventdev at a given time. The
518 * limit is required to ensure that the finite space in a closed system
519 * is not overwhelmed. The value cannot exceed the *max_num_events*
520 * as provided by rte_event_dev_info_get().
521 * This value should be set to -1 for *open system*.
523 uint8_t nb_event_queues;
524 /**< Number of event queues to configure on this device.
525 * This value cannot exceed the *max_event_queues* which previously
526 * provided in rte_event_dev_info_get()
528 uint8_t nb_event_ports;
529 /**< Number of event ports to configure on this device.
530 * This value cannot exceed the *max_event_ports* which previously
531 * provided in rte_event_dev_info_get()
533 uint32_t nb_event_queue_flows;
534 /**< Number of flows for any event queue on this device.
535 * This value cannot exceed the *max_event_queue_flows* which previously
536 * provided in rte_event_dev_info_get()
538 uint32_t nb_event_port_dequeue_depth;
539 /**< Maximum number of events can be dequeued at a time from an
540 * event port by this device.
541 * This value cannot exceed the *max_event_port_dequeue_depth*
542 * which previously provided in rte_event_dev_info_get().
543 * Ignored when device is not RTE_EVENT_DEV_CAP_BURST_MODE capable.
544 * @see rte_event_port_setup()
546 uint32_t nb_event_port_enqueue_depth;
547 /**< Maximum number of events can be enqueued at a time from an
548 * event port by this device.
549 * This value cannot exceed the *max_event_port_enqueue_depth*
550 * which previously provided in rte_event_dev_info_get().
551 * Ignored when device is not RTE_EVENT_DEV_CAP_BURST_MODE capable.
552 * @see rte_event_port_setup()
554 uint32_t event_dev_cfg;
555 /**< Event device config flags(RTE_EVENT_DEV_CFG_)*/
556 uint8_t nb_single_link_event_port_queues;
557 /**< Number of event ports and queues that will be singly-linked to
558 * each other. These are a subset of the overall event ports and
559 * queues; this value cannot exceed *nb_event_ports* or
560 * *nb_event_queues*. If the device has ports and queues that are
561 * optimized for single-link usage, this field is a hint for how many
562 * to allocate; otherwise, regular event ports and queues can be used.
567 * Configure an event device.
569 * This function must be invoked first before any other function in the
570 * API. This function can also be re-invoked when a device is in the
573 * The caller may use rte_event_dev_info_get() to get the capability of each
574 * resources available for this event device.
577 * The identifier of the device to configure.
579 * The event device configuration structure.
582 * - 0: Success, device configured.
583 * - <0: Error code returned by the driver configuration function.
586 rte_event_dev_configure(uint8_t dev_id,
587 const struct rte_event_dev_config *dev_conf);
589 /* Event queue specific APIs */
591 /* Event queue configuration bitmap flags */
592 #define RTE_EVENT_QUEUE_CFG_ALL_TYPES (1ULL << 0)
593 /**< Allow ATOMIC,ORDERED,PARALLEL schedule type enqueue
595 * @see RTE_SCHED_TYPE_ORDERED, RTE_SCHED_TYPE_ATOMIC, RTE_SCHED_TYPE_PARALLEL
596 * @see rte_event_enqueue_burst()
598 #define RTE_EVENT_QUEUE_CFG_SINGLE_LINK (1ULL << 1)
599 /**< This event queue links only to a single event port.
601 * @see rte_event_port_setup(), rte_event_port_link()
604 /** Event queue configuration structure */
605 struct rte_event_queue_conf {
606 uint32_t nb_atomic_flows;
607 /**< The maximum number of active flows this queue can track at any
608 * given time. If the queue is configured for atomic scheduling (by
609 * applying the RTE_EVENT_QUEUE_CFG_ALL_TYPES flag to event_queue_cfg
610 * or RTE_SCHED_TYPE_ATOMIC flag to schedule_type), then the
611 * value must be in the range of [1, nb_event_queue_flows], which was
612 * previously provided in rte_event_dev_configure().
614 uint32_t nb_atomic_order_sequences;
615 /**< The maximum number of outstanding events waiting to be
616 * reordered by this queue. In other words, the number of entries in
617 * this queue’s reorder buffer.When the number of events in the
618 * reorder buffer reaches to *nb_atomic_order_sequences* then the
619 * scheduler cannot schedule the events from this queue and invalid
620 * event will be returned from dequeue until one or more entries are
622 * If the queue is configured for ordered scheduling (by applying the
623 * RTE_EVENT_QUEUE_CFG_ALL_TYPES flag to event_queue_cfg or
624 * RTE_SCHED_TYPE_ORDERED flag to schedule_type), then the value must
625 * be in the range of [1, nb_event_queue_flows], which was
626 * previously supplied to rte_event_dev_configure().
628 uint32_t event_queue_cfg;
629 /**< Queue cfg flags(EVENT_QUEUE_CFG_) */
630 uint8_t schedule_type;
631 /**< Queue schedule type(RTE_SCHED_TYPE_*).
632 * Valid when RTE_EVENT_QUEUE_CFG_ALL_TYPES bit is not set in
636 /**< Priority for this event queue relative to other event queues.
637 * The requested priority should in the range of
638 * [RTE_EVENT_DEV_PRIORITY_HIGHEST, RTE_EVENT_DEV_PRIORITY_LOWEST].
639 * The implementation shall normalize the requested priority to
640 * event device supported priority value.
641 * Valid when the device has RTE_EVENT_DEV_CAP_QUEUE_QOS capability
646 * Retrieve the default configuration information of an event queue designated
647 * by its *queue_id* from the event driver for an event device.
649 * This function intended to be used in conjunction with rte_event_queue_setup()
650 * where caller needs to set up the queue by overriding few default values.
653 * The identifier of the device.
655 * The index of the event queue to get the configuration information.
656 * The value must be in the range [0, nb_event_queues - 1]
657 * previously supplied to rte_event_dev_configure().
658 * @param[out] queue_conf
659 * The pointer to the default event queue configuration data.
661 * - 0: Success, driver updates the default event queue configuration data.
662 * - <0: Error code returned by the driver info get function.
664 * @see rte_event_queue_setup()
668 rte_event_queue_default_conf_get(uint8_t dev_id, uint8_t queue_id,
669 struct rte_event_queue_conf *queue_conf);
672 * Allocate and set up an event queue for an event device.
675 * The identifier of the device.
677 * The index of the event queue to setup. The value must be in the range
678 * [0, nb_event_queues - 1] previously supplied to rte_event_dev_configure().
680 * The pointer to the configuration data to be used for the event queue.
681 * NULL value is allowed, in which case default configuration used.
683 * @see rte_event_queue_default_conf_get()
686 * - 0: Success, event queue correctly set up.
687 * - <0: event queue configuration failed
690 rte_event_queue_setup(uint8_t dev_id, uint8_t queue_id,
691 const struct rte_event_queue_conf *queue_conf);
694 * The priority of the queue.
696 #define RTE_EVENT_QUEUE_ATTR_PRIORITY 0
698 * The number of atomic flows configured for the queue.
700 #define RTE_EVENT_QUEUE_ATTR_NB_ATOMIC_FLOWS 1
702 * The number of atomic order sequences configured for the queue.
704 #define RTE_EVENT_QUEUE_ATTR_NB_ATOMIC_ORDER_SEQUENCES 2
706 * The cfg flags for the queue.
708 #define RTE_EVENT_QUEUE_ATTR_EVENT_QUEUE_CFG 3
710 * The schedule type of the queue.
712 #define RTE_EVENT_QUEUE_ATTR_SCHEDULE_TYPE 4
714 * The weight of the queue.
716 #define RTE_EVENT_QUEUE_ATTR_WEIGHT 5
718 * Affinity of the queue.
720 #define RTE_EVENT_QUEUE_ATTR_AFFINITY 6
723 * Get an attribute from a queue.
730 * The attribute ID to retrieve
731 * @param[out] attr_value
732 * A pointer that will be filled in with the attribute value if successful
735 * - 0: Successfully returned value
736 * - -EINVAL: invalid device, queue or attr_id provided, or attr_value was
738 * - -EOVERFLOW: returned when attr_id is set to
739 * RTE_EVENT_QUEUE_ATTR_SCHEDULE_TYPE and event_queue_cfg is set to
740 * RTE_EVENT_QUEUE_CFG_ALL_TYPES
743 rte_event_queue_attr_get(uint8_t dev_id, uint8_t queue_id, uint32_t attr_id,
744 uint32_t *attr_value);
747 * Set an event queue attribute.
754 * The attribute ID to set
756 * The attribute value to set
759 * - 0: Successfully set attribute.
760 * - -EINVAL: invalid device, queue or attr_id.
761 * - -ENOTSUP: device does not support setting the event attribute.
762 * - <0: failed to set event queue attribute
766 rte_event_queue_attr_set(uint8_t dev_id, uint8_t queue_id, uint32_t attr_id,
767 uint64_t attr_value);
769 /* Event port specific APIs */
771 /* Event port configuration bitmap flags */
772 #define RTE_EVENT_PORT_CFG_DISABLE_IMPL_REL (1ULL << 0)
773 /**< Configure the port not to release outstanding events in
774 * rte_event_dev_dequeue_burst(). If set, all events received through
775 * the port must be explicitly released with RTE_EVENT_OP_RELEASE or
776 * RTE_EVENT_OP_FORWARD. Must be unset if the device is not
777 * RTE_EVENT_DEV_CAP_IMPLICIT_RELEASE_DISABLE capable.
779 #define RTE_EVENT_PORT_CFG_SINGLE_LINK (1ULL << 1)
780 /**< This event port links only to a single event queue.
782 * @see rte_event_port_setup(), rte_event_port_link()
784 #define RTE_EVENT_PORT_CFG_HINT_PRODUCER (1ULL << 2)
785 /**< Hint that this event port will primarily enqueue events to the system.
786 * A PMD can optimize its internal workings by assuming that this port is
787 * primarily going to enqueue NEW events.
789 * Note that this flag is only a hint, so PMDs must operate under the
790 * assumption that any port can enqueue an event with any type of op.
792 * @see rte_event_port_setup()
794 #define RTE_EVENT_PORT_CFG_HINT_CONSUMER (1ULL << 3)
795 /**< Hint that this event port will primarily dequeue events from the system.
796 * A PMD can optimize its internal workings by assuming that this port is
797 * primarily going to consume events, and not enqueue FORWARD or RELEASE
800 * Note that this flag is only a hint, so PMDs must operate under the
801 * assumption that any port can enqueue an event with any type of op.
803 * @see rte_event_port_setup()
805 #define RTE_EVENT_PORT_CFG_HINT_WORKER (1ULL << 4)
806 /**< Hint that this event port will primarily pass existing events through.
807 * A PMD can optimize its internal workings by assuming that this port is
808 * primarily going to FORWARD events, and not enqueue NEW or RELEASE events
811 * Note that this flag is only a hint, so PMDs must operate under the
812 * assumption that any port can enqueue an event with any type of op.
814 * @see rte_event_port_setup()
817 /** Event port configuration structure */
818 struct rte_event_port_conf {
819 int32_t new_event_threshold;
820 /**< A backpressure threshold for new event enqueues on this port.
821 * Use for *closed system* event dev where event capacity is limited,
822 * and cannot exceed the capacity of the event dev.
823 * Configuring ports with different thresholds can make higher priority
824 * traffic less likely to be backpressured.
825 * For example, a port used to inject NIC Rx packets into the event dev
826 * can have a lower threshold so as not to overwhelm the device,
827 * while ports used for worker pools can have a higher threshold.
828 * This value cannot exceed the *nb_events_limit*
829 * which was previously supplied to rte_event_dev_configure().
830 * This should be set to '-1' for *open system*.
832 uint16_t dequeue_depth;
833 /**< Configure number of bulk dequeues for this event port.
834 * This value cannot exceed the *nb_event_port_dequeue_depth*
835 * which previously supplied to rte_event_dev_configure().
836 * Ignored when device is not RTE_EVENT_DEV_CAP_BURST_MODE capable.
838 uint16_t enqueue_depth;
839 /**< Configure number of bulk enqueues for this event port.
840 * This value cannot exceed the *nb_event_port_enqueue_depth*
841 * which previously supplied to rte_event_dev_configure().
842 * Ignored when device is not RTE_EVENT_DEV_CAP_BURST_MODE capable.
844 uint32_t event_port_cfg; /**< Port cfg flags(EVENT_PORT_CFG_) */
848 * Retrieve the default configuration information of an event port designated
849 * by its *port_id* from the event driver for an event device.
851 * This function intended to be used in conjunction with rte_event_port_setup()
852 * where caller needs to set up the port by overriding few default values.
855 * The identifier of the device.
857 * The index of the event port to get the configuration information.
858 * The value must be in the range [0, nb_event_ports - 1]
859 * previously supplied to rte_event_dev_configure().
860 * @param[out] port_conf
861 * The pointer to the default event port configuration data
863 * - 0: Success, driver updates the default event port configuration data.
864 * - <0: Error code returned by the driver info get function.
866 * @see rte_event_port_setup()
870 rte_event_port_default_conf_get(uint8_t dev_id, uint8_t port_id,
871 struct rte_event_port_conf *port_conf);
874 * Allocate and set up an event port for an event device.
877 * The identifier of the device.
879 * The index of the event port to setup. The value must be in the range
880 * [0, nb_event_ports - 1] previously supplied to rte_event_dev_configure().
882 * The pointer to the configuration data to be used for the queue.
883 * NULL value is allowed, in which case default configuration used.
885 * @see rte_event_port_default_conf_get()
888 * - 0: Success, event port correctly set up.
889 * - <0: Port configuration failed
890 * - (-EDQUOT) Quota exceeded(Application tried to link the queue configured
891 * with RTE_EVENT_QUEUE_CFG_SINGLE_LINK to more than one event ports)
894 rte_event_port_setup(uint8_t dev_id, uint8_t port_id,
895 const struct rte_event_port_conf *port_conf);
897 typedef void (*rte_eventdev_port_flush_t)(uint8_t dev_id,
898 struct rte_event event, void *arg);
899 /**< Callback function prototype that can be passed during
900 * rte_event_port_release(), invoked once per a released event.
904 * Quiesce any core specific resources consumed by the event port.
906 * Event ports are generally coupled with lcores, and a given Hardware
907 * implementation might require the PMD to store port specific data in the
909 * When the application decides to migrate the event port to another lcore
910 * or teardown the current lcore it may to call `rte_event_port_quiesce`
911 * to make sure that all the data associated with the event port are released
912 * from the lcore, this might also include any prefetched events.
913 * While releasing the event port from the lcore, this function calls the
914 * user-provided flush callback once per event.
916 * @note Invocation of this API does not affect the existing port configuration.
919 * The identifier of the device.
921 * The index of the event port to setup. The value must be in the range
922 * [0, nb_event_ports - 1] previously supplied to rte_event_dev_configure().
924 * Callback function invoked once per flushed event.
926 * Argument supplied to callback.
930 rte_event_port_quiesce(uint8_t dev_id, uint8_t port_id,
931 rte_eventdev_port_flush_t release_cb, void *args);
934 * The queue depth of the port on the enqueue side
936 #define RTE_EVENT_PORT_ATTR_ENQ_DEPTH 0
938 * The queue depth of the port on the dequeue side
940 #define RTE_EVENT_PORT_ATTR_DEQ_DEPTH 1
942 * The new event threshold of the port
944 #define RTE_EVENT_PORT_ATTR_NEW_EVENT_THRESHOLD 2
946 * The implicit release disable attribute of the port
948 #define RTE_EVENT_PORT_ATTR_IMPLICIT_RELEASE_DISABLE 3
951 * Get an attribute from a port.
958 * The attribute ID to retrieve
959 * @param[out] attr_value
960 * A pointer that will be filled in with the attribute value if successful
963 * - 0: Successfully returned value
964 * - (-EINVAL) Invalid device, port or attr_id, or attr_value was NULL
967 rte_event_port_attr_get(uint8_t dev_id, uint8_t port_id, uint32_t attr_id,
968 uint32_t *attr_value);
971 * Start an event device.
973 * The device start step is the last one and consists of setting the event
974 * queues to start accepting the events and schedules to event ports.
976 * On success, all basic functions exported by the API (event enqueue,
977 * event dequeue and so on) can be invoked.
980 * Event device identifier
982 * - 0: Success, device started.
983 * - -ESTALE : Not all ports of the device are configured
984 * - -ENOLINK: Not all queues are linked, which could lead to deadlock.
987 rte_event_dev_start(uint8_t dev_id);
990 * Stop an event device.
992 * This function causes all queued events to be drained, including those
993 * residing in event ports. While draining events out of the device, this
994 * function calls the user-provided flush callback (if one was registered) once
997 * The device can be restarted with a call to rte_event_dev_start(). Threads
998 * that continue to enqueue/dequeue while the device is stopped, or being
999 * stopped, will result in undefined behavior. This includes event adapters,
1000 * which must be stopped prior to stopping the eventdev.
1003 * Event device identifier.
1005 * @see rte_event_dev_stop_flush_callback_register()
1008 rte_event_dev_stop(uint8_t dev_id);
1010 typedef void (*eventdev_stop_flush_t)(uint8_t dev_id, struct rte_event event,
1012 /**< Callback function called during rte_event_dev_stop(), invoked once per
1017 * Registers a callback function to be invoked during rte_event_dev_stop() for
1018 * each flushed event. This function can be used to properly dispose of queued
1019 * events, for example events containing memory pointers.
1021 * The callback function is only registered for the calling process. The
1022 * callback function must be registered in every process that can call
1023 * rte_event_dev_stop().
1025 * To unregister a callback, call this function with a NULL callback pointer.
1028 * The identifier of the device.
1030 * Callback function invoked once per flushed event.
1032 * Argument supplied to callback.
1036 * - -EINVAL if *dev_id* is invalid
1038 * @see rte_event_dev_stop()
1041 rte_event_dev_stop_flush_callback_register(uint8_t dev_id,
1042 eventdev_stop_flush_t callback, void *userdata);
1045 * Close an event device. The device cannot be restarted!
1048 * Event device identifier
1051 * - 0 on successfully closing device
1052 * - <0 on failure to close device
1053 * - (-EAGAIN) if device is busy
1056 rte_event_dev_close(uint8_t dev_id);
1059 * Event vector structure.
1061 struct rte_event_vector {
1063 /**< Number of elements in this event vector. */
1065 /**< Reserved for future use */
1066 uint16_t attr_valid : 1;
1067 /**< Indicates that the below union attributes have valid information.
1070 /* Used by Rx/Tx adapter.
1071 * Indicates that all the elements in this vector belong to the
1072 * same port and queue pair when originating from Rx adapter,
1073 * valid only when event type is ETHDEV_VECTOR or
1074 * ETH_RX_ADAPTER_VECTOR.
1075 * Can also be used to indicate the Tx adapter the destination
1076 * port and queue of the mbufs in the vector
1080 /* Ethernet device port id. */
1082 /* Ethernet device queue id. */
1085 /**< Union to hold common attributes of the vector array. */
1086 uint64_t impl_opaque;
1088 /* empty structures do not have zero size in C++ leading to compilation errors
1089 * with clang about structure having different sizes in C and C++.
1090 * Since these are all zero-sized arrays, we can omit the "union" wrapper for
1091 * C++ builds, removing the warning.
1094 /**< Implementation specific opaque value.
1095 * An implementation may use this field to hold implementation specific
1096 * value to share between dequeue and enqueue operation.
1097 * The application should not modify this field.
1101 struct rte_mbuf *mbufs[0];
1105 } __rte_aligned(16);
1107 /**< Start of the vector array union. Depending upon the event type the
1108 * vector array can be an array of mbufs or pointers or opaque u64
1111 } __rte_aligned(16);
1113 /* Scheduler type definitions */
1114 #define RTE_SCHED_TYPE_ORDERED 0
1115 /**< Ordered scheduling
1117 * Events from an ordered flow of an event queue can be scheduled to multiple
1118 * ports for concurrent processing while maintaining the original event order.
1119 * This scheme enables the user to achieve high single flow throughput by
1120 * avoiding SW synchronization for ordering between ports which bound to cores.
1122 * The source flow ordering from an event queue is maintained when events are
1123 * enqueued to their destination queue within the same ordered flow context.
1124 * An event port holds the context until application call
1125 * rte_event_dequeue_burst() from the same port, which implicitly releases
1127 * User may allow the scheduler to release the context earlier than that
1128 * by invoking rte_event_enqueue_burst() with RTE_EVENT_OP_RELEASE operation.
1130 * Events from the source queue appear in their original order when dequeued
1131 * from a destination queue.
1132 * Event ordering is based on the received event(s), but also other
1133 * (newly allocated or stored) events are ordered when enqueued within the same
1134 * ordered context. Events not enqueued (e.g. released or stored) within the
1135 * context are considered missing from reordering and are skipped at this time
1136 * (but can be ordered again within another context).
1138 * @see rte_event_queue_setup(), rte_event_dequeue_burst(), RTE_EVENT_OP_RELEASE
1141 #define RTE_SCHED_TYPE_ATOMIC 1
1142 /**< Atomic scheduling
1144 * Events from an atomic flow of an event queue can be scheduled only to a
1145 * single port at a time. The port is guaranteed to have exclusive (atomic)
1146 * access to the associated flow context, which enables the user to avoid SW
1147 * synchronization. Atomic flows also help to maintain event ordering
1148 * since only one port at a time can process events from a flow of an
1151 * The atomic queue synchronization context is dedicated to the port until
1152 * application call rte_event_dequeue_burst() from the same port,
1153 * which implicitly releases the context. User may allow the scheduler to
1154 * release the context earlier than that by invoking rte_event_enqueue_burst()
1155 * with RTE_EVENT_OP_RELEASE operation.
1157 * @see rte_event_queue_setup(), rte_event_dequeue_burst(), RTE_EVENT_OP_RELEASE
1160 #define RTE_SCHED_TYPE_PARALLEL 2
1161 /**< Parallel scheduling
1163 * The scheduler performs priority scheduling, load balancing, etc. functions
1164 * but does not provide additional event synchronization or ordering.
1165 * It is free to schedule events from a single parallel flow of an event queue
1166 * to multiple events ports for concurrent processing.
1167 * The application is responsible for flow context synchronization and
1168 * event ordering (SW synchronization).
1170 * @see rte_event_queue_setup(), rte_event_dequeue_burst()
1173 /* Event types to classify the event source */
1174 #define RTE_EVENT_TYPE_ETHDEV 0x0
1175 /**< The event generated from ethdev subsystem */
1176 #define RTE_EVENT_TYPE_CRYPTODEV 0x1
1177 /**< The event generated from crypodev subsystem */
1178 #define RTE_EVENT_TYPE_TIMER 0x2
1179 /**< The event generated from event timer adapter */
1180 #define RTE_EVENT_TYPE_CPU 0x3
1181 /**< The event generated from cpu for pipelining.
1182 * Application may use *sub_event_type* to further classify the event
1184 #define RTE_EVENT_TYPE_ETH_RX_ADAPTER 0x4
1185 /**< The event generated from event eth Rx adapter */
1186 #define RTE_EVENT_TYPE_VECTOR 0x8
1187 /**< Indicates that event is a vector.
1188 * All vector event types should be a logical OR of EVENT_TYPE_VECTOR.
1189 * This simplifies the pipeline design as one can split processing the events
1190 * between vector events and normal event across event types.
1192 * if (ev.event_type & RTE_EVENT_TYPE_VECTOR) {
1193 * // Classify and handle vector event.
1195 * // Classify and handle event.
1198 #define RTE_EVENT_TYPE_ETHDEV_VECTOR \
1199 (RTE_EVENT_TYPE_VECTOR | RTE_EVENT_TYPE_ETHDEV)
1200 /**< The event vector generated from ethdev subsystem */
1201 #define RTE_EVENT_TYPE_CPU_VECTOR (RTE_EVENT_TYPE_VECTOR | RTE_EVENT_TYPE_CPU)
1202 /**< The event vector generated from cpu for pipelining. */
1203 #define RTE_EVENT_TYPE_ETH_RX_ADAPTER_VECTOR \
1204 (RTE_EVENT_TYPE_VECTOR | RTE_EVENT_TYPE_ETH_RX_ADAPTER)
1205 /**< The event vector generated from eth Rx adapter. */
1207 #define RTE_EVENT_TYPE_MAX 0x10
1208 /**< Maximum number of event types */
1210 /* Event enqueue operations */
1211 #define RTE_EVENT_OP_NEW 0
1212 /**< The event producers use this operation to inject a new event to the
1215 #define RTE_EVENT_OP_FORWARD 1
1216 /**< The CPU use this operation to forward the event to different event queue or
1217 * change to new application specific flow or schedule type to enable
1220 * This operation must only be enqueued to the same port that the
1221 * event to be forwarded was dequeued from.
1223 #define RTE_EVENT_OP_RELEASE 2
1224 /**< Release the flow context associated with the schedule type.
1226 * If current flow's scheduler type method is *RTE_SCHED_TYPE_ATOMIC*
1227 * then this function hints the scheduler that the user has completed critical
1228 * section processing in the current atomic context.
1229 * The scheduler is now allowed to schedule events from the same flow from
1230 * an event queue to another port. However, the context may be still held
1231 * until the next rte_event_dequeue_burst() call, this call allows but does not
1232 * force the scheduler to release the context early.
1234 * Early atomic context release may increase parallelism and thus system
1235 * performance, but the user needs to design carefully the split into critical
1236 * vs non-critical sections.
1238 * If current flow's scheduler type method is *RTE_SCHED_TYPE_ORDERED*
1239 * then this function hints the scheduler that the user has done all that need
1240 * to maintain event order in the current ordered context.
1241 * The scheduler is allowed to release the ordered context of this port and
1242 * avoid reordering any following enqueues.
1244 * Early ordered context release may increase parallelism and thus system
1247 * If current flow's scheduler type method is *RTE_SCHED_TYPE_PARALLEL*
1248 * or no scheduling context is held then this function may be an NOOP,
1249 * depending on the implementation.
1251 * This operation must only be enqueued to the same port that the
1252 * event to be released was dequeued from.
1257 * The generic *rte_event* structure to hold the event attributes
1258 * for dequeue and enqueue operation
1265 /** Event attributes for dequeue or enqueue operation */
1267 uint32_t flow_id:20;
1268 /**< Targeted flow identifier for the enqueue and
1269 * dequeue operation.
1270 * The value must be in the range of
1271 * [0, nb_event_queue_flows - 1] which
1272 * previously supplied to rte_event_dev_configure().
1274 uint32_t sub_event_type:8;
1275 /**< Sub-event types based on the event source.
1276 * @see RTE_EVENT_TYPE_CPU
1278 uint32_t event_type:4;
1279 /**< Event type to classify the event source.
1280 * @see RTE_EVENT_TYPE_ETHDEV, (RTE_EVENT_TYPE_*)
1283 /**< The type of event enqueue operation - new/forward/
1284 * etc.This field is not preserved across an instance
1285 * and is undefined on dequeue.
1286 * @see RTE_EVENT_OP_NEW, (RTE_EVENT_OP_*)
1289 /**< Reserved for future use */
1290 uint8_t sched_type:2;
1291 /**< Scheduler synchronization type (RTE_SCHED_TYPE_*)
1292 * associated with flow id on a given event queue
1293 * for the enqueue and dequeue operation.
1296 /**< Targeted event queue identifier for the enqueue or
1297 * dequeue operation.
1298 * The value must be in the range of
1299 * [0, nb_event_queues - 1] which previously supplied to
1300 * rte_event_dev_configure().
1303 /**< Event priority relative to other events in the
1304 * event queue. The requested priority should in the
1305 * range of [RTE_EVENT_DEV_PRIORITY_HIGHEST,
1306 * RTE_EVENT_DEV_PRIORITY_LOWEST].
1307 * The implementation shall normalize the requested
1308 * priority to supported priority value.
1309 * Valid when the device has
1310 * RTE_EVENT_DEV_CAP_EVENT_QOS capability.
1312 uint8_t impl_opaque;
1313 /**< Implementation specific opaque value.
1314 * An implementation may use this field to hold
1315 * implementation specific value to share between
1316 * dequeue and enqueue operation.
1317 * The application should not modify this field.
1324 /**< Opaque 64-bit value */
1326 /**< Opaque event pointer */
1327 struct rte_mbuf *mbuf;
1328 /**< mbuf pointer if dequeued event is associated with mbuf */
1329 struct rte_event_vector *vec;
1330 /**< Event vector pointer. */
1334 /* Ethdev Rx adapter capability bitmap flags */
1335 #define RTE_EVENT_ETH_RX_ADAPTER_CAP_INTERNAL_PORT 0x1
1336 /**< This flag is sent when the packet transfer mechanism is in HW.
1337 * Ethdev can send packets to the event device using internal event port.
1339 #define RTE_EVENT_ETH_RX_ADAPTER_CAP_MULTI_EVENTQ 0x2
1340 /**< Adapter supports multiple event queues per ethdev. Every ethdev
1341 * Rx queue can be connected to a unique event queue.
1343 #define RTE_EVENT_ETH_RX_ADAPTER_CAP_OVERRIDE_FLOW_ID 0x4
1344 /**< The application can override the adapter generated flow ID in the
1345 * event. This flow ID can be specified when adding an ethdev Rx queue
1346 * to the adapter using the ev.flow_id member.
1347 * @see struct rte_event_eth_rx_adapter_queue_conf::ev
1348 * @see struct rte_event_eth_rx_adapter_queue_conf::rx_queue_flags
1350 #define RTE_EVENT_ETH_RX_ADAPTER_CAP_EVENT_VECTOR 0x8
1351 /**< Adapter supports event vectorization per ethdev. */
1354 * Retrieve the event device's ethdev Rx adapter capabilities for the
1355 * specified ethernet port
1358 * The identifier of the device.
1360 * @param eth_port_id
1361 * The identifier of the ethernet device.
1364 * A pointer to memory filled with Rx event adapter capabilities.
1367 * - 0: Success, driver provides Rx event adapter capabilities for the
1369 * - <0: Error code returned by the driver function.
1373 rte_event_eth_rx_adapter_caps_get(uint8_t dev_id, uint16_t eth_port_id,
1376 #define RTE_EVENT_TIMER_ADAPTER_CAP_INTERNAL_PORT (1ULL << 0)
1377 /**< This flag is set when the timer mechanism is in HW. */
1379 #define RTE_EVENT_TIMER_ADAPTER_CAP_PERIODIC (1ULL << 1)
1380 /**< This flag is set if periodic mode is supported. */
1383 * Retrieve the event device's timer adapter capabilities.
1386 * The identifier of the device.
1389 * A pointer to memory to be filled with event timer adapter capabilities.
1392 * - 0: Success, driver provided event timer adapter capabilities.
1393 * - <0: Error code returned by the driver function.
1396 rte_event_timer_adapter_caps_get(uint8_t dev_id, uint32_t *caps);
1398 /* Crypto adapter capability bitmap flag */
1399 #define RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_NEW 0x1
1400 /**< Flag indicates HW is capable of generating events in
1401 * RTE_EVENT_OP_NEW enqueue operation. Cryptodev will send
1402 * packets to the event device as new events using an internal
1406 #define RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_FWD 0x2
1407 /**< Flag indicates HW is capable of generating events in
1408 * RTE_EVENT_OP_FORWARD enqueue operation. Cryptodev will send
1409 * packets to the event device as forwarded event using an
1410 * internal event port.
1413 #define RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_QP_EV_BIND 0x4
1414 /**< Flag indicates HW is capable of mapping crypto queue pair to
1418 #define RTE_EVENT_CRYPTO_ADAPTER_CAP_SESSION_PRIVATE_DATA 0x8
1419 /**< Flag indicates HW/SW supports a mechanism to store and retrieve
1420 * the private data information along with the crypto session.
1424 * Retrieve the event device's crypto adapter capabilities for the
1425 * specified cryptodev device
1428 * The identifier of the device.
1431 * The identifier of the cryptodev device.
1434 * A pointer to memory filled with event adapter capabilities.
1435 * It is expected to be pre-allocated & initialized by caller.
1438 * - 0: Success, driver provides event adapter capabilities for the
1440 * - <0: Error code returned by the driver function.
1444 rte_event_crypto_adapter_caps_get(uint8_t dev_id, uint8_t cdev_id,
1447 /* Ethdev Tx adapter capability bitmap flags */
1448 #define RTE_EVENT_ETH_TX_ADAPTER_CAP_INTERNAL_PORT 0x1
1449 /**< This flag is sent when the PMD supports a packet transmit callback
1451 #define RTE_EVENT_ETH_TX_ADAPTER_CAP_EVENT_VECTOR 0x2
1452 /**< Indicates that the Tx adapter is capable of handling event vector of
1457 * Retrieve the event device's eth Tx adapter capabilities
1460 * The identifier of the device.
1462 * @param eth_port_id
1463 * The identifier of the ethernet device.
1466 * A pointer to memory filled with eth Tx adapter capabilities.
1469 * - 0: Success, driver provides eth Tx adapter capabilities.
1470 * - <0: Error code returned by the driver function.
1474 rte_event_eth_tx_adapter_caps_get(uint8_t dev_id, uint16_t eth_port_id,
1478 * Converts nanoseconds to *timeout_ticks* value for rte_event_dequeue_burst()
1480 * If the device is configured with RTE_EVENT_DEV_CFG_PER_DEQUEUE_TIMEOUT flag
1481 * then application can use this function to convert timeout value in
1482 * nanoseconds to implementations specific timeout value supplied in
1483 * rte_event_dequeue_burst()
1486 * The identifier of the device.
1488 * Wait time in nanosecond
1489 * @param[out] timeout_ticks
1490 * Value for the *timeout_ticks* parameter in rte_event_dequeue_burst()
1494 * - -ENOTSUP if the device doesn't support timeouts
1495 * - -EINVAL if *dev_id* is invalid or *timeout_ticks* is NULL
1496 * - other values < 0 on failure.
1498 * @see rte_event_dequeue_burst(), RTE_EVENT_DEV_CFG_PER_DEQUEUE_TIMEOUT
1499 * @see rte_event_dev_configure()
1503 rte_event_dequeue_timeout_ticks(uint8_t dev_id, uint64_t ns,
1504 uint64_t *timeout_ticks);
1507 * Link multiple source event queues supplied in *queues* to the destination
1508 * event port designated by its *port_id* with associated service priority
1509 * supplied in *priorities* on the event device designated by its *dev_id*.
1511 * The link establishment shall enable the event port *port_id* from
1512 * receiving events from the specified event queue(s) supplied in *queues*
1514 * An event queue may link to one or more event ports.
1515 * The number of links can be established from an event queue to event port is
1516 * implementation defined.
1518 * Event queue(s) to event port link establishment can be changed at runtime
1519 * without re-configuring the device to support scaling and to reduce the
1520 * latency of critical work by establishing the link with more event ports
1524 * The identifier of the device.
1527 * Event port identifier to select the destination port to link.
1530 * Points to an array of *nb_links* event queues to be linked
1531 * to the event port.
1532 * NULL value is allowed, in which case this function links all the configured
1533 * event queues *nb_event_queues* which previously supplied to
1534 * rte_event_dev_configure() to the event port *port_id*
1537 * Points to an array of *nb_links* service priorities associated with each
1538 * event queue link to event port.
1539 * The priority defines the event port's servicing priority for
1540 * event queue, which may be ignored by an implementation.
1541 * The requested priority should in the range of
1542 * [RTE_EVENT_DEV_PRIORITY_HIGHEST, RTE_EVENT_DEV_PRIORITY_LOWEST].
1543 * The implementation shall normalize the requested priority to
1544 * implementation supported priority value.
1545 * NULL value is allowed, in which case this function links the event queues
1546 * with RTE_EVENT_DEV_PRIORITY_NORMAL servicing priority
1549 * The number of links to establish. This parameter is ignored if queues is
1553 * The number of links actually established. The return value can be less than
1554 * the value of the *nb_links* parameter when the implementation has the
1555 * limitation on specific queue to port link establishment or if invalid
1556 * parameters are specified in *queues*
1557 * If the return value is less than *nb_links*, the remaining links at the end
1558 * of link[] are not established, and the caller has to take care of them.
1559 * If return value is less than *nb_links* then implementation shall update the
1560 * rte_errno accordingly, Possible rte_errno values are
1561 * (EDQUOT) Quota exceeded(Application tried to link the queue configured with
1562 * RTE_EVENT_QUEUE_CFG_SINGLE_LINK to more than one event ports)
1563 * (EINVAL) Invalid parameter
1567 rte_event_port_link(uint8_t dev_id, uint8_t port_id,
1568 const uint8_t queues[], const uint8_t priorities[],
1572 * Unlink multiple source event queues supplied in *queues* from the destination
1573 * event port designated by its *port_id* on the event device designated
1576 * The unlink call issues an async request to disable the event port *port_id*
1577 * from receiving events from the specified event queue *queue_id*.
1578 * Event queue(s) to event port unlink establishment can be changed at runtime
1579 * without re-configuring the device.
1581 * @see rte_event_port_unlinks_in_progress() to poll for completed unlinks.
1584 * The identifier of the device.
1587 * Event port identifier to select the destination port to unlink.
1590 * Points to an array of *nb_unlinks* event queues to be unlinked
1591 * from the event port.
1592 * NULL value is allowed, in which case this function unlinks all the
1593 * event queue(s) from the event port *port_id*.
1596 * The number of unlinks to establish. This parameter is ignored if queues is
1600 * The number of unlinks successfully requested. The return value can be less
1601 * than the value of the *nb_unlinks* parameter when the implementation has the
1602 * limitation on specific queue to port unlink establishment or
1603 * if invalid parameters are specified.
1604 * If the return value is less than *nb_unlinks*, the remaining queues at the
1605 * end of queues[] are not unlinked, and the caller has to take care of them.
1606 * If return value is less than *nb_unlinks* then implementation shall update
1607 * the rte_errno accordingly, Possible rte_errno values are
1608 * (EINVAL) Invalid parameter
1611 rte_event_port_unlink(uint8_t dev_id, uint8_t port_id,
1612 uint8_t queues[], uint16_t nb_unlinks);
1615 * Returns the number of unlinks in progress.
1617 * This function provides the application with a method to detect when an
1618 * unlink has been completed by the implementation.
1620 * @see rte_event_port_unlink() to issue unlink requests.
1623 * The identifier of the device.
1626 * Event port identifier to select port to check for unlinks in progress.
1629 * The number of unlinks that are in progress. A return of zero indicates that
1630 * there are no outstanding unlink requests. A positive return value indicates
1631 * the number of unlinks that are in progress, but are not yet complete.
1632 * A negative return value indicates an error, -EINVAL indicates an invalid
1633 * parameter passed for *dev_id* or *port_id*.
1636 rte_event_port_unlinks_in_progress(uint8_t dev_id, uint8_t port_id);
1639 * Retrieve the list of source event queues and its associated service priority
1640 * linked to the destination event port designated by its *port_id*
1641 * on the event device designated by its *dev_id*.
1644 * The identifier of the device.
1647 * Event port identifier.
1649 * @param[out] queues
1650 * Points to an array of *queues* for output.
1651 * The caller has to allocate *RTE_EVENT_MAX_QUEUES_PER_DEV* bytes to
1652 * store the event queue(s) linked with event port *port_id*
1654 * @param[out] priorities
1655 * Points to an array of *priorities* for output.
1656 * The caller has to allocate *RTE_EVENT_MAX_QUEUES_PER_DEV* bytes to
1657 * store the service priority associated with each event queue linked
1660 * The number of links established on the event port designated by its
1666 rte_event_port_links_get(uint8_t dev_id, uint8_t port_id,
1667 uint8_t queues[], uint8_t priorities[]);
1670 * Retrieve the service ID of the event dev. If the adapter doesn't use
1671 * a rte_service function, this function returns -ESRCH.
1674 * The identifier of the device.
1676 * @param [out] service_id
1677 * A pointer to a uint32_t, to be filled in with the service id.
1681 * - <0: Error code on failure, if the event dev doesn't use a rte_service
1682 * function, this function returns -ESRCH.
1685 rte_event_dev_service_id_get(uint8_t dev_id, uint32_t *service_id);
1688 * Dump internal information about *dev_id* to the FILE* provided in *f*.
1691 * The identifier of the device.
1694 * A pointer to a file for output
1701 rte_event_dev_dump(uint8_t dev_id, FILE *f);
1703 /** Maximum name length for extended statistics counters */
1704 #define RTE_EVENT_DEV_XSTATS_NAME_SIZE 64
1707 * Selects the component of the eventdev to retrieve statistics from.
1709 enum rte_event_dev_xstats_mode {
1710 RTE_EVENT_DEV_XSTATS_DEVICE,
1711 RTE_EVENT_DEV_XSTATS_PORT,
1712 RTE_EVENT_DEV_XSTATS_QUEUE,
1716 * A name-key lookup element for extended statistics.
1718 * This structure is used to map between names and ID numbers
1719 * for extended ethdev statistics.
1721 struct rte_event_dev_xstats_name {
1722 char name[RTE_EVENT_DEV_XSTATS_NAME_SIZE];
1726 * Retrieve names of extended statistics of an event device.
1729 * The identifier of the event device.
1731 * The mode of statistics to retrieve. Choices include the device statistics,
1732 * port statistics or queue statistics.
1733 * @param queue_port_id
1734 * Used to specify the port or queue number in queue or port mode, and is
1735 * ignored in device mode.
1736 * @param[out] xstats_names
1737 * Block of memory to insert names into. Must be at least size in capacity.
1738 * If set to NULL, function returns required capacity.
1740 * Block of memory to insert ids into. Must be at least size in capacity.
1741 * If set to NULL, function returns required capacity. The id values returned
1742 * can be passed to *rte_event_dev_xstats_get* to select statistics.
1744 * Capacity of xstats_names (number of names).
1746 * - positive value lower or equal to size: success. The return value
1747 * is the number of entries filled in the stats table.
1748 * - positive value higher than size: error, the given statistics table
1749 * is too small. The return value corresponds to the size that should
1750 * be given to succeed. The entries in the table are not valid and
1751 * shall not be used by the caller.
1752 * - negative value on error:
1753 * -ENODEV for invalid *dev_id*
1754 * -EINVAL for invalid mode, queue port or id parameters
1755 * -ENOTSUP if the device doesn't support this function.
1758 rte_event_dev_xstats_names_get(uint8_t dev_id,
1759 enum rte_event_dev_xstats_mode mode,
1760 uint8_t queue_port_id,
1761 struct rte_event_dev_xstats_name *xstats_names,
1766 * Retrieve extended statistics of an event device.
1769 * The identifier of the device.
1771 * The mode of statistics to retrieve. Choices include the device statistics,
1772 * port statistics or queue statistics.
1773 * @param queue_port_id
1774 * Used to specify the port or queue number in queue or port mode, and is
1775 * ignored in device mode.
1777 * The id numbers of the stats to get. The ids can be got from the stat
1778 * position in the stat list from rte_event_dev_get_xstats_names(), or
1779 * by using rte_event_dev_xstats_by_name_get().
1780 * @param[out] values
1781 * The values for each stats request by ID.
1783 * The number of stats requested
1785 * - positive value: number of stat entries filled into the values array
1786 * - negative value on error:
1787 * -ENODEV for invalid *dev_id*
1788 * -EINVAL for invalid mode, queue port or id parameters
1789 * -ENOTSUP if the device doesn't support this function.
1792 rte_event_dev_xstats_get(uint8_t dev_id,
1793 enum rte_event_dev_xstats_mode mode,
1794 uint8_t queue_port_id,
1795 const unsigned int ids[],
1796 uint64_t values[], unsigned int n);
1799 * Retrieve the value of a single stat by requesting it by name.
1802 * The identifier of the device
1804 * The stat name to retrieve
1806 * If non-NULL, the numerical id of the stat will be returned, so that further
1807 * requests for the stat can be got using rte_event_dev_xstats_get, which will
1808 * be faster as it doesn't need to scan a list of names for the stat.
1809 * If the stat cannot be found, the id returned will be (unsigned)-1.
1811 * - positive value or zero: the stat value
1812 * - negative value: -EINVAL if stat not found, -ENOTSUP if not supported.
1815 rte_event_dev_xstats_by_name_get(uint8_t dev_id, const char *name,
1819 * Reset the values of the xstats of the selected component in the device.
1822 * The identifier of the device
1824 * The mode of the statistics to reset. Choose from device, queue or port.
1825 * @param queue_port_id
1826 * The queue or port to reset. 0 and positive values select ports and queues,
1827 * while -1 indicates all ports or queues.
1829 * Selects specific statistics to be reset. When NULL, all statistics selected
1830 * by *mode* will be reset. If non-NULL, must point to array of at least
1833 * The number of ids available from the *ids* array. Ignored when ids is NULL.
1835 * - zero: successfully reset the statistics to zero
1836 * - negative value: -EINVAL invalid parameters, -ENOTSUP if not supported.
1839 rte_event_dev_xstats_reset(uint8_t dev_id,
1840 enum rte_event_dev_xstats_mode mode,
1841 int16_t queue_port_id,
1842 const uint32_t ids[],
1846 * Trigger the eventdev self test.
1849 * The identifier of the device
1851 * - 0: Selftest successful
1852 * - -ENOTSUP if the device doesn't support selftest
1853 * - other values < 0 on failure.
1855 int rte_event_dev_selftest(uint8_t dev_id);
1858 * Get the memory required per event vector based on the number of elements per
1860 * This should be used to create the mempool that holds the event vectors.
1863 * The name of the vector pool.
1865 * The number of elements in the mbuf pool.
1867 * Size of the per-core object cache. See rte_mempool_create() for
1870 * The number of elements that a single event vector should be able to hold.
1872 * The socket identifier where the memory should be allocated. The
1873 * value can be *SOCKET_ID_ANY* if there is no NUMA constraint for the
1877 * The pointer to the newly allocated mempool, on success. NULL on error
1878 * with rte_errno set appropriately. Possible rte_errno values include:
1879 * - E_RTE_NO_CONFIG - function could not get pointer to rte_config structure
1880 * - E_RTE_SECONDARY - function was called from a secondary process instance
1881 * - EINVAL - cache size provided is too large, or priv_size is not aligned.
1882 * - ENOSPC - the maximum number of memzones has already been allocated
1883 * - EEXIST - a memzone with the same name already exists
1884 * - ENOMEM - no appropriate memory area found in which to create memzone
1885 * - ENAMETOOLONG - mempool name requested is too long.
1887 struct rte_mempool *
1888 rte_event_vector_pool_create(const char *name, unsigned int n,
1889 unsigned int cache_size, uint16_t nb_elem,
1892 #include <rte_eventdev_core.h>
1894 static __rte_always_inline uint16_t
1895 __rte_event_enqueue_burst(uint8_t dev_id, uint8_t port_id,
1896 const struct rte_event ev[], uint16_t nb_events,
1897 const event_enqueue_burst_t fn)
1899 const struct rte_event_fp_ops *fp_ops;
1902 fp_ops = &rte_event_fp_ops[dev_id];
1903 port = fp_ops->data[port_id];
1904 #ifdef RTE_LIBRTE_EVENTDEV_DEBUG
1905 if (dev_id >= RTE_EVENT_MAX_DEVS ||
1906 port_id >= RTE_EVENT_MAX_PORTS_PER_DEV) {
1916 rte_eventdev_trace_enq_burst(dev_id, port_id, ev, nb_events, (void *)fn);
1918 * Allow zero cost non burst mode routine invocation if application
1919 * requests nb_events as const one
1922 return (fp_ops->enqueue)(port, ev);
1924 return fn(port, ev, nb_events);
1928 * Enqueue a burst of events objects or an event object supplied in *rte_event*
1929 * structure on an event device designated by its *dev_id* through the event
1930 * port specified by *port_id*. Each event object specifies the event queue on
1931 * which it will be enqueued.
1933 * The *nb_events* parameter is the number of event objects to enqueue which are
1934 * supplied in the *ev* array of *rte_event* structure.
1936 * Event operations RTE_EVENT_OP_FORWARD and RTE_EVENT_OP_RELEASE must only be
1937 * enqueued to the same port that their associated events were dequeued from.
1939 * The rte_event_enqueue_burst() function returns the number of
1940 * events objects it actually enqueued. A return value equal to *nb_events*
1941 * means that all event objects have been enqueued.
1944 * The identifier of the device.
1946 * The identifier of the event port.
1948 * Points to an array of *nb_events* objects of type *rte_event* structure
1949 * which contain the event object enqueue operations to be processed.
1951 * The number of event objects to enqueue, typically number of
1952 * rte_event_port_attr_get(...RTE_EVENT_PORT_ATTR_ENQ_DEPTH...)
1953 * available for this port.
1956 * The number of event objects actually enqueued on the event device. The
1957 * return value can be less than the value of the *nb_events* parameter when
1958 * the event devices queue is full or if invalid parameters are specified in a
1959 * *rte_event*. If the return value is less than *nb_events*, the remaining
1960 * events at the end of ev[] are not consumed and the caller has to take care
1961 * of them, and rte_errno is set accordingly. Possible errno values include:
1962 * - EINVAL The port ID is invalid, device ID is invalid, an event's queue
1963 * ID is invalid, or an event's sched type doesn't match the
1964 * capabilities of the destination queue.
1965 * - ENOSPC The event port was backpressured and unable to enqueue
1966 * one or more events. This error code is only applicable to
1968 * @see rte_event_port_attr_get(), RTE_EVENT_PORT_ATTR_ENQ_DEPTH
1970 static inline uint16_t
1971 rte_event_enqueue_burst(uint8_t dev_id, uint8_t port_id,
1972 const struct rte_event ev[], uint16_t nb_events)
1974 const struct rte_event_fp_ops *fp_ops;
1976 fp_ops = &rte_event_fp_ops[dev_id];
1977 return __rte_event_enqueue_burst(dev_id, port_id, ev, nb_events,
1978 fp_ops->enqueue_burst);
1982 * Enqueue a burst of events objects of operation type *RTE_EVENT_OP_NEW* on
1983 * an event device designated by its *dev_id* through the event port specified
1986 * Provides the same functionality as rte_event_enqueue_burst(), expect that
1987 * application can use this API when the all objects in the burst contains
1988 * the enqueue operation of the type *RTE_EVENT_OP_NEW*. This specialized
1989 * function can provide the additional hint to the PMD and optimize if possible.
1991 * The rte_event_enqueue_new_burst() result is undefined if the enqueue burst
1992 * has event object of operation type != RTE_EVENT_OP_NEW.
1995 * The identifier of the device.
1997 * The identifier of the event port.
1999 * Points to an array of *nb_events* objects of type *rte_event* structure
2000 * which contain the event object enqueue operations to be processed.
2002 * The number of event objects to enqueue, typically number of
2003 * rte_event_port_attr_get(...RTE_EVENT_PORT_ATTR_ENQ_DEPTH...)
2004 * available for this port.
2007 * The number of event objects actually enqueued on the event device. The
2008 * return value can be less than the value of the *nb_events* parameter when
2009 * the event devices queue is full or if invalid parameters are specified in a
2010 * *rte_event*. If the return value is less than *nb_events*, the remaining
2011 * events at the end of ev[] are not consumed and the caller has to take care
2012 * of them, and rte_errno is set accordingly. Possible errno values include:
2013 * - EINVAL The port ID is invalid, device ID is invalid, an event's queue
2014 * ID is invalid, or an event's sched type doesn't match the
2015 * capabilities of the destination queue.
2016 * - ENOSPC The event port was backpressured and unable to enqueue
2017 * one or more events. This error code is only applicable to
2019 * @see rte_event_port_attr_get(), RTE_EVENT_PORT_ATTR_ENQ_DEPTH
2020 * @see rte_event_enqueue_burst()
2022 static inline uint16_t
2023 rte_event_enqueue_new_burst(uint8_t dev_id, uint8_t port_id,
2024 const struct rte_event ev[], uint16_t nb_events)
2026 const struct rte_event_fp_ops *fp_ops;
2028 fp_ops = &rte_event_fp_ops[dev_id];
2029 return __rte_event_enqueue_burst(dev_id, port_id, ev, nb_events,
2030 fp_ops->enqueue_new_burst);
2034 * Enqueue a burst of events objects of operation type *RTE_EVENT_OP_FORWARD*
2035 * on an event device designated by its *dev_id* through the event port
2036 * specified by *port_id*.
2038 * Provides the same functionality as rte_event_enqueue_burst(), expect that
2039 * application can use this API when the all objects in the burst contains
2040 * the enqueue operation of the type *RTE_EVENT_OP_FORWARD*. This specialized
2041 * function can provide the additional hint to the PMD and optimize if possible.
2043 * The rte_event_enqueue_new_burst() result is undefined if the enqueue burst
2044 * has event object of operation type != RTE_EVENT_OP_FORWARD.
2047 * The identifier of the device.
2049 * The identifier of the event port.
2051 * Points to an array of *nb_events* objects of type *rte_event* structure
2052 * which contain the event object enqueue operations to be processed.
2054 * The number of event objects to enqueue, typically number of
2055 * rte_event_port_attr_get(...RTE_EVENT_PORT_ATTR_ENQ_DEPTH...)
2056 * available for this port.
2059 * The number of event objects actually enqueued on the event device. The
2060 * return value can be less than the value of the *nb_events* parameter when
2061 * the event devices queue is full or if invalid parameters are specified in a
2062 * *rte_event*. If the return value is less than *nb_events*, the remaining
2063 * events at the end of ev[] are not consumed and the caller has to take care
2064 * of them, and rte_errno is set accordingly. Possible errno values include:
2065 * - EINVAL The port ID is invalid, device ID is invalid, an event's queue
2066 * ID is invalid, or an event's sched type doesn't match the
2067 * capabilities of the destination queue.
2068 * - ENOSPC The event port was backpressured and unable to enqueue
2069 * one or more events. This error code is only applicable to
2071 * @see rte_event_port_attr_get(), RTE_EVENT_PORT_ATTR_ENQ_DEPTH
2072 * @see rte_event_enqueue_burst()
2074 static inline uint16_t
2075 rte_event_enqueue_forward_burst(uint8_t dev_id, uint8_t port_id,
2076 const struct rte_event ev[], uint16_t nb_events)
2078 const struct rte_event_fp_ops *fp_ops;
2080 fp_ops = &rte_event_fp_ops[dev_id];
2081 return __rte_event_enqueue_burst(dev_id, port_id, ev, nb_events,
2082 fp_ops->enqueue_forward_burst);
2086 * Dequeue a burst of events objects or an event object from the event port
2087 * designated by its *event_port_id*, on an event device designated
2090 * rte_event_dequeue_burst() does not dictate the specifics of scheduling
2091 * algorithm as each eventdev driver may have different criteria to schedule
2092 * an event. However, in general, from an application perspective scheduler may
2093 * use the following scheme to dispatch an event to the port.
2095 * 1) Selection of event queue based on
2096 * a) The list of event queues are linked to the event port.
2097 * b) If the device has RTE_EVENT_DEV_CAP_QUEUE_QOS capability then event
2098 * queue selection from list is based on event queue priority relative to
2099 * other event queue supplied as *priority* in rte_event_queue_setup()
2100 * c) If the device has RTE_EVENT_DEV_CAP_EVENT_QOS capability then event
2101 * queue selection from the list is based on event priority supplied as
2102 * *priority* in rte_event_enqueue_burst()
2103 * 2) Selection of event
2104 * a) The number of flows available in selected event queue.
2105 * b) Schedule type method associated with the event
2107 * The *nb_events* parameter is the maximum number of event objects to dequeue
2108 * which are returned in the *ev* array of *rte_event* structure.
2110 * The rte_event_dequeue_burst() function returns the number of events objects
2111 * it actually dequeued. A return value equal to *nb_events* means that all
2112 * event objects have been dequeued.
2114 * The number of events dequeued is the number of scheduler contexts held by
2115 * this port. These contexts are automatically released in the next
2116 * rte_event_dequeue_burst() invocation if the port supports implicit
2117 * releases, or invoking rte_event_enqueue_burst() with RTE_EVENT_OP_RELEASE
2118 * operation can be used to release the contexts early.
2120 * Event operations RTE_EVENT_OP_FORWARD and RTE_EVENT_OP_RELEASE must only be
2121 * enqueued to the same port that their associated events were dequeued from.
2124 * The identifier of the device.
2126 * The identifier of the event port.
2128 * Points to an array of *nb_events* objects of type *rte_event* structure
2129 * for output to be populated with the dequeued event objects.
2131 * The maximum number of event objects to dequeue, typically number of
2132 * rte_event_port_dequeue_depth() available for this port.
2134 * @param timeout_ticks
2135 * - 0 no-wait, returns immediately if there is no event.
2136 * - >0 wait for the event, if the device is configured with
2137 * RTE_EVENT_DEV_CFG_PER_DEQUEUE_TIMEOUT then this function will wait until
2138 * at least one event is available or *timeout_ticks* time.
2139 * if the device is not configured with RTE_EVENT_DEV_CFG_PER_DEQUEUE_TIMEOUT
2140 * then this function will wait until the event available or
2141 * *dequeue_timeout_ns* ns which was previously supplied to
2142 * rte_event_dev_configure()
2145 * The number of event objects actually dequeued from the port. The return
2146 * value can be less than the value of the *nb_events* parameter when the
2147 * event port's queue is not full.
2149 * @see rte_event_port_dequeue_depth()
2151 static inline uint16_t
2152 rte_event_dequeue_burst(uint8_t dev_id, uint8_t port_id, struct rte_event ev[],
2153 uint16_t nb_events, uint64_t timeout_ticks)
2155 const struct rte_event_fp_ops *fp_ops;
2158 fp_ops = &rte_event_fp_ops[dev_id];
2159 port = fp_ops->data[port_id];
2160 #ifdef RTE_LIBRTE_EVENTDEV_DEBUG
2161 if (dev_id >= RTE_EVENT_MAX_DEVS ||
2162 port_id >= RTE_EVENT_MAX_PORTS_PER_DEV) {
2172 rte_eventdev_trace_deq_burst(dev_id, port_id, ev, nb_events);
2174 * Allow zero cost non burst mode routine invocation if application
2175 * requests nb_events as const one
2178 return (fp_ops->dequeue)(port, ev, timeout_ticks);
2180 return (fp_ops->dequeue_burst)(port, ev, nb_events,
2184 #define RTE_EVENT_DEV_MAINT_OP_FLUSH (1 << 0)
2185 /**< Force an immediately flush of any buffered events in the port,
2186 * potentially at the cost of additional overhead.
2188 * @see rte_event_maintain()
2192 * Maintain an event device.
2194 * This function is only relevant for event devices which do not have
2195 * the @ref RTE_EVENT_DEV_CAP_MAINTENANCE_FREE flag set. Such devices
2196 * require an application thread using a particular port to
2197 * periodically call rte_event_maintain() on that port during periods
2198 * which it is neither attempting to enqueue events to nor dequeue
2199 * events from the port. rte_event_maintain() is a low-overhead
2200 * function and should be called at a high rate (e.g., in the
2201 * application's poll loop).
2203 * No port may be left unmaintained.
2205 * At the application thread's convenience, rte_event_maintain() may
2206 * (but is not required to) be called even during periods when enqueue
2207 * or dequeue functions are being called, at the cost of a slight
2208 * increase in overhead.
2210 * rte_event_maintain() may be called on event devices which have set
2211 * @ref RTE_EVENT_DEV_CAP_MAINTENANCE_FREE, in which case it is a
2215 * The identifier of the device.
2217 * The identifier of the event port.
2219 * 0, or @ref RTE_EVENT_DEV_MAINT_OP_FLUSH.
2222 * - -EINVAL if *dev_id*, *port_id*, or *op* is invalid.
2224 * @see RTE_EVENT_DEV_CAP_MAINTENANCE_FREE
2228 rte_event_maintain(uint8_t dev_id, uint8_t port_id, int op)
2230 const struct rte_event_fp_ops *fp_ops;
2233 fp_ops = &rte_event_fp_ops[dev_id];
2234 port = fp_ops->data[port_id];
2235 #ifdef RTE_LIBRTE_EVENTDEV_DEBUG
2236 if (dev_id >= RTE_EVENT_MAX_DEVS ||
2237 port_id >= RTE_EVENT_MAX_PORTS_PER_DEV)
2243 if (op & (~RTE_EVENT_DEV_MAINT_OP_FLUSH))
2246 rte_eventdev_trace_maintain(dev_id, port_id, op);
2248 if (fp_ops->maintain != NULL)
2249 fp_ops->maintain(port, op);
2258 #endif /* _RTE_EVENTDEV_H_ */