4 * Copyright 2016 Cavium, Inc.
5 * Copyright 2016 Intel Corporation.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
12 * * Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * * Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in
16 * the documentation and/or other materials provided with the
18 * * Neither the name of Cavium, Inc nor the names of its
19 * contributors may be used to endorse or promote products derived
20 * from this software without specific prior written permission.
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 #ifndef _RTE_EVENTDEV_H_
36 #define _RTE_EVENTDEV_H_
41 * RTE Event Device API
43 * In a polling model, lcores poll ethdev ports and associated rx queues
44 * directly to look for packet. In an event driven model, by contrast, lcores
45 * call the scheduler that selects packets for them based on programmer
46 * specified criteria. Eventdev library adds support for event driven
47 * programming model, which offer applications automatic multicore scaling,
48 * dynamic load balancing, pipelining, packet ingress order maintenance and
49 * synchronization services to simplify application packet processing.
51 * The Event Device API is composed of two parts:
53 * - The application-oriented Event API that includes functions to setup
54 * an event device (configure it, setup its queues, ports and start it), to
55 * establish the link between queues to port and to receive events, and so on.
57 * - The driver-oriented Event API that exports a function allowing
58 * an event poll Mode Driver (PMD) to simultaneously register itself as
59 * an event device driver.
61 * Event device components:
65 * +-------+ | | flow 0 | |
66 * |Packet | | +-------------+ |
67 * |event | | +-------------+ |
68 * | | | | flow 1 | |port_link(port0, queue0)
69 * +-------+ | +-------------+ | | +--------+
70 * +-------+ | +-------------+ o-----v-----o |dequeue +------+
71 * |Crypto | | | flow n | | | event +------->|Core 0|
72 * |work | | +-------------+ o----+ | port 0 | | |
73 * |done ev| | event queue 0 | | +--------+ +------+
74 * +-------+ +-----------------+ |
76 * |Timer | +-----------------+ | +--------+
77 * |expiry | | +-------------+ | +------o |dequeue +------+
78 * |event | | | flow 0 | o-----------o event +------->|Core 1|
79 * +-------+ | +-------------+ | +----o port 1 | | |
80 * Event enqueue | +-------------+ | | +--------+ +------+
81 * o-------------> | | flow 1 | | |
82 * enqueue( | +-------------+ | |
83 * queue_id, | | | +--------+ +------+
84 * flow_id, | +-------------+ | | | |dequeue |Core 2|
85 * sched_type, | | flow n | o-----------o event +------->| |
86 * event_type, | +-------------+ | | | port 2 | +------+
87 * subev_type, | event queue 1 | | +--------+
88 * event) +-----------------+ | +--------+
89 * | | |dequeue +------+
90 * +-------+ +-----------------+ | | event +------->|Core n|
91 * |Core | | +-------------+ o-----------o port n | | |
92 * |(SW) | | | flow 0 | | | +--------+ +--+---+
93 * |event | | +-------------+ | | |
94 * +-------+ | +-------------+ | | |
95 * ^ | | flow 1 | | | |
96 * | | +-------------+ o------+ |
97 * | | +-------------+ | |
99 * | | +-------------+ | |
100 * | | event queue n | |
101 * | +-----------------+ |
103 * +-----------------------------------------------------------+
105 * Event device: A hardware or software-based event scheduler.
107 * Event: A unit of scheduling that encapsulates a packet or other datatype
108 * like SW generated event from the CPU, Crypto work completion notification,
109 * Timer expiry event notification etc as well as metadata.
110 * The metadata includes flow ID, scheduling type, event priority, event_type,
111 * sub_event_type etc.
113 * Event queue: A queue containing events that are scheduled by the event dev.
114 * An event queue contains events of different flows associated with scheduling
115 * types, such as atomic, ordered, or parallel.
117 * Event port: An application's interface into the event dev for enqueue and
118 * dequeue operations. Each event port can be linked with one or more
119 * event queues for dequeue operations.
121 * By default, all the functions of the Event Device API exported by a PMD
122 * are lock-free functions which assume to not be invoked in parallel on
123 * different logical cores to work on the same target object. For instance,
124 * the dequeue function of a PMD cannot be invoked in parallel on two logical
125 * cores to operates on same event port. Of course, this function
126 * can be invoked in parallel by different logical cores on different ports.
127 * It is the responsibility of the upper level application to enforce this rule.
129 * In all functions of the Event API, the Event device is
130 * designated by an integer >= 0 named the device identifier *dev_id*
132 * At the Event driver level, Event devices are represented by a generic
133 * data structure of type *rte_event_dev*.
135 * Event devices are dynamically registered during the PCI/SoC device probing
136 * phase performed at EAL initialization time.
137 * When an Event device is being probed, a *rte_event_dev* structure and
138 * a new device identifier are allocated for that device. Then, the
139 * event_dev_init() function supplied by the Event driver matching the probed
140 * device is invoked to properly initialize the device.
142 * The role of the device init function consists of resetting the hardware or
143 * software event driver implementations.
145 * If the device init operation is successful, the correspondence between
146 * the device identifier assigned to the new device and its associated
147 * *rte_event_dev* structure is effectively registered.
148 * Otherwise, both the *rte_event_dev* structure and the device identifier are
151 * The functions exported by the application Event API to setup a device
152 * designated by its device identifier must be invoked in the following order:
153 * - rte_event_dev_configure()
154 * - rte_event_queue_setup()
155 * - rte_event_port_setup()
156 * - rte_event_port_link()
157 * - rte_event_dev_start()
159 * Then, the application can invoke, in any order, the functions
160 * exported by the Event API to schedule events, dequeue events, enqueue events,
161 * change event queue(s) to event port [un]link establishment and so on.
163 * Application may use rte_event_[queue/port]_default_conf_get() to get the
164 * default configuration to set up an event queue or event port by
165 * overriding few default values.
167 * If the application wants to change the configuration (i.e. call
168 * rte_event_dev_configure(), rte_event_queue_setup(), or
169 * rte_event_port_setup()), it must call rte_event_dev_stop() first to stop the
170 * device and then do the reconfiguration before calling rte_event_dev_start()
171 * again. The schedule, enqueue and dequeue functions should not be invoked
172 * when the device is stopped.
174 * Finally, an application can close an Event device by invoking the
175 * rte_event_dev_close() function.
177 * Each function of the application Event API invokes a specific function
178 * of the PMD that controls the target device designated by its device
181 * For this purpose, all device-specific functions of an Event driver are
182 * supplied through a set of pointers contained in a generic structure of type
184 * The address of the *event_dev_ops* structure is stored in the *rte_event_dev*
185 * structure by the device init function of the Event driver, which is
186 * invoked during the PCI/SoC device probing phase, as explained earlier.
188 * In other words, each function of the Event API simply retrieves the
189 * *rte_event_dev* structure associated with the device identifier and
190 * performs an indirect invocation of the corresponding driver function
191 * supplied in the *event_dev_ops* structure of the *rte_event_dev* structure.
193 * For performance reasons, the address of the fast-path functions of the
194 * Event driver is not contained in the *event_dev_ops* structure.
195 * Instead, they are directly stored at the beginning of the *rte_event_dev*
196 * structure to avoid an extra indirect memory access during their invocation.
198 * RTE event device drivers do not use interrupts for enqueue or dequeue
199 * operation. Instead, Event drivers export Poll-Mode enqueue and dequeue
200 * functions to applications.
202 * The events are injected to event device through *enqueue* operation by
203 * event producers in the system. The typical event producers are ethdev
204 * subsystem for generating packet events, CPU(SW) for generating events based
205 * on different stages of application processing, cryptodev for generating
206 * crypto work completion notification etc
208 * The *dequeue* operation gets one or more events from the event ports.
209 * The application process the events and send to downstream event queue through
210 * rte_event_enqueue_burst() if it is an intermediate stage of event processing,
211 * on the final stage, the application may send to different subsystem like
212 * ethdev to send the packet/event on the wire using ethdev
213 * rte_eth_tx_burst() API.
215 * The point at which events are scheduled to ports depends on the device.
216 * For hardware devices, scheduling occurs asynchronously without any software
217 * intervention. Software schedulers can either be distributed
218 * (each worker thread schedules events to its own port) or centralized
219 * (a dedicated thread schedules to all ports). Distributed software schedulers
220 * perform the scheduling in rte_event_dequeue_burst(), whereas centralized
221 * scheduler logic is located in rte_event_schedule().
222 * The RTE_EVENT_DEV_CAP_DISTRIBUTED_SCHED capability flag is not set
223 * indicates the device is centralized and thus needs a dedicated scheduling
224 * thread that repeatedly calls rte_event_schedule().
226 * An event driven worker thread has following typical workflow on fastpath:
229 * rte_event_dequeue_burst(...);
231 * rte_event_enqueue_burst(...);
241 #include <rte_common.h>
242 #include <rte_memory.h>
243 #include <rte_errno.h>
245 struct rte_mbuf; /* we just use mbuf pointers; no need to include rte_mbuf.h */
247 /* Event device capability bitmap flags */
248 #define RTE_EVENT_DEV_CAP_QUEUE_QOS (1ULL << 0)
249 /**< Event scheduling prioritization is based on the priority associated with
252 * @see rte_event_queue_setup()
254 #define RTE_EVENT_DEV_CAP_EVENT_QOS (1ULL << 1)
255 /**< Event scheduling prioritization is based on the priority associated with
256 * each event. Priority of each event is supplied in *rte_event* structure
257 * on each enqueue operation.
259 * @see rte_event_enqueue_burst()
261 #define RTE_EVENT_DEV_CAP_DISTRIBUTED_SCHED (1ULL << 2)
262 /**< Event device operates in distributed scheduling mode.
263 * In distributed scheduling mode, event scheduling happens in HW or
264 * rte_event_dequeue_burst() or the combination of these two.
265 * If the flag is not set then eventdev is centralized and thus needs a
266 * dedicated scheduling thread that repeatedly calls rte_event_schedule().
268 * @see rte_event_schedule(), rte_event_dequeue_burst()
270 #define RTE_EVENT_DEV_CAP_QUEUE_ALL_TYPES (1ULL << 3)
271 /**< Event device is capable of enqueuing events of any type to any queue.
272 * If this capability is not set, the queue only supports events of the
273 * *RTE_EVENT_QUEUE_CFG_* type that it was created with.
275 * @see RTE_EVENT_QUEUE_CFG_* values
277 #define RTE_EVENT_DEV_CAP_BURST_MODE (1ULL << 4)
278 /**< Event device is capable of operating in burst mode for enqueue(forward,
279 * release) and dequeue operation. If this capability is not set, application
280 * still uses the rte_event_dequeue_burst() and rte_event_enqueue_burst() but
281 * PMD accepts only one event at a time.
283 * @see rte_event_dequeue_burst() rte_event_enqueue_burst()
286 /* Event device priority levels */
287 #define RTE_EVENT_DEV_PRIORITY_HIGHEST 0
288 /**< Highest priority expressed across eventdev subsystem
289 * @see rte_event_queue_setup(), rte_event_enqueue_burst()
290 * @see rte_event_port_link()
292 #define RTE_EVENT_DEV_PRIORITY_NORMAL 128
293 /**< Normal priority expressed across eventdev subsystem
294 * @see rte_event_queue_setup(), rte_event_enqueue_burst()
295 * @see rte_event_port_link()
297 #define RTE_EVENT_DEV_PRIORITY_LOWEST 255
298 /**< Lowest priority expressed across eventdev subsystem
299 * @see rte_event_queue_setup(), rte_event_enqueue_burst()
300 * @see rte_event_port_link()
304 * Get the total number of event devices that have been successfully
308 * The total number of usable event devices.
311 rte_event_dev_count(void);
314 * Get the device identifier for the named event device.
317 * Event device name to select the event device identifier.
320 * Returns event device identifier on success.
321 * - <0: Failure to find named event device.
324 rte_event_dev_get_dev_id(const char *name);
327 * Return the NUMA socket to which a device is connected.
330 * The identifier of the device.
332 * The NUMA socket id to which the device is connected or
333 * a default of zero if the socket could not be determined.
334 * -(-EINVAL) dev_id value is out of range.
337 rte_event_dev_socket_id(uint8_t dev_id);
340 * Event device information
342 struct rte_event_dev_info {
343 const char *driver_name; /**< Event driver name */
344 struct rte_device *dev; /**< Device information */
345 uint32_t min_dequeue_timeout_ns;
346 /**< Minimum supported global dequeue timeout(ns) by this device */
347 uint32_t max_dequeue_timeout_ns;
348 /**< Maximum supported global dequeue timeout(ns) by this device */
349 uint32_t dequeue_timeout_ns;
350 /**< Configured global dequeue timeout(ns) for this device */
351 uint8_t max_event_queues;
352 /**< Maximum event_queues supported by this device */
353 uint32_t max_event_queue_flows;
354 /**< Maximum supported flows in an event queue by this device*/
355 uint8_t max_event_queue_priority_levels;
356 /**< Maximum number of event queue priority levels by this device.
357 * Valid when the device has RTE_EVENT_DEV_CAP_QUEUE_QOS capability
359 uint8_t max_event_priority_levels;
360 /**< Maximum number of event priority levels by this device.
361 * Valid when the device has RTE_EVENT_DEV_CAP_EVENT_QOS capability
363 uint8_t max_event_ports;
364 /**< Maximum number of event ports supported by this device */
365 uint8_t max_event_port_dequeue_depth;
366 /**< Maximum number of events can be dequeued at a time from an
367 * event port by this device.
368 * A device that does not support bulk dequeue will set this as 1.
370 uint32_t max_event_port_enqueue_depth;
371 /**< Maximum number of events can be enqueued at a time from an
372 * event port by this device.
373 * A device that does not support bulk enqueue will set this as 1.
375 int32_t max_num_events;
376 /**< A *closed system* event dev has a limit on the number of events it
377 * can manage at a time. An *open system* event dev does not have a
378 * limit and will specify this as -1.
380 uint32_t event_dev_cap;
381 /**< Event device capabilities(RTE_EVENT_DEV_CAP_)*/
385 * Retrieve the contextual information of an event device.
388 * The identifier of the device.
390 * @param[out] dev_info
391 * A pointer to a structure of type *rte_event_dev_info* to be filled with the
392 * contextual information of the device.
395 * - 0: Success, driver updates the contextual information of the event device
396 * - <0: Error code returned by the driver info get function.
400 rte_event_dev_info_get(uint8_t dev_id, struct rte_event_dev_info *dev_info);
403 * The count of ports.
405 #define RTE_EVENT_DEV_ATTR_PORT_COUNT 0
407 * The count of queues.
409 #define RTE_EVENT_DEV_ATTR_QUEUE_COUNT 1
412 * Get an attribute from a device.
414 * @param dev_id Eventdev id
415 * @param attr_id The attribute ID to retrieve
416 * @param[out] attr_value A pointer that will be filled in with the attribute
417 * value if successful.
419 * @retval 0 Successfully retrieved attribute value
420 * -EINVAL Invalid device or *attr_id* provided, or *attr_value*
424 rte_event_dev_attr_get(uint8_t dev_id, uint32_t attr_id,
425 uint32_t *attr_value);
428 /* Event device configuration bitmap flags */
429 #define RTE_EVENT_DEV_CFG_PER_DEQUEUE_TIMEOUT (1ULL << 0)
430 /**< Override the global *dequeue_timeout_ns* and use per dequeue timeout in ns.
431 * @see rte_event_dequeue_timeout_ticks(), rte_event_dequeue_burst()
434 /** Event device configuration structure */
435 struct rte_event_dev_config {
436 uint32_t dequeue_timeout_ns;
437 /**< rte_event_dequeue_burst() timeout on this device.
438 * This value should be in the range of *min_dequeue_timeout_ns* and
439 * *max_dequeue_timeout_ns* which previously provided in
440 * rte_event_dev_info_get()
441 * The value 0 is allowed, in which case, default dequeue timeout used.
442 * @see RTE_EVENT_DEV_CFG_PER_DEQUEUE_TIMEOUT
444 int32_t nb_events_limit;
445 /**< In a *closed system* this field is the limit on maximum number of
446 * events that can be inflight in the eventdev at a given time. The
447 * limit is required to ensure that the finite space in a closed system
448 * is not overwhelmed. The value cannot exceed the *max_num_events*
449 * as provided by rte_event_dev_info_get().
450 * This value should be set to -1 for *open system*.
452 uint8_t nb_event_queues;
453 /**< Number of event queues to configure on this device.
454 * This value cannot exceed the *max_event_queues* which previously
455 * provided in rte_event_dev_info_get()
457 uint8_t nb_event_ports;
458 /**< Number of event ports to configure on this device.
459 * This value cannot exceed the *max_event_ports* which previously
460 * provided in rte_event_dev_info_get()
462 uint32_t nb_event_queue_flows;
463 /**< Number of flows for any event queue on this device.
464 * This value cannot exceed the *max_event_queue_flows* which previously
465 * provided in rte_event_dev_info_get()
467 uint32_t nb_event_port_dequeue_depth;
468 /**< Maximum number of events can be dequeued at a time from an
469 * event port by this device.
470 * This value cannot exceed the *max_event_port_dequeue_depth*
471 * which previously provided in rte_event_dev_info_get().
472 * Ignored when device is not RTE_EVENT_DEV_CAP_BURST_MODE capable.
473 * @see rte_event_port_setup()
475 uint32_t nb_event_port_enqueue_depth;
476 /**< Maximum number of events can be enqueued at a time from an
477 * event port by this device.
478 * This value cannot exceed the *max_event_port_enqueue_depth*
479 * which previously provided in rte_event_dev_info_get().
480 * Ignored when device is not RTE_EVENT_DEV_CAP_BURST_MODE capable.
481 * @see rte_event_port_setup()
483 uint32_t event_dev_cfg;
484 /**< Event device config flags(RTE_EVENT_DEV_CFG_)*/
488 * Configure an event device.
490 * This function must be invoked first before any other function in the
491 * API. This function can also be re-invoked when a device is in the
494 * The caller may use rte_event_dev_info_get() to get the capability of each
495 * resources available for this event device.
498 * The identifier of the device to configure.
500 * The event device configuration structure.
503 * - 0: Success, device configured.
504 * - <0: Error code returned by the driver configuration function.
507 rte_event_dev_configure(uint8_t dev_id,
508 const struct rte_event_dev_config *dev_conf);
511 /* Event queue specific APIs */
513 /* Event queue configuration bitmap flags */
514 #define RTE_EVENT_QUEUE_CFG_TYPE_MASK (3ULL << 0)
515 /**< Mask for event queue schedule type configuration request */
516 #define RTE_EVENT_QUEUE_CFG_ALL_TYPES (0ULL << 0)
517 /**< Allow ATOMIC,ORDERED,PARALLEL schedule type enqueue
519 * @see RTE_SCHED_TYPE_ORDERED, RTE_SCHED_TYPE_ATOMIC, RTE_SCHED_TYPE_PARALLEL
520 * @see rte_event_enqueue_burst()
522 #define RTE_EVENT_QUEUE_CFG_ATOMIC_ONLY (1ULL << 0)
523 /**< Allow only ATOMIC schedule type enqueue
525 * The rte_event_enqueue_burst() result is undefined if the queue configured
526 * with ATOMIC only and sched_type != RTE_SCHED_TYPE_ATOMIC
528 * @see RTE_SCHED_TYPE_ATOMIC, rte_event_enqueue_burst()
530 #define RTE_EVENT_QUEUE_CFG_ORDERED_ONLY (2ULL << 0)
531 /**< Allow only ORDERED schedule type enqueue
533 * The rte_event_enqueue_burst() result is undefined if the queue configured
534 * with ORDERED only and sched_type != RTE_SCHED_TYPE_ORDERED
536 * @see RTE_SCHED_TYPE_ORDERED, rte_event_enqueue_burst()
538 #define RTE_EVENT_QUEUE_CFG_PARALLEL_ONLY (3ULL << 0)
539 /**< Allow only PARALLEL schedule type enqueue
541 * The rte_event_enqueue_burst() result is undefined if the queue configured
542 * with PARALLEL only and sched_type != RTE_SCHED_TYPE_PARALLEL
544 * @see RTE_SCHED_TYPE_PARALLEL, rte_event_enqueue_burst()
546 #define RTE_EVENT_QUEUE_CFG_SINGLE_LINK (1ULL << 2)
547 /**< This event queue links only to a single event port.
549 * @see rte_event_port_setup(), rte_event_port_link()
552 /** Event queue configuration structure */
553 struct rte_event_queue_conf {
554 uint32_t nb_atomic_flows;
555 /**< The maximum number of active flows this queue can track at any
556 * given time. If the queue is configured for atomic scheduling (by
557 * applying the RTE_EVENT_QUEUE_CFG_ALL_TYPES or
558 * RTE_EVENT_QUEUE_CFG_ATOMIC_ONLY flags to event_queue_cfg), then the
559 * value must be in the range of [1, nb_event_queue_flows], which was
560 * previously provided in rte_event_dev_configure().
562 uint32_t nb_atomic_order_sequences;
563 /**< The maximum number of outstanding events waiting to be
564 * reordered by this queue. In other words, the number of entries in
565 * this queue’s reorder buffer.When the number of events in the
566 * reorder buffer reaches to *nb_atomic_order_sequences* then the
567 * scheduler cannot schedule the events from this queue and invalid
568 * event will be returned from dequeue until one or more entries are
570 * If the queue is configured for ordered scheduling (by applying the
571 * RTE_EVENT_QUEUE_CFG_ALL_TYPES or RTE_EVENT_QUEUE_CFG_ORDERED_ONLY
572 * flags to event_queue_cfg), then the value must be in the range of
573 * [1, nb_event_queue_flows], which was previously supplied to
574 * rte_event_dev_configure().
576 uint32_t event_queue_cfg; /**< Queue cfg flags(EVENT_QUEUE_CFG_) */
578 /**< Priority for this event queue relative to other event queues.
579 * The requested priority should in the range of
580 * [RTE_EVENT_DEV_PRIORITY_HIGHEST, RTE_EVENT_DEV_PRIORITY_LOWEST].
581 * The implementation shall normalize the requested priority to
582 * event device supported priority value.
583 * Valid when the device has RTE_EVENT_DEV_CAP_QUEUE_QOS capability
588 * Retrieve the default configuration information of an event queue designated
589 * by its *queue_id* from the event driver for an event device.
591 * This function intended to be used in conjunction with rte_event_queue_setup()
592 * where caller needs to set up the queue by overriding few default values.
595 * The identifier of the device.
597 * The index of the event queue to get the configuration information.
598 * The value must be in the range [0, nb_event_queues - 1]
599 * previously supplied to rte_event_dev_configure().
600 * @param[out] queue_conf
601 * The pointer to the default event queue configuration data.
603 * - 0: Success, driver updates the default event queue configuration data.
604 * - <0: Error code returned by the driver info get function.
606 * @see rte_event_queue_setup()
610 rte_event_queue_default_conf_get(uint8_t dev_id, uint8_t queue_id,
611 struct rte_event_queue_conf *queue_conf);
614 * Allocate and set up an event queue for an event device.
617 * The identifier of the device.
619 * The index of the event queue to setup. The value must be in the range
620 * [0, nb_event_queues - 1] previously supplied to rte_event_dev_configure().
622 * The pointer to the configuration data to be used for the event queue.
623 * NULL value is allowed, in which case default configuration used.
625 * @see rte_event_queue_default_conf_get()
628 * - 0: Success, event queue correctly set up.
629 * - <0: event queue configuration failed
632 rte_event_queue_setup(uint8_t dev_id, uint8_t queue_id,
633 const struct rte_event_queue_conf *queue_conf);
636 * Get the number of event queues on a specific event device
639 * Event device identifier.
641 * - The number of configured event queues
644 rte_event_queue_count(uint8_t dev_id);
647 * Get the priority of the event queue on a specific event device
650 * Event device identifier.
652 * Event queue identifier.
654 * - If the device has RTE_EVENT_DEV_CAP_QUEUE_QOS capability then the
655 * configured priority of the event queue in
656 * [RTE_EVENT_DEV_PRIORITY_HIGHEST, RTE_EVENT_DEV_PRIORITY_LOWEST] range
657 * else the value RTE_EVENT_DEV_PRIORITY_NORMAL
660 rte_event_queue_priority(uint8_t dev_id, uint8_t queue_id);
662 /* Event port specific APIs */
664 /** Event port configuration structure */
665 struct rte_event_port_conf {
666 int32_t new_event_threshold;
667 /**< A backpressure threshold for new event enqueues on this port.
668 * Use for *closed system* event dev where event capacity is limited,
669 * and cannot exceed the capacity of the event dev.
670 * Configuring ports with different thresholds can make higher priority
671 * traffic less likely to be backpressured.
672 * For example, a port used to inject NIC Rx packets into the event dev
673 * can have a lower threshold so as not to overwhelm the device,
674 * while ports used for worker pools can have a higher threshold.
675 * This value cannot exceed the *nb_events_limit*
676 * which was previously supplied to rte_event_dev_configure().
677 * This should be set to '-1' for *open system*.
679 uint16_t dequeue_depth;
680 /**< Configure number of bulk dequeues for this event port.
681 * This value cannot exceed the *nb_event_port_dequeue_depth*
682 * which previously supplied to rte_event_dev_configure().
683 * Ignored when device is not RTE_EVENT_DEV_CAP_BURST_MODE capable.
685 uint16_t enqueue_depth;
686 /**< Configure number of bulk enqueues for this event port.
687 * This value cannot exceed the *nb_event_port_enqueue_depth*
688 * which previously supplied to rte_event_dev_configure().
689 * Ignored when device is not RTE_EVENT_DEV_CAP_BURST_MODE capable.
694 * Retrieve the default configuration information of an event port designated
695 * by its *port_id* from the event driver for an event device.
697 * This function intended to be used in conjunction with rte_event_port_setup()
698 * where caller needs to set up the port by overriding few default values.
701 * The identifier of the device.
703 * The index of the event port to get the configuration information.
704 * The value must be in the range [0, nb_event_ports - 1]
705 * previously supplied to rte_event_dev_configure().
706 * @param[out] port_conf
707 * The pointer to the default event port configuration data
709 * - 0: Success, driver updates the default event port configuration data.
710 * - <0: Error code returned by the driver info get function.
712 * @see rte_event_port_setup()
716 rte_event_port_default_conf_get(uint8_t dev_id, uint8_t port_id,
717 struct rte_event_port_conf *port_conf);
720 * Allocate and set up an event port for an event device.
723 * The identifier of the device.
725 * The index of the event port to setup. The value must be in the range
726 * [0, nb_event_ports - 1] previously supplied to rte_event_dev_configure().
728 * The pointer to the configuration data to be used for the queue.
729 * NULL value is allowed, in which case default configuration used.
731 * @see rte_event_port_default_conf_get()
734 * - 0: Success, event port correctly set up.
735 * - <0: Port configuration failed
736 * - (-EDQUOT) Quota exceeded(Application tried to link the queue configured
737 * with RTE_EVENT_QUEUE_CFG_SINGLE_LINK to more than one event ports)
740 rte_event_port_setup(uint8_t dev_id, uint8_t port_id,
741 const struct rte_event_port_conf *port_conf);
744 * The queue depth of the port on the enqueue side
746 #define RTE_EVENT_PORT_ATTR_ENQ_DEPTH 0
748 * The queue depth of the port on the dequeue side
750 #define RTE_EVENT_PORT_ATTR_DEQ_DEPTH 1
753 * Get an attribute from a port.
755 * @param dev_id Eventdev id
756 * @param port_id Eventdev port id
757 * @param attr_id The attribute ID to retrieve
758 * @param[out] attr_value A pointer that will be filled in with the attribute
759 * value if successful
761 * @retval 0 Successfully returned value
762 * -EINVAL Invalid device, port or attr_id, or attr_value was NULL
765 rte_event_port_attr_get(uint8_t dev_id, uint8_t port_id, uint32_t attr_id,
766 uint32_t *attr_value);
769 * Start an event device.
771 * The device start step is the last one and consists of setting the event
772 * queues to start accepting the events and schedules to event ports.
774 * On success, all basic functions exported by the API (event enqueue,
775 * event dequeue and so on) can be invoked.
778 * Event device identifier
780 * - 0: Success, device started.
781 * - -ESTALE : Not all ports of the device are configured
782 * - -ENOLINK: Not all queues are linked, which could lead to deadlock.
785 rte_event_dev_start(uint8_t dev_id);
788 * Stop an event device. The device can be restarted with a call to
789 * rte_event_dev_start()
792 * Event device identifier.
795 rte_event_dev_stop(uint8_t dev_id);
798 * Close an event device. The device cannot be restarted!
801 * Event device identifier
804 * - 0 on successfully closing device
805 * - <0 on failure to close device
806 * - (-EAGAIN) if device is busy
809 rte_event_dev_close(uint8_t dev_id);
811 /* Scheduler type definitions */
812 #define RTE_SCHED_TYPE_ORDERED 0
813 /**< Ordered scheduling
815 * Events from an ordered flow of an event queue can be scheduled to multiple
816 * ports for concurrent processing while maintaining the original event order.
817 * This scheme enables the user to achieve high single flow throughput by
818 * avoiding SW synchronization for ordering between ports which bound to cores.
820 * The source flow ordering from an event queue is maintained when events are
821 * enqueued to their destination queue within the same ordered flow context.
822 * An event port holds the context until application call
823 * rte_event_dequeue_burst() from the same port, which implicitly releases
825 * User may allow the scheduler to release the context earlier than that
826 * by invoking rte_event_enqueue_burst() with RTE_EVENT_OP_RELEASE operation.
828 * Events from the source queue appear in their original order when dequeued
829 * from a destination queue.
830 * Event ordering is based on the received event(s), but also other
831 * (newly allocated or stored) events are ordered when enqueued within the same
832 * ordered context. Events not enqueued (e.g. released or stored) within the
833 * context are considered missing from reordering and are skipped at this time
834 * (but can be ordered again within another context).
836 * @see rte_event_queue_setup(), rte_event_dequeue_burst(), RTE_EVENT_OP_RELEASE
839 #define RTE_SCHED_TYPE_ATOMIC 1
840 /**< Atomic scheduling
842 * Events from an atomic flow of an event queue can be scheduled only to a
843 * single port at a time. The port is guaranteed to have exclusive (atomic)
844 * access to the associated flow context, which enables the user to avoid SW
845 * synchronization. Atomic flows also help to maintain event ordering
846 * since only one port at a time can process events from a flow of an
849 * The atomic queue synchronization context is dedicated to the port until
850 * application call rte_event_dequeue_burst() from the same port,
851 * which implicitly releases the context. User may allow the scheduler to
852 * release the context earlier than that by invoking rte_event_enqueue_burst()
853 * with RTE_EVENT_OP_RELEASE operation.
855 * @see rte_event_queue_setup(), rte_event_dequeue_burst(), RTE_EVENT_OP_RELEASE
858 #define RTE_SCHED_TYPE_PARALLEL 2
859 /**< Parallel scheduling
861 * The scheduler performs priority scheduling, load balancing, etc. functions
862 * but does not provide additional event synchronization or ordering.
863 * It is free to schedule events from a single parallel flow of an event queue
864 * to multiple events ports for concurrent processing.
865 * The application is responsible for flow context synchronization and
866 * event ordering (SW synchronization).
868 * @see rte_event_queue_setup(), rte_event_dequeue_burst()
871 /* Event types to classify the event source */
872 #define RTE_EVENT_TYPE_ETHDEV 0x0
873 /**< The event generated from ethdev subsystem */
874 #define RTE_EVENT_TYPE_CRYPTODEV 0x1
875 /**< The event generated from crypodev subsystem */
876 #define RTE_EVENT_TYPE_TIMERDEV 0x2
877 /**< The event generated from timerdev subsystem */
878 #define RTE_EVENT_TYPE_CPU 0x3
879 /**< The event generated from cpu for pipelining.
880 * Application may use *sub_event_type* to further classify the event
882 #define RTE_EVENT_TYPE_MAX 0x10
883 /**< Maximum number of event types */
885 /* Event enqueue operations */
886 #define RTE_EVENT_OP_NEW 0
887 /**< The event producers use this operation to inject a new event to the
890 #define RTE_EVENT_OP_FORWARD 1
891 /**< The CPU use this operation to forward the event to different event queue or
892 * change to new application specific flow or schedule type to enable
895 * This operation must only be enqueued to the same port that the
896 * event to be forwarded was dequeued from.
898 #define RTE_EVENT_OP_RELEASE 2
899 /**< Release the flow context associated with the schedule type.
901 * If current flow's scheduler type method is *RTE_SCHED_TYPE_ATOMIC*
902 * then this function hints the scheduler that the user has completed critical
903 * section processing in the current atomic context.
904 * The scheduler is now allowed to schedule events from the same flow from
905 * an event queue to another port. However, the context may be still held
906 * until the next rte_event_dequeue_burst() call, this call allows but does not
907 * force the scheduler to release the context early.
909 * Early atomic context release may increase parallelism and thus system
910 * performance, but the user needs to design carefully the split into critical
911 * vs non-critical sections.
913 * If current flow's scheduler type method is *RTE_SCHED_TYPE_ORDERED*
914 * then this function hints the scheduler that the user has done all that need
915 * to maintain event order in the current ordered context.
916 * The scheduler is allowed to release the ordered context of this port and
917 * avoid reordering any following enqueues.
919 * Early ordered context release may increase parallelism and thus system
922 * If current flow's scheduler type method is *RTE_SCHED_TYPE_PARALLEL*
923 * or no scheduling context is held then this function may be an NOOP,
924 * depending on the implementation.
926 * This operation must only be enqueued to the same port that the
927 * event to be released was dequeued from.
932 * The generic *rte_event* structure to hold the event attributes
933 * for dequeue and enqueue operation
940 /** Event attributes for dequeue or enqueue operation */
943 /**< Targeted flow identifier for the enqueue and
945 * The value must be in the range of
946 * [0, nb_event_queue_flows - 1] which
947 * previously supplied to rte_event_dev_configure().
949 uint32_t sub_event_type:8;
950 /**< Sub-event types based on the event source.
951 * @see RTE_EVENT_TYPE_CPU
953 uint32_t event_type:4;
954 /**< Event type to classify the event source.
955 * @see RTE_EVENT_TYPE_ETHDEV, (RTE_EVENT_TYPE_*)
958 /**< The type of event enqueue operation - new/forward/
959 * etc.This field is not preserved across an instance
960 * and is undefined on dequeue.
961 * @see RTE_EVENT_OP_NEW, (RTE_EVENT_OP_*)
964 /**< Reserved for future use */
965 uint8_t sched_type:2;
966 /**< Scheduler synchronization type (RTE_SCHED_TYPE_*)
967 * associated with flow id on a given event queue
968 * for the enqueue and dequeue operation.
971 /**< Targeted event queue identifier for the enqueue or
973 * The value must be in the range of
974 * [0, nb_event_queues - 1] which previously supplied to
975 * rte_event_dev_configure().
978 /**< Event priority relative to other events in the
979 * event queue. The requested priority should in the
980 * range of [RTE_EVENT_DEV_PRIORITY_HIGHEST,
981 * RTE_EVENT_DEV_PRIORITY_LOWEST].
982 * The implementation shall normalize the requested
983 * priority to supported priority value.
984 * Valid when the device has
985 * RTE_EVENT_DEV_CAP_EVENT_QOS capability.
988 /**< Implementation specific opaque value.
989 * An implementation may use this field to hold
990 * implementation specific value to share between
991 * dequeue and enqueue operation.
992 * The application should not modify this field.
999 /**< Opaque 64-bit value */
1001 /**< Opaque event pointer */
1002 struct rte_mbuf *mbuf;
1003 /**< mbuf pointer if dequeued event is associated with mbuf */
1008 struct rte_eventdev_driver;
1009 struct rte_eventdev_ops;
1010 struct rte_eventdev;
1012 typedef void (*event_schedule_t)(struct rte_eventdev *dev);
1013 /**< @internal Schedule one or more events in the event dev. */
1015 typedef uint16_t (*event_enqueue_t)(void *port, const struct rte_event *ev);
1016 /**< @internal Enqueue event on port of a device */
1018 typedef uint16_t (*event_enqueue_burst_t)(void *port,
1019 const struct rte_event ev[], uint16_t nb_events);
1020 /**< @internal Enqueue burst of events on port of a device */
1022 typedef uint16_t (*event_dequeue_t)(void *port, struct rte_event *ev,
1023 uint64_t timeout_ticks);
1024 /**< @internal Dequeue event from port of a device */
1026 typedef uint16_t (*event_dequeue_burst_t)(void *port, struct rte_event ev[],
1027 uint16_t nb_events, uint64_t timeout_ticks);
1028 /**< @internal Dequeue burst of events from port of a device */
1030 #define RTE_EVENTDEV_NAME_MAX_LEN (64)
1031 /**< @internal Max length of name of event PMD */
1035 * The data part, with no function pointers, associated with each device.
1037 * This structure is safe to place in shared memory to be common among
1038 * different processes in a multi-process configuration.
1040 struct rte_eventdev_data {
1042 /**< Socket ID where memory is allocated */
1044 /**< Device ID for this instance */
1046 /**< Number of event queues. */
1048 /**< Number of event ports. */
1050 /**< Array of pointers to ports. */
1051 uint8_t *ports_dequeue_depth;
1052 /**< Array of port dequeue depth. */
1053 uint8_t *ports_enqueue_depth;
1054 /**< Array of port enqueue depth. */
1055 uint8_t *queues_prio;
1056 /**< Array of queue priority. */
1057 uint16_t *links_map;
1058 /**< Memory to store queues to port connections. */
1060 /**< PMD-specific private data */
1061 uint32_t event_dev_cap;
1062 /**< Event device capabilities(RTE_EVENT_DEV_CAP_)*/
1063 struct rte_event_dev_config dev_conf;
1064 /**< Configuration applied to device. */
1067 uint8_t dev_started : 1;
1068 /**< Device state: STARTED(1)/STOPPED(0) */
1070 char name[RTE_EVENTDEV_NAME_MAX_LEN];
1071 /**< Unique identifier name */
1072 } __rte_cache_aligned;
1074 /** @internal The data structure associated with each event device. */
1075 struct rte_eventdev {
1076 event_schedule_t schedule;
1077 /**< Pointer to PMD schedule function. */
1078 event_enqueue_t enqueue;
1079 /**< Pointer to PMD enqueue function. */
1080 event_enqueue_burst_t enqueue_burst;
1081 /**< Pointer to PMD enqueue burst function. */
1082 event_enqueue_burst_t enqueue_new_burst;
1083 /**< Pointer to PMD enqueue burst function(op new variant) */
1084 event_enqueue_burst_t enqueue_forward_burst;
1085 /**< Pointer to PMD enqueue burst function(op forward variant) */
1086 event_dequeue_t dequeue;
1087 /**< Pointer to PMD dequeue function. */
1088 event_dequeue_burst_t dequeue_burst;
1089 /**< Pointer to PMD dequeue burst function. */
1091 struct rte_eventdev_data *data;
1092 /**< Pointer to device data */
1093 const struct rte_eventdev_ops *dev_ops;
1094 /**< Functions exported by PMD */
1095 struct rte_device *dev;
1096 /**< Device info. supplied by probing */
1099 uint8_t attached : 1;
1100 /**< Flag indicating the device is attached */
1101 } __rte_cache_aligned;
1103 extern struct rte_eventdev *rte_eventdevs;
1104 /** @internal The pool of rte_eventdev structures. */
1108 * Schedule one or more events in the event dev.
1110 * An event dev implementation may define this is a NOOP, for instance if
1111 * the event dev performs its scheduling in hardware.
1114 * The identifier of the device.
1117 rte_event_schedule(uint8_t dev_id)
1119 struct rte_eventdev *dev = &rte_eventdevs[dev_id];
1121 (*dev->schedule)(dev);
1124 static __rte_always_inline uint16_t
1125 __rte_event_enqueue_burst(uint8_t dev_id, uint8_t port_id,
1126 const struct rte_event ev[], uint16_t nb_events,
1127 const event_enqueue_burst_t fn)
1129 const struct rte_eventdev *dev = &rte_eventdevs[dev_id];
1131 #ifdef RTE_LIBRTE_EVENTDEV_DEBUG
1132 if (dev_id >= RTE_EVENT_MAX_DEVS || !rte_eventdevs[dev_id].attached) {
1133 rte_errno = -EINVAL;
1137 if (port_id >= dev->data->nb_ports) {
1138 rte_errno = -EINVAL;
1143 * Allow zero cost non burst mode routine invocation if application
1144 * requests nb_events as const one
1147 return (*dev->enqueue)(dev->data->ports[port_id], ev);
1149 return fn(dev->data->ports[port_id], ev, nb_events);
1153 * Enqueue a burst of events objects or an event object supplied in *rte_event*
1154 * structure on an event device designated by its *dev_id* through the event
1155 * port specified by *port_id*. Each event object specifies the event queue on
1156 * which it will be enqueued.
1158 * The *nb_events* parameter is the number of event objects to enqueue which are
1159 * supplied in the *ev* array of *rte_event* structure.
1161 * Event operations RTE_EVENT_OP_FORWARD and RTE_EVENT_OP_RELEASE must only be
1162 * enqueued to the same port that their associated events were dequeued from.
1164 * The rte_event_enqueue_burst() function returns the number of
1165 * events objects it actually enqueued. A return value equal to *nb_events*
1166 * means that all event objects have been enqueued.
1169 * The identifier of the device.
1171 * The identifier of the event port.
1173 * Points to an array of *nb_events* objects of type *rte_event* structure
1174 * which contain the event object enqueue operations to be processed.
1176 * The number of event objects to enqueue, typically number of
1177 * rte_event_port_enqueue_depth() available for this port.
1180 * The number of event objects actually enqueued on the event device. The
1181 * return value can be less than the value of the *nb_events* parameter when
1182 * the event devices queue is full or if invalid parameters are specified in a
1183 * *rte_event*. If the return value is less than *nb_events*, the remaining
1184 * events at the end of ev[] are not consumed and the caller has to take care
1185 * of them, and rte_errno is set accordingly. Possible errno values include:
1186 * - -EINVAL The port ID is invalid, device ID is invalid, an event's queue
1187 * ID is invalid, or an event's sched type doesn't match the
1188 * capabilities of the destination queue.
1189 * - -ENOSPC The event port was backpressured and unable to enqueue
1190 * one or more events. This error code is only applicable to
1192 * @see rte_event_port_enqueue_depth()
1194 static inline uint16_t
1195 rte_event_enqueue_burst(uint8_t dev_id, uint8_t port_id,
1196 const struct rte_event ev[], uint16_t nb_events)
1198 const struct rte_eventdev *dev = &rte_eventdevs[dev_id];
1200 return __rte_event_enqueue_burst(dev_id, port_id, ev, nb_events,
1201 dev->enqueue_burst);
1205 * Enqueue a burst of events objects of operation type *RTE_EVENT_OP_NEW* on
1206 * an event device designated by its *dev_id* through the event port specified
1209 * Provides the same functionality as rte_event_enqueue_burst(), expect that
1210 * application can use this API when the all objects in the burst contains
1211 * the enqueue operation of the type *RTE_EVENT_OP_NEW*. This specialized
1212 * function can provide the additional hint to the PMD and optimize if possible.
1214 * The rte_event_enqueue_new_burst() result is undefined if the enqueue burst
1215 * has event object of operation type != RTE_EVENT_OP_NEW.
1218 * The identifier of the device.
1220 * The identifier of the event port.
1222 * Points to an array of *nb_events* objects of type *rte_event* structure
1223 * which contain the event object enqueue operations to be processed.
1225 * The number of event objects to enqueue, typically number of
1226 * rte_event_port_enqueue_depth() available for this port.
1229 * The number of event objects actually enqueued on the event device. The
1230 * return value can be less than the value of the *nb_events* parameter when
1231 * the event devices queue is full or if invalid parameters are specified in a
1232 * *rte_event*. If the return value is less than *nb_events*, the remaining
1233 * events at the end of ev[] are not consumed and the caller has to take care
1234 * of them, and rte_errno is set accordingly. Possible errno values include:
1235 * - -EINVAL The port ID is invalid, device ID is invalid, an event's queue
1236 * ID is invalid, or an event's sched type doesn't match the
1237 * capabilities of the destination queue.
1238 * - -ENOSPC The event port was backpressured and unable to enqueue
1239 * one or more events. This error code is only applicable to
1241 * @see rte_event_port_enqueue_depth() rte_event_enqueue_burst()
1243 static inline uint16_t
1244 rte_event_enqueue_new_burst(uint8_t dev_id, uint8_t port_id,
1245 const struct rte_event ev[], uint16_t nb_events)
1247 const struct rte_eventdev *dev = &rte_eventdevs[dev_id];
1249 return __rte_event_enqueue_burst(dev_id, port_id, ev, nb_events,
1250 dev->enqueue_new_burst);
1254 * Enqueue a burst of events objects of operation type *RTE_EVENT_OP_FORWARD*
1255 * on an event device designated by its *dev_id* through the event port
1256 * specified by *port_id*.
1258 * Provides the same functionality as rte_event_enqueue_burst(), expect that
1259 * application can use this API when the all objects in the burst contains
1260 * the enqueue operation of the type *RTE_EVENT_OP_FORWARD*. This specialized
1261 * function can provide the additional hint to the PMD and optimize if possible.
1263 * The rte_event_enqueue_new_burst() result is undefined if the enqueue burst
1264 * has event object of operation type != RTE_EVENT_OP_FORWARD.
1267 * The identifier of the device.
1269 * The identifier of the event port.
1271 * Points to an array of *nb_events* objects of type *rte_event* structure
1272 * which contain the event object enqueue operations to be processed.
1274 * The number of event objects to enqueue, typically number of
1275 * rte_event_port_enqueue_depth() available for this port.
1278 * The number of event objects actually enqueued on the event device. The
1279 * return value can be less than the value of the *nb_events* parameter when
1280 * the event devices queue is full or if invalid parameters are specified in a
1281 * *rte_event*. If the return value is less than *nb_events*, the remaining
1282 * events at the end of ev[] are not consumed and the caller has to take care
1283 * of them, and rte_errno is set accordingly. Possible errno values include:
1284 * - -EINVAL The port ID is invalid, device ID is invalid, an event's queue
1285 * ID is invalid, or an event's sched type doesn't match the
1286 * capabilities of the destination queue.
1287 * - -ENOSPC The event port was backpressured and unable to enqueue
1288 * one or more events. This error code is only applicable to
1290 * @see rte_event_port_enqueue_depth() rte_event_enqueue_burst()
1292 static inline uint16_t
1293 rte_event_enqueue_forward_burst(uint8_t dev_id, uint8_t port_id,
1294 const struct rte_event ev[], uint16_t nb_events)
1296 const struct rte_eventdev *dev = &rte_eventdevs[dev_id];
1298 return __rte_event_enqueue_burst(dev_id, port_id, ev, nb_events,
1299 dev->enqueue_forward_burst);
1303 * Converts nanoseconds to *timeout_ticks* value for rte_event_dequeue_burst()
1305 * If the device is configured with RTE_EVENT_DEV_CFG_PER_DEQUEUE_TIMEOUT flag
1306 * then application can use this function to convert timeout value in
1307 * nanoseconds to implementations specific timeout value supplied in
1308 * rte_event_dequeue_burst()
1311 * The identifier of the device.
1313 * Wait time in nanosecond
1314 * @param[out] timeout_ticks
1315 * Value for the *timeout_ticks* parameter in rte_event_dequeue_burst()
1319 * - -ENOTSUP if the device doesn't support timeouts
1320 * - -EINVAL if *dev_id* is invalid or *timeout_ticks* is NULL
1321 * - other values < 0 on failure.
1323 * @see rte_event_dequeue_burst(), RTE_EVENT_DEV_CFG_PER_DEQUEUE_TIMEOUT
1324 * @see rte_event_dev_configure()
1328 rte_event_dequeue_timeout_ticks(uint8_t dev_id, uint64_t ns,
1329 uint64_t *timeout_ticks);
1332 * Dequeue a burst of events objects or an event object from the event port
1333 * designated by its *event_port_id*, on an event device designated
1336 * rte_event_dequeue_burst() does not dictate the specifics of scheduling
1337 * algorithm as each eventdev driver may have different criteria to schedule
1338 * an event. However, in general, from an application perspective scheduler may
1339 * use the following scheme to dispatch an event to the port.
1341 * 1) Selection of event queue based on
1342 * a) The list of event queues are linked to the event port.
1343 * b) If the device has RTE_EVENT_DEV_CAP_QUEUE_QOS capability then event
1344 * queue selection from list is based on event queue priority relative to
1345 * other event queue supplied as *priority* in rte_event_queue_setup()
1346 * c) If the device has RTE_EVENT_DEV_CAP_EVENT_QOS capability then event
1347 * queue selection from the list is based on event priority supplied as
1348 * *priority* in rte_event_enqueue_burst()
1349 * 2) Selection of event
1350 * a) The number of flows available in selected event queue.
1351 * b) Schedule type method associated with the event
1353 * The *nb_events* parameter is the maximum number of event objects to dequeue
1354 * which are returned in the *ev* array of *rte_event* structure.
1356 * The rte_event_dequeue_burst() function returns the number of events objects
1357 * it actually dequeued. A return value equal to *nb_events* means that all
1358 * event objects have been dequeued.
1360 * The number of events dequeued is the number of scheduler contexts held by
1361 * this port. These contexts are automatically released in the next
1362 * rte_event_dequeue_burst() invocation, or invoking rte_event_enqueue_burst()
1363 * with RTE_EVENT_OP_RELEASE operation can be used to release the
1366 * Event operations RTE_EVENT_OP_FORWARD and RTE_EVENT_OP_RELEASE must only be
1367 * enqueued to the same port that their associated events were dequeued from.
1370 * The identifier of the device.
1372 * The identifier of the event port.
1374 * Points to an array of *nb_events* objects of type *rte_event* structure
1375 * for output to be populated with the dequeued event objects.
1377 * The maximum number of event objects to dequeue, typically number of
1378 * rte_event_port_dequeue_depth() available for this port.
1380 * @param timeout_ticks
1381 * - 0 no-wait, returns immediately if there is no event.
1382 * - >0 wait for the event, if the device is configured with
1383 * RTE_EVENT_DEV_CFG_PER_DEQUEUE_TIMEOUT then this function will wait until
1384 * at least one event is available or *timeout_ticks* time.
1385 * if the device is not configured with RTE_EVENT_DEV_CFG_PER_DEQUEUE_TIMEOUT
1386 * then this function will wait until the event available or
1387 * *dequeue_timeout_ns* ns which was previously supplied to
1388 * rte_event_dev_configure()
1391 * The number of event objects actually dequeued from the port. The return
1392 * value can be less than the value of the *nb_events* parameter when the
1393 * event port's queue is not full.
1395 * @see rte_event_port_dequeue_depth()
1397 static inline uint16_t
1398 rte_event_dequeue_burst(uint8_t dev_id, uint8_t port_id, struct rte_event ev[],
1399 uint16_t nb_events, uint64_t timeout_ticks)
1401 struct rte_eventdev *dev = &rte_eventdevs[dev_id];
1403 #ifdef RTE_LIBRTE_EVENTDEV_DEBUG
1404 if (dev_id >= RTE_EVENT_MAX_DEVS || !rte_eventdevs[dev_id].attached) {
1405 rte_errno = -EINVAL;
1409 if (port_id >= dev->data->nb_ports) {
1410 rte_errno = -EINVAL;
1416 * Allow zero cost non burst mode routine invocation if application
1417 * requests nb_events as const one
1420 return (*dev->dequeue)(
1421 dev->data->ports[port_id], ev, timeout_ticks);
1423 return (*dev->dequeue_burst)(
1424 dev->data->ports[port_id], ev, nb_events,
1429 * Link multiple source event queues supplied in *queues* to the destination
1430 * event port designated by its *port_id* with associated service priority
1431 * supplied in *priorities* on the event device designated by its *dev_id*.
1433 * The link establishment shall enable the event port *port_id* from
1434 * receiving events from the specified event queue(s) supplied in *queues*
1436 * An event queue may link to one or more event ports.
1437 * The number of links can be established from an event queue to event port is
1438 * implementation defined.
1440 * Event queue(s) to event port link establishment can be changed at runtime
1441 * without re-configuring the device to support scaling and to reduce the
1442 * latency of critical work by establishing the link with more event ports
1446 * The identifier of the device.
1449 * Event port identifier to select the destination port to link.
1452 * Points to an array of *nb_links* event queues to be linked
1453 * to the event port.
1454 * NULL value is allowed, in which case this function links all the configured
1455 * event queues *nb_event_queues* which previously supplied to
1456 * rte_event_dev_configure() to the event port *port_id*
1459 * Points to an array of *nb_links* service priorities associated with each
1460 * event queue link to event port.
1461 * The priority defines the event port's servicing priority for
1462 * event queue, which may be ignored by an implementation.
1463 * The requested priority should in the range of
1464 * [RTE_EVENT_DEV_PRIORITY_HIGHEST, RTE_EVENT_DEV_PRIORITY_LOWEST].
1465 * The implementation shall normalize the requested priority to
1466 * implementation supported priority value.
1467 * NULL value is allowed, in which case this function links the event queues
1468 * with RTE_EVENT_DEV_PRIORITY_NORMAL servicing priority
1471 * The number of links to establish. This parameter is ignored if queues is
1475 * The number of links actually established. The return value can be less than
1476 * the value of the *nb_links* parameter when the implementation has the
1477 * limitation on specific queue to port link establishment or if invalid
1478 * parameters are specified in *queues*
1479 * If the return value is less than *nb_links*, the remaining links at the end
1480 * of link[] are not established, and the caller has to take care of them.
1481 * If return value is less than *nb_links* then implementation shall update the
1482 * rte_errno accordingly, Possible rte_errno values are
1483 * (-EDQUOT) Quota exceeded(Application tried to link the queue configured with
1484 * RTE_EVENT_QUEUE_CFG_SINGLE_LINK to more than one event ports)
1485 * (-EINVAL) Invalid parameter
1489 rte_event_port_link(uint8_t dev_id, uint8_t port_id,
1490 const uint8_t queues[], const uint8_t priorities[],
1494 * Unlink multiple source event queues supplied in *queues* from the destination
1495 * event port designated by its *port_id* on the event device designated
1498 * The unlink establishment shall disable the event port *port_id* from
1499 * receiving events from the specified event queue *queue_id*
1501 * Event queue(s) to event port unlink establishment can be changed at runtime
1502 * without re-configuring the device.
1505 * The identifier of the device.
1508 * Event port identifier to select the destination port to unlink.
1511 * Points to an array of *nb_unlinks* event queues to be unlinked
1512 * from the event port.
1513 * NULL value is allowed, in which case this function unlinks all the
1514 * event queue(s) from the event port *port_id*.
1517 * The number of unlinks to establish. This parameter is ignored if queues is
1521 * The number of unlinks actually established. The return value can be less
1522 * than the value of the *nb_unlinks* parameter when the implementation has the
1523 * limitation on specific queue to port unlink establishment or
1524 * if invalid parameters are specified.
1525 * If the return value is less than *nb_unlinks*, the remaining queues at the
1526 * end of queues[] are not established, and the caller has to take care of them.
1527 * If return value is less than *nb_unlinks* then implementation shall update
1528 * the rte_errno accordingly, Possible rte_errno values are
1529 * (-EINVAL) Invalid parameter
1533 rte_event_port_unlink(uint8_t dev_id, uint8_t port_id,
1534 uint8_t queues[], uint16_t nb_unlinks);
1537 * Retrieve the list of source event queues and its associated service priority
1538 * linked to the destination event port designated by its *port_id*
1539 * on the event device designated by its *dev_id*.
1542 * The identifier of the device.
1545 * Event port identifier.
1547 * @param[out] queues
1548 * Points to an array of *queues* for output.
1549 * The caller has to allocate *RTE_EVENT_MAX_QUEUES_PER_DEV* bytes to
1550 * store the event queue(s) linked with event port *port_id*
1552 * @param[out] priorities
1553 * Points to an array of *priorities* for output.
1554 * The caller has to allocate *RTE_EVENT_MAX_QUEUES_PER_DEV* bytes to
1555 * store the service priority associated with each event queue linked
1558 * The number of links established on the event port designated by its
1564 rte_event_port_links_get(uint8_t dev_id, uint8_t port_id,
1565 uint8_t queues[], uint8_t priorities[]);
1568 * Dump internal information about *dev_id* to the FILE* provided in *f*.
1571 * The identifier of the device.
1574 * A pointer to a file for output
1581 rte_event_dev_dump(uint8_t dev_id, FILE *f);
1583 /** Maximum name length for extended statistics counters */
1584 #define RTE_EVENT_DEV_XSTATS_NAME_SIZE 64
1587 * Selects the component of the eventdev to retrieve statistics from.
1589 enum rte_event_dev_xstats_mode {
1590 RTE_EVENT_DEV_XSTATS_DEVICE,
1591 RTE_EVENT_DEV_XSTATS_PORT,
1592 RTE_EVENT_DEV_XSTATS_QUEUE,
1596 * A name-key lookup element for extended statistics.
1598 * This structure is used to map between names and ID numbers
1599 * for extended ethdev statistics.
1601 struct rte_event_dev_xstats_name {
1602 char name[RTE_EVENT_DEV_XSTATS_NAME_SIZE];
1606 * Retrieve names of extended statistics of an event device.
1609 * The identifier of the event device.
1611 * The mode of statistics to retrieve. Choices include the device statistics,
1612 * port statistics or queue statistics.
1613 * @param queue_port_id
1614 * Used to specify the port or queue number in queue or port mode, and is
1615 * ignored in device mode.
1616 * @param[out] xstats_names
1617 * Block of memory to insert names into. Must be at least size in capacity.
1618 * If set to NULL, function returns required capacity.
1620 * Block of memory to insert ids into. Must be at least size in capacity.
1621 * If set to NULL, function returns required capacity. The id values returned
1622 * can be passed to *rte_event_dev_xstats_get* to select statistics.
1624 * Capacity of xstats_names (number of names).
1626 * - positive value lower or equal to size: success. The return value
1627 * is the number of entries filled in the stats table.
1628 * - positive value higher than size: error, the given statistics table
1629 * is too small. The return value corresponds to the size that should
1630 * be given to succeed. The entries in the table are not valid and
1631 * shall not be used by the caller.
1632 * - negative value on error:
1633 * -ENODEV for invalid *dev_id*
1634 * -EINVAL for invalid mode, queue port or id parameters
1635 * -ENOTSUP if the device doesn't support this function.
1638 rte_event_dev_xstats_names_get(uint8_t dev_id,
1639 enum rte_event_dev_xstats_mode mode,
1640 uint8_t queue_port_id,
1641 struct rte_event_dev_xstats_name *xstats_names,
1646 * Retrieve extended statistics of an event device.
1649 * The identifier of the device.
1651 * The mode of statistics to retrieve. Choices include the device statistics,
1652 * port statistics or queue statistics.
1653 * @param queue_port_id
1654 * Used to specify the port or queue number in queue or port mode, and is
1655 * ignored in device mode.
1657 * The id numbers of the stats to get. The ids can be got from the stat
1658 * position in the stat list from rte_event_dev_get_xstats_names(), or
1659 * by using rte_eventdev_get_xstats_by_name()
1660 * @param[out] values
1661 * The values for each stats request by ID.
1663 * The number of stats requested
1665 * - positive value: number of stat entries filled into the values array
1666 * - negative value on error:
1667 * -ENODEV for invalid *dev_id*
1668 * -EINVAL for invalid mode, queue port or id parameters
1669 * -ENOTSUP if the device doesn't support this function.
1672 rte_event_dev_xstats_get(uint8_t dev_id,
1673 enum rte_event_dev_xstats_mode mode,
1674 uint8_t queue_port_id,
1675 const unsigned int ids[],
1676 uint64_t values[], unsigned int n);
1679 * Retrieve the value of a single stat by requesting it by name.
1682 * The identifier of the device
1684 * The stat name to retrieve
1686 * If non-NULL, the numerical id of the stat will be returned, so that further
1687 * requests for the stat can be got using rte_eventdev_xstats_get, which will
1688 * be faster as it doesn't need to scan a list of names for the stat.
1689 * If the stat cannot be found, the id returned will be (unsigned)-1.
1691 * - positive value or zero: the stat value
1692 * - negative value: -EINVAL if stat not found, -ENOTSUP if not supported.
1695 rte_event_dev_xstats_by_name_get(uint8_t dev_id, const char *name,
1699 * Reset the values of the xstats of the selected component in the device.
1702 * The identifier of the device
1704 * The mode of the statistics to reset. Choose from device, queue or port.
1705 * @param queue_port_id
1706 * The queue or port to reset. 0 and positive values select ports and queues,
1707 * while -1 indicates all ports or queues.
1709 * Selects specific statistics to be reset. When NULL, all statistics selected
1710 * by *mode* will be reset. If non-NULL, must point to array of at least
1713 * The number of ids available from the *ids* array. Ignored when ids is NULL.
1715 * - zero: successfully reset the statistics to zero
1716 * - negative value: -EINVAL invalid parameters, -ENOTSUP if not supported.
1719 rte_event_dev_xstats_reset(uint8_t dev_id,
1720 enum rte_event_dev_xstats_mode mode,
1721 int16_t queue_port_id,
1722 const uint32_t ids[],
1729 #endif /* _RTE_EVENTDEV_H_ */