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_errno.h>
216 #include <rte_mbuf_pool_ops.h>
217 #include <rte_memory.h>
218 #include <rte_mempool.h>
220 #include "rte_eventdev_trace_fp.h"
222 struct rte_mbuf; /* we just use mbuf pointers; no need to include rte_mbuf.h */
225 /* Event device capability bitmap flags */
226 #define RTE_EVENT_DEV_CAP_QUEUE_QOS (1ULL << 0)
227 /**< Event scheduling prioritization is based on the priority associated with
230 * @see rte_event_queue_setup()
232 #define RTE_EVENT_DEV_CAP_EVENT_QOS (1ULL << 1)
233 /**< Event scheduling prioritization is based on the priority associated with
234 * each event. Priority of each event is supplied in *rte_event* structure
235 * on each enqueue operation.
237 * @see rte_event_enqueue_burst()
239 #define RTE_EVENT_DEV_CAP_DISTRIBUTED_SCHED (1ULL << 2)
240 /**< Event device operates in distributed scheduling mode.
241 * In distributed scheduling mode, event scheduling happens in HW or
242 * rte_event_dequeue_burst() or the combination of these two.
243 * If the flag is not set then eventdev is centralized and thus needs a
244 * dedicated service core that acts as a scheduling thread .
246 * @see rte_event_dequeue_burst()
248 #define RTE_EVENT_DEV_CAP_QUEUE_ALL_TYPES (1ULL << 3)
249 /**< Event device is capable of enqueuing events of any type to any queue.
250 * If this capability is not set, the queue only supports events of the
251 * *RTE_SCHED_TYPE_* type that it was created with.
253 * @see RTE_SCHED_TYPE_* values
255 #define RTE_EVENT_DEV_CAP_BURST_MODE (1ULL << 4)
256 /**< Event device is capable of operating in burst mode for enqueue(forward,
257 * release) and dequeue operation. If this capability is not set, application
258 * still uses the rte_event_dequeue_burst() and rte_event_enqueue_burst() but
259 * PMD accepts only one event at a time.
261 * @see rte_event_dequeue_burst() rte_event_enqueue_burst()
263 #define RTE_EVENT_DEV_CAP_IMPLICIT_RELEASE_DISABLE (1ULL << 5)
264 /**< Event device ports support disabling the implicit release feature, in
265 * which the port will release all unreleased events in its dequeue operation.
266 * If this capability is set and the port is configured with implicit release
267 * disabled, the application is responsible for explicitly releasing events
268 * using either the RTE_EVENT_OP_FORWARD or the RTE_EVENT_OP_RELEASE event
269 * enqueue operations.
271 * @see rte_event_dequeue_burst() rte_event_enqueue_burst()
274 #define RTE_EVENT_DEV_CAP_NONSEQ_MODE (1ULL << 6)
275 /**< Event device is capable of operating in none sequential mode. The path
276 * of the event is not necessary to be sequential. Application can change
277 * the path of event at runtime. If the flag is not set, then event each event
278 * will follow a path from queue 0 to queue 1 to queue 2 etc. If the flag is
279 * set, events may be sent to queues in any order. If the flag is not set, the
280 * eventdev will return an error when the application enqueues an event for a
281 * qid which is not the next in the sequence.
284 #define RTE_EVENT_DEV_CAP_RUNTIME_PORT_LINK (1ULL << 7)
285 /**< Event device is capable of configuring the queue/port link at runtime.
286 * If the flag is not set, the eventdev queue/port link is only can be
287 * configured during initialization.
290 #define RTE_EVENT_DEV_CAP_MULTIPLE_QUEUE_PORT (1ULL << 8)
291 /**< Event device is capable of setting up the link between multiple queue
292 * with single port. If the flag is not set, the eventdev can only map a
293 * single queue to each port or map a single queue to many port.
296 #define RTE_EVENT_DEV_CAP_CARRY_FLOW_ID (1ULL << 9)
297 /**< Event device preserves the flow ID from the enqueued
298 * event to the dequeued event if the flag is set. Otherwise,
299 * the content of this field is implementation dependent.
302 /* Event device priority levels */
303 #define RTE_EVENT_DEV_PRIORITY_HIGHEST 0
304 /**< Highest priority expressed across eventdev subsystem
305 * @see rte_event_queue_setup(), rte_event_enqueue_burst()
306 * @see rte_event_port_link()
308 #define RTE_EVENT_DEV_PRIORITY_NORMAL 128
309 /**< Normal priority expressed across eventdev subsystem
310 * @see rte_event_queue_setup(), rte_event_enqueue_burst()
311 * @see rte_event_port_link()
313 #define RTE_EVENT_DEV_PRIORITY_LOWEST 255
314 /**< Lowest priority expressed across eventdev subsystem
315 * @see rte_event_queue_setup(), rte_event_enqueue_burst()
316 * @see rte_event_port_link()
320 * Get the total number of event devices that have been successfully
324 * The total number of usable event devices.
327 rte_event_dev_count(void);
330 * Get the device identifier for the named event device.
333 * Event device name to select the event device identifier.
336 * Returns event device identifier on success.
337 * - <0: Failure to find named event device.
340 rte_event_dev_get_dev_id(const char *name);
343 * Return the NUMA socket to which a device is connected.
346 * The identifier of the device.
348 * The NUMA socket id to which the device is connected or
349 * a default of zero if the socket could not be determined.
350 * -(-EINVAL) dev_id value is out of range.
353 rte_event_dev_socket_id(uint8_t dev_id);
356 * Event device information
358 struct rte_event_dev_info {
359 const char *driver_name; /**< Event driver name */
360 struct rte_device *dev; /**< Device information */
361 uint32_t min_dequeue_timeout_ns;
362 /**< Minimum supported global dequeue timeout(ns) by this device */
363 uint32_t max_dequeue_timeout_ns;
364 /**< Maximum supported global dequeue timeout(ns) by this device */
365 uint32_t dequeue_timeout_ns;
366 /**< Configured global dequeue timeout(ns) for this device */
367 uint8_t max_event_queues;
368 /**< Maximum event_queues supported by this device */
369 uint32_t max_event_queue_flows;
370 /**< Maximum supported flows in an event queue by this device*/
371 uint8_t max_event_queue_priority_levels;
372 /**< Maximum number of event queue priority levels by this device.
373 * Valid when the device has RTE_EVENT_DEV_CAP_QUEUE_QOS capability
375 uint8_t max_event_priority_levels;
376 /**< Maximum number of event priority levels by this device.
377 * Valid when the device has RTE_EVENT_DEV_CAP_EVENT_QOS capability
379 uint8_t max_event_ports;
380 /**< Maximum number of event ports supported by this device */
381 uint8_t max_event_port_dequeue_depth;
382 /**< Maximum number of events can be dequeued at a time from an
383 * event port by this device.
384 * A device that does not support bulk dequeue will set this as 1.
386 uint32_t max_event_port_enqueue_depth;
387 /**< Maximum number of events can be enqueued at a time from an
388 * event port by this device.
389 * A device that does not support bulk enqueue will set this as 1.
391 uint8_t max_event_port_links;
392 /**< Maximum number of queues that can be linked to a single event
393 * port by this device.
395 int32_t max_num_events;
396 /**< A *closed system* event dev has a limit on the number of events it
397 * can manage at a time. An *open system* event dev does not have a
398 * limit and will specify this as -1.
400 uint32_t event_dev_cap;
401 /**< Event device capabilities(RTE_EVENT_DEV_CAP_)*/
402 uint8_t max_single_link_event_port_queue_pairs;
403 /**< Maximum number of event ports and queues that are optimized for
404 * (and only capable of) single-link configurations supported by this
405 * device. These ports and queues are not accounted for in
406 * max_event_ports or max_event_queues.
411 * Retrieve the contextual information of an event device.
414 * The identifier of the device.
416 * @param[out] dev_info
417 * A pointer to a structure of type *rte_event_dev_info* to be filled with the
418 * contextual information of the device.
421 * - 0: Success, driver updates the contextual information of the event device
422 * - <0: Error code returned by the driver info get function.
426 rte_event_dev_info_get(uint8_t dev_id, struct rte_event_dev_info *dev_info);
429 * The count of ports.
431 #define RTE_EVENT_DEV_ATTR_PORT_COUNT 0
433 * The count of queues.
435 #define RTE_EVENT_DEV_ATTR_QUEUE_COUNT 1
437 * The status of the device, zero for stopped, non-zero for started.
439 #define RTE_EVENT_DEV_ATTR_STARTED 2
442 * Get an attribute from a device.
444 * @param dev_id Eventdev id
445 * @param attr_id The attribute ID to retrieve
446 * @param[out] attr_value A pointer that will be filled in with the attribute
447 * value if successful.
450 * - 0: Successfully retrieved attribute value
451 * - -EINVAL: Invalid device or *attr_id* provided, or *attr_value* is NULL
454 rte_event_dev_attr_get(uint8_t dev_id, uint32_t attr_id,
455 uint32_t *attr_value);
458 /* Event device configuration bitmap flags */
459 #define RTE_EVENT_DEV_CFG_PER_DEQUEUE_TIMEOUT (1ULL << 0)
460 /**< Override the global *dequeue_timeout_ns* and use per dequeue timeout in ns.
461 * @see rte_event_dequeue_timeout_ticks(), rte_event_dequeue_burst()
464 /** Event device configuration structure */
465 struct rte_event_dev_config {
466 uint32_t dequeue_timeout_ns;
467 /**< rte_event_dequeue_burst() timeout on this device.
468 * This value should be in the range of *min_dequeue_timeout_ns* and
469 * *max_dequeue_timeout_ns* which previously provided in
470 * rte_event_dev_info_get()
471 * The value 0 is allowed, in which case, default dequeue timeout used.
472 * @see RTE_EVENT_DEV_CFG_PER_DEQUEUE_TIMEOUT
474 int32_t nb_events_limit;
475 /**< In a *closed system* this field is the limit on maximum number of
476 * events that can be inflight in the eventdev at a given time. The
477 * limit is required to ensure that the finite space in a closed system
478 * is not overwhelmed. The value cannot exceed the *max_num_events*
479 * as provided by rte_event_dev_info_get().
480 * This value should be set to -1 for *open system*.
482 uint8_t nb_event_queues;
483 /**< Number of event queues to configure on this device.
484 * This value cannot exceed the *max_event_queues* which previously
485 * provided in rte_event_dev_info_get()
487 uint8_t nb_event_ports;
488 /**< Number of event ports to configure on this device.
489 * This value cannot exceed the *max_event_ports* which previously
490 * provided in rte_event_dev_info_get()
492 uint32_t nb_event_queue_flows;
493 /**< Number of flows for any event queue on this device.
494 * This value cannot exceed the *max_event_queue_flows* which previously
495 * provided in rte_event_dev_info_get()
497 uint32_t nb_event_port_dequeue_depth;
498 /**< Maximum number of events can be dequeued at a time from an
499 * event port by this device.
500 * This value cannot exceed the *max_event_port_dequeue_depth*
501 * which previously provided in rte_event_dev_info_get().
502 * Ignored when device is not RTE_EVENT_DEV_CAP_BURST_MODE capable.
503 * @see rte_event_port_setup()
505 uint32_t nb_event_port_enqueue_depth;
506 /**< Maximum number of events can be enqueued at a time from an
507 * event port by this device.
508 * This value cannot exceed the *max_event_port_enqueue_depth*
509 * which previously provided in rte_event_dev_info_get().
510 * Ignored when device is not RTE_EVENT_DEV_CAP_BURST_MODE capable.
511 * @see rte_event_port_setup()
513 uint32_t event_dev_cfg;
514 /**< Event device config flags(RTE_EVENT_DEV_CFG_)*/
515 uint8_t nb_single_link_event_port_queues;
516 /**< Number of event ports and queues that will be singly-linked to
517 * each other. These are a subset of the overall event ports and
518 * queues; this value cannot exceed *nb_event_ports* or
519 * *nb_event_queues*. If the device has ports and queues that are
520 * optimized for single-link usage, this field is a hint for how many
521 * to allocate; otherwise, regular event ports and queues can be used.
526 * Configure an event device.
528 * This function must be invoked first before any other function in the
529 * API. This function can also be re-invoked when a device is in the
532 * The caller may use rte_event_dev_info_get() to get the capability of each
533 * resources available for this event device.
536 * The identifier of the device to configure.
538 * The event device configuration structure.
541 * - 0: Success, device configured.
542 * - <0: Error code returned by the driver configuration function.
545 rte_event_dev_configure(uint8_t dev_id,
546 const struct rte_event_dev_config *dev_conf);
548 /* Event queue specific APIs */
550 /* Event queue configuration bitmap flags */
551 #define RTE_EVENT_QUEUE_CFG_ALL_TYPES (1ULL << 0)
552 /**< Allow ATOMIC,ORDERED,PARALLEL schedule type enqueue
554 * @see RTE_SCHED_TYPE_ORDERED, RTE_SCHED_TYPE_ATOMIC, RTE_SCHED_TYPE_PARALLEL
555 * @see rte_event_enqueue_burst()
557 #define RTE_EVENT_QUEUE_CFG_SINGLE_LINK (1ULL << 1)
558 /**< This event queue links only to a single event port.
560 * @see rte_event_port_setup(), rte_event_port_link()
563 /** Event queue configuration structure */
564 struct rte_event_queue_conf {
565 uint32_t nb_atomic_flows;
566 /**< The maximum number of active flows this queue can track at any
567 * given time. If the queue is configured for atomic scheduling (by
568 * applying the RTE_EVENT_QUEUE_CFG_ALL_TYPES flag to event_queue_cfg
569 * or RTE_SCHED_TYPE_ATOMIC flag to schedule_type), then the
570 * value must be in the range of [1, nb_event_queue_flows], which was
571 * previously provided in rte_event_dev_configure().
573 uint32_t nb_atomic_order_sequences;
574 /**< The maximum number of outstanding events waiting to be
575 * reordered by this queue. In other words, the number of entries in
576 * this queue’s reorder buffer.When the number of events in the
577 * reorder buffer reaches to *nb_atomic_order_sequences* then the
578 * scheduler cannot schedule the events from this queue and invalid
579 * event will be returned from dequeue until one or more entries are
581 * If the queue is configured for ordered scheduling (by applying the
582 * RTE_EVENT_QUEUE_CFG_ALL_TYPES flag to event_queue_cfg or
583 * RTE_SCHED_TYPE_ORDERED flag to schedule_type), then the value must
584 * be in the range of [1, nb_event_queue_flows], which was
585 * previously supplied to rte_event_dev_configure().
587 uint32_t event_queue_cfg;
588 /**< Queue cfg flags(EVENT_QUEUE_CFG_) */
589 uint8_t schedule_type;
590 /**< Queue schedule type(RTE_SCHED_TYPE_*).
591 * Valid when RTE_EVENT_QUEUE_CFG_ALL_TYPES bit is not set in
595 /**< Priority for this event queue relative to other event queues.
596 * The requested priority should in the range of
597 * [RTE_EVENT_DEV_PRIORITY_HIGHEST, RTE_EVENT_DEV_PRIORITY_LOWEST].
598 * The implementation shall normalize the requested priority to
599 * event device supported priority value.
600 * Valid when the device has RTE_EVENT_DEV_CAP_QUEUE_QOS capability
605 * Retrieve the default configuration information of an event queue designated
606 * by its *queue_id* from the event driver for an event device.
608 * This function intended to be used in conjunction with rte_event_queue_setup()
609 * where caller needs to set up the queue by overriding few default values.
612 * The identifier of the device.
614 * The index of the event queue to get the configuration information.
615 * The value must be in the range [0, nb_event_queues - 1]
616 * previously supplied to rte_event_dev_configure().
617 * @param[out] queue_conf
618 * The pointer to the default event queue configuration data.
620 * - 0: Success, driver updates the default event queue configuration data.
621 * - <0: Error code returned by the driver info get function.
623 * @see rte_event_queue_setup()
627 rte_event_queue_default_conf_get(uint8_t dev_id, uint8_t queue_id,
628 struct rte_event_queue_conf *queue_conf);
631 * Allocate and set up an event queue for an event device.
634 * The identifier of the device.
636 * The index of the event queue to setup. The value must be in the range
637 * [0, nb_event_queues - 1] previously supplied to rte_event_dev_configure().
639 * The pointer to the configuration data to be used for the event queue.
640 * NULL value is allowed, in which case default configuration used.
642 * @see rte_event_queue_default_conf_get()
645 * - 0: Success, event queue correctly set up.
646 * - <0: event queue configuration failed
649 rte_event_queue_setup(uint8_t dev_id, uint8_t queue_id,
650 const struct rte_event_queue_conf *queue_conf);
653 * The priority of the queue.
655 #define RTE_EVENT_QUEUE_ATTR_PRIORITY 0
657 * The number of atomic flows configured for the queue.
659 #define RTE_EVENT_QUEUE_ATTR_NB_ATOMIC_FLOWS 1
661 * The number of atomic order sequences configured for the queue.
663 #define RTE_EVENT_QUEUE_ATTR_NB_ATOMIC_ORDER_SEQUENCES 2
665 * The cfg flags for the queue.
667 #define RTE_EVENT_QUEUE_ATTR_EVENT_QUEUE_CFG 3
669 * The schedule type of the queue.
671 #define RTE_EVENT_QUEUE_ATTR_SCHEDULE_TYPE 4
674 * Get an attribute from a queue.
681 * The attribute ID to retrieve
682 * @param[out] attr_value
683 * A pointer that will be filled in with the attribute value if successful
686 * - 0: Successfully returned value
687 * - -EINVAL: invalid device, queue or attr_id provided, or attr_value was
689 * - -EOVERFLOW: returned when attr_id is set to
690 * RTE_EVENT_QUEUE_ATTR_SCHEDULE_TYPE and event_queue_cfg is set to
691 * RTE_EVENT_QUEUE_CFG_ALL_TYPES
694 rte_event_queue_attr_get(uint8_t dev_id, uint8_t queue_id, uint32_t attr_id,
695 uint32_t *attr_value);
697 /* Event port specific APIs */
699 /* Event port configuration bitmap flags */
700 #define RTE_EVENT_PORT_CFG_DISABLE_IMPL_REL (1ULL << 0)
701 /**< Configure the port not to release outstanding events in
702 * rte_event_dev_dequeue_burst(). If set, all events received through
703 * the port must be explicitly released with RTE_EVENT_OP_RELEASE or
704 * RTE_EVENT_OP_FORWARD. Must be unset if the device is not
705 * RTE_EVENT_DEV_CAP_IMPLICIT_RELEASE_DISABLE capable.
707 #define RTE_EVENT_PORT_CFG_SINGLE_LINK (1ULL << 1)
708 /**< This event port links only to a single event queue.
710 * @see rte_event_port_setup(), rte_event_port_link()
713 /** Event port configuration structure */
714 struct rte_event_port_conf {
715 int32_t new_event_threshold;
716 /**< A backpressure threshold for new event enqueues on this port.
717 * Use for *closed system* event dev where event capacity is limited,
718 * and cannot exceed the capacity of the event dev.
719 * Configuring ports with different thresholds can make higher priority
720 * traffic less likely to be backpressured.
721 * For example, a port used to inject NIC Rx packets into the event dev
722 * can have a lower threshold so as not to overwhelm the device,
723 * while ports used for worker pools can have a higher threshold.
724 * This value cannot exceed the *nb_events_limit*
725 * which was previously supplied to rte_event_dev_configure().
726 * This should be set to '-1' for *open system*.
728 uint16_t dequeue_depth;
729 /**< Configure number of bulk dequeues for this event port.
730 * This value cannot exceed the *nb_event_port_dequeue_depth*
731 * which previously supplied to rte_event_dev_configure().
732 * Ignored when device is not RTE_EVENT_DEV_CAP_BURST_MODE capable.
734 uint16_t enqueue_depth;
735 /**< Configure number of bulk enqueues for this event port.
736 * This value cannot exceed the *nb_event_port_enqueue_depth*
737 * which previously supplied to rte_event_dev_configure().
738 * Ignored when device is not RTE_EVENT_DEV_CAP_BURST_MODE capable.
740 uint32_t event_port_cfg; /**< Port cfg flags(EVENT_PORT_CFG_) */
744 * Retrieve the default configuration information of an event port designated
745 * by its *port_id* from the event driver for an event device.
747 * This function intended to be used in conjunction with rte_event_port_setup()
748 * where caller needs to set up the port by overriding few default values.
751 * The identifier of the device.
753 * The index of the event port to get the configuration information.
754 * The value must be in the range [0, nb_event_ports - 1]
755 * previously supplied to rte_event_dev_configure().
756 * @param[out] port_conf
757 * The pointer to the default event port configuration data
759 * - 0: Success, driver updates the default event port configuration data.
760 * - <0: Error code returned by the driver info get function.
762 * @see rte_event_port_setup()
766 rte_event_port_default_conf_get(uint8_t dev_id, uint8_t port_id,
767 struct rte_event_port_conf *port_conf);
770 * Allocate and set up an event port for an event device.
773 * The identifier of the device.
775 * The index of the event port to setup. The value must be in the range
776 * [0, nb_event_ports - 1] previously supplied to rte_event_dev_configure().
778 * The pointer to the configuration data to be used for the queue.
779 * NULL value is allowed, in which case default configuration used.
781 * @see rte_event_port_default_conf_get()
784 * - 0: Success, event port correctly set up.
785 * - <0: Port configuration failed
786 * - (-EDQUOT) Quota exceeded(Application tried to link the queue configured
787 * with RTE_EVENT_QUEUE_CFG_SINGLE_LINK to more than one event ports)
790 rte_event_port_setup(uint8_t dev_id, uint8_t port_id,
791 const struct rte_event_port_conf *port_conf);
794 * The queue depth of the port on the enqueue side
796 #define RTE_EVENT_PORT_ATTR_ENQ_DEPTH 0
798 * The queue depth of the port on the dequeue side
800 #define RTE_EVENT_PORT_ATTR_DEQ_DEPTH 1
802 * The new event threshold of the port
804 #define RTE_EVENT_PORT_ATTR_NEW_EVENT_THRESHOLD 2
806 * The implicit release disable attribute of the port
808 #define RTE_EVENT_PORT_ATTR_IMPLICIT_RELEASE_DISABLE 3
811 * Get an attribute from a port.
818 * The attribute ID to retrieve
819 * @param[out] attr_value
820 * A pointer that will be filled in with the attribute value if successful
823 * - 0: Successfully returned value
824 * - (-EINVAL) Invalid device, port or attr_id, or attr_value was NULL
827 rte_event_port_attr_get(uint8_t dev_id, uint8_t port_id, uint32_t attr_id,
828 uint32_t *attr_value);
831 * Start an event device.
833 * The device start step is the last one and consists of setting the event
834 * queues to start accepting the events and schedules to event ports.
836 * On success, all basic functions exported by the API (event enqueue,
837 * event dequeue and so on) can be invoked.
840 * Event device identifier
842 * - 0: Success, device started.
843 * - -ESTALE : Not all ports of the device are configured
844 * - -ENOLINK: Not all queues are linked, which could lead to deadlock.
847 rte_event_dev_start(uint8_t dev_id);
850 * Stop an event device.
852 * This function causes all queued events to be drained, including those
853 * residing in event ports. While draining events out of the device, this
854 * function calls the user-provided flush callback (if one was registered) once
857 * The device can be restarted with a call to rte_event_dev_start(). Threads
858 * that continue to enqueue/dequeue while the device is stopped, or being
859 * stopped, will result in undefined behavior. This includes event adapters,
860 * which must be stopped prior to stopping the eventdev.
863 * Event device identifier.
865 * @see rte_event_dev_stop_flush_callback_register()
868 rte_event_dev_stop(uint8_t dev_id);
870 typedef void (*eventdev_stop_flush_t)(uint8_t dev_id, struct rte_event event,
872 /**< Callback function called during rte_event_dev_stop(), invoked once per
877 * Registers a callback function to be invoked during rte_event_dev_stop() for
878 * each flushed event. This function can be used to properly dispose of queued
879 * events, for example events containing memory pointers.
881 * The callback function is only registered for the calling process. The
882 * callback function must be registered in every process that can call
883 * rte_event_dev_stop().
885 * To unregister a callback, call this function with a NULL callback pointer.
888 * The identifier of the device.
890 * Callback function invoked once per flushed event.
892 * Argument supplied to callback.
896 * - -EINVAL if *dev_id* is invalid
898 * @see rte_event_dev_stop()
901 rte_event_dev_stop_flush_callback_register(uint8_t dev_id,
902 eventdev_stop_flush_t callback, void *userdata);
905 * Close an event device. The device cannot be restarted!
908 * Event device identifier
911 * - 0 on successfully closing device
912 * - <0 on failure to close device
913 * - (-EAGAIN) if device is busy
916 rte_event_dev_close(uint8_t dev_id);
919 * Event vector structure.
921 struct rte_event_vector {
923 /**< Number of elements in this event vector. */
925 /**< Reserved for future use */
926 uint16_t attr_valid : 1;
927 /**< Indicates that the below union attributes have valid information.
930 /* Used by Rx/Tx adapter.
931 * Indicates that all the elements in this vector belong to the
932 * same port and queue pair when originating from Rx adapter,
933 * valid only when event type is ETHDEV_VECTOR or
934 * ETH_RX_ADAPTER_VECTOR.
935 * Can also be used to indicate the Tx adapter the destination
936 * port and queue of the mbufs in the vector
940 /* Ethernet device port id. */
942 /* Ethernet device queue id. */
945 /**< Union to hold common attributes of the vector array. */
946 uint64_t impl_opaque;
947 /**< Implementation specific opaque value.
948 * An implementation may use this field to hold implementation specific
949 * value to share between dequeue and enqueue operation.
950 * The application should not modify this field.
953 struct rte_mbuf *mbufs[0];
957 /**< Start of the vector array union. Depending upon the event type the
958 * vector array can be an array of mbufs or pointers or opaque u64
963 /* Scheduler type definitions */
964 #define RTE_SCHED_TYPE_ORDERED 0
965 /**< Ordered scheduling
967 * Events from an ordered flow of an event queue can be scheduled to multiple
968 * ports for concurrent processing while maintaining the original event order.
969 * This scheme enables the user to achieve high single flow throughput by
970 * avoiding SW synchronization for ordering between ports which bound to cores.
972 * The source flow ordering from an event queue is maintained when events are
973 * enqueued to their destination queue within the same ordered flow context.
974 * An event port holds the context until application call
975 * rte_event_dequeue_burst() from the same port, which implicitly releases
977 * User may allow the scheduler to release the context earlier than that
978 * by invoking rte_event_enqueue_burst() with RTE_EVENT_OP_RELEASE operation.
980 * Events from the source queue appear in their original order when dequeued
981 * from a destination queue.
982 * Event ordering is based on the received event(s), but also other
983 * (newly allocated or stored) events are ordered when enqueued within the same
984 * ordered context. Events not enqueued (e.g. released or stored) within the
985 * context are considered missing from reordering and are skipped at this time
986 * (but can be ordered again within another context).
988 * @see rte_event_queue_setup(), rte_event_dequeue_burst(), RTE_EVENT_OP_RELEASE
991 #define RTE_SCHED_TYPE_ATOMIC 1
992 /**< Atomic scheduling
994 * Events from an atomic flow of an event queue can be scheduled only to a
995 * single port at a time. The port is guaranteed to have exclusive (atomic)
996 * access to the associated flow context, which enables the user to avoid SW
997 * synchronization. Atomic flows also help to maintain event ordering
998 * since only one port at a time can process events from a flow of an
1001 * The atomic queue synchronization context is dedicated to the port until
1002 * application call rte_event_dequeue_burst() from the same port,
1003 * which implicitly releases the context. User may allow the scheduler to
1004 * release the context earlier than that by invoking rte_event_enqueue_burst()
1005 * with RTE_EVENT_OP_RELEASE operation.
1007 * @see rte_event_queue_setup(), rte_event_dequeue_burst(), RTE_EVENT_OP_RELEASE
1010 #define RTE_SCHED_TYPE_PARALLEL 2
1011 /**< Parallel scheduling
1013 * The scheduler performs priority scheduling, load balancing, etc. functions
1014 * but does not provide additional event synchronization or ordering.
1015 * It is free to schedule events from a single parallel flow of an event queue
1016 * to multiple events ports for concurrent processing.
1017 * The application is responsible for flow context synchronization and
1018 * event ordering (SW synchronization).
1020 * @see rte_event_queue_setup(), rte_event_dequeue_burst()
1023 /* Event types to classify the event source */
1024 #define RTE_EVENT_TYPE_ETHDEV 0x0
1025 /**< The event generated from ethdev subsystem */
1026 #define RTE_EVENT_TYPE_CRYPTODEV 0x1
1027 /**< The event generated from crypodev subsystem */
1028 #define RTE_EVENT_TYPE_TIMER 0x2
1029 /**< The event generated from event timer adapter */
1030 #define RTE_EVENT_TYPE_CPU 0x3
1031 /**< The event generated from cpu for pipelining.
1032 * Application may use *sub_event_type* to further classify the event
1034 #define RTE_EVENT_TYPE_ETH_RX_ADAPTER 0x4
1035 /**< The event generated from event eth Rx adapter */
1036 #define RTE_EVENT_TYPE_VECTOR 0x8
1037 /**< Indicates that event is a vector.
1038 * All vector event types should be a logical OR of EVENT_TYPE_VECTOR.
1039 * This simplifies the pipeline design as one can split processing the events
1040 * between vector events and normal event across event types.
1042 * if (ev.event_type & RTE_EVENT_TYPE_VECTOR) {
1043 * // Classify and handle vector event.
1045 * // Classify and handle event.
1048 #define RTE_EVENT_TYPE_ETHDEV_VECTOR \
1049 (RTE_EVENT_TYPE_VECTOR | RTE_EVENT_TYPE_ETHDEV)
1050 /**< The event vector generated from ethdev subsystem */
1051 #define RTE_EVENT_TYPE_CPU_VECTOR (RTE_EVENT_TYPE_VECTOR | RTE_EVENT_TYPE_CPU)
1052 /**< The event vector generated from cpu for pipelining. */
1053 #define RTE_EVENT_TYPE_ETH_RX_ADAPTER_VECTOR \
1054 (RTE_EVENT_TYPE_VECTOR | RTE_EVENT_TYPE_ETH_RX_ADAPTER)
1055 /**< The event vector generated from eth Rx adapter. */
1057 #define RTE_EVENT_TYPE_MAX 0x10
1058 /**< Maximum number of event types */
1060 /* Event enqueue operations */
1061 #define RTE_EVENT_OP_NEW 0
1062 /**< The event producers use this operation to inject a new event to the
1065 #define RTE_EVENT_OP_FORWARD 1
1066 /**< The CPU use this operation to forward the event to different event queue or
1067 * change to new application specific flow or schedule type to enable
1070 * This operation must only be enqueued to the same port that the
1071 * event to be forwarded was dequeued from.
1073 #define RTE_EVENT_OP_RELEASE 2
1074 /**< Release the flow context associated with the schedule type.
1076 * If current flow's scheduler type method is *RTE_SCHED_TYPE_ATOMIC*
1077 * then this function hints the scheduler that the user has completed critical
1078 * section processing in the current atomic context.
1079 * The scheduler is now allowed to schedule events from the same flow from
1080 * an event queue to another port. However, the context may be still held
1081 * until the next rte_event_dequeue_burst() call, this call allows but does not
1082 * force the scheduler to release the context early.
1084 * Early atomic context release may increase parallelism and thus system
1085 * performance, but the user needs to design carefully the split into critical
1086 * vs non-critical sections.
1088 * If current flow's scheduler type method is *RTE_SCHED_TYPE_ORDERED*
1089 * then this function hints the scheduler that the user has done all that need
1090 * to maintain event order in the current ordered context.
1091 * The scheduler is allowed to release the ordered context of this port and
1092 * avoid reordering any following enqueues.
1094 * Early ordered context release may increase parallelism and thus system
1097 * If current flow's scheduler type method is *RTE_SCHED_TYPE_PARALLEL*
1098 * or no scheduling context is held then this function may be an NOOP,
1099 * depending on the implementation.
1101 * This operation must only be enqueued to the same port that the
1102 * event to be released was dequeued from.
1107 * The generic *rte_event* structure to hold the event attributes
1108 * for dequeue and enqueue operation
1115 /** Event attributes for dequeue or enqueue operation */
1117 uint32_t flow_id:20;
1118 /**< Targeted flow identifier for the enqueue and
1119 * dequeue operation.
1120 * The value must be in the range of
1121 * [0, nb_event_queue_flows - 1] which
1122 * previously supplied to rte_event_dev_configure().
1124 uint32_t sub_event_type:8;
1125 /**< Sub-event types based on the event source.
1126 * @see RTE_EVENT_TYPE_CPU
1128 uint32_t event_type:4;
1129 /**< Event type to classify the event source.
1130 * @see RTE_EVENT_TYPE_ETHDEV, (RTE_EVENT_TYPE_*)
1133 /**< The type of event enqueue operation - new/forward/
1134 * etc.This field is not preserved across an instance
1135 * and is undefined on dequeue.
1136 * @see RTE_EVENT_OP_NEW, (RTE_EVENT_OP_*)
1139 /**< Reserved for future use */
1140 uint8_t sched_type:2;
1141 /**< Scheduler synchronization type (RTE_SCHED_TYPE_*)
1142 * associated with flow id on a given event queue
1143 * for the enqueue and dequeue operation.
1146 /**< Targeted event queue identifier for the enqueue or
1147 * dequeue operation.
1148 * The value must be in the range of
1149 * [0, nb_event_queues - 1] which previously supplied to
1150 * rte_event_dev_configure().
1153 /**< Event priority relative to other events in the
1154 * event queue. The requested priority should in the
1155 * range of [RTE_EVENT_DEV_PRIORITY_HIGHEST,
1156 * RTE_EVENT_DEV_PRIORITY_LOWEST].
1157 * The implementation shall normalize the requested
1158 * priority to supported priority value.
1159 * Valid when the device has
1160 * RTE_EVENT_DEV_CAP_EVENT_QOS capability.
1162 uint8_t impl_opaque;
1163 /**< Implementation specific opaque value.
1164 * An implementation may use this field to hold
1165 * implementation specific value to share between
1166 * dequeue and enqueue operation.
1167 * The application should not modify this field.
1174 /**< Opaque 64-bit value */
1176 /**< Opaque event pointer */
1177 struct rte_mbuf *mbuf;
1178 /**< mbuf pointer if dequeued event is associated with mbuf */
1179 struct rte_event_vector *vec;
1180 /**< Event vector pointer. */
1184 /* Ethdev Rx adapter capability bitmap flags */
1185 #define RTE_EVENT_ETH_RX_ADAPTER_CAP_INTERNAL_PORT 0x1
1186 /**< This flag is sent when the packet transfer mechanism is in HW.
1187 * Ethdev can send packets to the event device using internal event port.
1189 #define RTE_EVENT_ETH_RX_ADAPTER_CAP_MULTI_EVENTQ 0x2
1190 /**< Adapter supports multiple event queues per ethdev. Every ethdev
1191 * Rx queue can be connected to a unique event queue.
1193 #define RTE_EVENT_ETH_RX_ADAPTER_CAP_OVERRIDE_FLOW_ID 0x4
1194 /**< The application can override the adapter generated flow ID in the
1195 * event. This flow ID can be specified when adding an ethdev Rx queue
1196 * to the adapter using the ev member of struct rte_event_eth_rx_adapter
1197 * @see struct rte_event_eth_rx_adapter_queue_conf::ev
1198 * @see struct rte_event_eth_rx_adapter_queue_conf::rx_queue_flags
1200 #define RTE_EVENT_ETH_RX_ADAPTER_CAP_EVENT_VECTOR 0x8
1201 /**< Adapter supports event vectorization per ethdev. */
1204 * Retrieve the event device's ethdev Rx adapter capabilities for the
1205 * specified ethernet port
1208 * The identifier of the device.
1210 * @param eth_port_id
1211 * The identifier of the ethernet device.
1214 * A pointer to memory filled with Rx event adapter capabilities.
1217 * - 0: Success, driver provides Rx event adapter capabilities for the
1219 * - <0: Error code returned by the driver function.
1223 rte_event_eth_rx_adapter_caps_get(uint8_t dev_id, uint16_t eth_port_id,
1226 #define RTE_EVENT_TIMER_ADAPTER_CAP_INTERNAL_PORT (1ULL << 0)
1227 /**< This flag is set when the timer mechanism is in HW. */
1229 #define RTE_EVENT_TIMER_ADAPTER_CAP_PERIODIC (1ULL << 1)
1230 /**< This flag is set if periodic mode is supported. */
1233 * Retrieve the event device's timer adapter capabilities.
1236 * The identifier of the device.
1239 * A pointer to memory to be filled with event timer adapter capabilities.
1242 * - 0: Success, driver provided event timer adapter capabilities.
1243 * - <0: Error code returned by the driver function.
1246 rte_event_timer_adapter_caps_get(uint8_t dev_id, uint32_t *caps);
1248 /* Crypto adapter capability bitmap flag */
1249 #define RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_NEW 0x1
1250 /**< Flag indicates HW is capable of generating events in
1251 * RTE_EVENT_OP_NEW enqueue operation. Cryptodev will send
1252 * packets to the event device as new events using an internal
1256 #define RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_FWD 0x2
1257 /**< Flag indicates HW is capable of generating events in
1258 * RTE_EVENT_OP_FORWARD enqueue operation. Cryptodev will send
1259 * packets to the event device as forwarded event using an
1260 * internal event port.
1263 #define RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_QP_EV_BIND 0x4
1264 /**< Flag indicates HW is capable of mapping crypto queue pair to
1268 #define RTE_EVENT_CRYPTO_ADAPTER_CAP_SESSION_PRIVATE_DATA 0x8
1269 /**< Flag indicates HW/SW supports a mechanism to store and retrieve
1270 * the private data information along with the crypto session.
1274 * Retrieve the event device's crypto adapter capabilities for the
1275 * specified cryptodev device
1278 * The identifier of the device.
1281 * The identifier of the cryptodev device.
1284 * A pointer to memory filled with event adapter capabilities.
1285 * It is expected to be pre-allocated & initialized by caller.
1288 * - 0: Success, driver provides event adapter capabilities for the
1290 * - <0: Error code returned by the driver function.
1294 rte_event_crypto_adapter_caps_get(uint8_t dev_id, uint8_t cdev_id,
1297 /* Ethdev Tx adapter capability bitmap flags */
1298 #define RTE_EVENT_ETH_TX_ADAPTER_CAP_INTERNAL_PORT 0x1
1299 /**< This flag is sent when the PMD supports a packet transmit callback
1301 #define RTE_EVENT_ETH_TX_ADAPTER_CAP_EVENT_VECTOR 0x2
1302 /**< Indicates that the Tx adapter is capable of handling event vector of
1307 * Retrieve the event device's eth Tx adapter capabilities
1310 * The identifier of the device.
1312 * @param eth_port_id
1313 * The identifier of the ethernet device.
1316 * A pointer to memory filled with eth Tx adapter capabilities.
1319 * - 0: Success, driver provides eth Tx adapter capabilities.
1320 * - <0: Error code returned by the driver function.
1324 rte_event_eth_tx_adapter_caps_get(uint8_t dev_id, uint16_t eth_port_id,
1328 * Converts nanoseconds to *timeout_ticks* value for rte_event_dequeue_burst()
1330 * If the device is configured with RTE_EVENT_DEV_CFG_PER_DEQUEUE_TIMEOUT flag
1331 * then application can use this function to convert timeout value in
1332 * nanoseconds to implementations specific timeout value supplied in
1333 * rte_event_dequeue_burst()
1336 * The identifier of the device.
1338 * Wait time in nanosecond
1339 * @param[out] timeout_ticks
1340 * Value for the *timeout_ticks* parameter in rte_event_dequeue_burst()
1344 * - -ENOTSUP if the device doesn't support timeouts
1345 * - -EINVAL if *dev_id* is invalid or *timeout_ticks* is NULL
1346 * - other values < 0 on failure.
1348 * @see rte_event_dequeue_burst(), RTE_EVENT_DEV_CFG_PER_DEQUEUE_TIMEOUT
1349 * @see rte_event_dev_configure()
1353 rte_event_dequeue_timeout_ticks(uint8_t dev_id, uint64_t ns,
1354 uint64_t *timeout_ticks);
1357 * Link multiple source event queues supplied in *queues* to the destination
1358 * event port designated by its *port_id* with associated service priority
1359 * supplied in *priorities* on the event device designated by its *dev_id*.
1361 * The link establishment shall enable the event port *port_id* from
1362 * receiving events from the specified event queue(s) supplied in *queues*
1364 * An event queue may link to one or more event ports.
1365 * The number of links can be established from an event queue to event port is
1366 * implementation defined.
1368 * Event queue(s) to event port link establishment can be changed at runtime
1369 * without re-configuring the device to support scaling and to reduce the
1370 * latency of critical work by establishing the link with more event ports
1374 * The identifier of the device.
1377 * Event port identifier to select the destination port to link.
1380 * Points to an array of *nb_links* event queues to be linked
1381 * to the event port.
1382 * NULL value is allowed, in which case this function links all the configured
1383 * event queues *nb_event_queues* which previously supplied to
1384 * rte_event_dev_configure() to the event port *port_id*
1387 * Points to an array of *nb_links* service priorities associated with each
1388 * event queue link to event port.
1389 * The priority defines the event port's servicing priority for
1390 * event queue, which may be ignored by an implementation.
1391 * The requested priority should in the range of
1392 * [RTE_EVENT_DEV_PRIORITY_HIGHEST, RTE_EVENT_DEV_PRIORITY_LOWEST].
1393 * The implementation shall normalize the requested priority to
1394 * implementation supported priority value.
1395 * NULL value is allowed, in which case this function links the event queues
1396 * with RTE_EVENT_DEV_PRIORITY_NORMAL servicing priority
1399 * The number of links to establish. This parameter is ignored if queues is
1403 * The number of links actually established. The return value can be less than
1404 * the value of the *nb_links* parameter when the implementation has the
1405 * limitation on specific queue to port link establishment or if invalid
1406 * parameters are specified in *queues*
1407 * If the return value is less than *nb_links*, the remaining links at the end
1408 * of link[] are not established, and the caller has to take care of them.
1409 * If return value is less than *nb_links* then implementation shall update the
1410 * rte_errno accordingly, Possible rte_errno values are
1411 * (EDQUOT) Quota exceeded(Application tried to link the queue configured with
1412 * RTE_EVENT_QUEUE_CFG_SINGLE_LINK to more than one event ports)
1413 * (EINVAL) Invalid parameter
1417 rte_event_port_link(uint8_t dev_id, uint8_t port_id,
1418 const uint8_t queues[], const uint8_t priorities[],
1422 * Unlink multiple source event queues supplied in *queues* from the destination
1423 * event port designated by its *port_id* on the event device designated
1426 * The unlink call issues an async request to disable the event port *port_id*
1427 * from receiving events from the specified event queue *queue_id*.
1428 * Event queue(s) to event port unlink establishment can be changed at runtime
1429 * without re-configuring the device.
1431 * @see rte_event_port_unlinks_in_progress() to poll for completed unlinks.
1434 * The identifier of the device.
1437 * Event port identifier to select the destination port to unlink.
1440 * Points to an array of *nb_unlinks* event queues to be unlinked
1441 * from the event port.
1442 * NULL value is allowed, in which case this function unlinks all the
1443 * event queue(s) from the event port *port_id*.
1446 * The number of unlinks to establish. This parameter is ignored if queues is
1450 * The number of unlinks successfully requested. The return value can be less
1451 * than the value of the *nb_unlinks* parameter when the implementation has the
1452 * limitation on specific queue to port unlink establishment or
1453 * if invalid parameters are specified.
1454 * If the return value is less than *nb_unlinks*, the remaining queues at the
1455 * end of queues[] are not unlinked, and the caller has to take care of them.
1456 * If return value is less than *nb_unlinks* then implementation shall update
1457 * the rte_errno accordingly, Possible rte_errno values are
1458 * (EINVAL) Invalid parameter
1461 rte_event_port_unlink(uint8_t dev_id, uint8_t port_id,
1462 uint8_t queues[], uint16_t nb_unlinks);
1465 * Returns the number of unlinks in progress.
1467 * This function provides the application with a method to detect when an
1468 * unlink has been completed by the implementation.
1470 * @see rte_event_port_unlink() to issue unlink requests.
1473 * The identifier of the device.
1476 * Event port identifier to select port to check for unlinks in progress.
1479 * The number of unlinks that are in progress. A return of zero indicates that
1480 * there are no outstanding unlink requests. A positive return value indicates
1481 * the number of unlinks that are in progress, but are not yet complete.
1482 * A negative return value indicates an error, -EINVAL indicates an invalid
1483 * parameter passed for *dev_id* or *port_id*.
1486 rte_event_port_unlinks_in_progress(uint8_t dev_id, uint8_t port_id);
1489 * Retrieve the list of source event queues and its associated service priority
1490 * linked to the destination event port designated by its *port_id*
1491 * on the event device designated by its *dev_id*.
1494 * The identifier of the device.
1497 * Event port identifier.
1499 * @param[out] queues
1500 * Points to an array of *queues* for output.
1501 * The caller has to allocate *RTE_EVENT_MAX_QUEUES_PER_DEV* bytes to
1502 * store the event queue(s) linked with event port *port_id*
1504 * @param[out] priorities
1505 * Points to an array of *priorities* for output.
1506 * The caller has to allocate *RTE_EVENT_MAX_QUEUES_PER_DEV* bytes to
1507 * store the service priority associated with each event queue linked
1510 * The number of links established on the event port designated by its
1516 rte_event_port_links_get(uint8_t dev_id, uint8_t port_id,
1517 uint8_t queues[], uint8_t priorities[]);
1520 * Retrieve the service ID of the event dev. If the adapter doesn't use
1521 * a rte_service function, this function returns -ESRCH.
1524 * The identifier of the device.
1526 * @param [out] service_id
1527 * A pointer to a uint32_t, to be filled in with the service id.
1531 * - <0: Error code on failure, if the event dev doesn't use a rte_service
1532 * function, this function returns -ESRCH.
1535 rte_event_dev_service_id_get(uint8_t dev_id, uint32_t *service_id);
1538 * Dump internal information about *dev_id* to the FILE* provided in *f*.
1541 * The identifier of the device.
1544 * A pointer to a file for output
1551 rte_event_dev_dump(uint8_t dev_id, FILE *f);
1553 /** Maximum name length for extended statistics counters */
1554 #define RTE_EVENT_DEV_XSTATS_NAME_SIZE 64
1557 * Selects the component of the eventdev to retrieve statistics from.
1559 enum rte_event_dev_xstats_mode {
1560 RTE_EVENT_DEV_XSTATS_DEVICE,
1561 RTE_EVENT_DEV_XSTATS_PORT,
1562 RTE_EVENT_DEV_XSTATS_QUEUE,
1566 * A name-key lookup element for extended statistics.
1568 * This structure is used to map between names and ID numbers
1569 * for extended ethdev statistics.
1571 struct rte_event_dev_xstats_name {
1572 char name[RTE_EVENT_DEV_XSTATS_NAME_SIZE];
1576 * Retrieve names of extended statistics of an event device.
1579 * The identifier of the event device.
1581 * The mode of statistics to retrieve. Choices include the device statistics,
1582 * port statistics or queue statistics.
1583 * @param queue_port_id
1584 * Used to specify the port or queue number in queue or port mode, and is
1585 * ignored in device mode.
1586 * @param[out] xstats_names
1587 * Block of memory to insert names into. Must be at least size in capacity.
1588 * If set to NULL, function returns required capacity.
1590 * Block of memory to insert ids into. Must be at least size in capacity.
1591 * If set to NULL, function returns required capacity. The id values returned
1592 * can be passed to *rte_event_dev_xstats_get* to select statistics.
1594 * Capacity of xstats_names (number of names).
1596 * - positive value lower or equal to size: success. The return value
1597 * is the number of entries filled in the stats table.
1598 * - positive value higher than size: error, the given statistics table
1599 * is too small. The return value corresponds to the size that should
1600 * be given to succeed. The entries in the table are not valid and
1601 * shall not be used by the caller.
1602 * - negative value on error:
1603 * -ENODEV for invalid *dev_id*
1604 * -EINVAL for invalid mode, queue port or id parameters
1605 * -ENOTSUP if the device doesn't support this function.
1608 rte_event_dev_xstats_names_get(uint8_t dev_id,
1609 enum rte_event_dev_xstats_mode mode,
1610 uint8_t queue_port_id,
1611 struct rte_event_dev_xstats_name *xstats_names,
1616 * Retrieve extended statistics of an event device.
1619 * The identifier of the device.
1621 * The mode of statistics to retrieve. Choices include the device statistics,
1622 * port statistics or queue statistics.
1623 * @param queue_port_id
1624 * Used to specify the port or queue number in queue or port mode, and is
1625 * ignored in device mode.
1627 * The id numbers of the stats to get. The ids can be got from the stat
1628 * position in the stat list from rte_event_dev_get_xstats_names(), or
1629 * by using rte_event_dev_xstats_by_name_get().
1630 * @param[out] values
1631 * The values for each stats request by ID.
1633 * The number of stats requested
1635 * - positive value: number of stat entries filled into the values array
1636 * - negative value on error:
1637 * -ENODEV for invalid *dev_id*
1638 * -EINVAL for invalid mode, queue port or id parameters
1639 * -ENOTSUP if the device doesn't support this function.
1642 rte_event_dev_xstats_get(uint8_t dev_id,
1643 enum rte_event_dev_xstats_mode mode,
1644 uint8_t queue_port_id,
1645 const unsigned int ids[],
1646 uint64_t values[], unsigned int n);
1649 * Retrieve the value of a single stat by requesting it by name.
1652 * The identifier of the device
1654 * The stat name to retrieve
1656 * If non-NULL, the numerical id of the stat will be returned, so that further
1657 * requests for the stat can be got using rte_event_dev_xstats_get, which will
1658 * be faster as it doesn't need to scan a list of names for the stat.
1659 * If the stat cannot be found, the id returned will be (unsigned)-1.
1661 * - positive value or zero: the stat value
1662 * - negative value: -EINVAL if stat not found, -ENOTSUP if not supported.
1665 rte_event_dev_xstats_by_name_get(uint8_t dev_id, const char *name,
1669 * Reset the values of the xstats of the selected component in the device.
1672 * The identifier of the device
1674 * The mode of the statistics to reset. Choose from device, queue or port.
1675 * @param queue_port_id
1676 * The queue or port to reset. 0 and positive values select ports and queues,
1677 * while -1 indicates all ports or queues.
1679 * Selects specific statistics to be reset. When NULL, all statistics selected
1680 * by *mode* will be reset. If non-NULL, must point to array of at least
1683 * The number of ids available from the *ids* array. Ignored when ids is NULL.
1685 * - zero: successfully reset the statistics to zero
1686 * - negative value: -EINVAL invalid parameters, -ENOTSUP if not supported.
1689 rte_event_dev_xstats_reset(uint8_t dev_id,
1690 enum rte_event_dev_xstats_mode mode,
1691 int16_t queue_port_id,
1692 const uint32_t ids[],
1696 * Trigger the eventdev self test.
1699 * The identifier of the device
1701 * - 0: Selftest successful
1702 * - -ENOTSUP if the device doesn't support selftest
1703 * - other values < 0 on failure.
1705 int rte_event_dev_selftest(uint8_t dev_id);
1708 * Get the memory required per event vector based on the number of elements per
1710 * This should be used to create the mempool that holds the event vectors.
1713 * The name of the vector pool.
1715 * The number of elements in the mbuf pool.
1717 * Size of the per-core object cache. See rte_mempool_create() for
1720 * The number of elements that a single event vector should be able to hold.
1722 * The socket identifier where the memory should be allocated. The
1723 * value can be *SOCKET_ID_ANY* if there is no NUMA constraint for the
1727 * The pointer to the newly allocated mempool, on success. NULL on error
1728 * with rte_errno set appropriately. Possible rte_errno values include:
1729 * - E_RTE_NO_CONFIG - function could not get pointer to rte_config structure
1730 * - E_RTE_SECONDARY - function was called from a secondary process instance
1731 * - EINVAL - cache size provided is too large, or priv_size is not aligned.
1732 * - ENOSPC - the maximum number of memzones has already been allocated
1733 * - EEXIST - a memzone with the same name already exists
1734 * - ENOMEM - no appropriate memory area found in which to create memzone
1735 * - ENAMETOOLONG - mempool name requested is too long.
1738 struct rte_mempool *
1739 rte_event_vector_pool_create(const char *name, unsigned int n,
1740 unsigned int cache_size, uint16_t nb_elem,
1743 #include <rte_eventdev_core.h>
1745 static __rte_always_inline uint16_t
1746 __rte_event_enqueue_burst(uint8_t dev_id, uint8_t port_id,
1747 const struct rte_event ev[], uint16_t nb_events,
1748 const event_enqueue_burst_t fn)
1750 const struct rte_eventdev *dev = &rte_eventdevs[dev_id];
1752 #ifdef RTE_LIBRTE_EVENTDEV_DEBUG
1753 if (dev_id >= RTE_EVENT_MAX_DEVS || !rte_eventdevs[dev_id].attached) {
1758 if (port_id >= dev->data->nb_ports) {
1763 rte_eventdev_trace_enq_burst(dev_id, port_id, ev, nb_events, fn);
1765 * Allow zero cost non burst mode routine invocation if application
1766 * requests nb_events as const one
1769 return (*dev->enqueue)(dev->data->ports[port_id], ev);
1771 return fn(dev->data->ports[port_id], ev, nb_events);
1775 * Enqueue a burst of events objects or an event object supplied in *rte_event*
1776 * structure on an event device designated by its *dev_id* through the event
1777 * port specified by *port_id*. Each event object specifies the event queue on
1778 * which it will be enqueued.
1780 * The *nb_events* parameter is the number of event objects to enqueue which are
1781 * supplied in the *ev* array of *rte_event* structure.
1783 * Event operations RTE_EVENT_OP_FORWARD and RTE_EVENT_OP_RELEASE must only be
1784 * enqueued to the same port that their associated events were dequeued from.
1786 * The rte_event_enqueue_burst() function returns the number of
1787 * events objects it actually enqueued. A return value equal to *nb_events*
1788 * means that all event objects have been enqueued.
1791 * The identifier of the device.
1793 * The identifier of the event port.
1795 * Points to an array of *nb_events* objects of type *rte_event* structure
1796 * which contain the event object enqueue operations to be processed.
1798 * The number of event objects to enqueue, typically number of
1799 * rte_event_port_attr_get(...RTE_EVENT_PORT_ATTR_ENQ_DEPTH...)
1800 * available for this port.
1803 * The number of event objects actually enqueued on the event device. The
1804 * return value can be less than the value of the *nb_events* parameter when
1805 * the event devices queue is full or if invalid parameters are specified in a
1806 * *rte_event*. If the return value is less than *nb_events*, the remaining
1807 * events at the end of ev[] are not consumed and the caller has to take care
1808 * of them, and rte_errno is set accordingly. Possible errno values include:
1809 * - EINVAL The port ID is invalid, device ID is invalid, an event's queue
1810 * ID is invalid, or an event's sched type doesn't match the
1811 * capabilities of the destination queue.
1812 * - ENOSPC The event port was backpressured and unable to enqueue
1813 * one or more events. This error code is only applicable to
1815 * @see rte_event_port_attr_get(), RTE_EVENT_PORT_ATTR_ENQ_DEPTH
1817 static inline uint16_t
1818 rte_event_enqueue_burst(uint8_t dev_id, uint8_t port_id,
1819 const struct rte_event ev[], uint16_t nb_events)
1821 const struct rte_eventdev *dev = &rte_eventdevs[dev_id];
1823 return __rte_event_enqueue_burst(dev_id, port_id, ev, nb_events,
1824 dev->enqueue_burst);
1828 * Enqueue a burst of events objects of operation type *RTE_EVENT_OP_NEW* on
1829 * an event device designated by its *dev_id* through the event port specified
1832 * Provides the same functionality as rte_event_enqueue_burst(), expect that
1833 * application can use this API when the all objects in the burst contains
1834 * the enqueue operation of the type *RTE_EVENT_OP_NEW*. This specialized
1835 * function can provide the additional hint to the PMD and optimize if possible.
1837 * The rte_event_enqueue_new_burst() result is undefined if the enqueue burst
1838 * has event object of operation type != RTE_EVENT_OP_NEW.
1841 * The identifier of the device.
1843 * The identifier of the event port.
1845 * Points to an array of *nb_events* objects of type *rte_event* structure
1846 * which contain the event object enqueue operations to be processed.
1848 * The number of event objects to enqueue, typically number of
1849 * rte_event_port_attr_get(...RTE_EVENT_PORT_ATTR_ENQ_DEPTH...)
1850 * available for this port.
1853 * The number of event objects actually enqueued on the event device. The
1854 * return value can be less than the value of the *nb_events* parameter when
1855 * the event devices queue is full or if invalid parameters are specified in a
1856 * *rte_event*. If the return value is less than *nb_events*, the remaining
1857 * events at the end of ev[] are not consumed and the caller has to take care
1858 * of them, and rte_errno is set accordingly. Possible errno values include:
1859 * - EINVAL The port ID is invalid, device ID is invalid, an event's queue
1860 * ID is invalid, or an event's sched type doesn't match the
1861 * capabilities of the destination queue.
1862 * - ENOSPC The event port was backpressured and unable to enqueue
1863 * one or more events. This error code is only applicable to
1865 * @see rte_event_port_attr_get(), RTE_EVENT_PORT_ATTR_ENQ_DEPTH
1866 * @see rte_event_enqueue_burst()
1868 static inline uint16_t
1869 rte_event_enqueue_new_burst(uint8_t dev_id, uint8_t port_id,
1870 const struct rte_event ev[], uint16_t nb_events)
1872 const struct rte_eventdev *dev = &rte_eventdevs[dev_id];
1874 return __rte_event_enqueue_burst(dev_id, port_id, ev, nb_events,
1875 dev->enqueue_new_burst);
1879 * Enqueue a burst of events objects of operation type *RTE_EVENT_OP_FORWARD*
1880 * on an event device designated by its *dev_id* through the event port
1881 * specified by *port_id*.
1883 * Provides the same functionality as rte_event_enqueue_burst(), expect that
1884 * application can use this API when the all objects in the burst contains
1885 * the enqueue operation of the type *RTE_EVENT_OP_FORWARD*. This specialized
1886 * function can provide the additional hint to the PMD and optimize if possible.
1888 * The rte_event_enqueue_new_burst() result is undefined if the enqueue burst
1889 * has event object of operation type != RTE_EVENT_OP_FORWARD.
1892 * The identifier of the device.
1894 * The identifier of the event port.
1896 * Points to an array of *nb_events* objects of type *rte_event* structure
1897 * which contain the event object enqueue operations to be processed.
1899 * The number of event objects to enqueue, typically number of
1900 * rte_event_port_attr_get(...RTE_EVENT_PORT_ATTR_ENQ_DEPTH...)
1901 * available for this port.
1904 * The number of event objects actually enqueued on the event device. The
1905 * return value can be less than the value of the *nb_events* parameter when
1906 * the event devices queue is full or if invalid parameters are specified in a
1907 * *rte_event*. If the return value is less than *nb_events*, the remaining
1908 * events at the end of ev[] are not consumed and the caller has to take care
1909 * of them, and rte_errno is set accordingly. Possible errno values include:
1910 * - EINVAL The port ID is invalid, device ID is invalid, an event's queue
1911 * ID is invalid, or an event's sched type doesn't match the
1912 * capabilities of the destination queue.
1913 * - ENOSPC The event port was backpressured and unable to enqueue
1914 * one or more events. This error code is only applicable to
1916 * @see rte_event_port_attr_get(), RTE_EVENT_PORT_ATTR_ENQ_DEPTH
1917 * @see rte_event_enqueue_burst()
1919 static inline uint16_t
1920 rte_event_enqueue_forward_burst(uint8_t dev_id, uint8_t port_id,
1921 const struct rte_event ev[], uint16_t nb_events)
1923 const struct rte_eventdev *dev = &rte_eventdevs[dev_id];
1925 return __rte_event_enqueue_burst(dev_id, port_id, ev, nb_events,
1926 dev->enqueue_forward_burst);
1930 * Dequeue a burst of events objects or an event object from the event port
1931 * designated by its *event_port_id*, on an event device designated
1934 * rte_event_dequeue_burst() does not dictate the specifics of scheduling
1935 * algorithm as each eventdev driver may have different criteria to schedule
1936 * an event. However, in general, from an application perspective scheduler may
1937 * use the following scheme to dispatch an event to the port.
1939 * 1) Selection of event queue based on
1940 * a) The list of event queues are linked to the event port.
1941 * b) If the device has RTE_EVENT_DEV_CAP_QUEUE_QOS capability then event
1942 * queue selection from list is based on event queue priority relative to
1943 * other event queue supplied as *priority* in rte_event_queue_setup()
1944 * c) If the device has RTE_EVENT_DEV_CAP_EVENT_QOS capability then event
1945 * queue selection from the list is based on event priority supplied as
1946 * *priority* in rte_event_enqueue_burst()
1947 * 2) Selection of event
1948 * a) The number of flows available in selected event queue.
1949 * b) Schedule type method associated with the event
1951 * The *nb_events* parameter is the maximum number of event objects to dequeue
1952 * which are returned in the *ev* array of *rte_event* structure.
1954 * The rte_event_dequeue_burst() function returns the number of events objects
1955 * it actually dequeued. A return value equal to *nb_events* means that all
1956 * event objects have been dequeued.
1958 * The number of events dequeued is the number of scheduler contexts held by
1959 * this port. These contexts are automatically released in the next
1960 * rte_event_dequeue_burst() invocation if the port supports implicit
1961 * releases, or invoking rte_event_enqueue_burst() with RTE_EVENT_OP_RELEASE
1962 * operation can be used to release the contexts early.
1964 * Event operations RTE_EVENT_OP_FORWARD and RTE_EVENT_OP_RELEASE must only be
1965 * enqueued to the same port that their associated events were dequeued from.
1968 * The identifier of the device.
1970 * The identifier of the event port.
1972 * Points to an array of *nb_events* objects of type *rte_event* structure
1973 * for output to be populated with the dequeued event objects.
1975 * The maximum number of event objects to dequeue, typically number of
1976 * rte_event_port_dequeue_depth() available for this port.
1978 * @param timeout_ticks
1979 * - 0 no-wait, returns immediately if there is no event.
1980 * - >0 wait for the event, if the device is configured with
1981 * RTE_EVENT_DEV_CFG_PER_DEQUEUE_TIMEOUT then this function will wait until
1982 * at least one event is available or *timeout_ticks* time.
1983 * if the device is not configured with RTE_EVENT_DEV_CFG_PER_DEQUEUE_TIMEOUT
1984 * then this function will wait until the event available or
1985 * *dequeue_timeout_ns* ns which was previously supplied to
1986 * rte_event_dev_configure()
1989 * The number of event objects actually dequeued from the port. The return
1990 * value can be less than the value of the *nb_events* parameter when the
1991 * event port's queue is not full.
1993 * @see rte_event_port_dequeue_depth()
1995 static inline uint16_t
1996 rte_event_dequeue_burst(uint8_t dev_id, uint8_t port_id, struct rte_event ev[],
1997 uint16_t nb_events, uint64_t timeout_ticks)
1999 struct rte_eventdev *dev = &rte_eventdevs[dev_id];
2001 #ifdef RTE_LIBRTE_EVENTDEV_DEBUG
2002 if (dev_id >= RTE_EVENT_MAX_DEVS || !rte_eventdevs[dev_id].attached) {
2007 if (port_id >= dev->data->nb_ports) {
2012 rte_eventdev_trace_deq_burst(dev_id, port_id, ev, nb_events);
2014 * Allow zero cost non burst mode routine invocation if application
2015 * requests nb_events as const one
2018 return (*dev->dequeue)(dev->data->ports[port_id], ev,
2021 return (*dev->dequeue_burst)(dev->data->ports[port_id], ev,
2022 nb_events, timeout_ticks);
2029 #endif /* _RTE_EVENTDEV_H_ */