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 need a dedicated service core for scheduling.
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 software specific scheduling function.
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_config.h>
243 #include <rte_memory.h>
244 #include <rte_errno.h>
246 struct rte_mbuf; /* we just use mbuf pointers; no need to include rte_mbuf.h */
248 /* Event device capability bitmap flags */
249 #define RTE_EVENT_DEV_CAP_QUEUE_QOS (1ULL << 0)
250 /**< Event scheduling prioritization is based on the priority associated with
253 * @see rte_event_queue_setup()
255 #define RTE_EVENT_DEV_CAP_EVENT_QOS (1ULL << 1)
256 /**< Event scheduling prioritization is based on the priority associated with
257 * each event. Priority of each event is supplied in *rte_event* structure
258 * on each enqueue operation.
260 * @see rte_event_enqueue_burst()
262 #define RTE_EVENT_DEV_CAP_DISTRIBUTED_SCHED (1ULL << 2)
263 /**< Event device operates in distributed scheduling mode.
264 * In distributed scheduling mode, event scheduling happens in HW or
265 * rte_event_dequeue_burst() or the combination of these two.
266 * If the flag is not set then eventdev is centralized and thus needs a
267 * dedicated service core that acts as a scheduling thread .
269 * @see rte_event_dequeue_burst()
271 #define RTE_EVENT_DEV_CAP_QUEUE_ALL_TYPES (1ULL << 3)
272 /**< Event device is capable of enqueuing events of any type to any queue.
273 * If this capability is not set, the queue only supports events of the
274 * *RTE_SCHED_TYPE_* type that it was created with.
276 * @see RTE_SCHED_TYPE_* values
278 #define RTE_EVENT_DEV_CAP_BURST_MODE (1ULL << 4)
279 /**< Event device is capable of operating in burst mode for enqueue(forward,
280 * release) and dequeue operation. If this capability is not set, application
281 * still uses the rte_event_dequeue_burst() and rte_event_enqueue_burst() but
282 * PMD accepts only one event at a time.
284 * @see rte_event_dequeue_burst() rte_event_enqueue_burst()
286 #define RTE_EVENT_DEV_CAP_IMPLICIT_RELEASE_DISABLE (1ULL << 5)
287 /**< Event device ports support disabling the implicit release feature, in
288 * which the port will release all unreleased events in its dequeue operation.
289 * If this capability is set and the port is configured with implicit release
290 * disabled, the application is responsible for explicitly releasing events
291 * using either the RTE_EVENT_OP_FORWARD or the RTE_EVENT_OP_RELEASE event
292 * enqueue operations.
294 * @see rte_event_dequeue_burst() rte_event_enqueue_burst()
297 #define RTE_EVENT_DEV_CAP_NONSEQ_MODE (1ULL << 6)
298 /**< Event device is capable of operating in none sequential mode. The path
299 * of the event is not necessary to be sequential. Application can change
300 * the path of event at runtime. If the flag is not set, then event each event
301 * will follow a path from queue 0 to queue 1 to queue 2 etc. If the flag is
302 * set, events may be sent to queues in any order. If the flag is not set, the
303 * eventdev will return an error when the application enqueues an event for a
304 * qid which is not the next in the sequence.
307 #define RTE_EVENT_DEV_CAP_RUNTIME_PORT_LINK (1ULL << 7)
308 /**< Event device is capable of configuring the queue/port link at runtime.
309 * If the flag is not set, the eventdev queue/port link is only can be
310 * configured during initialization.
313 #define RTE_EVENT_DEV_CAP_MULTIPLE_QUEUE_PORT (1ULL << 8)
314 /**< Event device is capable of setting up the link between multiple queue
315 * with single port. If the flag is not set, the eventdev can only map a
316 * single queue to each port or map a single queue to many port.
319 /* Event device priority levels */
320 #define RTE_EVENT_DEV_PRIORITY_HIGHEST 0
321 /**< Highest priority expressed across eventdev subsystem
322 * @see rte_event_queue_setup(), rte_event_enqueue_burst()
323 * @see rte_event_port_link()
325 #define RTE_EVENT_DEV_PRIORITY_NORMAL 128
326 /**< Normal priority expressed across eventdev subsystem
327 * @see rte_event_queue_setup(), rte_event_enqueue_burst()
328 * @see rte_event_port_link()
330 #define RTE_EVENT_DEV_PRIORITY_LOWEST 255
331 /**< Lowest priority expressed across eventdev subsystem
332 * @see rte_event_queue_setup(), rte_event_enqueue_burst()
333 * @see rte_event_port_link()
337 * Get the total number of event devices that have been successfully
341 * The total number of usable event devices.
344 rte_event_dev_count(void);
347 * Get the device identifier for the named event device.
350 * Event device name to select the event device identifier.
353 * Returns event device identifier on success.
354 * - <0: Failure to find named event device.
357 rte_event_dev_get_dev_id(const char *name);
360 * Return the NUMA socket to which a device is connected.
363 * The identifier of the device.
365 * The NUMA socket id to which the device is connected or
366 * a default of zero if the socket could not be determined.
367 * -(-EINVAL) dev_id value is out of range.
370 rte_event_dev_socket_id(uint8_t dev_id);
373 * Event device information
375 struct rte_event_dev_info {
376 const char *driver_name; /**< Event driver name */
377 struct rte_device *dev; /**< Device information */
378 uint32_t min_dequeue_timeout_ns;
379 /**< Minimum supported global dequeue timeout(ns) by this device */
380 uint32_t max_dequeue_timeout_ns;
381 /**< Maximum supported global dequeue timeout(ns) by this device */
382 uint32_t dequeue_timeout_ns;
383 /**< Configured global dequeue timeout(ns) for this device */
384 uint8_t max_event_queues;
385 /**< Maximum event_queues supported by this device */
386 uint32_t max_event_queue_flows;
387 /**< Maximum supported flows in an event queue by this device*/
388 uint8_t max_event_queue_priority_levels;
389 /**< Maximum number of event queue priority levels by this device.
390 * Valid when the device has RTE_EVENT_DEV_CAP_QUEUE_QOS capability
392 uint8_t max_event_priority_levels;
393 /**< Maximum number of event priority levels by this device.
394 * Valid when the device has RTE_EVENT_DEV_CAP_EVENT_QOS capability
396 uint8_t max_event_ports;
397 /**< Maximum number of event ports supported by this device */
398 uint8_t max_event_port_dequeue_depth;
399 /**< Maximum number of events can be dequeued at a time from an
400 * event port by this device.
401 * A device that does not support bulk dequeue will set this as 1.
403 uint32_t max_event_port_enqueue_depth;
404 /**< Maximum number of events can be enqueued at a time from an
405 * event port by this device.
406 * A device that does not support bulk enqueue will set this as 1.
408 int32_t max_num_events;
409 /**< A *closed system* event dev has a limit on the number of events it
410 * can manage at a time. An *open system* event dev does not have a
411 * limit and will specify this as -1.
413 uint32_t event_dev_cap;
414 /**< Event device capabilities(RTE_EVENT_DEV_CAP_)*/
418 * Retrieve the contextual information of an event device.
421 * The identifier of the device.
423 * @param[out] dev_info
424 * A pointer to a structure of type *rte_event_dev_info* to be filled with the
425 * contextual information of the device.
428 * - 0: Success, driver updates the contextual information of the event device
429 * - <0: Error code returned by the driver info get function.
433 rte_event_dev_info_get(uint8_t dev_id, struct rte_event_dev_info *dev_info);
436 * The count of ports.
438 #define RTE_EVENT_DEV_ATTR_PORT_COUNT 0
440 * The count of queues.
442 #define RTE_EVENT_DEV_ATTR_QUEUE_COUNT 1
444 * The status of the device, zero for stopped, non-zero for started.
446 #define RTE_EVENT_DEV_ATTR_STARTED 2
449 * Get an attribute from a device.
451 * @param dev_id Eventdev id
452 * @param attr_id The attribute ID to retrieve
453 * @param[out] attr_value A pointer that will be filled in with the attribute
454 * value if successful.
457 * - 0: Successfully retrieved attribute value
458 * - -EINVAL: Invalid device or *attr_id* provided, or *attr_value* is NULL
461 rte_event_dev_attr_get(uint8_t dev_id, uint32_t attr_id,
462 uint32_t *attr_value);
465 /* Event device configuration bitmap flags */
466 #define RTE_EVENT_DEV_CFG_PER_DEQUEUE_TIMEOUT (1ULL << 0)
467 /**< Override the global *dequeue_timeout_ns* and use per dequeue timeout in ns.
468 * @see rte_event_dequeue_timeout_ticks(), rte_event_dequeue_burst()
471 /** Event device configuration structure */
472 struct rte_event_dev_config {
473 uint32_t dequeue_timeout_ns;
474 /**< rte_event_dequeue_burst() timeout on this device.
475 * This value should be in the range of *min_dequeue_timeout_ns* and
476 * *max_dequeue_timeout_ns* which previously provided in
477 * rte_event_dev_info_get()
478 * The value 0 is allowed, in which case, default dequeue timeout used.
479 * @see RTE_EVENT_DEV_CFG_PER_DEQUEUE_TIMEOUT
481 int32_t nb_events_limit;
482 /**< In a *closed system* this field is the limit on maximum number of
483 * events that can be inflight in the eventdev at a given time. The
484 * limit is required to ensure that the finite space in a closed system
485 * is not overwhelmed. The value cannot exceed the *max_num_events*
486 * as provided by rte_event_dev_info_get().
487 * This value should be set to -1 for *open system*.
489 uint8_t nb_event_queues;
490 /**< Number of event queues to configure on this device.
491 * This value cannot exceed the *max_event_queues* which previously
492 * provided in rte_event_dev_info_get()
494 uint8_t nb_event_ports;
495 /**< Number of event ports to configure on this device.
496 * This value cannot exceed the *max_event_ports* which previously
497 * provided in rte_event_dev_info_get()
499 uint32_t nb_event_queue_flows;
500 /**< Number of flows for any event queue on this device.
501 * This value cannot exceed the *max_event_queue_flows* which previously
502 * provided in rte_event_dev_info_get()
504 uint32_t nb_event_port_dequeue_depth;
505 /**< Maximum number of events can be dequeued at a time from an
506 * event port by this device.
507 * This value cannot exceed the *max_event_port_dequeue_depth*
508 * which previously provided in rte_event_dev_info_get().
509 * Ignored when device is not RTE_EVENT_DEV_CAP_BURST_MODE capable.
510 * @see rte_event_port_setup()
512 uint32_t nb_event_port_enqueue_depth;
513 /**< Maximum number of events can be enqueued at a time from an
514 * event port by this device.
515 * This value cannot exceed the *max_event_port_enqueue_depth*
516 * which previously provided in rte_event_dev_info_get().
517 * Ignored when device is not RTE_EVENT_DEV_CAP_BURST_MODE capable.
518 * @see rte_event_port_setup()
520 uint32_t event_dev_cfg;
521 /**< Event device config flags(RTE_EVENT_DEV_CFG_)*/
525 * Configure an event device.
527 * This function must be invoked first before any other function in the
528 * API. This function can also be re-invoked when a device is in the
531 * The caller may use rte_event_dev_info_get() to get the capability of each
532 * resources available for this event device.
535 * The identifier of the device to configure.
537 * The event device configuration structure.
540 * - 0: Success, device configured.
541 * - <0: Error code returned by the driver configuration function.
544 rte_event_dev_configure(uint8_t dev_id,
545 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 structure */
700 struct rte_event_port_conf {
701 int32_t new_event_threshold;
702 /**< A backpressure threshold for new event enqueues on this port.
703 * Use for *closed system* event dev where event capacity is limited,
704 * and cannot exceed the capacity of the event dev.
705 * Configuring ports with different thresholds can make higher priority
706 * traffic less likely to be backpressured.
707 * For example, a port used to inject NIC Rx packets into the event dev
708 * can have a lower threshold so as not to overwhelm the device,
709 * while ports used for worker pools can have a higher threshold.
710 * This value cannot exceed the *nb_events_limit*
711 * which was previously supplied to rte_event_dev_configure().
712 * This should be set to '-1' for *open system*.
714 uint16_t dequeue_depth;
715 /**< Configure number of bulk dequeues for this event port.
716 * This value cannot exceed the *nb_event_port_dequeue_depth*
717 * which previously supplied to rte_event_dev_configure().
718 * Ignored when device is not RTE_EVENT_DEV_CAP_BURST_MODE capable.
720 uint16_t enqueue_depth;
721 /**< Configure number of bulk enqueues for this event port.
722 * This value cannot exceed the *nb_event_port_enqueue_depth*
723 * which previously supplied to rte_event_dev_configure().
724 * Ignored when device is not RTE_EVENT_DEV_CAP_BURST_MODE capable.
726 uint8_t disable_implicit_release;
727 /**< Configure the port not to release outstanding events in
728 * rte_event_dev_dequeue_burst(). If true, all events received through
729 * the port must be explicitly released with RTE_EVENT_OP_RELEASE or
730 * RTE_EVENT_OP_FORWARD. Must be false when the device is not
731 * RTE_EVENT_DEV_CAP_IMPLICIT_RELEASE_DISABLE capable.
736 * Retrieve the default configuration information of an event port designated
737 * by its *port_id* from the event driver for an event device.
739 * This function intended to be used in conjunction with rte_event_port_setup()
740 * where caller needs to set up the port by overriding few default values.
743 * The identifier of the device.
745 * The index of the event port to get the configuration information.
746 * The value must be in the range [0, nb_event_ports - 1]
747 * previously supplied to rte_event_dev_configure().
748 * @param[out] port_conf
749 * The pointer to the default event port configuration data
751 * - 0: Success, driver updates the default event port configuration data.
752 * - <0: Error code returned by the driver info get function.
754 * @see rte_event_port_setup()
758 rte_event_port_default_conf_get(uint8_t dev_id, uint8_t port_id,
759 struct rte_event_port_conf *port_conf);
762 * Allocate and set up an event port for an event device.
765 * The identifier of the device.
767 * The index of the event port to setup. The value must be in the range
768 * [0, nb_event_ports - 1] previously supplied to rte_event_dev_configure().
770 * The pointer to the configuration data to be used for the queue.
771 * NULL value is allowed, in which case default configuration used.
773 * @see rte_event_port_default_conf_get()
776 * - 0: Success, event port correctly set up.
777 * - <0: Port configuration failed
778 * - (-EDQUOT) Quota exceeded(Application tried to link the queue configured
779 * with RTE_EVENT_QUEUE_CFG_SINGLE_LINK to more than one event ports)
782 rte_event_port_setup(uint8_t dev_id, uint8_t port_id,
783 const struct rte_event_port_conf *port_conf);
786 * The queue depth of the port on the enqueue side
788 #define RTE_EVENT_PORT_ATTR_ENQ_DEPTH 0
790 * The queue depth of the port on the dequeue side
792 #define RTE_EVENT_PORT_ATTR_DEQ_DEPTH 1
794 * The new event threshold of the port
796 #define RTE_EVENT_PORT_ATTR_NEW_EVENT_THRESHOLD 2
799 * Get an attribute from a port.
806 * The attribute ID to retrieve
807 * @param[out] attr_value
808 * A pointer that will be filled in with the attribute value if successful
811 * - 0: Successfully returned value
812 * - (-EINVAL) Invalid device, port or attr_id, or attr_value was NULL
815 rte_event_port_attr_get(uint8_t dev_id, uint8_t port_id, uint32_t attr_id,
816 uint32_t *attr_value);
819 * Start an event device.
821 * The device start step is the last one and consists of setting the event
822 * queues to start accepting the events and schedules to event ports.
824 * On success, all basic functions exported by the API (event enqueue,
825 * event dequeue and so on) can be invoked.
828 * Event device identifier
830 * - 0: Success, device started.
831 * - -ESTALE : Not all ports of the device are configured
832 * - -ENOLINK: Not all queues are linked, which could lead to deadlock.
835 rte_event_dev_start(uint8_t dev_id);
838 * Stop an event device. The device can be restarted with a call to
839 * rte_event_dev_start()
842 * Event device identifier.
845 rte_event_dev_stop(uint8_t dev_id);
848 * Close an event device. The device cannot be restarted!
851 * Event device identifier
854 * - 0 on successfully closing device
855 * - <0 on failure to close device
856 * - (-EAGAIN) if device is busy
859 rte_event_dev_close(uint8_t dev_id);
861 /* Scheduler type definitions */
862 #define RTE_SCHED_TYPE_ORDERED 0
863 /**< Ordered scheduling
865 * Events from an ordered flow of an event queue can be scheduled to multiple
866 * ports for concurrent processing while maintaining the original event order.
867 * This scheme enables the user to achieve high single flow throughput by
868 * avoiding SW synchronization for ordering between ports which bound to cores.
870 * The source flow ordering from an event queue is maintained when events are
871 * enqueued to their destination queue within the same ordered flow context.
872 * An event port holds the context until application call
873 * rte_event_dequeue_burst() from the same port, which implicitly releases
875 * User may allow the scheduler to release the context earlier than that
876 * by invoking rte_event_enqueue_burst() with RTE_EVENT_OP_RELEASE operation.
878 * Events from the source queue appear in their original order when dequeued
879 * from a destination queue.
880 * Event ordering is based on the received event(s), but also other
881 * (newly allocated or stored) events are ordered when enqueued within the same
882 * ordered context. Events not enqueued (e.g. released or stored) within the
883 * context are considered missing from reordering and are skipped at this time
884 * (but can be ordered again within another context).
886 * @see rte_event_queue_setup(), rte_event_dequeue_burst(), RTE_EVENT_OP_RELEASE
889 #define RTE_SCHED_TYPE_ATOMIC 1
890 /**< Atomic scheduling
892 * Events from an atomic flow of an event queue can be scheduled only to a
893 * single port at a time. The port is guaranteed to have exclusive (atomic)
894 * access to the associated flow context, which enables the user to avoid SW
895 * synchronization. Atomic flows also help to maintain event ordering
896 * since only one port at a time can process events from a flow of an
899 * The atomic queue synchronization context is dedicated to the port until
900 * application call rte_event_dequeue_burst() from the same port,
901 * which implicitly releases the context. User may allow the scheduler to
902 * release the context earlier than that by invoking rte_event_enqueue_burst()
903 * with RTE_EVENT_OP_RELEASE operation.
905 * @see rte_event_queue_setup(), rte_event_dequeue_burst(), RTE_EVENT_OP_RELEASE
908 #define RTE_SCHED_TYPE_PARALLEL 2
909 /**< Parallel scheduling
911 * The scheduler performs priority scheduling, load balancing, etc. functions
912 * but does not provide additional event synchronization or ordering.
913 * It is free to schedule events from a single parallel flow of an event queue
914 * to multiple events ports for concurrent processing.
915 * The application is responsible for flow context synchronization and
916 * event ordering (SW synchronization).
918 * @see rte_event_queue_setup(), rte_event_dequeue_burst()
921 /* Event types to classify the event source */
922 #define RTE_EVENT_TYPE_ETHDEV 0x0
923 /**< The event generated from ethdev subsystem */
924 #define RTE_EVENT_TYPE_CRYPTODEV 0x1
925 /**< The event generated from crypodev subsystem */
926 #define RTE_EVENT_TYPE_TIMERDEV 0x2
927 /**< The event generated from timerdev subsystem */
928 #define RTE_EVENT_TYPE_CPU 0x3
929 /**< The event generated from cpu for pipelining.
930 * Application may use *sub_event_type* to further classify the event
932 #define RTE_EVENT_TYPE_ETH_RX_ADAPTER 0x4
933 /**< The event generated from event eth Rx adapter */
934 #define RTE_EVENT_TYPE_MAX 0x10
935 /**< Maximum number of event types */
937 /* Event enqueue operations */
938 #define RTE_EVENT_OP_NEW 0
939 /**< The event producers use this operation to inject a new event to the
942 #define RTE_EVENT_OP_FORWARD 1
943 /**< The CPU use this operation to forward the event to different event queue or
944 * change to new application specific flow or schedule type to enable
947 * This operation must only be enqueued to the same port that the
948 * event to be forwarded was dequeued from.
950 #define RTE_EVENT_OP_RELEASE 2
951 /**< Release the flow context associated with the schedule type.
953 * If current flow's scheduler type method is *RTE_SCHED_TYPE_ATOMIC*
954 * then this function hints the scheduler that the user has completed critical
955 * section processing in the current atomic context.
956 * The scheduler is now allowed to schedule events from the same flow from
957 * an event queue to another port. However, the context may be still held
958 * until the next rte_event_dequeue_burst() call, this call allows but does not
959 * force the scheduler to release the context early.
961 * Early atomic context release may increase parallelism and thus system
962 * performance, but the user needs to design carefully the split into critical
963 * vs non-critical sections.
965 * If current flow's scheduler type method is *RTE_SCHED_TYPE_ORDERED*
966 * then this function hints the scheduler that the user has done all that need
967 * to maintain event order in the current ordered context.
968 * The scheduler is allowed to release the ordered context of this port and
969 * avoid reordering any following enqueues.
971 * Early ordered context release may increase parallelism and thus system
974 * If current flow's scheduler type method is *RTE_SCHED_TYPE_PARALLEL*
975 * or no scheduling context is held then this function may be an NOOP,
976 * depending on the implementation.
978 * This operation must only be enqueued to the same port that the
979 * event to be released was dequeued from.
984 * The generic *rte_event* structure to hold the event attributes
985 * for dequeue and enqueue operation
992 /** Event attributes for dequeue or enqueue operation */
995 /**< Targeted flow identifier for the enqueue and
997 * The value must be in the range of
998 * [0, nb_event_queue_flows - 1] which
999 * previously supplied to rte_event_dev_configure().
1001 uint32_t sub_event_type:8;
1002 /**< Sub-event types based on the event source.
1003 * @see RTE_EVENT_TYPE_CPU
1005 uint32_t event_type:4;
1006 /**< Event type to classify the event source.
1007 * @see RTE_EVENT_TYPE_ETHDEV, (RTE_EVENT_TYPE_*)
1010 /**< The type of event enqueue operation - new/forward/
1011 * etc.This field is not preserved across an instance
1012 * and is undefined on dequeue.
1013 * @see RTE_EVENT_OP_NEW, (RTE_EVENT_OP_*)
1016 /**< Reserved for future use */
1017 uint8_t sched_type:2;
1018 /**< Scheduler synchronization type (RTE_SCHED_TYPE_*)
1019 * associated with flow id on a given event queue
1020 * for the enqueue and dequeue operation.
1023 /**< Targeted event queue identifier for the enqueue or
1024 * dequeue operation.
1025 * The value must be in the range of
1026 * [0, nb_event_queues - 1] which previously supplied to
1027 * rte_event_dev_configure().
1030 /**< Event priority relative to other events in the
1031 * event queue. The requested priority should in the
1032 * range of [RTE_EVENT_DEV_PRIORITY_HIGHEST,
1033 * RTE_EVENT_DEV_PRIORITY_LOWEST].
1034 * The implementation shall normalize the requested
1035 * priority to supported priority value.
1036 * Valid when the device has
1037 * RTE_EVENT_DEV_CAP_EVENT_QOS capability.
1039 uint8_t impl_opaque;
1040 /**< Implementation specific opaque value.
1041 * An implementation may use this field to hold
1042 * implementation specific value to share between
1043 * dequeue and enqueue operation.
1044 * The application should not modify this field.
1051 /**< Opaque 64-bit value */
1053 /**< Opaque event pointer */
1054 struct rte_mbuf *mbuf;
1055 /**< mbuf pointer if dequeued event is associated with mbuf */
1059 /* Ethdev Rx adapter capability bitmap flags */
1060 #define RTE_EVENT_ETH_RX_ADAPTER_CAP_INTERNAL_PORT 0x1
1061 /**< This flag is sent when the packet transfer mechanism is in HW.
1062 * Ethdev can send packets to the event device using internal event port.
1064 #define RTE_EVENT_ETH_RX_ADAPTER_CAP_MULTI_EVENTQ 0x2
1065 /**< Adapter supports multiple event queues per ethdev. Every ethdev
1066 * Rx queue can be connected to a unique event queue.
1068 #define RTE_EVENT_ETH_RX_ADAPTER_CAP_OVERRIDE_FLOW_ID 0x4
1069 /**< The application can override the adapter generated flow ID in the
1070 * event. This flow ID can be specified when adding an ethdev Rx queue
1071 * to the adapter using the ev member of struct rte_event_eth_rx_adapter
1072 * @see struct rte_event_eth_rx_adapter_queue_conf::ev
1073 * @see struct rte_event_eth_rx_adapter_queue_conf::rx_queue_flags
1077 * Retrieve the event device's ethdev Rx adapter capabilities for the
1078 * specified ethernet port
1081 * The identifier of the device.
1083 * @param eth_port_id
1084 * The identifier of the ethernet device.
1087 * A pointer to memory filled with Rx event adapter capabilities.
1090 * - 0: Success, driver provides Rx event adapter capabilities for the
1092 * - <0: Error code returned by the driver function.
1096 rte_event_eth_rx_adapter_caps_get(uint8_t dev_id, uint8_t eth_port_id,
1099 struct rte_eventdev_driver;
1100 struct rte_eventdev_ops;
1101 struct rte_eventdev;
1103 typedef uint16_t (*event_enqueue_t)(void *port, const struct rte_event *ev);
1104 /**< @internal Enqueue event on port of a device */
1106 typedef uint16_t (*event_enqueue_burst_t)(void *port,
1107 const struct rte_event ev[], uint16_t nb_events);
1108 /**< @internal Enqueue burst of events on port of a device */
1110 typedef uint16_t (*event_dequeue_t)(void *port, struct rte_event *ev,
1111 uint64_t timeout_ticks);
1112 /**< @internal Dequeue event from port of a device */
1114 typedef uint16_t (*event_dequeue_burst_t)(void *port, struct rte_event ev[],
1115 uint16_t nb_events, uint64_t timeout_ticks);
1116 /**< @internal Dequeue burst of events from port of a device */
1118 #define RTE_EVENTDEV_NAME_MAX_LEN (64)
1119 /**< @internal Max length of name of event PMD */
1123 * The data part, with no function pointers, associated with each device.
1125 * This structure is safe to place in shared memory to be common among
1126 * different processes in a multi-process configuration.
1128 struct rte_eventdev_data {
1130 /**< Socket ID where memory is allocated */
1132 /**< Device ID for this instance */
1134 /**< Number of event queues. */
1136 /**< Number of event ports. */
1138 /**< Array of pointers to ports. */
1139 struct rte_event_port_conf *ports_cfg;
1140 /**< Array of port configuration structures. */
1141 struct rte_event_queue_conf *queues_cfg;
1142 /**< Array of queue configuration structures. */
1143 uint16_t *links_map;
1144 /**< Memory to store queues to port connections. */
1146 /**< PMD-specific private data */
1147 uint32_t event_dev_cap;
1148 /**< Event device capabilities(RTE_EVENT_DEV_CAP_)*/
1149 struct rte_event_dev_config dev_conf;
1150 /**< Configuration applied to device. */
1151 uint8_t service_inited;
1152 /* Service initialization state */
1153 uint32_t service_id;
1157 uint8_t dev_started : 1;
1158 /**< Device state: STARTED(1)/STOPPED(0) */
1160 char name[RTE_EVENTDEV_NAME_MAX_LEN];
1161 /**< Unique identifier name */
1162 } __rte_cache_aligned;
1164 /** @internal The data structure associated with each event device. */
1165 struct rte_eventdev {
1166 event_enqueue_t enqueue;
1167 /**< Pointer to PMD enqueue function. */
1168 event_enqueue_burst_t enqueue_burst;
1169 /**< Pointer to PMD enqueue burst function. */
1170 event_enqueue_burst_t enqueue_new_burst;
1171 /**< Pointer to PMD enqueue burst function(op new variant) */
1172 event_enqueue_burst_t enqueue_forward_burst;
1173 /**< Pointer to PMD enqueue burst function(op forward variant) */
1174 event_dequeue_t dequeue;
1175 /**< Pointer to PMD dequeue function. */
1176 event_dequeue_burst_t dequeue_burst;
1177 /**< Pointer to PMD dequeue burst function. */
1179 struct rte_eventdev_data *data;
1180 /**< Pointer to device data */
1181 const struct rte_eventdev_ops *dev_ops;
1182 /**< Functions exported by PMD */
1183 struct rte_device *dev;
1184 /**< Device info. supplied by probing */
1187 uint8_t attached : 1;
1188 /**< Flag indicating the device is attached */
1189 } __rte_cache_aligned;
1191 extern struct rte_eventdev *rte_eventdevs;
1192 /** @internal The pool of rte_eventdev structures. */
1194 static __rte_always_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,
1197 const event_enqueue_burst_t fn)
1199 const struct rte_eventdev *dev = &rte_eventdevs[dev_id];
1201 #ifdef RTE_LIBRTE_EVENTDEV_DEBUG
1202 if (dev_id >= RTE_EVENT_MAX_DEVS || !rte_eventdevs[dev_id].attached) {
1203 rte_errno = -EINVAL;
1207 if (port_id >= dev->data->nb_ports) {
1208 rte_errno = -EINVAL;
1213 * Allow zero cost non burst mode routine invocation if application
1214 * requests nb_events as const one
1217 return (*dev->enqueue)(dev->data->ports[port_id], ev);
1219 return fn(dev->data->ports[port_id], ev, nb_events);
1223 * Enqueue a burst of events objects or an event object supplied in *rte_event*
1224 * structure on an event device designated by its *dev_id* through the event
1225 * port specified by *port_id*. Each event object specifies the event queue on
1226 * which it will be enqueued.
1228 * The *nb_events* parameter is the number of event objects to enqueue which are
1229 * supplied in the *ev* array of *rte_event* structure.
1231 * Event operations RTE_EVENT_OP_FORWARD and RTE_EVENT_OP_RELEASE must only be
1232 * enqueued to the same port that their associated events were dequeued from.
1234 * The rte_event_enqueue_burst() function returns the number of
1235 * events objects it actually enqueued. A return value equal to *nb_events*
1236 * means that all event objects have been enqueued.
1239 * The identifier of the device.
1241 * The identifier of the event port.
1243 * Points to an array of *nb_events* objects of type *rte_event* structure
1244 * which contain the event object enqueue operations to be processed.
1246 * The number of event objects to enqueue, typically number of
1247 * rte_event_port_enqueue_depth() available for this port.
1250 * The number of event objects actually enqueued on the event device. The
1251 * return value can be less than the value of the *nb_events* parameter when
1252 * the event devices queue is full or if invalid parameters are specified in a
1253 * *rte_event*. If the return value is less than *nb_events*, the remaining
1254 * events at the end of ev[] are not consumed and the caller has to take care
1255 * of them, and rte_errno is set accordingly. Possible errno values include:
1256 * - -EINVAL The port ID is invalid, device ID is invalid, an event's queue
1257 * ID is invalid, or an event's sched type doesn't match the
1258 * capabilities of the destination queue.
1259 * - -ENOSPC The event port was backpressured and unable to enqueue
1260 * one or more events. This error code is only applicable to
1262 * @see rte_event_port_enqueue_depth()
1264 static inline uint16_t
1265 rte_event_enqueue_burst(uint8_t dev_id, uint8_t port_id,
1266 const struct rte_event ev[], uint16_t nb_events)
1268 const struct rte_eventdev *dev = &rte_eventdevs[dev_id];
1270 return __rte_event_enqueue_burst(dev_id, port_id, ev, nb_events,
1271 dev->enqueue_burst);
1275 * Enqueue a burst of events objects of operation type *RTE_EVENT_OP_NEW* on
1276 * an event device designated by its *dev_id* through the event port specified
1279 * Provides the same functionality as rte_event_enqueue_burst(), expect that
1280 * application can use this API when the all objects in the burst contains
1281 * the enqueue operation of the type *RTE_EVENT_OP_NEW*. This specialized
1282 * function can provide the additional hint to the PMD and optimize if possible.
1284 * The rte_event_enqueue_new_burst() result is undefined if the enqueue burst
1285 * has event object of operation type != RTE_EVENT_OP_NEW.
1288 * The identifier of the device.
1290 * The identifier of the event port.
1292 * Points to an array of *nb_events* objects of type *rte_event* structure
1293 * which contain the event object enqueue operations to be processed.
1295 * The number of event objects to enqueue, typically number of
1296 * rte_event_port_enqueue_depth() available for this port.
1299 * The number of event objects actually enqueued on the event device. The
1300 * return value can be less than the value of the *nb_events* parameter when
1301 * the event devices queue is full or if invalid parameters are specified in a
1302 * *rte_event*. If the return value is less than *nb_events*, the remaining
1303 * events at the end of ev[] are not consumed and the caller has to take care
1304 * of them, and rte_errno is set accordingly. Possible errno values include:
1305 * - -EINVAL The port ID is invalid, device ID is invalid, an event's queue
1306 * ID is invalid, or an event's sched type doesn't match the
1307 * capabilities of the destination queue.
1308 * - -ENOSPC The event port was backpressured and unable to enqueue
1309 * one or more events. This error code is only applicable to
1311 * @see rte_event_port_enqueue_depth() rte_event_enqueue_burst()
1313 static inline uint16_t
1314 rte_event_enqueue_new_burst(uint8_t dev_id, uint8_t port_id,
1315 const struct rte_event ev[], uint16_t nb_events)
1317 const struct rte_eventdev *dev = &rte_eventdevs[dev_id];
1319 return __rte_event_enqueue_burst(dev_id, port_id, ev, nb_events,
1320 dev->enqueue_new_burst);
1324 * Enqueue a burst of events objects of operation type *RTE_EVENT_OP_FORWARD*
1325 * on an event device designated by its *dev_id* through the event port
1326 * specified by *port_id*.
1328 * Provides the same functionality as rte_event_enqueue_burst(), expect that
1329 * application can use this API when the all objects in the burst contains
1330 * the enqueue operation of the type *RTE_EVENT_OP_FORWARD*. This specialized
1331 * function can provide the additional hint to the PMD and optimize if possible.
1333 * The rte_event_enqueue_new_burst() result is undefined if the enqueue burst
1334 * has event object of operation type != RTE_EVENT_OP_FORWARD.
1337 * The identifier of the device.
1339 * The identifier of the event port.
1341 * Points to an array of *nb_events* objects of type *rte_event* structure
1342 * which contain the event object enqueue operations to be processed.
1344 * The number of event objects to enqueue, typically number of
1345 * rte_event_port_enqueue_depth() available for this port.
1348 * The number of event objects actually enqueued on the event device. The
1349 * return value can be less than the value of the *nb_events* parameter when
1350 * the event devices queue is full or if invalid parameters are specified in a
1351 * *rte_event*. If the return value is less than *nb_events*, the remaining
1352 * events at the end of ev[] are not consumed and the caller has to take care
1353 * of them, and rte_errno is set accordingly. Possible errno values include:
1354 * - -EINVAL The port ID is invalid, device ID is invalid, an event's queue
1355 * ID is invalid, or an event's sched type doesn't match the
1356 * capabilities of the destination queue.
1357 * - -ENOSPC The event port was backpressured and unable to enqueue
1358 * one or more events. This error code is only applicable to
1360 * @see rte_event_port_enqueue_depth() rte_event_enqueue_burst()
1362 static inline uint16_t
1363 rte_event_enqueue_forward_burst(uint8_t dev_id, uint8_t port_id,
1364 const struct rte_event ev[], uint16_t nb_events)
1366 const struct rte_eventdev *dev = &rte_eventdevs[dev_id];
1368 return __rte_event_enqueue_burst(dev_id, port_id, ev, nb_events,
1369 dev->enqueue_forward_burst);
1373 * Converts nanoseconds to *timeout_ticks* value for rte_event_dequeue_burst()
1375 * If the device is configured with RTE_EVENT_DEV_CFG_PER_DEQUEUE_TIMEOUT flag
1376 * then application can use this function to convert timeout value in
1377 * nanoseconds to implementations specific timeout value supplied in
1378 * rte_event_dequeue_burst()
1381 * The identifier of the device.
1383 * Wait time in nanosecond
1384 * @param[out] timeout_ticks
1385 * Value for the *timeout_ticks* parameter in rte_event_dequeue_burst()
1389 * - -ENOTSUP if the device doesn't support timeouts
1390 * - -EINVAL if *dev_id* is invalid or *timeout_ticks* is NULL
1391 * - other values < 0 on failure.
1393 * @see rte_event_dequeue_burst(), RTE_EVENT_DEV_CFG_PER_DEQUEUE_TIMEOUT
1394 * @see rte_event_dev_configure()
1398 rte_event_dequeue_timeout_ticks(uint8_t dev_id, uint64_t ns,
1399 uint64_t *timeout_ticks);
1402 * Dequeue a burst of events objects or an event object from the event port
1403 * designated by its *event_port_id*, on an event device designated
1406 * rte_event_dequeue_burst() does not dictate the specifics of scheduling
1407 * algorithm as each eventdev driver may have different criteria to schedule
1408 * an event. However, in general, from an application perspective scheduler may
1409 * use the following scheme to dispatch an event to the port.
1411 * 1) Selection of event queue based on
1412 * a) The list of event queues are linked to the event port.
1413 * b) If the device has RTE_EVENT_DEV_CAP_QUEUE_QOS capability then event
1414 * queue selection from list is based on event queue priority relative to
1415 * other event queue supplied as *priority* in rte_event_queue_setup()
1416 * c) If the device has RTE_EVENT_DEV_CAP_EVENT_QOS capability then event
1417 * queue selection from the list is based on event priority supplied as
1418 * *priority* in rte_event_enqueue_burst()
1419 * 2) Selection of event
1420 * a) The number of flows available in selected event queue.
1421 * b) Schedule type method associated with the event
1423 * The *nb_events* parameter is the maximum number of event objects to dequeue
1424 * which are returned in the *ev* array of *rte_event* structure.
1426 * The rte_event_dequeue_burst() function returns the number of events objects
1427 * it actually dequeued. A return value equal to *nb_events* means that all
1428 * event objects have been dequeued.
1430 * The number of events dequeued is the number of scheduler contexts held by
1431 * this port. These contexts are automatically released in the next
1432 * rte_event_dequeue_burst() invocation if the port supports implicit
1433 * releases, or invoking rte_event_enqueue_burst() with RTE_EVENT_OP_RELEASE
1434 * operation can be used to release the contexts early.
1436 * Event operations RTE_EVENT_OP_FORWARD and RTE_EVENT_OP_RELEASE must only be
1437 * enqueued to the same port that their associated events were dequeued from.
1440 * The identifier of the device.
1442 * The identifier of the event port.
1444 * Points to an array of *nb_events* objects of type *rte_event* structure
1445 * for output to be populated with the dequeued event objects.
1447 * The maximum number of event objects to dequeue, typically number of
1448 * rte_event_port_dequeue_depth() available for this port.
1450 * @param timeout_ticks
1451 * - 0 no-wait, returns immediately if there is no event.
1452 * - >0 wait for the event, if the device is configured with
1453 * RTE_EVENT_DEV_CFG_PER_DEQUEUE_TIMEOUT then this function will wait until
1454 * at least one event is available or *timeout_ticks* time.
1455 * if the device is not configured with RTE_EVENT_DEV_CFG_PER_DEQUEUE_TIMEOUT
1456 * then this function will wait until the event available or
1457 * *dequeue_timeout_ns* ns which was previously supplied to
1458 * rte_event_dev_configure()
1461 * The number of event objects actually dequeued from the port. The return
1462 * value can be less than the value of the *nb_events* parameter when the
1463 * event port's queue is not full.
1465 * @see rte_event_port_dequeue_depth()
1467 static inline uint16_t
1468 rte_event_dequeue_burst(uint8_t dev_id, uint8_t port_id, struct rte_event ev[],
1469 uint16_t nb_events, uint64_t timeout_ticks)
1471 struct rte_eventdev *dev = &rte_eventdevs[dev_id];
1473 #ifdef RTE_LIBRTE_EVENTDEV_DEBUG
1474 if (dev_id >= RTE_EVENT_MAX_DEVS || !rte_eventdevs[dev_id].attached) {
1475 rte_errno = -EINVAL;
1479 if (port_id >= dev->data->nb_ports) {
1480 rte_errno = -EINVAL;
1486 * Allow zero cost non burst mode routine invocation if application
1487 * requests nb_events as const one
1490 return (*dev->dequeue)(
1491 dev->data->ports[port_id], ev, timeout_ticks);
1493 return (*dev->dequeue_burst)(
1494 dev->data->ports[port_id], ev, nb_events,
1499 * Link multiple source event queues supplied in *queues* to the destination
1500 * event port designated by its *port_id* with associated service priority
1501 * supplied in *priorities* on the event device designated by its *dev_id*.
1503 * The link establishment shall enable the event port *port_id* from
1504 * receiving events from the specified event queue(s) supplied in *queues*
1506 * An event queue may link to one or more event ports.
1507 * The number of links can be established from an event queue to event port is
1508 * implementation defined.
1510 * Event queue(s) to event port link establishment can be changed at runtime
1511 * without re-configuring the device to support scaling and to reduce the
1512 * latency of critical work by establishing the link with more event ports
1516 * The identifier of the device.
1519 * Event port identifier to select the destination port to link.
1522 * Points to an array of *nb_links* event queues to be linked
1523 * to the event port.
1524 * NULL value is allowed, in which case this function links all the configured
1525 * event queues *nb_event_queues* which previously supplied to
1526 * rte_event_dev_configure() to the event port *port_id*
1529 * Points to an array of *nb_links* service priorities associated with each
1530 * event queue link to event port.
1531 * The priority defines the event port's servicing priority for
1532 * event queue, which may be ignored by an implementation.
1533 * The requested priority should in the range of
1534 * [RTE_EVENT_DEV_PRIORITY_HIGHEST, RTE_EVENT_DEV_PRIORITY_LOWEST].
1535 * The implementation shall normalize the requested priority to
1536 * implementation supported priority value.
1537 * NULL value is allowed, in which case this function links the event queues
1538 * with RTE_EVENT_DEV_PRIORITY_NORMAL servicing priority
1541 * The number of links to establish. This parameter is ignored if queues is
1545 * The number of links actually established. The return value can be less than
1546 * the value of the *nb_links* parameter when the implementation has the
1547 * limitation on specific queue to port link establishment or if invalid
1548 * parameters are specified in *queues*
1549 * If the return value is less than *nb_links*, the remaining links at the end
1550 * of link[] are not established, and the caller has to take care of them.
1551 * If return value is less than *nb_links* then implementation shall update the
1552 * rte_errno accordingly, Possible rte_errno values are
1553 * (-EDQUOT) Quota exceeded(Application tried to link the queue configured with
1554 * RTE_EVENT_QUEUE_CFG_SINGLE_LINK to more than one event ports)
1555 * (-EINVAL) Invalid parameter
1559 rte_event_port_link(uint8_t dev_id, uint8_t port_id,
1560 const uint8_t queues[], const uint8_t priorities[],
1564 * Unlink multiple source event queues supplied in *queues* from the destination
1565 * event port designated by its *port_id* on the event device designated
1568 * The unlink establishment shall disable the event port *port_id* from
1569 * receiving events from the specified event queue *queue_id*
1571 * Event queue(s) to event port unlink establishment can be changed at runtime
1572 * without re-configuring the device.
1575 * The identifier of the device.
1578 * Event port identifier to select the destination port to unlink.
1581 * Points to an array of *nb_unlinks* event queues to be unlinked
1582 * from the event port.
1583 * NULL value is allowed, in which case this function unlinks all the
1584 * event queue(s) from the event port *port_id*.
1587 * The number of unlinks to establish. This parameter is ignored if queues is
1591 * The number of unlinks actually established. The return value can be less
1592 * than the value of the *nb_unlinks* parameter when the implementation has the
1593 * limitation on specific queue to port unlink establishment or
1594 * if invalid parameters are specified.
1595 * If the return value is less than *nb_unlinks*, the remaining queues at the
1596 * end of queues[] are not established, and the caller has to take care of them.
1597 * If return value is less than *nb_unlinks* then implementation shall update
1598 * the rte_errno accordingly, Possible rte_errno values are
1599 * (-EINVAL) Invalid parameter
1603 rte_event_port_unlink(uint8_t dev_id, uint8_t port_id,
1604 uint8_t queues[], uint16_t nb_unlinks);
1607 * Retrieve the list of source event queues and its associated service priority
1608 * linked to the destination event port designated by its *port_id*
1609 * on the event device designated by its *dev_id*.
1612 * The identifier of the device.
1615 * Event port identifier.
1617 * @param[out] queues
1618 * Points to an array of *queues* for output.
1619 * The caller has to allocate *RTE_EVENT_MAX_QUEUES_PER_DEV* bytes to
1620 * store the event queue(s) linked with event port *port_id*
1622 * @param[out] priorities
1623 * Points to an array of *priorities* for output.
1624 * The caller has to allocate *RTE_EVENT_MAX_QUEUES_PER_DEV* bytes to
1625 * store the service priority associated with each event queue linked
1628 * The number of links established on the event port designated by its
1634 rte_event_port_links_get(uint8_t dev_id, uint8_t port_id,
1635 uint8_t queues[], uint8_t priorities[]);
1638 * Retrieve the service ID of the event dev. If the adapter doesn't use
1639 * a rte_service function, this function returns -ESRCH.
1642 * The identifier of the device.
1644 * @param [out] service_id
1645 * A pointer to a uint32_t, to be filled in with the service id.
1649 * - <0: Error code on failure, if the event dev doesn't use a rte_service
1650 * function, this function returns -ESRCH.
1653 rte_event_dev_service_id_get(uint8_t dev_id, uint32_t *service_id);
1656 * Dump internal information about *dev_id* to the FILE* provided in *f*.
1659 * The identifier of the device.
1662 * A pointer to a file for output
1669 rte_event_dev_dump(uint8_t dev_id, FILE *f);
1671 /** Maximum name length for extended statistics counters */
1672 #define RTE_EVENT_DEV_XSTATS_NAME_SIZE 64
1675 * Selects the component of the eventdev to retrieve statistics from.
1677 enum rte_event_dev_xstats_mode {
1678 RTE_EVENT_DEV_XSTATS_DEVICE,
1679 RTE_EVENT_DEV_XSTATS_PORT,
1680 RTE_EVENT_DEV_XSTATS_QUEUE,
1684 * A name-key lookup element for extended statistics.
1686 * This structure is used to map between names and ID numbers
1687 * for extended ethdev statistics.
1689 struct rte_event_dev_xstats_name {
1690 char name[RTE_EVENT_DEV_XSTATS_NAME_SIZE];
1694 * Retrieve names of extended statistics of an event device.
1697 * The identifier of the event device.
1699 * The mode of statistics to retrieve. Choices include the device statistics,
1700 * port statistics or queue statistics.
1701 * @param queue_port_id
1702 * Used to specify the port or queue number in queue or port mode, and is
1703 * ignored in device mode.
1704 * @param[out] xstats_names
1705 * Block of memory to insert names into. Must be at least size in capacity.
1706 * If set to NULL, function returns required capacity.
1708 * Block of memory to insert ids into. Must be at least size in capacity.
1709 * If set to NULL, function returns required capacity. The id values returned
1710 * can be passed to *rte_event_dev_xstats_get* to select statistics.
1712 * Capacity of xstats_names (number of names).
1714 * - positive value lower or equal to size: success. The return value
1715 * is the number of entries filled in the stats table.
1716 * - positive value higher than size: error, the given statistics table
1717 * is too small. The return value corresponds to the size that should
1718 * be given to succeed. The entries in the table are not valid and
1719 * shall not be used by the caller.
1720 * - negative value on error:
1721 * -ENODEV for invalid *dev_id*
1722 * -EINVAL for invalid mode, queue port or id parameters
1723 * -ENOTSUP if the device doesn't support this function.
1726 rte_event_dev_xstats_names_get(uint8_t dev_id,
1727 enum rte_event_dev_xstats_mode mode,
1728 uint8_t queue_port_id,
1729 struct rte_event_dev_xstats_name *xstats_names,
1734 * Retrieve extended statistics of an event device.
1737 * The identifier of the device.
1739 * The mode of statistics to retrieve. Choices include the device statistics,
1740 * port statistics or queue statistics.
1741 * @param queue_port_id
1742 * Used to specify the port or queue number in queue or port mode, and is
1743 * ignored in device mode.
1745 * The id numbers of the stats to get. The ids can be got from the stat
1746 * position in the stat list from rte_event_dev_get_xstats_names(), or
1747 * by using rte_eventdev_get_xstats_by_name()
1748 * @param[out] values
1749 * The values for each stats request by ID.
1751 * The number of stats requested
1753 * - positive value: number of stat entries filled into the values array
1754 * - negative value on error:
1755 * -ENODEV for invalid *dev_id*
1756 * -EINVAL for invalid mode, queue port or id parameters
1757 * -ENOTSUP if the device doesn't support this function.
1760 rte_event_dev_xstats_get(uint8_t dev_id,
1761 enum rte_event_dev_xstats_mode mode,
1762 uint8_t queue_port_id,
1763 const unsigned int ids[],
1764 uint64_t values[], unsigned int n);
1767 * Retrieve the value of a single stat by requesting it by name.
1770 * The identifier of the device
1772 * The stat name to retrieve
1774 * If non-NULL, the numerical id of the stat will be returned, so that further
1775 * requests for the stat can be got using rte_eventdev_xstats_get, which will
1776 * be faster as it doesn't need to scan a list of names for the stat.
1777 * If the stat cannot be found, the id returned will be (unsigned)-1.
1779 * - positive value or zero: the stat value
1780 * - negative value: -EINVAL if stat not found, -ENOTSUP if not supported.
1783 rte_event_dev_xstats_by_name_get(uint8_t dev_id, const char *name,
1787 * Reset the values of the xstats of the selected component in the device.
1790 * The identifier of the device
1792 * The mode of the statistics to reset. Choose from device, queue or port.
1793 * @param queue_port_id
1794 * The queue or port to reset. 0 and positive values select ports and queues,
1795 * while -1 indicates all ports or queues.
1797 * Selects specific statistics to be reset. When NULL, all statistics selected
1798 * by *mode* will be reset. If non-NULL, must point to array of at least
1801 * The number of ids available from the *ids* array. Ignored when ids is NULL.
1803 * - zero: successfully reset the statistics to zero
1804 * - negative value: -EINVAL invalid parameters, -ENOTSUP if not supported.
1807 rte_event_dev_xstats_reset(uint8_t dev_id,
1808 enum rte_event_dev_xstats_mode mode,
1809 int16_t queue_port_id,
1810 const uint32_t ids[],
1814 * Trigger the eventdev self test.
1817 * The identifier of the device
1819 * - 0: Selftest successful
1820 * - -ENOTSUP if the device doesn't support selftest
1821 * - other values < 0 on failure.
1823 int rte_event_dev_selftest(uint8_t dev_id);
1829 #endif /* _RTE_EVENTDEV_H_ */