xref: /dpdk/lib/eventdev/rte_eventdev.h (revision bccda56af8d7ebb2bd161aa83b6107b9b63d05dc)
199a2dd95SBruce Richardson /* SPDX-License-Identifier: BSD-3-Clause
299a2dd95SBruce Richardson  * Copyright(c) 2016 Cavium, Inc.
399a2dd95SBruce Richardson  * Copyright(c) 2016-2018 Intel Corporation.
499a2dd95SBruce Richardson  * Copyright 2016 NXP
599a2dd95SBruce Richardson  * All rights reserved.
699a2dd95SBruce Richardson  */
799a2dd95SBruce Richardson 
899a2dd95SBruce Richardson #ifndef _RTE_EVENTDEV_H_
999a2dd95SBruce Richardson #define _RTE_EVENTDEV_H_
1099a2dd95SBruce Richardson 
1199a2dd95SBruce Richardson /**
1299a2dd95SBruce Richardson  * @file
1399a2dd95SBruce Richardson  *
1499a2dd95SBruce Richardson  * RTE Event Device API
159d22ced0SBruce Richardson  * ====================
1699a2dd95SBruce Richardson  *
179d22ced0SBruce Richardson  * In a traditional DPDK application model, the application polls Ethdev port RX
189d22ced0SBruce Richardson  * queues to look for work, and processing is done in a run-to-completion manner,
199d22ced0SBruce Richardson  * after which the packets are transmitted on a Ethdev TX queue. Load is
209d22ced0SBruce Richardson  * distributed by statically assigning ports and queues to lcores, and NIC
219d22ced0SBruce Richardson  * receive-side scaling (RSS), or similar, is employed to distribute network flows
229d22ced0SBruce Richardson  * (and thus work) on the same port across multiple RX queues.
239d22ced0SBruce Richardson  *
249d22ced0SBruce Richardson  * In contrast, in an event-driven model, as supported by this "eventdev" library,
259d22ced0SBruce Richardson  * incoming packets (or other input events) are fed into an event device, which
269d22ced0SBruce Richardson  * schedules those packets across the available lcores, in accordance with its configuration.
279d22ced0SBruce Richardson  * This event-driven programming model offers applications automatic multicore scaling,
289d22ced0SBruce Richardson  * dynamic load balancing, pipelining, packet order maintenance, synchronization,
299d22ced0SBruce Richardson  * and prioritization/quality of service.
3099a2dd95SBruce Richardson  *
3199a2dd95SBruce Richardson  * The Event Device API is composed of two parts:
3299a2dd95SBruce Richardson  *
3399a2dd95SBruce Richardson  * - The application-oriented Event API that includes functions to setup
3499a2dd95SBruce Richardson  *   an event device (configure it, setup its queues, ports and start it), to
359d22ced0SBruce Richardson  *   establish the links between queues and ports to receive events, and so on.
3699a2dd95SBruce Richardson  *
3799a2dd95SBruce Richardson  * - The driver-oriented Event API that exports a function allowing
389d22ced0SBruce Richardson  *   an event poll Mode Driver (PMD) to register itself as
3999a2dd95SBruce Richardson  *   an event device driver.
4099a2dd95SBruce Richardson  *
419d22ced0SBruce Richardson  * Application-oriented Event API
429d22ced0SBruce Richardson  * ------------------------------
439d22ced0SBruce Richardson  *
4499a2dd95SBruce Richardson  * Event device components:
4599a2dd95SBruce Richardson  *
4699a2dd95SBruce Richardson  *                     +-----------------+
4799a2dd95SBruce Richardson  *                     | +-------------+ |
4899a2dd95SBruce Richardson  *        +-------+    | |    flow 0   | |
4999a2dd95SBruce Richardson  *        |Packet |    | +-------------+ |
5099a2dd95SBruce Richardson  *        |event  |    | +-------------+ |
5199a2dd95SBruce Richardson  *        |       |    | |    flow 1   | |port_link(port0, queue0)
5299a2dd95SBruce Richardson  *        +-------+    | +-------------+ |     |     +--------+
5399a2dd95SBruce Richardson  *        +-------+    | +-------------+ o-----v-----o        |dequeue +------+
5499a2dd95SBruce Richardson  *        |Crypto |    | |    flow n   | |           | event  +------->|Core 0|
5599a2dd95SBruce Richardson  *        |work   |    | +-------------+ o----+      | port 0 |        |      |
5699a2dd95SBruce Richardson  *        |done ev|    |  event queue 0  |    |      +--------+        +------+
5799a2dd95SBruce Richardson  *        +-------+    +-----------------+    |
5899a2dd95SBruce Richardson  *        +-------+                           |
5999a2dd95SBruce Richardson  *        |Timer  |    +-----------------+    |      +--------+
6099a2dd95SBruce Richardson  *        |expiry |    | +-------------+ |    +------o        |dequeue +------+
6199a2dd95SBruce Richardson  *        |event  |    | |    flow 0   | o-----------o event  +------->|Core 1|
6299a2dd95SBruce Richardson  *        +-------+    | +-------------+ |      +----o port 1 |        |      |
6399a2dd95SBruce Richardson  *       Event enqueue | +-------------+ |      |    +--------+        +------+
6499a2dd95SBruce Richardson  *     o-------------> | |    flow 1   | |      |
6599a2dd95SBruce Richardson  *        enqueue(     | +-------------+ |      |
6699a2dd95SBruce Richardson  *        queue_id,    |                 |      |    +--------+        +------+
6799a2dd95SBruce Richardson  *        flow_id,     | +-------------+ |      |    |        |dequeue |Core 2|
6899a2dd95SBruce Richardson  *        sched_type,  | |    flow n   | o-----------o event  +------->|      |
6999a2dd95SBruce Richardson  *        event_type,  | +-------------+ |      |    | port 2 |        +------+
7099a2dd95SBruce Richardson  *        subev_type,  |  event queue 1  |      |    +--------+
7199a2dd95SBruce Richardson  *        event)       +-----------------+      |    +--------+
7299a2dd95SBruce Richardson  *                                              |    |        |dequeue +------+
7399a2dd95SBruce Richardson  *        +-------+    +-----------------+      |    | event  +------->|Core n|
7499a2dd95SBruce Richardson  *        |Core   |    | +-------------+ o-----------o port n |        |      |
7599a2dd95SBruce Richardson  *        |(SW)   |    | |    flow 0   | |      |    +--------+        +--+---+
7699a2dd95SBruce Richardson  *        |event  |    | +-------------+ |      |                         |
7799a2dd95SBruce Richardson  *        +-------+    | +-------------+ |      |                         |
7899a2dd95SBruce Richardson  *            ^        | |    flow 1   | |      |                         |
7999a2dd95SBruce Richardson  *            |        | +-------------+ o------+                         |
8099a2dd95SBruce Richardson  *            |        | +-------------+ |                                |
8199a2dd95SBruce Richardson  *            |        | |    flow n   | |                                |
8299a2dd95SBruce Richardson  *            |        | +-------------+ |                                |
8399a2dd95SBruce Richardson  *            |        |  event queue n  |                                |
8499a2dd95SBruce Richardson  *            |        +-----------------+                                |
8599a2dd95SBruce Richardson  *            |                                                           |
8699a2dd95SBruce Richardson  *            +-----------------------------------------------------------+
8799a2dd95SBruce Richardson  *
889d22ced0SBruce Richardson  * **Event device**: A hardware or software-based event scheduler.
8999a2dd95SBruce Richardson  *
909d22ced0SBruce Richardson  * **Event**: Represents an item of work and is the smallest unit of scheduling.
919d22ced0SBruce Richardson  * An event carries metadata, such as queue ID, scheduling type, and event priority,
929d22ced0SBruce Richardson  * and data such as one or more packets or other kinds of buffers.
939d22ced0SBruce Richardson  * Some examples of events are:
949d22ced0SBruce Richardson  * - a software-generated item of work originating from a lcore,
959d22ced0SBruce Richardson  *   perhaps carrying a packet to be processed.
969d22ced0SBruce Richardson  * - a crypto work completion notification.
979d22ced0SBruce Richardson  * - a timer expiry notification.
9899a2dd95SBruce Richardson  *
999d22ced0SBruce Richardson  * **Event queue**: A queue containing events that are to be scheduled by the event device.
10099a2dd95SBruce Richardson  * An event queue contains events of different flows associated with scheduling
10199a2dd95SBruce Richardson  * types, such as atomic, ordered, or parallel.
1029d22ced0SBruce Richardson  * Each event given to an event device must have a valid event queue id field in the metadata,
1039d22ced0SBruce Richardson  * to specify on which event queue in the device the event must be placed,
1049d22ced0SBruce Richardson  * for later scheduling.
10599a2dd95SBruce Richardson  *
1069d22ced0SBruce Richardson  * **Event port**: An application's interface into the event dev for enqueue and
10799a2dd95SBruce Richardson  * dequeue operations. Each event port can be linked with one or more
10899a2dd95SBruce Richardson  * event queues for dequeue operations.
1099d22ced0SBruce Richardson  * Enqueue and dequeue from a port is not thread-safe, and the expected use-case is
1109d22ced0SBruce Richardson  * that each port is polled by only a single lcore. [If this is not the case,
1119d22ced0SBruce Richardson  * a suitable synchronization mechanism should be used to prevent simultaneous
1129d22ced0SBruce Richardson  * access from multiple lcores.]
1139d22ced0SBruce Richardson  * To schedule events to an lcore, the event device will schedule them to the event port(s)
1149d22ced0SBruce Richardson  * being polled by that lcore.
11599a2dd95SBruce Richardson  *
1169d22ced0SBruce Richardson  * *NOTE*: By default, all the functions of the Event Device API exported by a PMD
1179d22ced0SBruce Richardson  * are non-thread-safe functions, which must not be invoked on the same object in parallel on
1189d22ced0SBruce Richardson  * different logical cores.
1199d22ced0SBruce Richardson  * For instance, the dequeue function of a PMD cannot be invoked in parallel on two logical
1209d22ced0SBruce Richardson  * cores to operate on same  event port. Of course, this function
12199a2dd95SBruce Richardson  * can be invoked in parallel by different logical cores on different ports.
12299a2dd95SBruce Richardson  * It is the responsibility of the upper level application to enforce this rule.
12399a2dd95SBruce Richardson  *
12499a2dd95SBruce Richardson  * In all functions of the Event API, the Event device is
12599a2dd95SBruce Richardson  * designated by an integer >= 0 named the device identifier *dev_id*
12699a2dd95SBruce Richardson  *
12799a2dd95SBruce Richardson  * The functions exported by the application Event API to setup a device
1289d22ced0SBruce Richardson  * must be invoked in the following order:
12999a2dd95SBruce Richardson  *     - rte_event_dev_configure()
13099a2dd95SBruce Richardson  *     - rte_event_queue_setup()
13199a2dd95SBruce Richardson  *     - rte_event_port_setup()
13299a2dd95SBruce Richardson  *     - rte_event_port_link()
13399a2dd95SBruce Richardson  *     - rte_event_dev_start()
13499a2dd95SBruce Richardson  *
13599a2dd95SBruce Richardson  * Then, the application can invoke, in any order, the functions
1369d22ced0SBruce Richardson  * exported by the Event API to dequeue events, enqueue events,
1379d22ced0SBruce Richardson  * and link and unlink event queue(s) to event ports.
13899a2dd95SBruce Richardson  *
1399d22ced0SBruce Richardson  * Before configuring a device, an application should call rte_event_dev_info_get()
1409d22ced0SBruce Richardson  * to determine the capabilities of the event device, and any queue or port
1419d22ced0SBruce Richardson  * limits of that device. The parameters set in the various device configuration
1429d22ced0SBruce Richardson  * structures may need to be adjusted based on the max values provided in the
1439d22ced0SBruce Richardson  * device information structure returned from the rte_event_dev_info_get() API.
1449d22ced0SBruce Richardson  * An application may use rte_event_queue_default_conf_get() or
1459d22ced0SBruce Richardson  * rte_event_port_default_conf_get() to get the default configuration
1469d22ced0SBruce Richardson  * to set up an event queue or event port by overriding few default values.
14799a2dd95SBruce Richardson  *
14899a2dd95SBruce Richardson  * If the application wants to change the configuration (i.e. call
14999a2dd95SBruce Richardson  * rte_event_dev_configure(), rte_event_queue_setup(), or
15099a2dd95SBruce Richardson  * rte_event_port_setup()), it must call rte_event_dev_stop() first to stop the
15199a2dd95SBruce Richardson  * device and then do the reconfiguration before calling rte_event_dev_start()
15299a2dd95SBruce Richardson  * again. The schedule, enqueue and dequeue functions should not be invoked
15399a2dd95SBruce Richardson  * when the device is stopped.
15499a2dd95SBruce Richardson  *
15599a2dd95SBruce Richardson  * Finally, an application can close an Event device by invoking the
1569d22ced0SBruce Richardson  * rte_event_dev_close() function. Once closed, a device cannot be
1579d22ced0SBruce Richardson  * reconfigured or restarted.
1589d22ced0SBruce Richardson  *
1599d22ced0SBruce Richardson  * Driver-Oriented Event API
1609d22ced0SBruce Richardson  * -------------------------
16199a2dd95SBruce Richardson  *
162de972a78SBruce Richardson  * At the Event driver level, Event devices are represented by a generic
163de972a78SBruce Richardson  * data structure of type *rte_event_dev*.
164de972a78SBruce Richardson  *
165de972a78SBruce Richardson  * Event devices are dynamically registered during the PCI/SoC device probing
166de972a78SBruce Richardson  * phase performed at EAL initialization time.
167de972a78SBruce Richardson  * When an Event device is being probed, an *rte_event_dev* structure is allocated
168de972a78SBruce Richardson  * for it and the event_dev_init() function supplied by the Event driver
169de972a78SBruce Richardson  * is invoked to properly initialize the device.
170de972a78SBruce Richardson  *
171de972a78SBruce Richardson  * The role of the device init function is to reset the device hardware or
172de972a78SBruce Richardson  * to initialize the software event driver implementation.
173de972a78SBruce Richardson  *
174de972a78SBruce Richardson  * If the device init operation is successful, the device is assigned a device
175de972a78SBruce Richardson  * id (dev_id) for application use.
176de972a78SBruce Richardson  * Otherwise, the *rte_event_dev* structure is freed.
177de972a78SBruce Richardson  *
17899a2dd95SBruce Richardson  * Each function of the application Event API invokes a specific function
17999a2dd95SBruce Richardson  * of the PMD that controls the target device designated by its device
18099a2dd95SBruce Richardson  * identifier.
18199a2dd95SBruce Richardson  *
18299a2dd95SBruce Richardson  * For this purpose, all device-specific functions of an Event driver are
18399a2dd95SBruce Richardson  * supplied through a set of pointers contained in a generic structure of type
18499a2dd95SBruce Richardson  * *event_dev_ops*.
18599a2dd95SBruce Richardson  * The address of the *event_dev_ops* structure is stored in the *rte_event_dev*
18699a2dd95SBruce Richardson  * structure by the device init function of the Event driver, which is
18799a2dd95SBruce Richardson  * invoked during the PCI/SoC device probing phase, as explained earlier.
18899a2dd95SBruce Richardson  *
18999a2dd95SBruce Richardson  * In other words, each function of the Event API simply retrieves the
19099a2dd95SBruce Richardson  * *rte_event_dev* structure associated with the device identifier and
19199a2dd95SBruce Richardson  * performs an indirect invocation of the corresponding driver function
19299a2dd95SBruce Richardson  * supplied in the *event_dev_ops* structure of the *rte_event_dev* structure.
19399a2dd95SBruce Richardson  *
1949d22ced0SBruce Richardson  * For performance reasons, the addresses of the fast-path functions of the
1959d22ced0SBruce Richardson  * event driver are not contained in the *event_dev_ops* structure.
19699a2dd95SBruce Richardson  * Instead, they are directly stored at the beginning of the *rte_event_dev*
19799a2dd95SBruce Richardson  * structure to avoid an extra indirect memory access during their invocation.
19899a2dd95SBruce Richardson  *
1999d22ced0SBruce Richardson  * Event Enqueue, Dequeue and Scheduling
2009d22ced0SBruce Richardson  * -------------------------------------
2019d22ced0SBruce Richardson  *
20299a2dd95SBruce Richardson  * RTE event device drivers do not use interrupts for enqueue or dequeue
20399a2dd95SBruce Richardson  * operation. Instead, Event drivers export Poll-Mode enqueue and dequeue
20499a2dd95SBruce Richardson  * functions to applications.
20599a2dd95SBruce Richardson  *
20699a2dd95SBruce Richardson  * The events are injected to event device through *enqueue* operation by
20799a2dd95SBruce Richardson  * event producers in the system. The typical event producers are ethdev
20899a2dd95SBruce Richardson  * subsystem for generating packet events, CPU(SW) for generating events based
20999a2dd95SBruce Richardson  * on different stages of application processing, cryptodev for generating
21099a2dd95SBruce Richardson  * crypto work completion notification etc
21199a2dd95SBruce Richardson  *
21299a2dd95SBruce Richardson  * The *dequeue* operation gets one or more events from the event ports.
2139d22ced0SBruce Richardson  * The application processes the events and sends them to a downstream event queue through
2149d22ced0SBruce Richardson  * rte_event_enqueue_burst(), if it is an intermediate stage of event processing.
2159d22ced0SBruce Richardson  * On the final stage of processing, the application may use the Tx adapter API for maintaining
2169d22ced0SBruce Richardson  * the event ingress order while sending the packet/event on the wire via NIC Tx.
21799a2dd95SBruce Richardson  *
21899a2dd95SBruce Richardson  * The point at which events are scheduled to ports depends on the device.
21999a2dd95SBruce Richardson  * For hardware devices, scheduling occurs asynchronously without any software
22099a2dd95SBruce Richardson  * intervention. Software schedulers can either be distributed
22199a2dd95SBruce Richardson  * (each worker thread schedules events to its own port) or centralized
22299a2dd95SBruce Richardson  * (a dedicated thread schedules to all ports). Distributed software schedulers
2239d22ced0SBruce Richardson  * perform the scheduling inside the enqueue or dequeue functions, whereas centralized
2249d22ced0SBruce Richardson  * software schedulers need a dedicated service core for scheduling.
2259d22ced0SBruce Richardson  * The absence of the RTE_EVENT_DEV_CAP_DISTRIBUTED_SCHED capability flag
2269d22ced0SBruce Richardson  * indicates that the device is centralized and thus needs a dedicated scheduling
2279d22ced0SBruce Richardson  * thread (generally an RTE service that should be mapped to one or more service cores)
2289d22ced0SBruce Richardson  * that repeatedly calls the software specific scheduling function.
22999a2dd95SBruce Richardson  *
23099a2dd95SBruce Richardson  * An event driven worker thread has following typical workflow on fastpath:
23199a2dd95SBruce Richardson  * \code{.c}
23299a2dd95SBruce Richardson  *	while (1) {
23399a2dd95SBruce Richardson  *		rte_event_dequeue_burst(...);
23499a2dd95SBruce Richardson  *		(event processing)
23599a2dd95SBruce Richardson  *		rte_event_enqueue_burst(...);
23699a2dd95SBruce Richardson  *	}
23799a2dd95SBruce Richardson  * \endcode
23899a2dd95SBruce Richardson  */
23999a2dd95SBruce Richardson 
24099a2dd95SBruce Richardson #ifdef __cplusplus
24199a2dd95SBruce Richardson extern "C" {
24299a2dd95SBruce Richardson #endif
24399a2dd95SBruce Richardson 
2441094dd94SDavid Marchand #include <rte_compat.h>
24599a2dd95SBruce Richardson #include <rte_common.h>
24699a2dd95SBruce Richardson #include <rte_errno.h>
24799a2dd95SBruce Richardson #include <rte_mbuf_pool_ops.h>
24899a2dd95SBruce Richardson #include <rte_mempool.h>
24999a2dd95SBruce Richardson 
25099a2dd95SBruce Richardson #include "rte_eventdev_trace_fp.h"
25199a2dd95SBruce Richardson 
25299a2dd95SBruce Richardson struct rte_mbuf; /* we just use mbuf pointers; no need to include rte_mbuf.h */
25399a2dd95SBruce Richardson struct rte_event;
25499a2dd95SBruce Richardson 
25599a2dd95SBruce Richardson /* Event device capability bitmap flags */
25699a2dd95SBruce Richardson #define RTE_EVENT_DEV_CAP_QUEUE_QOS           (1ULL << 0)
25744516e6bSShijith Thotton /**< Event scheduling prioritization is based on the priority and weight
258*bccda56aSBruce Richardson  * associated with each event queue.
259*bccda56aSBruce Richardson  *
260*bccda56aSBruce Richardson  * Events from a queue with highest priority
261*bccda56aSBruce Richardson  * are scheduled first. If the queues are of same priority, weight of the queues
26244516e6bSShijith Thotton  * are considered to select a queue in a weighted round robin fashion.
26344516e6bSShijith Thotton  * Subsequent dequeue calls from an event port could see events from the same
26444516e6bSShijith Thotton  * event queue, if the queue is configured with an affinity count. Affinity
26544516e6bSShijith Thotton  * count is the number of subsequent dequeue calls, in which an event port
26644516e6bSShijith Thotton  * should use the same event queue if the queue is non-empty
26799a2dd95SBruce Richardson  *
268*bccda56aSBruce Richardson  * NOTE: A device may use both queue prioritization and event prioritization
269*bccda56aSBruce Richardson  * (@ref RTE_EVENT_DEV_CAP_EVENT_QOS capability) when making packet scheduling decisions.
270*bccda56aSBruce Richardson  *
271*bccda56aSBruce Richardson  *  @see rte_event_queue_setup()
272*bccda56aSBruce Richardson  *  @see rte_event_queue_attr_set()
27399a2dd95SBruce Richardson  */
27499a2dd95SBruce Richardson #define RTE_EVENT_DEV_CAP_EVENT_QOS           (1ULL << 1)
27599a2dd95SBruce Richardson /**< Event scheduling prioritization is based on the priority associated with
276*bccda56aSBruce Richardson  *  each event.
27799a2dd95SBruce Richardson  *
278*bccda56aSBruce Richardson  *  Priority of each event is supplied in *rte_event* structure
279*bccda56aSBruce Richardson  *  on each enqueue operation.
280*bccda56aSBruce Richardson  *  If this capability is not set, the priority field of the event structure
281*bccda56aSBruce Richardson  *  is ignored for each event.
282*bccda56aSBruce Richardson  *
283*bccda56aSBruce Richardson  * NOTE: A device may use both queue prioritization (@ref RTE_EVENT_DEV_CAP_QUEUE_QOS capability)
284*bccda56aSBruce Richardson  * and event prioritization when making packet scheduling decisions.
285*bccda56aSBruce Richardson 
28699a2dd95SBruce Richardson  *  @see rte_event_enqueue_burst()
28799a2dd95SBruce Richardson  */
28899a2dd95SBruce Richardson #define RTE_EVENT_DEV_CAP_DISTRIBUTED_SCHED   (1ULL << 2)
28999a2dd95SBruce Richardson /**< Event device operates in distributed scheduling mode.
290*bccda56aSBruce Richardson  *
29199a2dd95SBruce Richardson  * In distributed scheduling mode, event scheduling happens in HW or
292*bccda56aSBruce Richardson  * rte_event_dequeue_burst() / rte_event_enqueue_burst() or the combination of these two.
29399a2dd95SBruce Richardson  * If the flag is not set then eventdev is centralized and thus needs a
29499a2dd95SBruce Richardson  * dedicated service core that acts as a scheduling thread.
29599a2dd95SBruce Richardson  *
296*bccda56aSBruce Richardson  * @see rte_event_dev_service_id_get()
29799a2dd95SBruce Richardson  */
29899a2dd95SBruce Richardson #define RTE_EVENT_DEV_CAP_QUEUE_ALL_TYPES     (1ULL << 3)
299ef0646ceSBruce Richardson /**< Event device is capable of accepting enqueued events, of any type
300ef0646ceSBruce Richardson  * advertised as supported by the device, to all destination queues.
30199a2dd95SBruce Richardson  *
302*bccda56aSBruce Richardson  * When this capability is set, and @ref RTE_EVENT_QUEUE_CFG_ALL_TYPES flag is set
303*bccda56aSBruce Richardson  * in @ref rte_event_queue_conf.event_queue_cfg, the "schedule_type" field of the
304*bccda56aSBruce Richardson  * @ref rte_event_queue_conf structure is ignored when a queue is being configured.
305ef0646ceSBruce Richardson  * Instead the "sched_type" field of each event enqueued is used to
306ef0646ceSBruce Richardson  * select the scheduling to be performed on that event.
307ef0646ceSBruce Richardson  *
308*bccda56aSBruce Richardson  * If this capability is not set, or the configuration flag is not set,
309*bccda56aSBruce Richardson  * the queue only supports events of the *RTE_SCHED_TYPE_* type specified
310*bccda56aSBruce Richardson  * in the @ref rte_event_queue_conf structure  at time of configuration.
311*bccda56aSBruce Richardson  * The behaviour when events of other scheduling types are sent to the queue is
312*bccda56aSBruce Richardson  * undefined.
313ef0646ceSBruce Richardson  *
314*bccda56aSBruce Richardson  * @see RTE_EVENT_QUEUE_CFG_ALL_TYPES
315ef0646ceSBruce Richardson  * @see RTE_SCHED_TYPE_ATOMIC
316ef0646ceSBruce Richardson  * @see RTE_SCHED_TYPE_ORDERED
317ef0646ceSBruce Richardson  * @see RTE_SCHED_TYPE_PARALLEL
318*bccda56aSBruce Richardson  * @see rte_event_queue_conf.event_queue_cfg
319ef0646ceSBruce Richardson  * @see rte_event_queue_conf.schedule_type
320*bccda56aSBruce Richardson  * @see rte_event_enqueue_burst()
32199a2dd95SBruce Richardson  */
32299a2dd95SBruce Richardson #define RTE_EVENT_DEV_CAP_BURST_MODE          (1ULL << 4)
32399a2dd95SBruce Richardson /**< Event device is capable of operating in burst mode for enqueue(forward,
324*bccda56aSBruce Richardson  * release) and dequeue operation.
32599a2dd95SBruce Richardson  *
326*bccda56aSBruce Richardson  * If this capability is not set, application
327*bccda56aSBruce Richardson  * can still use the rte_event_dequeue_burst() and rte_event_enqueue_burst() but
328*bccda56aSBruce Richardson  * PMD accepts or returns only one event at a time.
329*bccda56aSBruce Richardson  *
330*bccda56aSBruce Richardson  * @see rte_event_dequeue_burst()
331*bccda56aSBruce Richardson  * @see rte_event_enqueue_burst()
33299a2dd95SBruce Richardson  */
33399a2dd95SBruce Richardson #define RTE_EVENT_DEV_CAP_IMPLICIT_RELEASE_DISABLE    (1ULL << 5)
33499a2dd95SBruce Richardson /**< Event device ports support disabling the implicit release feature, in
33599a2dd95SBruce Richardson  * which the port will release all unreleased events in its dequeue operation.
336*bccda56aSBruce Richardson  *
33799a2dd95SBruce Richardson  * If this capability is set and the port is configured with implicit release
33899a2dd95SBruce Richardson  * disabled, the application is responsible for explicitly releasing events
339*bccda56aSBruce Richardson  * using either the @ref RTE_EVENT_OP_FORWARD or the @ref RTE_EVENT_OP_RELEASE event
34099a2dd95SBruce Richardson  * enqueue operations.
34199a2dd95SBruce Richardson  *
342*bccda56aSBruce Richardson  * @see rte_event_dequeue_burst()
343*bccda56aSBruce Richardson  * @see rte_event_enqueue_burst()
34499a2dd95SBruce Richardson  */
34599a2dd95SBruce Richardson 
34699a2dd95SBruce Richardson #define RTE_EVENT_DEV_CAP_NONSEQ_MODE         (1ULL << 6)
347*bccda56aSBruce Richardson /**< Event device is capable of operating in non-sequential mode.
348*bccda56aSBruce Richardson  *
349*bccda56aSBruce Richardson  * The path of the event is not necessary to be sequential. Application can change
350*bccda56aSBruce Richardson  * the path of event at runtime and events may be sent to queues in any order.
351*bccda56aSBruce Richardson  *
352*bccda56aSBruce Richardson  * If the flag is not set, then event each event will follow a path from queue 0
353*bccda56aSBruce Richardson  * to queue 1 to queue 2 etc.
354*bccda56aSBruce Richardson  * The eventdev will return an error when the application enqueues an event for a
35599a2dd95SBruce Richardson  * qid which is not the next in the sequence.
35699a2dd95SBruce Richardson  */
35799a2dd95SBruce Richardson 
35899a2dd95SBruce Richardson #define RTE_EVENT_DEV_CAP_RUNTIME_PORT_LINK   (1ULL << 7)
359*bccda56aSBruce Richardson /**< Event device is capable of reconfiguring the queue/port link at runtime.
360*bccda56aSBruce Richardson  *
36199a2dd95SBruce Richardson  * If the flag is not set, the eventdev queue/port link is only can be
362*bccda56aSBruce Richardson  * configured during  initialization, or by stopping the device and
363*bccda56aSBruce Richardson  * then later restarting it after reconfiguration.
364*bccda56aSBruce Richardson  *
365*bccda56aSBruce Richardson  * @see rte_event_port_link()
366*bccda56aSBruce Richardson  * @see rte_event_port_unlink()
36799a2dd95SBruce Richardson  */
36899a2dd95SBruce Richardson 
36999a2dd95SBruce Richardson #define RTE_EVENT_DEV_CAP_MULTIPLE_QUEUE_PORT (1ULL << 8)
370*bccda56aSBruce Richardson /**< Event device is capable of setting up links between multiple queues and a single port.
371*bccda56aSBruce Richardson  *
372*bccda56aSBruce Richardson  * If the flag is not set, each port may only be linked to a single queue, and
373*bccda56aSBruce Richardson  * so can only receive events from that queue.
374*bccda56aSBruce Richardson  * However, each queue may be linked to multiple ports.
375*bccda56aSBruce Richardson  *
376*bccda56aSBruce Richardson  * @see rte_event_port_link()
37799a2dd95SBruce Richardson  */
37899a2dd95SBruce Richardson 
37999a2dd95SBruce Richardson #define RTE_EVENT_DEV_CAP_CARRY_FLOW_ID (1ULL << 9)
380*bccda56aSBruce Richardson /**< Event device preserves the flow ID from the enqueued event to the dequeued event.
381*bccda56aSBruce Richardson  *
382*bccda56aSBruce Richardson  * If this flag is not set,
383*bccda56aSBruce Richardson  * the content of the flow-id field in dequeued events is implementation dependent.
384*bccda56aSBruce Richardson  *
385*bccda56aSBruce Richardson  * @see rte_event_dequeue_burst()
38699a2dd95SBruce Richardson  */
38799a2dd95SBruce Richardson 
388bd991897SMattias Rönnblom #define RTE_EVENT_DEV_CAP_MAINTENANCE_FREE (1ULL << 10)
389bd991897SMattias Rönnblom /**< Event device *does not* require calls to rte_event_maintain().
390*bccda56aSBruce Richardson  *
391bd991897SMattias Rönnblom  * An event device that does not set this flag requires calls to
392bd991897SMattias Rönnblom  * rte_event_maintain() during periods when neither
393bd991897SMattias Rönnblom  * rte_event_dequeue_burst() nor rte_event_enqueue_burst() are called
394bd991897SMattias Rönnblom  * on a port. This will allow the event device to perform internal
395bd991897SMattias Rönnblom  * processing, such as flushing buffered events, return credits to a
396bd991897SMattias Rönnblom  * global pool, or process signaling related to load balancing.
397*bccda56aSBruce Richardson  *
398*bccda56aSBruce Richardson  * @see rte_event_maintain()
39954f17843SMattias Rönnblom  */
40054f17843SMattias Rönnblom 
40197b914f4SShijith Thotton #define RTE_EVENT_DEV_CAP_RUNTIME_QUEUE_ATTR (1ULL << 11)
40297b914f4SShijith Thotton /**< Event device is capable of changing the queue attributes at runtime i.e
403*bccda56aSBruce Richardson  * after rte_event_queue_setup() or rte_event_dev_start() call sequence.
404*bccda56aSBruce Richardson  *
405*bccda56aSBruce Richardson  * If this flag is not set, event queue attributes can only be configured during
40697b914f4SShijith Thotton  * rte_event_queue_setup().
407*bccda56aSBruce Richardson  *
408*bccda56aSBruce Richardson  * @see rte_event_queue_setup()
40997b914f4SShijith Thotton  */
41097b914f4SShijith Thotton 
411d007a7f3SPavan Nikhilesh #define RTE_EVENT_DEV_CAP_PROFILE_LINK (1ULL << 12)
412*bccda56aSBruce Richardson /**< Event device is capable of supporting multiple link profiles per event port.
413*bccda56aSBruce Richardson  *
414*bccda56aSBruce Richardson  * When set, the value of `rte_event_dev_info::max_profiles_per_port` is greater
415*bccda56aSBruce Richardson  * than one, and multiple profiles may be configured and then switched at runtime.
416*bccda56aSBruce Richardson  * If not set, only a single profile may be configured, which may itself be
417*bccda56aSBruce Richardson  * runtime adjustable (if @ref RTE_EVENT_DEV_CAP_RUNTIME_PORT_LINK is set).
418*bccda56aSBruce Richardson  *
419*bccda56aSBruce Richardson  * @see rte_event_port_profile_links_set()
420*bccda56aSBruce Richardson  * @see rte_event_port_profile_links_get()
421*bccda56aSBruce Richardson  * @see rte_event_port_profile_switch()
422*bccda56aSBruce Richardson  * @see RTE_EVENT_DEV_CAP_RUNTIME_PORT_LINK
423d007a7f3SPavan Nikhilesh  */
424d007a7f3SPavan Nikhilesh 
425eaa8fb6cSBruce Richardson #define RTE_EVENT_DEV_CAP_ATOMIC  (1ULL << 13)
426eaa8fb6cSBruce Richardson /**< Event device is capable of atomic scheduling.
427eaa8fb6cSBruce Richardson  * When this flag is set, the application can configure queues with scheduling type
428eaa8fb6cSBruce Richardson  * atomic on this event device.
429*bccda56aSBruce Richardson  *
430eaa8fb6cSBruce Richardson  * @see RTE_SCHED_TYPE_ATOMIC
431eaa8fb6cSBruce Richardson  */
432eaa8fb6cSBruce Richardson 
433eaa8fb6cSBruce Richardson #define RTE_EVENT_DEV_CAP_ORDERED  (1ULL << 14)
434eaa8fb6cSBruce Richardson /**< Event device is capable of ordered scheduling.
435eaa8fb6cSBruce Richardson  * When this flag is set, the application can configure queues with scheduling type
436eaa8fb6cSBruce Richardson  * ordered on this event device.
437*bccda56aSBruce Richardson  *
438eaa8fb6cSBruce Richardson  * @see RTE_SCHED_TYPE_ORDERED
439eaa8fb6cSBruce Richardson  */
440eaa8fb6cSBruce Richardson 
441eaa8fb6cSBruce Richardson #define RTE_EVENT_DEV_CAP_PARALLEL  (1ULL << 15)
442eaa8fb6cSBruce Richardson /**< Event device is capable of parallel scheduling.
443eaa8fb6cSBruce Richardson  * When this flag is set, the application can configure queues with scheduling type
444eaa8fb6cSBruce Richardson  * parallel on this event device.
445*bccda56aSBruce Richardson  *
446eaa8fb6cSBruce Richardson  * @see RTE_SCHED_TYPE_PARALLEL
447eaa8fb6cSBruce Richardson  */
448eaa8fb6cSBruce Richardson 
44999a2dd95SBruce Richardson /* Event device priority levels */
45099a2dd95SBruce Richardson #define RTE_EVENT_DEV_PRIORITY_HIGHEST   0
451*bccda56aSBruce Richardson /**< Highest priority level for events and queues.
452*bccda56aSBruce Richardson  *
453*bccda56aSBruce Richardson  * @see rte_event_queue_setup()
454*bccda56aSBruce Richardson  * @see rte_event_enqueue_burst()
45599a2dd95SBruce Richardson  * @see rte_event_port_link()
45699a2dd95SBruce Richardson  */
45799a2dd95SBruce Richardson #define RTE_EVENT_DEV_PRIORITY_NORMAL    128
458*bccda56aSBruce Richardson /**< Normal priority level for events and queues.
459*bccda56aSBruce Richardson  *
460*bccda56aSBruce Richardson  * @see rte_event_queue_setup()
461*bccda56aSBruce Richardson  * @see rte_event_enqueue_burst()
46299a2dd95SBruce Richardson  * @see rte_event_port_link()
46399a2dd95SBruce Richardson  */
46499a2dd95SBruce Richardson #define RTE_EVENT_DEV_PRIORITY_LOWEST    255
465*bccda56aSBruce Richardson /**< Lowest priority level for events and queues.
466*bccda56aSBruce Richardson  *
467*bccda56aSBruce Richardson  * @see rte_event_queue_setup()
468*bccda56aSBruce Richardson  * @see rte_event_enqueue_burst()
46999a2dd95SBruce Richardson  * @see rte_event_port_link()
47099a2dd95SBruce Richardson  */
47199a2dd95SBruce Richardson 
47244516e6bSShijith Thotton /* Event queue scheduling weights */
47344516e6bSShijith Thotton #define RTE_EVENT_QUEUE_WEIGHT_HIGHEST 255
474*bccda56aSBruce Richardson /**< Highest weight of an event queue.
475*bccda56aSBruce Richardson  *
476*bccda56aSBruce Richardson  * @see rte_event_queue_attr_get()
477*bccda56aSBruce Richardson  * @see rte_event_queue_attr_set()
47844516e6bSShijith Thotton  */
47944516e6bSShijith Thotton #define RTE_EVENT_QUEUE_WEIGHT_LOWEST 0
480*bccda56aSBruce Richardson /**< Lowest weight of an event queue.
481*bccda56aSBruce Richardson  *
482*bccda56aSBruce Richardson  * @see rte_event_queue_attr_get()
483*bccda56aSBruce Richardson  * @see rte_event_queue_attr_set()
48444516e6bSShijith Thotton  */
48544516e6bSShijith Thotton 
48644516e6bSShijith Thotton /* Event queue scheduling affinity */
48744516e6bSShijith Thotton #define RTE_EVENT_QUEUE_AFFINITY_HIGHEST 255
488*bccda56aSBruce Richardson /**< Highest scheduling affinity of an event queue.
489*bccda56aSBruce Richardson  *
490*bccda56aSBruce Richardson  * @see rte_event_queue_attr_get()
491*bccda56aSBruce Richardson  * @see rte_event_queue_attr_set()
49244516e6bSShijith Thotton  */
49344516e6bSShijith Thotton #define RTE_EVENT_QUEUE_AFFINITY_LOWEST 0
494*bccda56aSBruce Richardson /**< Lowest scheduling affinity of an event queue.
495*bccda56aSBruce Richardson  *
496*bccda56aSBruce Richardson  * @see rte_event_queue_attr_get()
497*bccda56aSBruce Richardson  * @see rte_event_queue_attr_set()
49844516e6bSShijith Thotton  */
49944516e6bSShijith Thotton 
50099a2dd95SBruce Richardson /**
50199a2dd95SBruce Richardson  * Get the total number of event devices that have been successfully
50299a2dd95SBruce Richardson  * initialised.
50399a2dd95SBruce Richardson  *
50499a2dd95SBruce Richardson  * @return
50599a2dd95SBruce Richardson  *   The total number of usable event devices.
50699a2dd95SBruce Richardson  */
50799a2dd95SBruce Richardson uint8_t
50899a2dd95SBruce Richardson rte_event_dev_count(void);
50999a2dd95SBruce Richardson 
51099a2dd95SBruce Richardson /**
51199a2dd95SBruce Richardson  * Get the device identifier for the named event device.
51299a2dd95SBruce Richardson  *
51399a2dd95SBruce Richardson  * @param name
51499a2dd95SBruce Richardson  *   Event device name to select the event device identifier.
51599a2dd95SBruce Richardson  *
51699a2dd95SBruce Richardson  * @return
51799a2dd95SBruce Richardson  *   Returns event device identifier on success.
51899a2dd95SBruce Richardson  *   - <0: Failure to find named event device.
51999a2dd95SBruce Richardson  */
52099a2dd95SBruce Richardson int
52199a2dd95SBruce Richardson rte_event_dev_get_dev_id(const char *name);
52299a2dd95SBruce Richardson 
52399a2dd95SBruce Richardson /**
52499a2dd95SBruce Richardson  * Return the NUMA socket to which a device is connected.
52599a2dd95SBruce Richardson  *
52699a2dd95SBruce Richardson  * @param dev_id
52799a2dd95SBruce Richardson  *   The identifier of the device.
52899a2dd95SBruce Richardson  * @return
52999a2dd95SBruce Richardson  *   The NUMA socket id to which the device is connected or
53099a2dd95SBruce Richardson  *   a default of zero if the socket could not be determined.
53199a2dd95SBruce Richardson  *   -(-EINVAL)  dev_id value is out of range.
53299a2dd95SBruce Richardson  */
53399a2dd95SBruce Richardson int
53499a2dd95SBruce Richardson rte_event_dev_socket_id(uint8_t dev_id);
53599a2dd95SBruce Richardson 
53699a2dd95SBruce Richardson /**
53799a2dd95SBruce Richardson  * Event device information
53899a2dd95SBruce Richardson  */
53999a2dd95SBruce Richardson struct rte_event_dev_info {
54099a2dd95SBruce Richardson 	const char *driver_name;	/**< Event driver name */
54199a2dd95SBruce Richardson 	struct rte_device *dev;	/**< Device information */
54299a2dd95SBruce Richardson 	uint32_t min_dequeue_timeout_ns;
54399a2dd95SBruce Richardson 	/**< Minimum supported global dequeue timeout(ns) by this device */
54499a2dd95SBruce Richardson 	uint32_t max_dequeue_timeout_ns;
54599a2dd95SBruce Richardson 	/**< Maximum supported global dequeue timeout(ns) by this device */
54699a2dd95SBruce Richardson 	uint32_t dequeue_timeout_ns;
54799a2dd95SBruce Richardson 	/**< Configured global dequeue timeout(ns) for this device */
54899a2dd95SBruce Richardson 	uint8_t max_event_queues;
54999a2dd95SBruce Richardson 	/**< Maximum event_queues supported by this device */
55099a2dd95SBruce Richardson 	uint32_t max_event_queue_flows;
55199a2dd95SBruce Richardson 	/**< Maximum supported flows in an event queue by this device*/
55299a2dd95SBruce Richardson 	uint8_t max_event_queue_priority_levels;
55399a2dd95SBruce Richardson 	/**< Maximum number of event queue priority levels by this device.
55499a2dd95SBruce Richardson 	 * Valid when the device has RTE_EVENT_DEV_CAP_QUEUE_QOS capability
55599a2dd95SBruce Richardson 	 */
55699a2dd95SBruce Richardson 	uint8_t max_event_priority_levels;
55799a2dd95SBruce Richardson 	/**< Maximum number of event priority levels by this device.
55899a2dd95SBruce Richardson 	 * Valid when the device has RTE_EVENT_DEV_CAP_EVENT_QOS capability
55999a2dd95SBruce Richardson 	 */
56099a2dd95SBruce Richardson 	uint8_t max_event_ports;
56199a2dd95SBruce Richardson 	/**< Maximum number of event ports supported by this device */
56299a2dd95SBruce Richardson 	uint8_t max_event_port_dequeue_depth;
56399a2dd95SBruce Richardson 	/**< Maximum number of events can be dequeued at a time from an
56499a2dd95SBruce Richardson 	 * event port by this device.
56599a2dd95SBruce Richardson 	 * A device that does not support bulk dequeue will set this as 1.
56699a2dd95SBruce Richardson 	 */
56799a2dd95SBruce Richardson 	uint32_t max_event_port_enqueue_depth;
56899a2dd95SBruce Richardson 	/**< Maximum number of events can be enqueued at a time from an
56999a2dd95SBruce Richardson 	 * event port by this device.
57099a2dd95SBruce Richardson 	 * A device that does not support bulk enqueue will set this as 1.
57199a2dd95SBruce Richardson 	 */
57299a2dd95SBruce Richardson 	uint8_t max_event_port_links;
57399a2dd95SBruce Richardson 	/**< Maximum number of queues that can be linked to a single event
57499a2dd95SBruce Richardson 	 * port by this device.
57599a2dd95SBruce Richardson 	 */
57699a2dd95SBruce Richardson 	int32_t max_num_events;
57799a2dd95SBruce Richardson 	/**< A *closed system* event dev has a limit on the number of events it
57899a2dd95SBruce Richardson 	 * can manage at a time. An *open system* event dev does not have a
57999a2dd95SBruce Richardson 	 * limit and will specify this as -1.
58099a2dd95SBruce Richardson 	 */
58199a2dd95SBruce Richardson 	uint32_t event_dev_cap;
58299a2dd95SBruce Richardson 	/**< Event device capabilities(RTE_EVENT_DEV_CAP_)*/
58399a2dd95SBruce Richardson 	uint8_t max_single_link_event_port_queue_pairs;
58499a2dd95SBruce Richardson 	/**< Maximum number of event ports and queues that are optimized for
58599a2dd95SBruce Richardson 	 * (and only capable of) single-link configurations supported by this
58699a2dd95SBruce Richardson 	 * device. These ports and queues are not accounted for in
58799a2dd95SBruce Richardson 	 * max_event_ports or max_event_queues.
58899a2dd95SBruce Richardson 	 */
589d007a7f3SPavan Nikhilesh 	uint8_t max_profiles_per_port;
590d007a7f3SPavan Nikhilesh 	/**< Maximum number of event queue profiles per event port.
591d007a7f3SPavan Nikhilesh 	 * A device that doesn't support multiple profiles will set this as 1.
592d007a7f3SPavan Nikhilesh 	 */
59399a2dd95SBruce Richardson };
59499a2dd95SBruce Richardson 
59599a2dd95SBruce Richardson /**
59699a2dd95SBruce Richardson  * Retrieve the contextual information of an event device.
59799a2dd95SBruce Richardson  *
59899a2dd95SBruce Richardson  * @param dev_id
59999a2dd95SBruce Richardson  *   The identifier of the device.
60099a2dd95SBruce Richardson  *
60199a2dd95SBruce Richardson  * @param[out] dev_info
60299a2dd95SBruce Richardson  *   A pointer to a structure of type *rte_event_dev_info* to be filled with the
60399a2dd95SBruce Richardson  *   contextual information of the device.
60499a2dd95SBruce Richardson  *
60599a2dd95SBruce Richardson  * @return
60699a2dd95SBruce Richardson  *   - 0: Success, driver updates the contextual information of the event device
60799a2dd95SBruce Richardson  *   - <0: Error code returned by the driver info get function.
60899a2dd95SBruce Richardson  */
60999a2dd95SBruce Richardson int
61099a2dd95SBruce Richardson rte_event_dev_info_get(uint8_t dev_id, struct rte_event_dev_info *dev_info);
61199a2dd95SBruce Richardson 
61299a2dd95SBruce Richardson /**
61399a2dd95SBruce Richardson  * The count of ports.
61499a2dd95SBruce Richardson  */
61599a2dd95SBruce Richardson #define RTE_EVENT_DEV_ATTR_PORT_COUNT 0
61699a2dd95SBruce Richardson /**
61799a2dd95SBruce Richardson  * The count of queues.
61899a2dd95SBruce Richardson  */
61999a2dd95SBruce Richardson #define RTE_EVENT_DEV_ATTR_QUEUE_COUNT 1
62099a2dd95SBruce Richardson /**
62199a2dd95SBruce Richardson  * The status of the device, zero for stopped, non-zero for started.
62299a2dd95SBruce Richardson  */
62399a2dd95SBruce Richardson #define RTE_EVENT_DEV_ATTR_STARTED 2
62499a2dd95SBruce Richardson 
62599a2dd95SBruce Richardson /**
62699a2dd95SBruce Richardson  * Get an attribute from a device.
62799a2dd95SBruce Richardson  *
62899a2dd95SBruce Richardson  * @param dev_id Eventdev id
62999a2dd95SBruce Richardson  * @param attr_id The attribute ID to retrieve
63099a2dd95SBruce Richardson  * @param[out] attr_value A pointer that will be filled in with the attribute
63199a2dd95SBruce Richardson  *             value if successful.
63299a2dd95SBruce Richardson  *
63399a2dd95SBruce Richardson  * @return
63499a2dd95SBruce Richardson  *   - 0: Successfully retrieved attribute value
63599a2dd95SBruce Richardson  *   - -EINVAL: Invalid device or  *attr_id* provided, or *attr_value* is NULL
63699a2dd95SBruce Richardson  */
63799a2dd95SBruce Richardson int
63899a2dd95SBruce Richardson rte_event_dev_attr_get(uint8_t dev_id, uint32_t attr_id,
63999a2dd95SBruce Richardson 		       uint32_t *attr_value);
64099a2dd95SBruce Richardson 
64199a2dd95SBruce Richardson 
64299a2dd95SBruce Richardson /* Event device configuration bitmap flags */
64399a2dd95SBruce Richardson #define RTE_EVENT_DEV_CFG_PER_DEQUEUE_TIMEOUT (1ULL << 0)
64499a2dd95SBruce Richardson /**< Override the global *dequeue_timeout_ns* and use per dequeue timeout in ns.
64599a2dd95SBruce Richardson  *  @see rte_event_dequeue_timeout_ticks(), rte_event_dequeue_burst()
64699a2dd95SBruce Richardson  */
64799a2dd95SBruce Richardson 
64899a2dd95SBruce Richardson /** Event device configuration structure */
64999a2dd95SBruce Richardson struct rte_event_dev_config {
65099a2dd95SBruce Richardson 	uint32_t dequeue_timeout_ns;
65199a2dd95SBruce Richardson 	/**< rte_event_dequeue_burst() timeout on this device.
65299a2dd95SBruce Richardson 	 * This value should be in the range of *min_dequeue_timeout_ns* and
65399a2dd95SBruce Richardson 	 * *max_dequeue_timeout_ns* which previously provided in
65499a2dd95SBruce Richardson 	 * rte_event_dev_info_get()
65599a2dd95SBruce Richardson 	 * The value 0 is allowed, in which case, default dequeue timeout used.
65699a2dd95SBruce Richardson 	 * @see RTE_EVENT_DEV_CFG_PER_DEQUEUE_TIMEOUT
65799a2dd95SBruce Richardson 	 */
65899a2dd95SBruce Richardson 	int32_t nb_events_limit;
65999a2dd95SBruce Richardson 	/**< In a *closed system* this field is the limit on maximum number of
66099a2dd95SBruce Richardson 	 * events that can be inflight in the eventdev at a given time. The
66199a2dd95SBruce Richardson 	 * limit is required to ensure that the finite space in a closed system
66299a2dd95SBruce Richardson 	 * is not overwhelmed. The value cannot exceed the *max_num_events*
66399a2dd95SBruce Richardson 	 * as provided by rte_event_dev_info_get().
66499a2dd95SBruce Richardson 	 * This value should be set to -1 for *open system*.
66599a2dd95SBruce Richardson 	 */
66699a2dd95SBruce Richardson 	uint8_t nb_event_queues;
66799a2dd95SBruce Richardson 	/**< Number of event queues to configure on this device.
66899a2dd95SBruce Richardson 	 * This value cannot exceed the *max_event_queues* which previously
66999a2dd95SBruce Richardson 	 * provided in rte_event_dev_info_get()
67099a2dd95SBruce Richardson 	 */
67199a2dd95SBruce Richardson 	uint8_t nb_event_ports;
67299a2dd95SBruce Richardson 	/**< Number of event ports to configure on this device.
67399a2dd95SBruce Richardson 	 * This value cannot exceed the *max_event_ports* which previously
67499a2dd95SBruce Richardson 	 * provided in rte_event_dev_info_get()
67599a2dd95SBruce Richardson 	 */
67699a2dd95SBruce Richardson 	uint32_t nb_event_queue_flows;
67799a2dd95SBruce Richardson 	/**< Number of flows for any event queue on this device.
67899a2dd95SBruce Richardson 	 * This value cannot exceed the *max_event_queue_flows* which previously
67999a2dd95SBruce Richardson 	 * provided in rte_event_dev_info_get()
68099a2dd95SBruce Richardson 	 */
68199a2dd95SBruce Richardson 	uint32_t nb_event_port_dequeue_depth;
68299a2dd95SBruce Richardson 	/**< Maximum number of events can be dequeued at a time from an
68399a2dd95SBruce Richardson 	 * event port by this device.
68499a2dd95SBruce Richardson 	 * This value cannot exceed the *max_event_port_dequeue_depth*
68599a2dd95SBruce Richardson 	 * which previously provided in rte_event_dev_info_get().
68699a2dd95SBruce Richardson 	 * Ignored when device is not RTE_EVENT_DEV_CAP_BURST_MODE capable.
68799a2dd95SBruce Richardson 	 * @see rte_event_port_setup()
68899a2dd95SBruce Richardson 	 */
68999a2dd95SBruce Richardson 	uint32_t nb_event_port_enqueue_depth;
69099a2dd95SBruce Richardson 	/**< Maximum number of events can be enqueued at a time from an
69199a2dd95SBruce Richardson 	 * event port by this device.
69299a2dd95SBruce Richardson 	 * This value cannot exceed the *max_event_port_enqueue_depth*
69399a2dd95SBruce Richardson 	 * which previously provided in rte_event_dev_info_get().
69499a2dd95SBruce Richardson 	 * Ignored when device is not RTE_EVENT_DEV_CAP_BURST_MODE capable.
69599a2dd95SBruce Richardson 	 * @see rte_event_port_setup()
69699a2dd95SBruce Richardson 	 */
69799a2dd95SBruce Richardson 	uint32_t event_dev_cfg;
69899a2dd95SBruce Richardson 	/**< Event device config flags(RTE_EVENT_DEV_CFG_)*/
69999a2dd95SBruce Richardson 	uint8_t nb_single_link_event_port_queues;
70099a2dd95SBruce Richardson 	/**< Number of event ports and queues that will be singly-linked to
70199a2dd95SBruce Richardson 	 * each other. These are a subset of the overall event ports and
70299a2dd95SBruce Richardson 	 * queues; this value cannot exceed *nb_event_ports* or
70399a2dd95SBruce Richardson 	 * *nb_event_queues*. If the device has ports and queues that are
70499a2dd95SBruce Richardson 	 * optimized for single-link usage, this field is a hint for how many
70599a2dd95SBruce Richardson 	 * to allocate; otherwise, regular event ports and queues can be used.
70699a2dd95SBruce Richardson 	 */
70799a2dd95SBruce Richardson };
70899a2dd95SBruce Richardson 
70999a2dd95SBruce Richardson /**
71099a2dd95SBruce Richardson  * Configure an event device.
71199a2dd95SBruce Richardson  *
71299a2dd95SBruce Richardson  * This function must be invoked first before any other function in the
71399a2dd95SBruce Richardson  * API. This function can also be re-invoked when a device is in the
71499a2dd95SBruce Richardson  * stopped state.
71599a2dd95SBruce Richardson  *
71699a2dd95SBruce Richardson  * The caller may use rte_event_dev_info_get() to get the capability of each
71799a2dd95SBruce Richardson  * resources available for this event device.
71899a2dd95SBruce Richardson  *
71999a2dd95SBruce Richardson  * @param dev_id
72099a2dd95SBruce Richardson  *   The identifier of the device to configure.
72199a2dd95SBruce Richardson  * @param dev_conf
72299a2dd95SBruce Richardson  *   The event device configuration structure.
72399a2dd95SBruce Richardson  *
72499a2dd95SBruce Richardson  * @return
72599a2dd95SBruce Richardson  *   - 0: Success, device configured.
72699a2dd95SBruce Richardson  *   - <0: Error code returned by the driver configuration function.
72799a2dd95SBruce Richardson  */
72899a2dd95SBruce Richardson int
72999a2dd95SBruce Richardson rte_event_dev_configure(uint8_t dev_id,
73099a2dd95SBruce Richardson 			const struct rte_event_dev_config *dev_conf);
73199a2dd95SBruce Richardson 
73299a2dd95SBruce Richardson /* Event queue specific APIs */
73399a2dd95SBruce Richardson 
73499a2dd95SBruce Richardson /* Event queue configuration bitmap flags */
73599a2dd95SBruce Richardson #define RTE_EVENT_QUEUE_CFG_ALL_TYPES          (1ULL << 0)
73699a2dd95SBruce Richardson /**< Allow ATOMIC,ORDERED,PARALLEL schedule type enqueue
73799a2dd95SBruce Richardson  *
73899a2dd95SBruce Richardson  * @see RTE_SCHED_TYPE_ORDERED, RTE_SCHED_TYPE_ATOMIC, RTE_SCHED_TYPE_PARALLEL
73999a2dd95SBruce Richardson  * @see rte_event_enqueue_burst()
74099a2dd95SBruce Richardson  */
74199a2dd95SBruce Richardson #define RTE_EVENT_QUEUE_CFG_SINGLE_LINK        (1ULL << 1)
74299a2dd95SBruce Richardson /**< This event queue links only to a single event port.
74399a2dd95SBruce Richardson  *
74499a2dd95SBruce Richardson  *  @see rte_event_port_setup(), rte_event_port_link()
74599a2dd95SBruce Richardson  */
74699a2dd95SBruce Richardson 
74799a2dd95SBruce Richardson /** Event queue configuration structure */
74899a2dd95SBruce Richardson struct rte_event_queue_conf {
74999a2dd95SBruce Richardson 	uint32_t nb_atomic_flows;
75099a2dd95SBruce Richardson 	/**< The maximum number of active flows this queue can track at any
75199a2dd95SBruce Richardson 	 * given time. If the queue is configured for atomic scheduling (by
75299a2dd95SBruce Richardson 	 * applying the RTE_EVENT_QUEUE_CFG_ALL_TYPES flag to event_queue_cfg
75399a2dd95SBruce Richardson 	 * or RTE_SCHED_TYPE_ATOMIC flag to schedule_type), then the
75499a2dd95SBruce Richardson 	 * value must be in the range of [1, nb_event_queue_flows], which was
75599a2dd95SBruce Richardson 	 * previously provided in rte_event_dev_configure().
75699a2dd95SBruce Richardson 	 */
75799a2dd95SBruce Richardson 	uint32_t nb_atomic_order_sequences;
75899a2dd95SBruce Richardson 	/**< The maximum number of outstanding events waiting to be
75999a2dd95SBruce Richardson 	 * reordered by this queue. In other words, the number of entries in
76099a2dd95SBruce Richardson 	 * this queue’s reorder buffer.When the number of events in the
76199a2dd95SBruce Richardson 	 * reorder buffer reaches to *nb_atomic_order_sequences* then the
76299a2dd95SBruce Richardson 	 * scheduler cannot schedule the events from this queue and invalid
76399a2dd95SBruce Richardson 	 * event will be returned from dequeue until one or more entries are
76499a2dd95SBruce Richardson 	 * freed up/released.
76599a2dd95SBruce Richardson 	 * If the queue is configured for ordered scheduling (by applying the
76699a2dd95SBruce Richardson 	 * RTE_EVENT_QUEUE_CFG_ALL_TYPES flag to event_queue_cfg or
76799a2dd95SBruce Richardson 	 * RTE_SCHED_TYPE_ORDERED flag to schedule_type), then the value must
76899a2dd95SBruce Richardson 	 * be in the range of [1, nb_event_queue_flows], which was
76999a2dd95SBruce Richardson 	 * previously supplied to rte_event_dev_configure().
77099a2dd95SBruce Richardson 	 */
77199a2dd95SBruce Richardson 	uint32_t event_queue_cfg;
77299a2dd95SBruce Richardson 	/**< Queue cfg flags(EVENT_QUEUE_CFG_) */
77399a2dd95SBruce Richardson 	uint8_t schedule_type;
77499a2dd95SBruce Richardson 	/**< Queue schedule type(RTE_SCHED_TYPE_*).
77599a2dd95SBruce Richardson 	 * Valid when RTE_EVENT_QUEUE_CFG_ALL_TYPES bit is not set in
77699a2dd95SBruce Richardson 	 * event_queue_cfg.
77799a2dd95SBruce Richardson 	 */
77899a2dd95SBruce Richardson 	uint8_t priority;
77999a2dd95SBruce Richardson 	/**< Priority for this event queue relative to other event queues.
78099a2dd95SBruce Richardson 	 * The requested priority should in the range of
78199a2dd95SBruce Richardson 	 * [RTE_EVENT_DEV_PRIORITY_HIGHEST, RTE_EVENT_DEV_PRIORITY_LOWEST].
78299a2dd95SBruce Richardson 	 * The implementation shall normalize the requested priority to
78399a2dd95SBruce Richardson 	 * event device supported priority value.
78499a2dd95SBruce Richardson 	 * Valid when the device has RTE_EVENT_DEV_CAP_QUEUE_QOS capability
78599a2dd95SBruce Richardson 	 */
7862f279a1bSShijith Thotton 	uint8_t weight;
7872f279a1bSShijith Thotton 	/**< Weight of the event queue relative to other event queues.
7882f279a1bSShijith Thotton 	 * The requested weight should be in the range of
7892f279a1bSShijith Thotton 	 * [RTE_EVENT_DEV_WEIGHT_HIGHEST, RTE_EVENT_DEV_WEIGHT_LOWEST].
7902f279a1bSShijith Thotton 	 * The implementation shall normalize the requested weight to event
7912f279a1bSShijith Thotton 	 * device supported weight value.
7922f279a1bSShijith Thotton 	 * Valid when the device has RTE_EVENT_DEV_CAP_QUEUE_QOS capability.
7932f279a1bSShijith Thotton 	 */
7942f279a1bSShijith Thotton 	uint8_t affinity;
7952f279a1bSShijith Thotton 	/**< Affinity of the event queue relative to other event queues.
7962f279a1bSShijith Thotton 	 * The requested affinity should be in the range of
7972f279a1bSShijith Thotton 	 * [RTE_EVENT_DEV_AFFINITY_HIGHEST, RTE_EVENT_DEV_AFFINITY_LOWEST].
7982f279a1bSShijith Thotton 	 * The implementation shall normalize the requested affinity to event
7992f279a1bSShijith Thotton 	 * device supported affinity value.
8002f279a1bSShijith Thotton 	 * Valid when the device has RTE_EVENT_DEV_CAP_QUEUE_QOS capability.
8012f279a1bSShijith Thotton 	 */
80299a2dd95SBruce Richardson };
80399a2dd95SBruce Richardson 
80499a2dd95SBruce Richardson /**
80599a2dd95SBruce Richardson  * Retrieve the default configuration information of an event queue designated
80699a2dd95SBruce Richardson  * by its *queue_id* from the event driver for an event device.
80799a2dd95SBruce Richardson  *
80899a2dd95SBruce Richardson  * This function intended to be used in conjunction with rte_event_queue_setup()
80999a2dd95SBruce Richardson  * where caller needs to set up the queue by overriding few default values.
81099a2dd95SBruce Richardson  *
81199a2dd95SBruce Richardson  * @param dev_id
81299a2dd95SBruce Richardson  *   The identifier of the device.
81399a2dd95SBruce Richardson  * @param queue_id
81499a2dd95SBruce Richardson  *   The index of the event queue to get the configuration information.
81599a2dd95SBruce Richardson  *   The value must be in the range [0, nb_event_queues - 1]
81699a2dd95SBruce Richardson  *   previously supplied to rte_event_dev_configure().
81799a2dd95SBruce Richardson  * @param[out] queue_conf
81899a2dd95SBruce Richardson  *   The pointer to the default event queue configuration data.
81999a2dd95SBruce Richardson  * @return
82099a2dd95SBruce Richardson  *   - 0: Success, driver updates the default event queue configuration data.
82199a2dd95SBruce Richardson  *   - <0: Error code returned by the driver info get function.
82299a2dd95SBruce Richardson  *
82399a2dd95SBruce Richardson  * @see rte_event_queue_setup()
82499a2dd95SBruce Richardson  */
82599a2dd95SBruce Richardson int
82699a2dd95SBruce Richardson rte_event_queue_default_conf_get(uint8_t dev_id, uint8_t queue_id,
82799a2dd95SBruce Richardson 				 struct rte_event_queue_conf *queue_conf);
82899a2dd95SBruce Richardson 
82999a2dd95SBruce Richardson /**
83099a2dd95SBruce Richardson  * Allocate and set up an event queue for an event device.
83199a2dd95SBruce Richardson  *
83299a2dd95SBruce Richardson  * @param dev_id
83399a2dd95SBruce Richardson  *   The identifier of the device.
83499a2dd95SBruce Richardson  * @param queue_id
83599a2dd95SBruce Richardson  *   The index of the event queue to setup. The value must be in the range
83699a2dd95SBruce Richardson  *   [0, nb_event_queues - 1] previously supplied to rte_event_dev_configure().
83799a2dd95SBruce Richardson  * @param queue_conf
83899a2dd95SBruce Richardson  *   The pointer to the configuration data to be used for the event queue.
83999a2dd95SBruce Richardson  *   NULL value is allowed, in which case default configuration	used.
84099a2dd95SBruce Richardson  *
84199a2dd95SBruce Richardson  * @see rte_event_queue_default_conf_get()
84299a2dd95SBruce Richardson  *
84399a2dd95SBruce Richardson  * @return
84499a2dd95SBruce Richardson  *   - 0: Success, event queue correctly set up.
84599a2dd95SBruce Richardson  *   - <0: event queue configuration failed
84699a2dd95SBruce Richardson  */
84799a2dd95SBruce Richardson int
84899a2dd95SBruce Richardson rte_event_queue_setup(uint8_t dev_id, uint8_t queue_id,
84999a2dd95SBruce Richardson 		      const struct rte_event_queue_conf *queue_conf);
85099a2dd95SBruce Richardson 
85199a2dd95SBruce Richardson /**
85299a2dd95SBruce Richardson  * The priority of the queue.
85399a2dd95SBruce Richardson  */
85499a2dd95SBruce Richardson #define RTE_EVENT_QUEUE_ATTR_PRIORITY 0
85599a2dd95SBruce Richardson /**
85699a2dd95SBruce Richardson  * The number of atomic flows configured for the queue.
85799a2dd95SBruce Richardson  */
85899a2dd95SBruce Richardson #define RTE_EVENT_QUEUE_ATTR_NB_ATOMIC_FLOWS 1
85999a2dd95SBruce Richardson /**
86099a2dd95SBruce Richardson  * The number of atomic order sequences configured for the queue.
86199a2dd95SBruce Richardson  */
86299a2dd95SBruce Richardson #define RTE_EVENT_QUEUE_ATTR_NB_ATOMIC_ORDER_SEQUENCES 2
86399a2dd95SBruce Richardson /**
86499a2dd95SBruce Richardson  * The cfg flags for the queue.
86599a2dd95SBruce Richardson  */
86699a2dd95SBruce Richardson #define RTE_EVENT_QUEUE_ATTR_EVENT_QUEUE_CFG 3
86799a2dd95SBruce Richardson /**
86899a2dd95SBruce Richardson  * The schedule type of the queue.
86999a2dd95SBruce Richardson  */
87099a2dd95SBruce Richardson #define RTE_EVENT_QUEUE_ATTR_SCHEDULE_TYPE 4
87144516e6bSShijith Thotton /**
87244516e6bSShijith Thotton  * The weight of the queue.
87344516e6bSShijith Thotton  */
87444516e6bSShijith Thotton #define RTE_EVENT_QUEUE_ATTR_WEIGHT 5
87544516e6bSShijith Thotton /**
87644516e6bSShijith Thotton  * Affinity of the queue.
87744516e6bSShijith Thotton  */
87844516e6bSShijith Thotton #define RTE_EVENT_QUEUE_ATTR_AFFINITY 6
87999a2dd95SBruce Richardson 
88099a2dd95SBruce Richardson /**
88199a2dd95SBruce Richardson  * Get an attribute from a queue.
88299a2dd95SBruce Richardson  *
88399a2dd95SBruce Richardson  * @param dev_id
88499a2dd95SBruce Richardson  *   Eventdev id
88599a2dd95SBruce Richardson  * @param queue_id
88699a2dd95SBruce Richardson  *   Eventdev queue id
88799a2dd95SBruce Richardson  * @param attr_id
88899a2dd95SBruce Richardson  *   The attribute ID to retrieve
88999a2dd95SBruce Richardson  * @param[out] attr_value
89099a2dd95SBruce Richardson  *   A pointer that will be filled in with the attribute value if successful
89199a2dd95SBruce Richardson  *
89299a2dd95SBruce Richardson  * @return
89399a2dd95SBruce Richardson  *   - 0: Successfully returned value
89499a2dd95SBruce Richardson  *   - -EINVAL: invalid device, queue or attr_id provided, or attr_value was
89599a2dd95SBruce Richardson  *		NULL
89699a2dd95SBruce Richardson  *   - -EOVERFLOW: returned when attr_id is set to
89799a2dd95SBruce Richardson  *   RTE_EVENT_QUEUE_ATTR_SCHEDULE_TYPE and event_queue_cfg is set to
89899a2dd95SBruce Richardson  *   RTE_EVENT_QUEUE_CFG_ALL_TYPES
89999a2dd95SBruce Richardson  */
90099a2dd95SBruce Richardson int
90199a2dd95SBruce Richardson rte_event_queue_attr_get(uint8_t dev_id, uint8_t queue_id, uint32_t attr_id,
90299a2dd95SBruce Richardson 			uint32_t *attr_value);
90399a2dd95SBruce Richardson 
90497b914f4SShijith Thotton /**
90597b914f4SShijith Thotton  * Set an event queue attribute.
90697b914f4SShijith Thotton  *
90797b914f4SShijith Thotton  * @param dev_id
90897b914f4SShijith Thotton  *   Eventdev id
90997b914f4SShijith Thotton  * @param queue_id
91097b914f4SShijith Thotton  *   Eventdev queue id
91197b914f4SShijith Thotton  * @param attr_id
91297b914f4SShijith Thotton  *   The attribute ID to set
91397b914f4SShijith Thotton  * @param attr_value
91497b914f4SShijith Thotton  *   The attribute value to set
91597b914f4SShijith Thotton  *
91697b914f4SShijith Thotton  * @return
91797b914f4SShijith Thotton  *   - 0: Successfully set attribute.
91897b914f4SShijith Thotton  *   - -EINVAL: invalid device, queue or attr_id.
91997b914f4SShijith Thotton  *   - -ENOTSUP: device does not support setting the event attribute.
92097b914f4SShijith Thotton  *   - <0: failed to set event queue attribute
92197b914f4SShijith Thotton  */
92297b914f4SShijith Thotton int
92397b914f4SShijith Thotton rte_event_queue_attr_set(uint8_t dev_id, uint8_t queue_id, uint32_t attr_id,
92497b914f4SShijith Thotton 			 uint64_t attr_value);
92597b914f4SShijith Thotton 
92699a2dd95SBruce Richardson /* Event port specific APIs */
92799a2dd95SBruce Richardson 
92899a2dd95SBruce Richardson /* Event port configuration bitmap flags */
92999a2dd95SBruce Richardson #define RTE_EVENT_PORT_CFG_DISABLE_IMPL_REL    (1ULL << 0)
93099a2dd95SBruce Richardson /**< Configure the port not to release outstanding events in
93199a2dd95SBruce Richardson  * rte_event_dev_dequeue_burst(). If set, all events received through
93299a2dd95SBruce Richardson  * the port must be explicitly released with RTE_EVENT_OP_RELEASE or
93399a2dd95SBruce Richardson  * RTE_EVENT_OP_FORWARD. Must be unset if the device is not
93499a2dd95SBruce Richardson  * RTE_EVENT_DEV_CAP_IMPLICIT_RELEASE_DISABLE capable.
93599a2dd95SBruce Richardson  */
93699a2dd95SBruce Richardson #define RTE_EVENT_PORT_CFG_SINGLE_LINK         (1ULL << 1)
93799a2dd95SBruce Richardson /**< This event port links only to a single event queue.
93899a2dd95SBruce Richardson  *
93999a2dd95SBruce Richardson  *  @see rte_event_port_setup(), rte_event_port_link()
94099a2dd95SBruce Richardson  */
94197632958SHarry van Haaren #define RTE_EVENT_PORT_CFG_HINT_PRODUCER       (1ULL << 2)
94297632958SHarry van Haaren /**< Hint that this event port will primarily enqueue events to the system.
94397632958SHarry van Haaren  * A PMD can optimize its internal workings by assuming that this port is
94497632958SHarry van Haaren  * primarily going to enqueue NEW events.
94597632958SHarry van Haaren  *
94697632958SHarry van Haaren  * Note that this flag is only a hint, so PMDs must operate under the
94797632958SHarry van Haaren  * assumption that any port can enqueue an event with any type of op.
94897632958SHarry van Haaren  *
94997632958SHarry van Haaren  *  @see rte_event_port_setup()
95097632958SHarry van Haaren  */
95197632958SHarry van Haaren #define RTE_EVENT_PORT_CFG_HINT_CONSUMER       (1ULL << 3)
95297632958SHarry van Haaren /**< Hint that this event port will primarily dequeue events from the system.
95397632958SHarry van Haaren  * A PMD can optimize its internal workings by assuming that this port is
95497632958SHarry van Haaren  * primarily going to consume events, and not enqueue FORWARD or RELEASE
95597632958SHarry van Haaren  * events.
95697632958SHarry van Haaren  *
95797632958SHarry van Haaren  * Note that this flag is only a hint, so PMDs must operate under the
95897632958SHarry van Haaren  * assumption that any port can enqueue an event with any type of op.
95997632958SHarry van Haaren  *
96097632958SHarry van Haaren  *  @see rte_event_port_setup()
96197632958SHarry van Haaren  */
96297632958SHarry van Haaren #define RTE_EVENT_PORT_CFG_HINT_WORKER         (1ULL << 4)
96397632958SHarry van Haaren /**< Hint that this event port will primarily pass existing events through.
96497632958SHarry van Haaren  * A PMD can optimize its internal workings by assuming that this port is
96597632958SHarry van Haaren  * primarily going to FORWARD events, and not enqueue NEW or RELEASE events
96697632958SHarry van Haaren  * often.
96797632958SHarry van Haaren  *
96897632958SHarry van Haaren  * Note that this flag is only a hint, so PMDs must operate under the
96997632958SHarry van Haaren  * assumption that any port can enqueue an event with any type of op.
97097632958SHarry van Haaren  *
97197632958SHarry van Haaren  *  @see rte_event_port_setup()
97297632958SHarry van Haaren  */
97399a2dd95SBruce Richardson 
97499a2dd95SBruce Richardson /** Event port configuration structure */
97599a2dd95SBruce Richardson struct rte_event_port_conf {
97699a2dd95SBruce Richardson 	int32_t new_event_threshold;
97799a2dd95SBruce Richardson 	/**< A backpressure threshold for new event enqueues on this port.
97899a2dd95SBruce Richardson 	 * Use for *closed system* event dev where event capacity is limited,
97999a2dd95SBruce Richardson 	 * and cannot exceed the capacity of the event dev.
98099a2dd95SBruce Richardson 	 * Configuring ports with different thresholds can make higher priority
98199a2dd95SBruce Richardson 	 * traffic less likely to  be backpressured.
98299a2dd95SBruce Richardson 	 * For example, a port used to inject NIC Rx packets into the event dev
98399a2dd95SBruce Richardson 	 * can have a lower threshold so as not to overwhelm the device,
98499a2dd95SBruce Richardson 	 * while ports used for worker pools can have a higher threshold.
98599a2dd95SBruce Richardson 	 * This value cannot exceed the *nb_events_limit*
98699a2dd95SBruce Richardson 	 * which was previously supplied to rte_event_dev_configure().
98799a2dd95SBruce Richardson 	 * This should be set to '-1' for *open system*.
98899a2dd95SBruce Richardson 	 */
98999a2dd95SBruce Richardson 	uint16_t dequeue_depth;
99099a2dd95SBruce Richardson 	/**< Configure number of bulk dequeues for this event port.
99199a2dd95SBruce Richardson 	 * This value cannot exceed the *nb_event_port_dequeue_depth*
99299a2dd95SBruce Richardson 	 * which previously supplied to rte_event_dev_configure().
99399a2dd95SBruce Richardson 	 * Ignored when device is not RTE_EVENT_DEV_CAP_BURST_MODE capable.
99499a2dd95SBruce Richardson 	 */
99599a2dd95SBruce Richardson 	uint16_t enqueue_depth;
99699a2dd95SBruce Richardson 	/**< Configure number of bulk enqueues for this event port.
99799a2dd95SBruce Richardson 	 * This value cannot exceed the *nb_event_port_enqueue_depth*
99899a2dd95SBruce Richardson 	 * which previously supplied to rte_event_dev_configure().
99999a2dd95SBruce Richardson 	 * Ignored when device is not RTE_EVENT_DEV_CAP_BURST_MODE capable.
100099a2dd95SBruce Richardson 	 */
100199a2dd95SBruce Richardson 	uint32_t event_port_cfg; /**< Port cfg flags(EVENT_PORT_CFG_) */
100299a2dd95SBruce Richardson };
100399a2dd95SBruce Richardson 
100499a2dd95SBruce Richardson /**
100599a2dd95SBruce Richardson  * Retrieve the default configuration information of an event port designated
100699a2dd95SBruce Richardson  * by its *port_id* from the event driver for an event device.
100799a2dd95SBruce Richardson  *
100899a2dd95SBruce Richardson  * This function intended to be used in conjunction with rte_event_port_setup()
100999a2dd95SBruce Richardson  * where caller needs to set up the port by overriding few default values.
101099a2dd95SBruce Richardson  *
101199a2dd95SBruce Richardson  * @param dev_id
101299a2dd95SBruce Richardson  *   The identifier of the device.
101399a2dd95SBruce Richardson  * @param port_id
101499a2dd95SBruce Richardson  *   The index of the event port to get the configuration information.
101599a2dd95SBruce Richardson  *   The value must be in the range [0, nb_event_ports - 1]
101699a2dd95SBruce Richardson  *   previously supplied to rte_event_dev_configure().
101799a2dd95SBruce Richardson  * @param[out] port_conf
101899a2dd95SBruce Richardson  *   The pointer to the default event port configuration data
101999a2dd95SBruce Richardson  * @return
102099a2dd95SBruce Richardson  *   - 0: Success, driver updates the default event port configuration data.
102199a2dd95SBruce Richardson  *   - <0: Error code returned by the driver info get function.
102299a2dd95SBruce Richardson  *
102399a2dd95SBruce Richardson  * @see rte_event_port_setup()
102499a2dd95SBruce Richardson  */
102599a2dd95SBruce Richardson int
102699a2dd95SBruce Richardson rte_event_port_default_conf_get(uint8_t dev_id, uint8_t port_id,
102799a2dd95SBruce Richardson 				struct rte_event_port_conf *port_conf);
102899a2dd95SBruce Richardson 
102999a2dd95SBruce Richardson /**
103099a2dd95SBruce Richardson  * Allocate and set up an event port for an event device.
103199a2dd95SBruce Richardson  *
103299a2dd95SBruce Richardson  * @param dev_id
103399a2dd95SBruce Richardson  *   The identifier of the device.
103499a2dd95SBruce Richardson  * @param port_id
103599a2dd95SBruce Richardson  *   The index of the event port to setup. The value must be in the range
103699a2dd95SBruce Richardson  *   [0, nb_event_ports - 1] previously supplied to rte_event_dev_configure().
103799a2dd95SBruce Richardson  * @param port_conf
103899a2dd95SBruce Richardson  *   The pointer to the configuration data to be used for the queue.
103999a2dd95SBruce Richardson  *   NULL value is allowed, in which case default configuration	used.
104099a2dd95SBruce Richardson  *
104199a2dd95SBruce Richardson  * @see rte_event_port_default_conf_get()
104299a2dd95SBruce Richardson  *
104399a2dd95SBruce Richardson  * @return
104499a2dd95SBruce Richardson  *   - 0: Success, event port correctly set up.
104599a2dd95SBruce Richardson  *   - <0: Port configuration failed
104699a2dd95SBruce Richardson  *   - (-EDQUOT) Quota exceeded(Application tried to link the queue configured
104799a2dd95SBruce Richardson  *   with RTE_EVENT_QUEUE_CFG_SINGLE_LINK to more than one event ports)
104899a2dd95SBruce Richardson  */
104999a2dd95SBruce Richardson int
105099a2dd95SBruce Richardson rte_event_port_setup(uint8_t dev_id, uint8_t port_id,
105199a2dd95SBruce Richardson 		     const struct rte_event_port_conf *port_conf);
105299a2dd95SBruce Richardson 
10531ff23ce6SPavan Nikhilesh typedef void (*rte_eventdev_port_flush_t)(uint8_t dev_id,
10541ff23ce6SPavan Nikhilesh 					  struct rte_event event, void *arg);
10551ff23ce6SPavan Nikhilesh /**< Callback function prototype that can be passed during
10561ff23ce6SPavan Nikhilesh  * rte_event_port_release(), invoked once per a released event.
10571ff23ce6SPavan Nikhilesh  */
10581ff23ce6SPavan Nikhilesh 
10591ff23ce6SPavan Nikhilesh /**
10601ff23ce6SPavan Nikhilesh  * Quiesce any core specific resources consumed by the event port.
10611ff23ce6SPavan Nikhilesh  *
10621ff23ce6SPavan Nikhilesh  * Event ports are generally coupled with lcores, and a given Hardware
10631ff23ce6SPavan Nikhilesh  * implementation might require the PMD to store port specific data in the
10641ff23ce6SPavan Nikhilesh  * lcore.
10651ff23ce6SPavan Nikhilesh  * When the application decides to migrate the event port to another lcore
10661ff23ce6SPavan Nikhilesh  * or teardown the current lcore it may to call `rte_event_port_quiesce`
10671ff23ce6SPavan Nikhilesh  * to make sure that all the data associated with the event port are released
10681ff23ce6SPavan Nikhilesh  * from the lcore, this might also include any prefetched events.
10691ff23ce6SPavan Nikhilesh  * While releasing the event port from the lcore, this function calls the
10701ff23ce6SPavan Nikhilesh  * user-provided flush callback once per event.
10711ff23ce6SPavan Nikhilesh  *
10721ff23ce6SPavan Nikhilesh  * @note Invocation of this API does not affect the existing port configuration.
10731ff23ce6SPavan Nikhilesh  *
10741ff23ce6SPavan Nikhilesh  * @param dev_id
10751ff23ce6SPavan Nikhilesh  *   The identifier of the device.
10761ff23ce6SPavan Nikhilesh  * @param port_id
10771ff23ce6SPavan Nikhilesh  *   The index of the event port to setup. The value must be in the range
10781ff23ce6SPavan Nikhilesh  *   [0, nb_event_ports - 1] previously supplied to rte_event_dev_configure().
10791ff23ce6SPavan Nikhilesh  * @param release_cb
10801ff23ce6SPavan Nikhilesh  *   Callback function invoked once per flushed event.
10811ff23ce6SPavan Nikhilesh  * @param args
10821ff23ce6SPavan Nikhilesh  *   Argument supplied to callback.
10831ff23ce6SPavan Nikhilesh  */
10841ff23ce6SPavan Nikhilesh void
10851ff23ce6SPavan Nikhilesh rte_event_port_quiesce(uint8_t dev_id, uint8_t port_id,
10861ff23ce6SPavan Nikhilesh 		       rte_eventdev_port_flush_t release_cb, void *args);
10871ff23ce6SPavan Nikhilesh 
108899a2dd95SBruce Richardson /**
108999a2dd95SBruce Richardson  * The queue depth of the port on the enqueue side
109099a2dd95SBruce Richardson  */
109199a2dd95SBruce Richardson #define RTE_EVENT_PORT_ATTR_ENQ_DEPTH 0
109299a2dd95SBruce Richardson /**
109399a2dd95SBruce Richardson  * The queue depth of the port on the dequeue side
109499a2dd95SBruce Richardson  */
109599a2dd95SBruce Richardson #define RTE_EVENT_PORT_ATTR_DEQ_DEPTH 1
109699a2dd95SBruce Richardson /**
109799a2dd95SBruce Richardson  * The new event threshold of the port
109899a2dd95SBruce Richardson  */
109999a2dd95SBruce Richardson #define RTE_EVENT_PORT_ATTR_NEW_EVENT_THRESHOLD 2
110099a2dd95SBruce Richardson /**
110199a2dd95SBruce Richardson  * The implicit release disable attribute of the port
110299a2dd95SBruce Richardson  */
110399a2dd95SBruce Richardson #define RTE_EVENT_PORT_ATTR_IMPLICIT_RELEASE_DISABLE 3
110499a2dd95SBruce Richardson 
110599a2dd95SBruce Richardson /**
110699a2dd95SBruce Richardson  * Get an attribute from a port.
110799a2dd95SBruce Richardson  *
110899a2dd95SBruce Richardson  * @param dev_id
110999a2dd95SBruce Richardson  *   Eventdev id
111099a2dd95SBruce Richardson  * @param port_id
111199a2dd95SBruce Richardson  *   Eventdev port id
111299a2dd95SBruce Richardson  * @param attr_id
111399a2dd95SBruce Richardson  *   The attribute ID to retrieve
111499a2dd95SBruce Richardson  * @param[out] attr_value
111599a2dd95SBruce Richardson  *   A pointer that will be filled in with the attribute value if successful
111699a2dd95SBruce Richardson  *
111799a2dd95SBruce Richardson  * @return
111899a2dd95SBruce Richardson  *   - 0: Successfully returned value
111999a2dd95SBruce Richardson  *   - (-EINVAL) Invalid device, port or attr_id, or attr_value was NULL
112099a2dd95SBruce Richardson  */
112199a2dd95SBruce Richardson int
112299a2dd95SBruce Richardson rte_event_port_attr_get(uint8_t dev_id, uint8_t port_id, uint32_t attr_id,
112399a2dd95SBruce Richardson 			uint32_t *attr_value);
112499a2dd95SBruce Richardson 
112599a2dd95SBruce Richardson /**
112699a2dd95SBruce Richardson  * Start an event device.
112799a2dd95SBruce Richardson  *
112899a2dd95SBruce Richardson  * The device start step is the last one and consists of setting the event
112999a2dd95SBruce Richardson  * queues to start accepting the events and schedules to event ports.
113099a2dd95SBruce Richardson  *
113199a2dd95SBruce Richardson  * On success, all basic functions exported by the API (event enqueue,
113299a2dd95SBruce Richardson  * event dequeue and so on) can be invoked.
113399a2dd95SBruce Richardson  *
113499a2dd95SBruce Richardson  * @param dev_id
113599a2dd95SBruce Richardson  *   Event device identifier
113699a2dd95SBruce Richardson  * @return
113799a2dd95SBruce Richardson  *   - 0: Success, device started.
113899a2dd95SBruce Richardson  *   - -ESTALE : Not all ports of the device are configured
113999a2dd95SBruce Richardson  *   - -ENOLINK: Not all queues are linked, which could lead to deadlock.
114099a2dd95SBruce Richardson  */
114199a2dd95SBruce Richardson int
114299a2dd95SBruce Richardson rte_event_dev_start(uint8_t dev_id);
114399a2dd95SBruce Richardson 
114499a2dd95SBruce Richardson /**
114599a2dd95SBruce Richardson  * Stop an event device.
114699a2dd95SBruce Richardson  *
114799a2dd95SBruce Richardson  * This function causes all queued events to be drained, including those
114899a2dd95SBruce Richardson  * residing in event ports. While draining events out of the device, this
114999a2dd95SBruce Richardson  * function calls the user-provided flush callback (if one was registered) once
115099a2dd95SBruce Richardson  * per event.
115199a2dd95SBruce Richardson  *
115299a2dd95SBruce Richardson  * The device can be restarted with a call to rte_event_dev_start(). Threads
115399a2dd95SBruce Richardson  * that continue to enqueue/dequeue while the device is stopped, or being
115499a2dd95SBruce Richardson  * stopped, will result in undefined behavior. This includes event adapters,
115599a2dd95SBruce Richardson  * which must be stopped prior to stopping the eventdev.
115699a2dd95SBruce Richardson  *
115799a2dd95SBruce Richardson  * @param dev_id
115899a2dd95SBruce Richardson  *   Event device identifier.
115999a2dd95SBruce Richardson  *
116099a2dd95SBruce Richardson  * @see rte_event_dev_stop_flush_callback_register()
116199a2dd95SBruce Richardson  */
116299a2dd95SBruce Richardson void
116399a2dd95SBruce Richardson rte_event_dev_stop(uint8_t dev_id);
116499a2dd95SBruce Richardson 
1165d986276fSPavan Nikhilesh typedef void (*rte_eventdev_stop_flush_t)(uint8_t dev_id,
1166d986276fSPavan Nikhilesh 					  struct rte_event event, void *arg);
116799a2dd95SBruce Richardson /**< Callback function called during rte_event_dev_stop(), invoked once per
116899a2dd95SBruce Richardson  * flushed event.
116999a2dd95SBruce Richardson  */
117099a2dd95SBruce Richardson 
117199a2dd95SBruce Richardson /**
117299a2dd95SBruce Richardson  * Registers a callback function to be invoked during rte_event_dev_stop() for
117399a2dd95SBruce Richardson  * each flushed event. This function can be used to properly dispose of queued
117499a2dd95SBruce Richardson  * events, for example events containing memory pointers.
117599a2dd95SBruce Richardson  *
117699a2dd95SBruce Richardson  * The callback function is only registered for the calling process. The
117799a2dd95SBruce Richardson  * callback function must be registered in every process that can call
117899a2dd95SBruce Richardson  * rte_event_dev_stop().
117999a2dd95SBruce Richardson  *
118099a2dd95SBruce Richardson  * To unregister a callback, call this function with a NULL callback pointer.
118199a2dd95SBruce Richardson  *
118299a2dd95SBruce Richardson  * @param dev_id
118399a2dd95SBruce Richardson  *   The identifier of the device.
118499a2dd95SBruce Richardson  * @param callback
118599a2dd95SBruce Richardson  *   Callback function invoked once per flushed event.
118699a2dd95SBruce Richardson  * @param userdata
118799a2dd95SBruce Richardson  *   Argument supplied to callback.
118899a2dd95SBruce Richardson  *
118999a2dd95SBruce Richardson  * @return
119099a2dd95SBruce Richardson  *  - 0 on success.
119199a2dd95SBruce Richardson  *  - -EINVAL if *dev_id* is invalid
119299a2dd95SBruce Richardson  *
119399a2dd95SBruce Richardson  * @see rte_event_dev_stop()
119499a2dd95SBruce Richardson  */
1195d986276fSPavan Nikhilesh int rte_event_dev_stop_flush_callback_register(uint8_t dev_id,
1196d986276fSPavan Nikhilesh 					       rte_eventdev_stop_flush_t callback, void *userdata);
119799a2dd95SBruce Richardson 
119899a2dd95SBruce Richardson /**
119999a2dd95SBruce Richardson  * Close an event device. The device cannot be restarted!
120099a2dd95SBruce Richardson  *
120199a2dd95SBruce Richardson  * @param dev_id
120299a2dd95SBruce Richardson  *   Event device identifier
120399a2dd95SBruce Richardson  *
120499a2dd95SBruce Richardson  * @return
120599a2dd95SBruce Richardson  *  - 0 on successfully closing device
120699a2dd95SBruce Richardson  *  - <0 on failure to close device
120799a2dd95SBruce Richardson  *  - (-EAGAIN) if device is busy
120899a2dd95SBruce Richardson  */
120999a2dd95SBruce Richardson int
121099a2dd95SBruce Richardson rte_event_dev_close(uint8_t dev_id);
121199a2dd95SBruce Richardson 
121299a2dd95SBruce Richardson /**
121399a2dd95SBruce Richardson  * Event vector structure.
121499a2dd95SBruce Richardson  */
121599a2dd95SBruce Richardson struct rte_event_vector {
121699a2dd95SBruce Richardson 	uint16_t nb_elem;
12170fbb55efSPavan Nikhilesh 	/**< Number of elements valid in this event vector. */
12180fbb55efSPavan Nikhilesh 	uint16_t elem_offset : 12;
12190fbb55efSPavan Nikhilesh 	/**< Offset into the vector array where valid elements start from. */
12200fbb55efSPavan Nikhilesh 	uint16_t rsvd : 3;
122199a2dd95SBruce Richardson 	/**< Reserved for future use */
122299a2dd95SBruce Richardson 	uint16_t attr_valid : 1;
122399a2dd95SBruce Richardson 	/**< Indicates that the below union attributes have valid information.
122499a2dd95SBruce Richardson 	 */
122599a2dd95SBruce Richardson 	union {
122699a2dd95SBruce Richardson 		/* Used by Rx/Tx adapter.
122799a2dd95SBruce Richardson 		 * Indicates that all the elements in this vector belong to the
122899a2dd95SBruce Richardson 		 * same port and queue pair when originating from Rx adapter,
122999a2dd95SBruce Richardson 		 * valid only when event type is ETHDEV_VECTOR or
123099a2dd95SBruce Richardson 		 * ETH_RX_ADAPTER_VECTOR.
123199a2dd95SBruce Richardson 		 * Can also be used to indicate the Tx adapter the destination
123299a2dd95SBruce Richardson 		 * port and queue of the mbufs in the vector
123399a2dd95SBruce Richardson 		 */
123499a2dd95SBruce Richardson 		struct {
123599a2dd95SBruce Richardson 			uint16_t port;
123699a2dd95SBruce Richardson 			/* Ethernet device port id. */
123799a2dd95SBruce Richardson 			uint16_t queue;
123899a2dd95SBruce Richardson 			/* Ethernet device queue id. */
123999a2dd95SBruce Richardson 		};
124099a2dd95SBruce Richardson 	};
124199a2dd95SBruce Richardson 	/**< Union to hold common attributes of the vector array. */
124299a2dd95SBruce Richardson 	uint64_t impl_opaque;
1243699155f2SBruce Richardson 
1244699155f2SBruce Richardson /* empty structures do not have zero size in C++ leading to compilation errors
1245699155f2SBruce Richardson  * with clang about structure having different sizes in C and C++.
1246699155f2SBruce Richardson  * Since these are all zero-sized arrays, we can omit the "union" wrapper for
1247699155f2SBruce Richardson  * C++ builds, removing the warning.
1248699155f2SBruce Richardson  */
1249699155f2SBruce Richardson #ifndef __cplusplus
125099a2dd95SBruce Richardson 	/**< Implementation specific opaque value.
125199a2dd95SBruce Richardson 	 * An implementation may use this field to hold implementation specific
125299a2dd95SBruce Richardson 	 * value to share between dequeue and enqueue operation.
125399a2dd95SBruce Richardson 	 * The application should not modify this field.
125499a2dd95SBruce Richardson 	 */
125599a2dd95SBruce Richardson 	union {
1256699155f2SBruce Richardson #endif
125799a2dd95SBruce Richardson 		struct rte_mbuf *mbufs[0];
125899a2dd95SBruce Richardson 		void *ptrs[0];
12595fa63911SPavan Nikhilesh 		uint64_t u64s[0];
1260699155f2SBruce Richardson #ifndef __cplusplus
126199a2dd95SBruce Richardson 	} __rte_aligned(16);
1262699155f2SBruce Richardson #endif
126399a2dd95SBruce Richardson 	/**< Start of the vector array union. Depending upon the event type the
126499a2dd95SBruce Richardson 	 * vector array can be an array of mbufs or pointers or opaque u64
126599a2dd95SBruce Richardson 	 * values.
126699a2dd95SBruce Richardson 	 */
1267699155f2SBruce Richardson } __rte_aligned(16);
126899a2dd95SBruce Richardson 
126999a2dd95SBruce Richardson /* Scheduler type definitions */
127099a2dd95SBruce Richardson #define RTE_SCHED_TYPE_ORDERED          0
127199a2dd95SBruce Richardson /**< Ordered scheduling
127299a2dd95SBruce Richardson  *
127399a2dd95SBruce Richardson  * Events from an ordered flow of an event queue can be scheduled to multiple
127499a2dd95SBruce Richardson  * ports for concurrent processing while maintaining the original event order.
127599a2dd95SBruce Richardson  * This scheme enables the user to achieve high single flow throughput by
127699a2dd95SBruce Richardson  * avoiding SW synchronization for ordering between ports which bound to cores.
127799a2dd95SBruce Richardson  *
127899a2dd95SBruce Richardson  * The source flow ordering from an event queue is maintained when events are
127999a2dd95SBruce Richardson  * enqueued to their destination queue within the same ordered flow context.
128099a2dd95SBruce Richardson  * An event port holds the context until application call
128199a2dd95SBruce Richardson  * rte_event_dequeue_burst() from the same port, which implicitly releases
128299a2dd95SBruce Richardson  * the context.
128399a2dd95SBruce Richardson  * User may allow the scheduler to release the context earlier than that
128499a2dd95SBruce Richardson  * by invoking rte_event_enqueue_burst() with RTE_EVENT_OP_RELEASE operation.
128599a2dd95SBruce Richardson  *
128699a2dd95SBruce Richardson  * Events from the source queue appear in their original order when dequeued
128799a2dd95SBruce Richardson  * from a destination queue.
128899a2dd95SBruce Richardson  * Event ordering is based on the received event(s), but also other
128999a2dd95SBruce Richardson  * (newly allocated or stored) events are ordered when enqueued within the same
129099a2dd95SBruce Richardson  * ordered context. Events not enqueued (e.g. released or stored) within the
129199a2dd95SBruce Richardson  * context are  considered missing from reordering and are skipped at this time
129299a2dd95SBruce Richardson  * (but can be ordered again within another context).
129399a2dd95SBruce Richardson  *
129499a2dd95SBruce Richardson  * @see rte_event_queue_setup(), rte_event_dequeue_burst(), RTE_EVENT_OP_RELEASE
129599a2dd95SBruce Richardson  */
129699a2dd95SBruce Richardson 
129799a2dd95SBruce Richardson #define RTE_SCHED_TYPE_ATOMIC           1
129899a2dd95SBruce Richardson /**< Atomic scheduling
129999a2dd95SBruce Richardson  *
130099a2dd95SBruce Richardson  * Events from an atomic flow of an event queue can be scheduled only to a
130199a2dd95SBruce Richardson  * single port at a time. The port is guaranteed to have exclusive (atomic)
130299a2dd95SBruce Richardson  * access to the associated flow context, which enables the user to avoid SW
130399a2dd95SBruce Richardson  * synchronization. Atomic flows also help to maintain event ordering
130499a2dd95SBruce Richardson  * since only one port at a time can process events from a flow of an
130599a2dd95SBruce Richardson  * event queue.
130699a2dd95SBruce Richardson  *
130799a2dd95SBruce Richardson  * The atomic queue synchronization context is dedicated to the port until
130899a2dd95SBruce Richardson  * application call rte_event_dequeue_burst() from the same port,
130999a2dd95SBruce Richardson  * which implicitly releases the context. User may allow the scheduler to
131099a2dd95SBruce Richardson  * release the context earlier than that by invoking rte_event_enqueue_burst()
131199a2dd95SBruce Richardson  * with RTE_EVENT_OP_RELEASE operation.
131299a2dd95SBruce Richardson  *
131399a2dd95SBruce Richardson  * @see rte_event_queue_setup(), rte_event_dequeue_burst(), RTE_EVENT_OP_RELEASE
131499a2dd95SBruce Richardson  */
131599a2dd95SBruce Richardson 
131699a2dd95SBruce Richardson #define RTE_SCHED_TYPE_PARALLEL         2
131799a2dd95SBruce Richardson /**< Parallel scheduling
131899a2dd95SBruce Richardson  *
131999a2dd95SBruce Richardson  * The scheduler performs priority scheduling, load balancing, etc. functions
132099a2dd95SBruce Richardson  * but does not provide additional event synchronization or ordering.
132199a2dd95SBruce Richardson  * It is free to schedule events from a single parallel flow of an event queue
132299a2dd95SBruce Richardson  * to multiple events ports for concurrent processing.
132399a2dd95SBruce Richardson  * The application is responsible for flow context synchronization and
132499a2dd95SBruce Richardson  * event ordering (SW synchronization).
132599a2dd95SBruce Richardson  *
132699a2dd95SBruce Richardson  * @see rte_event_queue_setup(), rte_event_dequeue_burst()
132799a2dd95SBruce Richardson  */
132899a2dd95SBruce Richardson 
132999a2dd95SBruce Richardson /* Event types to classify the event source */
133099a2dd95SBruce Richardson #define RTE_EVENT_TYPE_ETHDEV           0x0
133199a2dd95SBruce Richardson /**< The event generated from ethdev subsystem */
133299a2dd95SBruce Richardson #define RTE_EVENT_TYPE_CRYPTODEV        0x1
133399a2dd95SBruce Richardson /**< The event generated from crypodev subsystem */
133499a2dd95SBruce Richardson #define RTE_EVENT_TYPE_TIMER		0x2
133599a2dd95SBruce Richardson /**< The event generated from event timer adapter */
133699a2dd95SBruce Richardson #define RTE_EVENT_TYPE_CPU              0x3
133799a2dd95SBruce Richardson /**< The event generated from cpu for pipelining.
133899a2dd95SBruce Richardson  * Application may use *sub_event_type* to further classify the event
133999a2dd95SBruce Richardson  */
134099a2dd95SBruce Richardson #define RTE_EVENT_TYPE_ETH_RX_ADAPTER   0x4
134199a2dd95SBruce Richardson /**< The event generated from event eth Rx adapter */
134266a30a29SAmit Prakash Shukla #define RTE_EVENT_TYPE_DMADEV           0x5
134366a30a29SAmit Prakash Shukla /**< The event generated from dma subsystem */
134499a2dd95SBruce Richardson #define RTE_EVENT_TYPE_VECTOR           0x8
134599a2dd95SBruce Richardson /**< Indicates that event is a vector.
134699a2dd95SBruce Richardson  * All vector event types should be a logical OR of EVENT_TYPE_VECTOR.
134799a2dd95SBruce Richardson  * This simplifies the pipeline design as one can split processing the events
134899a2dd95SBruce Richardson  * between vector events and normal event across event types.
134999a2dd95SBruce Richardson  * Example:
135099a2dd95SBruce Richardson  *	if (ev.event_type & RTE_EVENT_TYPE_VECTOR) {
135199a2dd95SBruce Richardson  *		// Classify and handle vector event.
135299a2dd95SBruce Richardson  *	} else {
135399a2dd95SBruce Richardson  *		// Classify and handle event.
135499a2dd95SBruce Richardson  *	}
135599a2dd95SBruce Richardson  */
135699a2dd95SBruce Richardson #define RTE_EVENT_TYPE_ETHDEV_VECTOR                                           \
135799a2dd95SBruce Richardson 	(RTE_EVENT_TYPE_VECTOR | RTE_EVENT_TYPE_ETHDEV)
135899a2dd95SBruce Richardson /**< The event vector generated from ethdev subsystem */
135999a2dd95SBruce Richardson #define RTE_EVENT_TYPE_CPU_VECTOR (RTE_EVENT_TYPE_VECTOR | RTE_EVENT_TYPE_CPU)
136099a2dd95SBruce Richardson /**< The event vector generated from cpu for pipelining. */
136199a2dd95SBruce Richardson #define RTE_EVENT_TYPE_ETH_RX_ADAPTER_VECTOR                                   \
136299a2dd95SBruce Richardson 	(RTE_EVENT_TYPE_VECTOR | RTE_EVENT_TYPE_ETH_RX_ADAPTER)
136399a2dd95SBruce Richardson /**< The event vector generated from eth Rx adapter. */
1364c1749bc5SVolodymyr Fialko #define RTE_EVENT_TYPE_CRYPTODEV_VECTOR                                        \
1365c1749bc5SVolodymyr Fialko 	(RTE_EVENT_TYPE_VECTOR | RTE_EVENT_TYPE_CRYPTODEV)
1366c1749bc5SVolodymyr Fialko /**< The event vector generated from cryptodev adapter. */
136799a2dd95SBruce Richardson 
136899a2dd95SBruce Richardson #define RTE_EVENT_TYPE_MAX              0x10
136999a2dd95SBruce Richardson /**< Maximum number of event types */
137099a2dd95SBruce Richardson 
137199a2dd95SBruce Richardson /* Event enqueue operations */
137299a2dd95SBruce Richardson #define RTE_EVENT_OP_NEW                0
137399a2dd95SBruce Richardson /**< The event producers use this operation to inject a new event to the
137499a2dd95SBruce Richardson  * event device.
137599a2dd95SBruce Richardson  */
137699a2dd95SBruce Richardson #define RTE_EVENT_OP_FORWARD            1
137799a2dd95SBruce Richardson /**< The CPU use this operation to forward the event to different event queue or
137899a2dd95SBruce Richardson  * change to new application specific flow or schedule type to enable
137999a2dd95SBruce Richardson  * pipelining.
138099a2dd95SBruce Richardson  *
138199a2dd95SBruce Richardson  * This operation must only be enqueued to the same port that the
138299a2dd95SBruce Richardson  * event to be forwarded was dequeued from.
138399a2dd95SBruce Richardson  */
138499a2dd95SBruce Richardson #define RTE_EVENT_OP_RELEASE            2
138599a2dd95SBruce Richardson /**< Release the flow context associated with the schedule type.
138699a2dd95SBruce Richardson  *
138799a2dd95SBruce Richardson  * If current flow's scheduler type method is *RTE_SCHED_TYPE_ATOMIC*
138899a2dd95SBruce Richardson  * then this function hints the scheduler that the user has completed critical
138999a2dd95SBruce Richardson  * section processing in the current atomic context.
139099a2dd95SBruce Richardson  * The scheduler is now allowed to schedule events from the same flow from
139199a2dd95SBruce Richardson  * an event queue to another port. However, the context may be still held
139299a2dd95SBruce Richardson  * until the next rte_event_dequeue_burst() call, this call allows but does not
139399a2dd95SBruce Richardson  * force the scheduler to release the context early.
139499a2dd95SBruce Richardson  *
139599a2dd95SBruce Richardson  * Early atomic context release may increase parallelism and thus system
139699a2dd95SBruce Richardson  * performance, but the user needs to design carefully the split into critical
139799a2dd95SBruce Richardson  * vs non-critical sections.
139899a2dd95SBruce Richardson  *
139999a2dd95SBruce Richardson  * If current flow's scheduler type method is *RTE_SCHED_TYPE_ORDERED*
140099a2dd95SBruce Richardson  * then this function hints the scheduler that the user has done all that need
140199a2dd95SBruce Richardson  * to maintain event order in the current ordered context.
140299a2dd95SBruce Richardson  * The scheduler is allowed to release the ordered context of this port and
140399a2dd95SBruce Richardson  * avoid reordering any following enqueues.
140499a2dd95SBruce Richardson  *
140599a2dd95SBruce Richardson  * Early ordered context release may increase parallelism and thus system
140699a2dd95SBruce Richardson  * performance.
140799a2dd95SBruce Richardson  *
140899a2dd95SBruce Richardson  * If current flow's scheduler type method is *RTE_SCHED_TYPE_PARALLEL*
140999a2dd95SBruce Richardson  * or no scheduling context is held then this function may be an NOOP,
141099a2dd95SBruce Richardson  * depending on the implementation.
141199a2dd95SBruce Richardson  *
141299a2dd95SBruce Richardson  * This operation must only be enqueued to the same port that the
141399a2dd95SBruce Richardson  * event to be released was dequeued from.
141499a2dd95SBruce Richardson  */
141599a2dd95SBruce Richardson 
141699a2dd95SBruce Richardson /**
141799a2dd95SBruce Richardson  * The generic *rte_event* structure to hold the event attributes
141899a2dd95SBruce Richardson  * for dequeue and enqueue operation
141999a2dd95SBruce Richardson  */
142099a2dd95SBruce Richardson struct rte_event {
142199a2dd95SBruce Richardson 	/** WORD0 */
142299a2dd95SBruce Richardson 	union {
142399a2dd95SBruce Richardson 		uint64_t event;
142499a2dd95SBruce Richardson 		/** Event attributes for dequeue or enqueue operation */
142599a2dd95SBruce Richardson 		struct {
142699a2dd95SBruce Richardson 			uint32_t flow_id:20;
142799a2dd95SBruce Richardson 			/**< Targeted flow identifier for the enqueue and
142899a2dd95SBruce Richardson 			 * dequeue operation.
142999a2dd95SBruce Richardson 			 * The value must be in the range of
143099a2dd95SBruce Richardson 			 * [0, nb_event_queue_flows - 1] which
143199a2dd95SBruce Richardson 			 * previously supplied to rte_event_dev_configure().
143299a2dd95SBruce Richardson 			 */
143399a2dd95SBruce Richardson 			uint32_t sub_event_type:8;
143499a2dd95SBruce Richardson 			/**< Sub-event types based on the event source.
143599a2dd95SBruce Richardson 			 * @see RTE_EVENT_TYPE_CPU
143699a2dd95SBruce Richardson 			 */
143799a2dd95SBruce Richardson 			uint32_t event_type:4;
143899a2dd95SBruce Richardson 			/**< Event type to classify the event source.
143999a2dd95SBruce Richardson 			 * @see RTE_EVENT_TYPE_ETHDEV, (RTE_EVENT_TYPE_*)
144099a2dd95SBruce Richardson 			 */
144199a2dd95SBruce Richardson 			uint8_t op:2;
144299a2dd95SBruce Richardson 			/**< The type of event enqueue operation - new/forward/
144399a2dd95SBruce Richardson 			 * etc.This field is not preserved across an instance
144499a2dd95SBruce Richardson 			 * and is undefined on dequeue.
144599a2dd95SBruce Richardson 			 * @see RTE_EVENT_OP_NEW, (RTE_EVENT_OP_*)
144699a2dd95SBruce Richardson 			 */
144799a2dd95SBruce Richardson 			uint8_t rsvd:4;
144899a2dd95SBruce Richardson 			/**< Reserved for future use */
144999a2dd95SBruce Richardson 			uint8_t sched_type:2;
145099a2dd95SBruce Richardson 			/**< Scheduler synchronization type (RTE_SCHED_TYPE_*)
145199a2dd95SBruce Richardson 			 * associated with flow id on a given event queue
145299a2dd95SBruce Richardson 			 * for the enqueue and dequeue operation.
145399a2dd95SBruce Richardson 			 */
145499a2dd95SBruce Richardson 			uint8_t queue_id;
145599a2dd95SBruce Richardson 			/**< Targeted event queue identifier for the enqueue or
145699a2dd95SBruce Richardson 			 * dequeue operation.
145799a2dd95SBruce Richardson 			 * The value must be in the range of
145899a2dd95SBruce Richardson 			 * [0, nb_event_queues - 1] which previously supplied to
145999a2dd95SBruce Richardson 			 * rte_event_dev_configure().
146099a2dd95SBruce Richardson 			 */
146199a2dd95SBruce Richardson 			uint8_t priority;
146299a2dd95SBruce Richardson 			/**< Event priority relative to other events in the
146399a2dd95SBruce Richardson 			 * event queue. The requested priority should in the
146499a2dd95SBruce Richardson 			 * range of  [RTE_EVENT_DEV_PRIORITY_HIGHEST,
146599a2dd95SBruce Richardson 			 * RTE_EVENT_DEV_PRIORITY_LOWEST].
146699a2dd95SBruce Richardson 			 * The implementation shall normalize the requested
146799a2dd95SBruce Richardson 			 * priority to supported priority value.
146899a2dd95SBruce Richardson 			 * Valid when the device has
146999a2dd95SBruce Richardson 			 * RTE_EVENT_DEV_CAP_EVENT_QOS capability.
147099a2dd95SBruce Richardson 			 */
147199a2dd95SBruce Richardson 			uint8_t impl_opaque;
147299a2dd95SBruce Richardson 			/**< Implementation specific opaque value.
147399a2dd95SBruce Richardson 			 * An implementation may use this field to hold
147499a2dd95SBruce Richardson 			 * implementation specific value to share between
147599a2dd95SBruce Richardson 			 * dequeue and enqueue operation.
147699a2dd95SBruce Richardson 			 * The application should not modify this field.
147799a2dd95SBruce Richardson 			 */
147899a2dd95SBruce Richardson 		};
147999a2dd95SBruce Richardson 	};
148099a2dd95SBruce Richardson 	/** WORD1 */
148199a2dd95SBruce Richardson 	union {
148299a2dd95SBruce Richardson 		uint64_t u64;
148399a2dd95SBruce Richardson 		/**< Opaque 64-bit value */
148499a2dd95SBruce Richardson 		void *event_ptr;
148599a2dd95SBruce Richardson 		/**< Opaque event pointer */
148699a2dd95SBruce Richardson 		struct rte_mbuf *mbuf;
148799a2dd95SBruce Richardson 		/**< mbuf pointer if dequeued event is associated with mbuf */
148899a2dd95SBruce Richardson 		struct rte_event_vector *vec;
148999a2dd95SBruce Richardson 		/**< Event vector pointer. */
149099a2dd95SBruce Richardson 	};
149199a2dd95SBruce Richardson };
149299a2dd95SBruce Richardson 
149399a2dd95SBruce Richardson /* Ethdev Rx adapter capability bitmap flags */
149499a2dd95SBruce Richardson #define RTE_EVENT_ETH_RX_ADAPTER_CAP_INTERNAL_PORT	0x1
149599a2dd95SBruce Richardson /**< This flag is sent when the packet transfer mechanism is in HW.
149699a2dd95SBruce Richardson  * Ethdev can send packets to the event device using internal event port.
149799a2dd95SBruce Richardson  */
149899a2dd95SBruce Richardson #define RTE_EVENT_ETH_RX_ADAPTER_CAP_MULTI_EVENTQ	0x2
149999a2dd95SBruce Richardson /**< Adapter supports multiple event queues per ethdev. Every ethdev
150099a2dd95SBruce Richardson  * Rx queue can be connected to a unique event queue.
150199a2dd95SBruce Richardson  */
150299a2dd95SBruce Richardson #define RTE_EVENT_ETH_RX_ADAPTER_CAP_OVERRIDE_FLOW_ID	0x4
150399a2dd95SBruce Richardson /**< The application can override the adapter generated flow ID in the
150499a2dd95SBruce Richardson  * event. This flow ID can be specified when adding an ethdev Rx queue
1505a256a743SPavan Nikhilesh  * to the adapter using the ev.flow_id member.
150699a2dd95SBruce Richardson  * @see struct rte_event_eth_rx_adapter_queue_conf::ev
150799a2dd95SBruce Richardson  * @see struct rte_event_eth_rx_adapter_queue_conf::rx_queue_flags
150899a2dd95SBruce Richardson  */
150999a2dd95SBruce Richardson #define RTE_EVENT_ETH_RX_ADAPTER_CAP_EVENT_VECTOR	0x8
151099a2dd95SBruce Richardson /**< Adapter supports event vectorization per ethdev. */
151199a2dd95SBruce Richardson 
151299a2dd95SBruce Richardson /**
151399a2dd95SBruce Richardson  * Retrieve the event device's ethdev Rx adapter capabilities for the
151499a2dd95SBruce Richardson  * specified ethernet port
151599a2dd95SBruce Richardson  *
151699a2dd95SBruce Richardson  * @param dev_id
151799a2dd95SBruce Richardson  *   The identifier of the device.
151899a2dd95SBruce Richardson  *
151999a2dd95SBruce Richardson  * @param eth_port_id
152099a2dd95SBruce Richardson  *   The identifier of the ethernet device.
152199a2dd95SBruce Richardson  *
152299a2dd95SBruce Richardson  * @param[out] caps
152399a2dd95SBruce Richardson  *   A pointer to memory filled with Rx event adapter capabilities.
152499a2dd95SBruce Richardson  *
152599a2dd95SBruce Richardson  * @return
152699a2dd95SBruce Richardson  *   - 0: Success, driver provides Rx event adapter capabilities for the
152799a2dd95SBruce Richardson  *	ethernet device.
152899a2dd95SBruce Richardson  *   - <0: Error code returned by the driver function.
152999a2dd95SBruce Richardson  */
153099a2dd95SBruce Richardson int
153199a2dd95SBruce Richardson rte_event_eth_rx_adapter_caps_get(uint8_t dev_id, uint16_t eth_port_id,
153299a2dd95SBruce Richardson 				uint32_t *caps);
153399a2dd95SBruce Richardson 
153499a2dd95SBruce Richardson #define RTE_EVENT_TIMER_ADAPTER_CAP_INTERNAL_PORT (1ULL << 0)
153599a2dd95SBruce Richardson /**< This flag is set when the timer mechanism is in HW. */
153699a2dd95SBruce Richardson 
153799a2dd95SBruce Richardson #define RTE_EVENT_TIMER_ADAPTER_CAP_PERIODIC      (1ULL << 1)
153899a2dd95SBruce Richardson /**< This flag is set if periodic mode is supported. */
153999a2dd95SBruce Richardson 
154099a2dd95SBruce Richardson /**
154199a2dd95SBruce Richardson  * Retrieve the event device's timer adapter capabilities.
154299a2dd95SBruce Richardson  *
154399a2dd95SBruce Richardson  * @param dev_id
154499a2dd95SBruce Richardson  *   The identifier of the device.
154599a2dd95SBruce Richardson  *
154699a2dd95SBruce Richardson  * @param[out] caps
154799a2dd95SBruce Richardson  *   A pointer to memory to be filled with event timer adapter capabilities.
154899a2dd95SBruce Richardson  *
154999a2dd95SBruce Richardson  * @return
155099a2dd95SBruce Richardson  *   - 0: Success, driver provided event timer adapter capabilities.
155199a2dd95SBruce Richardson  *   - <0: Error code returned by the driver function.
155299a2dd95SBruce Richardson  */
155399a2dd95SBruce Richardson int
155499a2dd95SBruce Richardson rte_event_timer_adapter_caps_get(uint8_t dev_id, uint32_t *caps);
155599a2dd95SBruce Richardson 
155699a2dd95SBruce Richardson /* Crypto adapter capability bitmap flag */
155799a2dd95SBruce Richardson #define RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_NEW   0x1
155899a2dd95SBruce Richardson /**< Flag indicates HW is capable of generating events in
155999a2dd95SBruce Richardson  * RTE_EVENT_OP_NEW enqueue operation. Cryptodev will send
156099a2dd95SBruce Richardson  * packets to the event device as new events using an internal
156199a2dd95SBruce Richardson  * event port.
156299a2dd95SBruce Richardson  */
156399a2dd95SBruce Richardson 
156499a2dd95SBruce Richardson #define RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_FWD   0x2
156599a2dd95SBruce Richardson /**< Flag indicates HW is capable of generating events in
156699a2dd95SBruce Richardson  * RTE_EVENT_OP_FORWARD enqueue operation. Cryptodev will send
156799a2dd95SBruce Richardson  * packets to the event device as forwarded event using an
156899a2dd95SBruce Richardson  * internal event port.
156999a2dd95SBruce Richardson  */
157099a2dd95SBruce Richardson 
157199a2dd95SBruce Richardson #define RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_QP_EV_BIND  0x4
157299a2dd95SBruce Richardson /**< Flag indicates HW is capable of mapping crypto queue pair to
157399a2dd95SBruce Richardson  * event queue.
157499a2dd95SBruce Richardson  */
157599a2dd95SBruce Richardson 
157699a2dd95SBruce Richardson #define RTE_EVENT_CRYPTO_ADAPTER_CAP_SESSION_PRIVATE_DATA   0x8
157799a2dd95SBruce Richardson /**< Flag indicates HW/SW supports a mechanism to store and retrieve
157899a2dd95SBruce Richardson  * the private data information along with the crypto session.
157999a2dd95SBruce Richardson  */
158099a2dd95SBruce Richardson 
1581c1749bc5SVolodymyr Fialko #define RTE_EVENT_CRYPTO_ADAPTER_CAP_EVENT_VECTOR   0x10
1582c1749bc5SVolodymyr Fialko /**< Flag indicates HW is capable of aggregating processed
1583c1749bc5SVolodymyr Fialko  * crypto operations into rte_event_vector.
1584c1749bc5SVolodymyr Fialko  */
1585c1749bc5SVolodymyr Fialko 
158699a2dd95SBruce Richardson /**
158799a2dd95SBruce Richardson  * Retrieve the event device's crypto adapter capabilities for the
158899a2dd95SBruce Richardson  * specified cryptodev device
158999a2dd95SBruce Richardson  *
159099a2dd95SBruce Richardson  * @param dev_id
159199a2dd95SBruce Richardson  *   The identifier of the device.
159299a2dd95SBruce Richardson  *
159399a2dd95SBruce Richardson  * @param cdev_id
159499a2dd95SBruce Richardson  *   The identifier of the cryptodev device.
159599a2dd95SBruce Richardson  *
159699a2dd95SBruce Richardson  * @param[out] caps
159799a2dd95SBruce Richardson  *   A pointer to memory filled with event adapter capabilities.
159899a2dd95SBruce Richardson  *   It is expected to be pre-allocated & initialized by caller.
159999a2dd95SBruce Richardson  *
160099a2dd95SBruce Richardson  * @return
160199a2dd95SBruce Richardson  *   - 0: Success, driver provides event adapter capabilities for the
160299a2dd95SBruce Richardson  *     cryptodev device.
160399a2dd95SBruce Richardson  *   - <0: Error code returned by the driver function.
160499a2dd95SBruce Richardson  */
160599a2dd95SBruce Richardson int
160699a2dd95SBruce Richardson rte_event_crypto_adapter_caps_get(uint8_t dev_id, uint8_t cdev_id,
160799a2dd95SBruce Richardson 				  uint32_t *caps);
160899a2dd95SBruce Richardson 
160966a30a29SAmit Prakash Shukla /* DMA adapter capability bitmap flag */
161066a30a29SAmit Prakash Shukla #define RTE_EVENT_DMA_ADAPTER_CAP_INTERNAL_PORT_OP_NEW 0x1
161166a30a29SAmit Prakash Shukla /**< Flag indicates HW is capable of generating events in
161266a30a29SAmit Prakash Shukla  * RTE_EVENT_OP_NEW enqueue operation. DMADEV will send
161366a30a29SAmit Prakash Shukla  * packets to the event device as new events using an
161466a30a29SAmit Prakash Shukla  * internal event port.
161566a30a29SAmit Prakash Shukla  */
161666a30a29SAmit Prakash Shukla 
161766a30a29SAmit Prakash Shukla #define RTE_EVENT_DMA_ADAPTER_CAP_INTERNAL_PORT_OP_FWD 0x2
161866a30a29SAmit Prakash Shukla /**< Flag indicates HW is capable of generating events in
161966a30a29SAmit Prakash Shukla  * RTE_EVENT_OP_FORWARD enqueue operation. DMADEV will send
162066a30a29SAmit Prakash Shukla  * packets to the event device as forwarded event using an
162166a30a29SAmit Prakash Shukla  * internal event port.
162266a30a29SAmit Prakash Shukla  */
162366a30a29SAmit Prakash Shukla 
162466a30a29SAmit Prakash Shukla #define RTE_EVENT_DMA_ADAPTER_CAP_INTERNAL_PORT_VCHAN_EV_BIND 0x4
162566a30a29SAmit Prakash Shukla /**< Flag indicates HW is capable of mapping DMA vchan to event queue. */
162666a30a29SAmit Prakash Shukla 
162766a30a29SAmit Prakash Shukla /**
162866a30a29SAmit Prakash Shukla  * Retrieve the event device's DMA adapter capabilities for the
162966a30a29SAmit Prakash Shukla  * specified dmadev device
163066a30a29SAmit Prakash Shukla  *
163166a30a29SAmit Prakash Shukla  * @param dev_id
163266a30a29SAmit Prakash Shukla  *   The identifier of the device.
163366a30a29SAmit Prakash Shukla  *
163466a30a29SAmit Prakash Shukla  * @param dmadev_id
163566a30a29SAmit Prakash Shukla  *   The identifier of the dmadev device.
163666a30a29SAmit Prakash Shukla  *
163766a30a29SAmit Prakash Shukla  * @param[out] caps
163866a30a29SAmit Prakash Shukla  *   A pointer to memory filled with event adapter capabilities.
163966a30a29SAmit Prakash Shukla  *   It is expected to be pre-allocated & initialized by caller.
164066a30a29SAmit Prakash Shukla  *
164166a30a29SAmit Prakash Shukla  * @return
164266a30a29SAmit Prakash Shukla  *   - 0: Success, driver provides event adapter capabilities for the
164366a30a29SAmit Prakash Shukla  *     dmadev device.
164466a30a29SAmit Prakash Shukla  *   - <0: Error code returned by the driver function.
164566a30a29SAmit Prakash Shukla  *
164666a30a29SAmit Prakash Shukla  */
164766a30a29SAmit Prakash Shukla __rte_experimental
164866a30a29SAmit Prakash Shukla int
164966a30a29SAmit Prakash Shukla rte_event_dma_adapter_caps_get(uint8_t dev_id, uint8_t dmadev_id, uint32_t *caps);
165066a30a29SAmit Prakash Shukla 
165199a2dd95SBruce Richardson /* Ethdev Tx adapter capability bitmap flags */
165299a2dd95SBruce Richardson #define RTE_EVENT_ETH_TX_ADAPTER_CAP_INTERNAL_PORT	0x1
165399a2dd95SBruce Richardson /**< This flag is sent when the PMD supports a packet transmit callback
165499a2dd95SBruce Richardson  */
165599a2dd95SBruce Richardson #define RTE_EVENT_ETH_TX_ADAPTER_CAP_EVENT_VECTOR	0x2
165699a2dd95SBruce Richardson /**< Indicates that the Tx adapter is capable of handling event vector of
165799a2dd95SBruce Richardson  * mbufs.
165899a2dd95SBruce Richardson  */
165999a2dd95SBruce Richardson 
166099a2dd95SBruce Richardson /**
166199a2dd95SBruce Richardson  * Retrieve the event device's eth Tx adapter capabilities
166299a2dd95SBruce Richardson  *
166399a2dd95SBruce Richardson  * @param dev_id
166499a2dd95SBruce Richardson  *   The identifier of the device.
166599a2dd95SBruce Richardson  *
166699a2dd95SBruce Richardson  * @param eth_port_id
166799a2dd95SBruce Richardson  *   The identifier of the ethernet device.
166899a2dd95SBruce Richardson  *
166999a2dd95SBruce Richardson  * @param[out] caps
167099a2dd95SBruce Richardson  *   A pointer to memory filled with eth Tx adapter capabilities.
167199a2dd95SBruce Richardson  *
167299a2dd95SBruce Richardson  * @return
167399a2dd95SBruce Richardson  *   - 0: Success, driver provides eth Tx adapter capabilities.
167499a2dd95SBruce Richardson  *   - <0: Error code returned by the driver function.
167599a2dd95SBruce Richardson  */
167699a2dd95SBruce Richardson int
167799a2dd95SBruce Richardson rte_event_eth_tx_adapter_caps_get(uint8_t dev_id, uint16_t eth_port_id,
167899a2dd95SBruce Richardson 				uint32_t *caps);
167999a2dd95SBruce Richardson 
168099a2dd95SBruce Richardson /**
168199a2dd95SBruce Richardson  * Converts nanoseconds to *timeout_ticks* value for rte_event_dequeue_burst()
168299a2dd95SBruce Richardson  *
168399a2dd95SBruce Richardson  * If the device is configured with RTE_EVENT_DEV_CFG_PER_DEQUEUE_TIMEOUT flag
168499a2dd95SBruce Richardson  * then application can use this function to convert timeout value in
168599a2dd95SBruce Richardson  * nanoseconds to implementations specific timeout value supplied in
168699a2dd95SBruce Richardson  * rte_event_dequeue_burst()
168799a2dd95SBruce Richardson  *
168899a2dd95SBruce Richardson  * @param dev_id
168999a2dd95SBruce Richardson  *   The identifier of the device.
169099a2dd95SBruce Richardson  * @param ns
169199a2dd95SBruce Richardson  *   Wait time in nanosecond
169299a2dd95SBruce Richardson  * @param[out] timeout_ticks
169399a2dd95SBruce Richardson  *   Value for the *timeout_ticks* parameter in rte_event_dequeue_burst()
169499a2dd95SBruce Richardson  *
169599a2dd95SBruce Richardson  * @return
169699a2dd95SBruce Richardson  *  - 0 on success.
169799a2dd95SBruce Richardson  *  - -ENOTSUP if the device doesn't support timeouts
169899a2dd95SBruce Richardson  *  - -EINVAL if *dev_id* is invalid or *timeout_ticks* is NULL
169999a2dd95SBruce Richardson  *  - other values < 0 on failure.
170099a2dd95SBruce Richardson  *
170199a2dd95SBruce Richardson  * @see rte_event_dequeue_burst(), RTE_EVENT_DEV_CFG_PER_DEQUEUE_TIMEOUT
170299a2dd95SBruce Richardson  * @see rte_event_dev_configure()
170399a2dd95SBruce Richardson  */
170499a2dd95SBruce Richardson int
170599a2dd95SBruce Richardson rte_event_dequeue_timeout_ticks(uint8_t dev_id, uint64_t ns,
170699a2dd95SBruce Richardson 					uint64_t *timeout_ticks);
170799a2dd95SBruce Richardson 
170899a2dd95SBruce Richardson /**
170999a2dd95SBruce Richardson  * Link multiple source event queues supplied in *queues* to the destination
171099a2dd95SBruce Richardson  * event port designated by its *port_id* with associated service priority
171199a2dd95SBruce Richardson  * supplied in *priorities* on the event device designated by its *dev_id*.
171299a2dd95SBruce Richardson  *
171399a2dd95SBruce Richardson  * The link establishment shall enable the event port *port_id* from
171499a2dd95SBruce Richardson  * receiving events from the specified event queue(s) supplied in *queues*
171599a2dd95SBruce Richardson  *
171699a2dd95SBruce Richardson  * An event queue may link to one or more event ports.
171799a2dd95SBruce Richardson  * The number of links can be established from an event queue to event port is
171899a2dd95SBruce Richardson  * implementation defined.
171999a2dd95SBruce Richardson  *
172099a2dd95SBruce Richardson  * Event queue(s) to event port link establishment can be changed at runtime
172199a2dd95SBruce Richardson  * without re-configuring the device to support scaling and to reduce the
172299a2dd95SBruce Richardson  * latency of critical work by establishing the link with more event ports
172399a2dd95SBruce Richardson  * at runtime.
172499a2dd95SBruce Richardson  *
1725d007a7f3SPavan Nikhilesh  * When the value of ``rte_event_dev_info::max_profiles_per_port`` is greater
1726d007a7f3SPavan Nikhilesh  * than or equal to one, this function links the event queues to the default
1727d007a7f3SPavan Nikhilesh  * profile_id i.e. profile_id 0 of the event port.
1728d007a7f3SPavan Nikhilesh  *
172999a2dd95SBruce Richardson  * @param dev_id
173099a2dd95SBruce Richardson  *   The identifier of the device.
173199a2dd95SBruce Richardson  *
173299a2dd95SBruce Richardson  * @param port_id
173399a2dd95SBruce Richardson  *   Event port identifier to select the destination port to link.
173499a2dd95SBruce Richardson  *
173599a2dd95SBruce Richardson  * @param queues
173699a2dd95SBruce Richardson  *   Points to an array of *nb_links* event queues to be linked
173799a2dd95SBruce Richardson  *   to the event port.
173899a2dd95SBruce Richardson  *   NULL value is allowed, in which case this function links all the configured
173999a2dd95SBruce Richardson  *   event queues *nb_event_queues* which previously supplied to
174099a2dd95SBruce Richardson  *   rte_event_dev_configure() to the event port *port_id*
174199a2dd95SBruce Richardson  *
174299a2dd95SBruce Richardson  * @param priorities
174399a2dd95SBruce Richardson  *   Points to an array of *nb_links* service priorities associated with each
174499a2dd95SBruce Richardson  *   event queue link to event port.
174599a2dd95SBruce Richardson  *   The priority defines the event port's servicing priority for
174699a2dd95SBruce Richardson  *   event queue, which may be ignored by an implementation.
174799a2dd95SBruce Richardson  *   The requested priority should in the range of
174899a2dd95SBruce Richardson  *   [RTE_EVENT_DEV_PRIORITY_HIGHEST, RTE_EVENT_DEV_PRIORITY_LOWEST].
174999a2dd95SBruce Richardson  *   The implementation shall normalize the requested priority to
175099a2dd95SBruce Richardson  *   implementation supported priority value.
175199a2dd95SBruce Richardson  *   NULL value is allowed, in which case this function links the event queues
175299a2dd95SBruce Richardson  *   with RTE_EVENT_DEV_PRIORITY_NORMAL servicing priority
175399a2dd95SBruce Richardson  *
175499a2dd95SBruce Richardson  * @param nb_links
175599a2dd95SBruce Richardson  *   The number of links to establish. This parameter is ignored if queues is
175699a2dd95SBruce Richardson  *   NULL.
175799a2dd95SBruce Richardson  *
175899a2dd95SBruce Richardson  * @return
175999a2dd95SBruce Richardson  * The number of links actually established. The return value can be less than
176099a2dd95SBruce Richardson  * the value of the *nb_links* parameter when the implementation has the
176199a2dd95SBruce Richardson  * limitation on specific queue to port link establishment or if invalid
176299a2dd95SBruce Richardson  * parameters are specified in *queues*
176399a2dd95SBruce Richardson  * If the return value is less than *nb_links*, the remaining links at the end
176499a2dd95SBruce Richardson  * of link[] are not established, and the caller has to take care of them.
176599a2dd95SBruce Richardson  * If return value is less than *nb_links* then implementation shall update the
176699a2dd95SBruce Richardson  * rte_errno accordingly, Possible rte_errno values are
176799a2dd95SBruce Richardson  * (EDQUOT) Quota exceeded(Application tried to link the queue configured with
176899a2dd95SBruce Richardson  *  RTE_EVENT_QUEUE_CFG_SINGLE_LINK to more than one event ports)
176999a2dd95SBruce Richardson  * (EINVAL) Invalid parameter
177099a2dd95SBruce Richardson  */
177199a2dd95SBruce Richardson int
177299a2dd95SBruce Richardson rte_event_port_link(uint8_t dev_id, uint8_t port_id,
177399a2dd95SBruce Richardson 		    const uint8_t queues[], const uint8_t priorities[],
177499a2dd95SBruce Richardson 		    uint16_t nb_links);
177599a2dd95SBruce Richardson 
177699a2dd95SBruce Richardson /**
177799a2dd95SBruce Richardson  * Unlink multiple source event queues supplied in *queues* from the destination
177899a2dd95SBruce Richardson  * event port designated by its *port_id* on the event device designated
177999a2dd95SBruce Richardson  * by its *dev_id*.
178099a2dd95SBruce Richardson  *
178199a2dd95SBruce Richardson  * The unlink call issues an async request to disable the event port *port_id*
178299a2dd95SBruce Richardson  * from receiving events from the specified event queue *queue_id*.
178399a2dd95SBruce Richardson  * Event queue(s) to event port unlink establishment can be changed at runtime
178499a2dd95SBruce Richardson  * without re-configuring the device.
178599a2dd95SBruce Richardson  *
1786d007a7f3SPavan Nikhilesh  * When the value of ``rte_event_dev_info::max_profiles_per_port`` is greater
1787d007a7f3SPavan Nikhilesh  * than or equal to one, this function unlinks the event queues from the default
1788d007a7f3SPavan Nikhilesh  * profile identifier i.e. profile 0 of the event port.
1789d007a7f3SPavan Nikhilesh  *
179099a2dd95SBruce Richardson  * @see rte_event_port_unlinks_in_progress() to poll for completed unlinks.
179199a2dd95SBruce Richardson  *
179299a2dd95SBruce Richardson  * @param dev_id
179399a2dd95SBruce Richardson  *   The identifier of the device.
179499a2dd95SBruce Richardson  *
179599a2dd95SBruce Richardson  * @param port_id
179699a2dd95SBruce Richardson  *   Event port identifier to select the destination port to unlink.
179799a2dd95SBruce Richardson  *
179899a2dd95SBruce Richardson  * @param queues
179999a2dd95SBruce Richardson  *   Points to an array of *nb_unlinks* event queues to be unlinked
180099a2dd95SBruce Richardson  *   from the event port.
180199a2dd95SBruce Richardson  *   NULL value is allowed, in which case this function unlinks all the
180299a2dd95SBruce Richardson  *   event queue(s) from the event port *port_id*.
180399a2dd95SBruce Richardson  *
180499a2dd95SBruce Richardson  * @param nb_unlinks
180599a2dd95SBruce Richardson  *   The number of unlinks to establish. This parameter is ignored if queues is
180699a2dd95SBruce Richardson  *   NULL.
180799a2dd95SBruce Richardson  *
180899a2dd95SBruce Richardson  * @return
180999a2dd95SBruce Richardson  * The number of unlinks successfully requested. The return value can be less
181099a2dd95SBruce Richardson  * than the value of the *nb_unlinks* parameter when the implementation has the
181199a2dd95SBruce Richardson  * limitation on specific queue to port unlink establishment or
181299a2dd95SBruce Richardson  * if invalid parameters are specified.
181399a2dd95SBruce Richardson  * If the return value is less than *nb_unlinks*, the remaining queues at the
181499a2dd95SBruce Richardson  * end of queues[] are not unlinked, and the caller has to take care of them.
181599a2dd95SBruce Richardson  * If return value is less than *nb_unlinks* then implementation shall update
181699a2dd95SBruce Richardson  * the rte_errno accordingly, Possible rte_errno values are
181799a2dd95SBruce Richardson  * (EINVAL) Invalid parameter
181899a2dd95SBruce Richardson  */
181999a2dd95SBruce Richardson int
182099a2dd95SBruce Richardson rte_event_port_unlink(uint8_t dev_id, uint8_t port_id,
182199a2dd95SBruce Richardson 		      uint8_t queues[], uint16_t nb_unlinks);
182299a2dd95SBruce Richardson 
182399a2dd95SBruce Richardson /**
1824d007a7f3SPavan Nikhilesh  * Link multiple source event queues supplied in *queues* to the destination
1825d007a7f3SPavan Nikhilesh  * event port designated by its *port_id* with associated profile identifier
1826d007a7f3SPavan Nikhilesh  * supplied in *profile_id* with service priorities supplied in *priorities*
1827d007a7f3SPavan Nikhilesh  * on the event device designated by its *dev_id*.
1828d007a7f3SPavan Nikhilesh  *
1829d007a7f3SPavan Nikhilesh  * If *profile_id* is set to 0 then, the links created by the call `rte_event_port_link`
1830d007a7f3SPavan Nikhilesh  * will be overwritten.
1831d007a7f3SPavan Nikhilesh  *
1832d007a7f3SPavan Nikhilesh  * Event ports by default use profile_id 0 unless it is changed using the
1833d007a7f3SPavan Nikhilesh  * call ``rte_event_port_profile_switch()``.
1834d007a7f3SPavan Nikhilesh  *
1835d007a7f3SPavan Nikhilesh  * The link establishment shall enable the event port *port_id* from
1836d007a7f3SPavan Nikhilesh  * receiving events from the specified event queue(s) supplied in *queues*
1837d007a7f3SPavan Nikhilesh  *
1838d007a7f3SPavan Nikhilesh  * An event queue may link to one or more event ports.
1839d007a7f3SPavan Nikhilesh  * The number of links can be established from an event queue to event port is
1840d007a7f3SPavan Nikhilesh  * implementation defined.
1841d007a7f3SPavan Nikhilesh  *
1842d007a7f3SPavan Nikhilesh  * Event queue(s) to event port link establishment can be changed at runtime
1843d007a7f3SPavan Nikhilesh  * without re-configuring the device to support scaling and to reduce the
1844d007a7f3SPavan Nikhilesh  * latency of critical work by establishing the link with more event ports
1845d007a7f3SPavan Nikhilesh  * at runtime.
1846d007a7f3SPavan Nikhilesh  *
1847d007a7f3SPavan Nikhilesh  * @param dev_id
1848d007a7f3SPavan Nikhilesh  *   The identifier of the device.
1849d007a7f3SPavan Nikhilesh  *
1850d007a7f3SPavan Nikhilesh  * @param port_id
1851d007a7f3SPavan Nikhilesh  *   Event port identifier to select the destination port to link.
1852d007a7f3SPavan Nikhilesh  *
1853d007a7f3SPavan Nikhilesh  * @param queues
1854d007a7f3SPavan Nikhilesh  *   Points to an array of *nb_links* event queues to be linked
1855d007a7f3SPavan Nikhilesh  *   to the event port.
1856d007a7f3SPavan Nikhilesh  *   NULL value is allowed, in which case this function links all the configured
1857d007a7f3SPavan Nikhilesh  *   event queues *nb_event_queues* which previously supplied to
1858d007a7f3SPavan Nikhilesh  *   rte_event_dev_configure() to the event port *port_id*
1859d007a7f3SPavan Nikhilesh  *
1860d007a7f3SPavan Nikhilesh  * @param priorities
1861d007a7f3SPavan Nikhilesh  *   Points to an array of *nb_links* service priorities associated with each
1862d007a7f3SPavan Nikhilesh  *   event queue link to event port.
1863d007a7f3SPavan Nikhilesh  *   The priority defines the event port's servicing priority for
1864d007a7f3SPavan Nikhilesh  *   event queue, which may be ignored by an implementation.
1865d007a7f3SPavan Nikhilesh  *   The requested priority should in the range of
1866d007a7f3SPavan Nikhilesh  *   [RTE_EVENT_DEV_PRIORITY_HIGHEST, RTE_EVENT_DEV_PRIORITY_LOWEST].
1867d007a7f3SPavan Nikhilesh  *   The implementation shall normalize the requested priority to
1868d007a7f3SPavan Nikhilesh  *   implementation supported priority value.
1869d007a7f3SPavan Nikhilesh  *   NULL value is allowed, in which case this function links the event queues
1870d007a7f3SPavan Nikhilesh  *   with RTE_EVENT_DEV_PRIORITY_NORMAL servicing priority
1871d007a7f3SPavan Nikhilesh  *
1872d007a7f3SPavan Nikhilesh  * @param nb_links
1873d007a7f3SPavan Nikhilesh  *   The number of links to establish. This parameter is ignored if queues is
1874d007a7f3SPavan Nikhilesh  *   NULL.
1875d007a7f3SPavan Nikhilesh  *
1876d007a7f3SPavan Nikhilesh  * @param profile_id
1877d007a7f3SPavan Nikhilesh  *   The profile identifier associated with the links between event queues and
1878d007a7f3SPavan Nikhilesh  *   event port. Should be less than the max capability reported by
1879d007a7f3SPavan Nikhilesh  *   ``rte_event_dev_info::max_profiles_per_port``
1880d007a7f3SPavan Nikhilesh  *
1881d007a7f3SPavan Nikhilesh  * @return
1882d007a7f3SPavan Nikhilesh  * The number of links actually established. The return value can be less than
1883d007a7f3SPavan Nikhilesh  * the value of the *nb_links* parameter when the implementation has the
1884d007a7f3SPavan Nikhilesh  * limitation on specific queue to port link establishment or if invalid
1885d007a7f3SPavan Nikhilesh  * parameters are specified in *queues*
1886d007a7f3SPavan Nikhilesh  * If the return value is less than *nb_links*, the remaining links at the end
1887d007a7f3SPavan Nikhilesh  * of link[] are not established, and the caller has to take care of them.
1888d007a7f3SPavan Nikhilesh  * If return value is less than *nb_links* then implementation shall update the
1889d007a7f3SPavan Nikhilesh  * rte_errno accordingly, Possible rte_errno values are
1890d007a7f3SPavan Nikhilesh  * (EDQUOT) Quota exceeded(Application tried to link the queue configured with
1891d007a7f3SPavan Nikhilesh  *  RTE_EVENT_QUEUE_CFG_SINGLE_LINK to more than one event ports)
1892d007a7f3SPavan Nikhilesh  * (EINVAL) Invalid parameter
1893d007a7f3SPavan Nikhilesh  *
1894d007a7f3SPavan Nikhilesh  */
1895d007a7f3SPavan Nikhilesh __rte_experimental
1896d007a7f3SPavan Nikhilesh int
1897d007a7f3SPavan Nikhilesh rte_event_port_profile_links_set(uint8_t dev_id, uint8_t port_id, const uint8_t queues[],
1898d007a7f3SPavan Nikhilesh 				 const uint8_t priorities[], uint16_t nb_links, uint8_t profile_id);
1899d007a7f3SPavan Nikhilesh 
1900d007a7f3SPavan Nikhilesh /**
1901d007a7f3SPavan Nikhilesh  * Unlink multiple source event queues supplied in *queues* that belong to profile
1902d007a7f3SPavan Nikhilesh  * designated by *profile_id* from the destination event port designated by its
1903d007a7f3SPavan Nikhilesh  * *port_id* on the event device designated by its *dev_id*.
1904d007a7f3SPavan Nikhilesh  *
1905d007a7f3SPavan Nikhilesh  * If *profile_id* is set to 0 i.e., the default profile then, then this function
1906d007a7f3SPavan Nikhilesh  * will act as ``rte_event_port_unlink``.
1907d007a7f3SPavan Nikhilesh  *
1908d007a7f3SPavan Nikhilesh  * The unlink call issues an async request to disable the event port *port_id*
1909d007a7f3SPavan Nikhilesh  * from receiving events from the specified event queue *queue_id*.
1910d007a7f3SPavan Nikhilesh  * Event queue(s) to event port unlink establishment can be changed at runtime
1911d007a7f3SPavan Nikhilesh  * without re-configuring the device.
1912d007a7f3SPavan Nikhilesh  *
1913d007a7f3SPavan Nikhilesh  * @see rte_event_port_unlinks_in_progress() to poll for completed unlinks.
1914d007a7f3SPavan Nikhilesh  *
1915d007a7f3SPavan Nikhilesh  * @param dev_id
1916d007a7f3SPavan Nikhilesh  *   The identifier of the device.
1917d007a7f3SPavan Nikhilesh  *
1918d007a7f3SPavan Nikhilesh  * @param port_id
1919d007a7f3SPavan Nikhilesh  *   Event port identifier to select the destination port to unlink.
1920d007a7f3SPavan Nikhilesh  *
1921d007a7f3SPavan Nikhilesh  * @param queues
1922d007a7f3SPavan Nikhilesh  *   Points to an array of *nb_unlinks* event queues to be unlinked
1923d007a7f3SPavan Nikhilesh  *   from the event port.
1924d007a7f3SPavan Nikhilesh  *   NULL value is allowed, in which case this function unlinks all the
1925d007a7f3SPavan Nikhilesh  *   event queue(s) from the event port *port_id*.
1926d007a7f3SPavan Nikhilesh  *
1927d007a7f3SPavan Nikhilesh  * @param nb_unlinks
1928d007a7f3SPavan Nikhilesh  *   The number of unlinks to establish. This parameter is ignored if queues is
1929d007a7f3SPavan Nikhilesh  *   NULL.
1930d007a7f3SPavan Nikhilesh  *
1931d007a7f3SPavan Nikhilesh  * @param profile_id
1932d007a7f3SPavan Nikhilesh  *   The profile identifier associated with the links between event queues and
1933d007a7f3SPavan Nikhilesh  *   event port. Should be less than the max capability reported by
1934d007a7f3SPavan Nikhilesh  *   ``rte_event_dev_info::max_profiles_per_port``
1935d007a7f3SPavan Nikhilesh  *
1936d007a7f3SPavan Nikhilesh  * @return
1937d007a7f3SPavan Nikhilesh  * The number of unlinks successfully requested. The return value can be less
1938d007a7f3SPavan Nikhilesh  * than the value of the *nb_unlinks* parameter when the implementation has the
1939d007a7f3SPavan Nikhilesh  * limitation on specific queue to port unlink establishment or
1940d007a7f3SPavan Nikhilesh  * if invalid parameters are specified.
1941d007a7f3SPavan Nikhilesh  * If the return value is less than *nb_unlinks*, the remaining queues at the
1942d007a7f3SPavan Nikhilesh  * end of queues[] are not unlinked, and the caller has to take care of them.
1943d007a7f3SPavan Nikhilesh  * If return value is less than *nb_unlinks* then implementation shall update
1944d007a7f3SPavan Nikhilesh  * the rte_errno accordingly, Possible rte_errno values are
1945d007a7f3SPavan Nikhilesh  * (EINVAL) Invalid parameter
1946d007a7f3SPavan Nikhilesh  *
1947d007a7f3SPavan Nikhilesh  */
1948d007a7f3SPavan Nikhilesh __rte_experimental
1949d007a7f3SPavan Nikhilesh int
1950d007a7f3SPavan Nikhilesh rte_event_port_profile_unlink(uint8_t dev_id, uint8_t port_id, uint8_t queues[],
1951d007a7f3SPavan Nikhilesh 			      uint16_t nb_unlinks, uint8_t profile_id);
1952d007a7f3SPavan Nikhilesh 
1953d007a7f3SPavan Nikhilesh /**
195499a2dd95SBruce Richardson  * Returns the number of unlinks in progress.
195599a2dd95SBruce Richardson  *
195699a2dd95SBruce Richardson  * This function provides the application with a method to detect when an
195799a2dd95SBruce Richardson  * unlink has been completed by the implementation.
195899a2dd95SBruce Richardson  *
195999a2dd95SBruce Richardson  * @see rte_event_port_unlink() to issue unlink requests.
196099a2dd95SBruce Richardson  *
196199a2dd95SBruce Richardson  * @param dev_id
196299a2dd95SBruce Richardson  *   The identifier of the device.
196399a2dd95SBruce Richardson  *
196499a2dd95SBruce Richardson  * @param port_id
196599a2dd95SBruce Richardson  *   Event port identifier to select port to check for unlinks in progress.
196699a2dd95SBruce Richardson  *
196799a2dd95SBruce Richardson  * @return
196899a2dd95SBruce Richardson  * The number of unlinks that are in progress. A return of zero indicates that
196999a2dd95SBruce Richardson  * there are no outstanding unlink requests. A positive return value indicates
197099a2dd95SBruce Richardson  * the number of unlinks that are in progress, but are not yet complete.
197199a2dd95SBruce Richardson  * A negative return value indicates an error, -EINVAL indicates an invalid
197299a2dd95SBruce Richardson  * parameter passed for *dev_id* or *port_id*.
197399a2dd95SBruce Richardson  */
197499a2dd95SBruce Richardson int
197599a2dd95SBruce Richardson rte_event_port_unlinks_in_progress(uint8_t dev_id, uint8_t port_id);
197699a2dd95SBruce Richardson 
197799a2dd95SBruce Richardson /**
197899a2dd95SBruce Richardson  * Retrieve the list of source event queues and its associated service priority
197999a2dd95SBruce Richardson  * linked to the destination event port designated by its *port_id*
198099a2dd95SBruce Richardson  * on the event device designated by its *dev_id*.
198199a2dd95SBruce Richardson  *
198299a2dd95SBruce Richardson  * @param dev_id
198399a2dd95SBruce Richardson  *   The identifier of the device.
198499a2dd95SBruce Richardson  *
198599a2dd95SBruce Richardson  * @param port_id
198699a2dd95SBruce Richardson  *   Event port identifier.
198799a2dd95SBruce Richardson  *
198899a2dd95SBruce Richardson  * @param[out] queues
198999a2dd95SBruce Richardson  *   Points to an array of *queues* for output.
199099a2dd95SBruce Richardson  *   The caller has to allocate *RTE_EVENT_MAX_QUEUES_PER_DEV* bytes to
199199a2dd95SBruce Richardson  *   store the event queue(s) linked with event port *port_id*
199299a2dd95SBruce Richardson  *
199399a2dd95SBruce Richardson  * @param[out] priorities
199499a2dd95SBruce Richardson  *   Points to an array of *priorities* for output.
199599a2dd95SBruce Richardson  *   The caller has to allocate *RTE_EVENT_MAX_QUEUES_PER_DEV* bytes to
199699a2dd95SBruce Richardson  *   store the service priority associated with each event queue linked
199799a2dd95SBruce Richardson  *
199899a2dd95SBruce Richardson  * @return
199999a2dd95SBruce Richardson  * The number of links established on the event port designated by its
200099a2dd95SBruce Richardson  *  *port_id*.
200199a2dd95SBruce Richardson  * - <0 on failure.
200299a2dd95SBruce Richardson  */
200399a2dd95SBruce Richardson int
200499a2dd95SBruce Richardson rte_event_port_links_get(uint8_t dev_id, uint8_t port_id,
200599a2dd95SBruce Richardson 			 uint8_t queues[], uint8_t priorities[]);
200699a2dd95SBruce Richardson 
200799a2dd95SBruce Richardson /**
2008d007a7f3SPavan Nikhilesh  * Retrieve the list of source event queues and its service priority
2009d007a7f3SPavan Nikhilesh  * associated to a *profile_id* and linked to the destination event port
2010d007a7f3SPavan Nikhilesh  * designated by its *port_id* on the event device designated by its *dev_id*.
2011d007a7f3SPavan Nikhilesh  *
2012d007a7f3SPavan Nikhilesh  * @param dev_id
2013d007a7f3SPavan Nikhilesh  *   The identifier of the device.
2014d007a7f3SPavan Nikhilesh  *
2015d007a7f3SPavan Nikhilesh  * @param port_id
2016d007a7f3SPavan Nikhilesh  *   Event port identifier.
2017d007a7f3SPavan Nikhilesh  *
2018d007a7f3SPavan Nikhilesh  * @param[out] queues
2019d007a7f3SPavan Nikhilesh  *   Points to an array of *queues* for output.
2020d007a7f3SPavan Nikhilesh  *   The caller has to allocate *RTE_EVENT_MAX_QUEUES_PER_DEV* bytes to
2021d007a7f3SPavan Nikhilesh  *   store the event queue(s) linked with event port *port_id*
2022d007a7f3SPavan Nikhilesh  *
2023d007a7f3SPavan Nikhilesh  * @param[out] priorities
2024d007a7f3SPavan Nikhilesh  *   Points to an array of *priorities* for output.
2025d007a7f3SPavan Nikhilesh  *   The caller has to allocate *RTE_EVENT_MAX_QUEUES_PER_DEV* bytes to
2026d007a7f3SPavan Nikhilesh  *   store the service priority associated with each event queue linked
2027d007a7f3SPavan Nikhilesh  *
2028d007a7f3SPavan Nikhilesh  * @param profile_id
2029d007a7f3SPavan Nikhilesh  *   The profile identifier associated with the links between event queues and
2030d007a7f3SPavan Nikhilesh  *   event port. Should be less than the max capability reported by
2031d007a7f3SPavan Nikhilesh  *   ``rte_event_dev_info::max_profiles_per_port``
2032d007a7f3SPavan Nikhilesh  *
2033d007a7f3SPavan Nikhilesh  * @return
2034d007a7f3SPavan Nikhilesh  * The number of links established on the event port designated by its
2035d007a7f3SPavan Nikhilesh  *  *port_id*.
2036d007a7f3SPavan Nikhilesh  * - <0 on failure.
2037d007a7f3SPavan Nikhilesh  */
2038d007a7f3SPavan Nikhilesh __rte_experimental
2039d007a7f3SPavan Nikhilesh int
2040d007a7f3SPavan Nikhilesh rte_event_port_profile_links_get(uint8_t dev_id, uint8_t port_id, uint8_t queues[],
2041d007a7f3SPavan Nikhilesh 				 uint8_t priorities[], uint8_t profile_id);
2042d007a7f3SPavan Nikhilesh 
2043d007a7f3SPavan Nikhilesh /**
204499a2dd95SBruce Richardson  * Retrieve the service ID of the event dev. If the adapter doesn't use
204599a2dd95SBruce Richardson  * a rte_service function, this function returns -ESRCH.
204699a2dd95SBruce Richardson  *
204799a2dd95SBruce Richardson  * @param dev_id
204899a2dd95SBruce Richardson  *   The identifier of the device.
204999a2dd95SBruce Richardson  *
205099a2dd95SBruce Richardson  * @param [out] service_id
205199a2dd95SBruce Richardson  *   A pointer to a uint32_t, to be filled in with the service id.
205299a2dd95SBruce Richardson  *
205399a2dd95SBruce Richardson  * @return
205499a2dd95SBruce Richardson  *   - 0: Success
205599a2dd95SBruce Richardson  *   - <0: Error code on failure, if the event dev doesn't use a rte_service
205699a2dd95SBruce Richardson  *   function, this function returns -ESRCH.
205799a2dd95SBruce Richardson  */
205899a2dd95SBruce Richardson int
205999a2dd95SBruce Richardson rte_event_dev_service_id_get(uint8_t dev_id, uint32_t *service_id);
206099a2dd95SBruce Richardson 
206199a2dd95SBruce Richardson /**
206299a2dd95SBruce Richardson  * Dump internal information about *dev_id* to the FILE* provided in *f*.
206399a2dd95SBruce Richardson  *
206499a2dd95SBruce Richardson  * @param dev_id
206599a2dd95SBruce Richardson  *   The identifier of the device.
206699a2dd95SBruce Richardson  *
206799a2dd95SBruce Richardson  * @param f
206899a2dd95SBruce Richardson  *   A pointer to a file for output
206999a2dd95SBruce Richardson  *
207099a2dd95SBruce Richardson  * @return
207199a2dd95SBruce Richardson  *   - 0: on success
207299a2dd95SBruce Richardson  *   - <0: on failure.
207399a2dd95SBruce Richardson  */
207499a2dd95SBruce Richardson int
207599a2dd95SBruce Richardson rte_event_dev_dump(uint8_t dev_id, FILE *f);
207699a2dd95SBruce Richardson 
207799a2dd95SBruce Richardson /** Maximum name length for extended statistics counters */
207899a2dd95SBruce Richardson #define RTE_EVENT_DEV_XSTATS_NAME_SIZE 64
207999a2dd95SBruce Richardson 
208099a2dd95SBruce Richardson /**
208199a2dd95SBruce Richardson  * Selects the component of the eventdev to retrieve statistics from.
208299a2dd95SBruce Richardson  */
208399a2dd95SBruce Richardson enum rte_event_dev_xstats_mode {
208499a2dd95SBruce Richardson 	RTE_EVENT_DEV_XSTATS_DEVICE,
208599a2dd95SBruce Richardson 	RTE_EVENT_DEV_XSTATS_PORT,
208699a2dd95SBruce Richardson 	RTE_EVENT_DEV_XSTATS_QUEUE,
208799a2dd95SBruce Richardson };
208899a2dd95SBruce Richardson 
208999a2dd95SBruce Richardson /**
209099a2dd95SBruce Richardson  * A name-key lookup element for extended statistics.
209199a2dd95SBruce Richardson  *
209299a2dd95SBruce Richardson  * This structure is used to map between names and ID numbers
209399a2dd95SBruce Richardson  * for extended ethdev statistics.
209499a2dd95SBruce Richardson  */
209599a2dd95SBruce Richardson struct rte_event_dev_xstats_name {
209699a2dd95SBruce Richardson 	char name[RTE_EVENT_DEV_XSTATS_NAME_SIZE];
209799a2dd95SBruce Richardson };
209899a2dd95SBruce Richardson 
209999a2dd95SBruce Richardson /**
210099a2dd95SBruce Richardson  * Retrieve names of extended statistics of an event device.
210199a2dd95SBruce Richardson  *
210299a2dd95SBruce Richardson  * @param dev_id
210399a2dd95SBruce Richardson  *   The identifier of the event device.
210499a2dd95SBruce Richardson  * @param mode
210599a2dd95SBruce Richardson  *   The mode of statistics to retrieve. Choices include the device statistics,
210699a2dd95SBruce Richardson  *   port statistics or queue statistics.
210799a2dd95SBruce Richardson  * @param queue_port_id
210899a2dd95SBruce Richardson  *   Used to specify the port or queue number in queue or port mode, and is
210999a2dd95SBruce Richardson  *   ignored in device mode.
211099a2dd95SBruce Richardson  * @param[out] xstats_names
211199a2dd95SBruce Richardson  *   Block of memory to insert names into. Must be at least size in capacity.
211299a2dd95SBruce Richardson  *   If set to NULL, function returns required capacity.
211399a2dd95SBruce Richardson  * @param[out] ids
211499a2dd95SBruce Richardson  *   Block of memory to insert ids into. Must be at least size in capacity.
211599a2dd95SBruce Richardson  *   If set to NULL, function returns required capacity. The id values returned
211699a2dd95SBruce Richardson  *   can be passed to *rte_event_dev_xstats_get* to select statistics.
211799a2dd95SBruce Richardson  * @param size
211899a2dd95SBruce Richardson  *   Capacity of xstats_names (number of names).
211999a2dd95SBruce Richardson  * @return
212099a2dd95SBruce Richardson  *   - positive value lower or equal to size: success. The return value
212199a2dd95SBruce Richardson  *     is the number of entries filled in the stats table.
212299a2dd95SBruce Richardson  *   - positive value higher than size: error, the given statistics table
212399a2dd95SBruce Richardson  *     is too small. The return value corresponds to the size that should
212499a2dd95SBruce Richardson  *     be given to succeed. The entries in the table are not valid and
212599a2dd95SBruce Richardson  *     shall not be used by the caller.
212699a2dd95SBruce Richardson  *   - negative value on error:
212799a2dd95SBruce Richardson  *        -ENODEV for invalid *dev_id*
212899a2dd95SBruce Richardson  *        -EINVAL for invalid mode, queue port or id parameters
212999a2dd95SBruce Richardson  *        -ENOTSUP if the device doesn't support this function.
213099a2dd95SBruce Richardson  */
213199a2dd95SBruce Richardson int
213299a2dd95SBruce Richardson rte_event_dev_xstats_names_get(uint8_t dev_id,
213399a2dd95SBruce Richardson 			       enum rte_event_dev_xstats_mode mode,
213499a2dd95SBruce Richardson 			       uint8_t queue_port_id,
213599a2dd95SBruce Richardson 			       struct rte_event_dev_xstats_name *xstats_names,
21361bdfe4d7SPavan Nikhilesh 			       uint64_t *ids,
213799a2dd95SBruce Richardson 			       unsigned int size);
213899a2dd95SBruce Richardson 
213999a2dd95SBruce Richardson /**
214099a2dd95SBruce Richardson  * Retrieve extended statistics of an event device.
214199a2dd95SBruce Richardson  *
214299a2dd95SBruce Richardson  * @param dev_id
214399a2dd95SBruce Richardson  *   The identifier of the device.
214499a2dd95SBruce Richardson  * @param mode
214599a2dd95SBruce Richardson  *  The mode of statistics to retrieve. Choices include the device statistics,
214699a2dd95SBruce Richardson  *  port statistics or queue statistics.
214799a2dd95SBruce Richardson  * @param queue_port_id
214899a2dd95SBruce Richardson  *   Used to specify the port or queue number in queue or port mode, and is
214999a2dd95SBruce Richardson  *   ignored in device mode.
215099a2dd95SBruce Richardson  * @param ids
215199a2dd95SBruce Richardson  *   The id numbers of the stats to get. The ids can be got from the stat
215299a2dd95SBruce Richardson  *   position in the stat list from rte_event_dev_get_xstats_names(), or
215399a2dd95SBruce Richardson  *   by using rte_event_dev_xstats_by_name_get().
215499a2dd95SBruce Richardson  * @param[out] values
215599a2dd95SBruce Richardson  *   The values for each stats request by ID.
215699a2dd95SBruce Richardson  * @param n
215799a2dd95SBruce Richardson  *   The number of stats requested
215899a2dd95SBruce Richardson  * @return
215999a2dd95SBruce Richardson  *   - positive value: number of stat entries filled into the values array
216099a2dd95SBruce Richardson  *   - negative value on error:
216199a2dd95SBruce Richardson  *        -ENODEV for invalid *dev_id*
216299a2dd95SBruce Richardson  *        -EINVAL for invalid mode, queue port or id parameters
216399a2dd95SBruce Richardson  *        -ENOTSUP if the device doesn't support this function.
216499a2dd95SBruce Richardson  */
216599a2dd95SBruce Richardson int
216699a2dd95SBruce Richardson rte_event_dev_xstats_get(uint8_t dev_id,
216799a2dd95SBruce Richardson 			 enum rte_event_dev_xstats_mode mode,
216899a2dd95SBruce Richardson 			 uint8_t queue_port_id,
21691bdfe4d7SPavan Nikhilesh 			 const uint64_t ids[],
217099a2dd95SBruce Richardson 			 uint64_t values[], unsigned int n);
217199a2dd95SBruce Richardson 
217299a2dd95SBruce Richardson /**
217399a2dd95SBruce Richardson  * Retrieve the value of a single stat by requesting it by name.
217499a2dd95SBruce Richardson  *
217599a2dd95SBruce Richardson  * @param dev_id
217699a2dd95SBruce Richardson  *   The identifier of the device
217799a2dd95SBruce Richardson  * @param name
217899a2dd95SBruce Richardson  *   The stat name to retrieve
217999a2dd95SBruce Richardson  * @param[out] id
218099a2dd95SBruce Richardson  *   If non-NULL, the numerical id of the stat will be returned, so that further
218199a2dd95SBruce Richardson  *   requests for the stat can be got using rte_event_dev_xstats_get, which will
218299a2dd95SBruce Richardson  *   be faster as it doesn't need to scan a list of names for the stat.
218399a2dd95SBruce Richardson  *   If the stat cannot be found, the id returned will be (unsigned)-1.
218499a2dd95SBruce Richardson  * @return
218599a2dd95SBruce Richardson  *   - positive value or zero: the stat value
218699a2dd95SBruce Richardson  *   - negative value: -EINVAL if stat not found, -ENOTSUP if not supported.
218799a2dd95SBruce Richardson  */
218899a2dd95SBruce Richardson uint64_t
218999a2dd95SBruce Richardson rte_event_dev_xstats_by_name_get(uint8_t dev_id, const char *name,
21901bdfe4d7SPavan Nikhilesh 				 uint64_t *id);
219199a2dd95SBruce Richardson 
219299a2dd95SBruce Richardson /**
219399a2dd95SBruce Richardson  * Reset the values of the xstats of the selected component in the device.
219499a2dd95SBruce Richardson  *
219599a2dd95SBruce Richardson  * @param dev_id
219699a2dd95SBruce Richardson  *   The identifier of the device
219799a2dd95SBruce Richardson  * @param mode
219899a2dd95SBruce Richardson  *   The mode of the statistics to reset. Choose from device, queue or port.
219999a2dd95SBruce Richardson  * @param queue_port_id
220099a2dd95SBruce Richardson  *   The queue or port to reset. 0 and positive values select ports and queues,
220199a2dd95SBruce Richardson  *   while -1 indicates all ports or queues.
220299a2dd95SBruce Richardson  * @param ids
220399a2dd95SBruce Richardson  *   Selects specific statistics to be reset. When NULL, all statistics selected
220499a2dd95SBruce Richardson  *   by *mode* will be reset. If non-NULL, must point to array of at least
220599a2dd95SBruce Richardson  *   *nb_ids* size.
220699a2dd95SBruce Richardson  * @param nb_ids
220799a2dd95SBruce Richardson  *   The number of ids available from the *ids* array. Ignored when ids is NULL.
220899a2dd95SBruce Richardson  * @return
220999a2dd95SBruce Richardson  *   - zero: successfully reset the statistics to zero
221099a2dd95SBruce Richardson  *   - negative value: -EINVAL invalid parameters, -ENOTSUP if not supported.
221199a2dd95SBruce Richardson  */
221299a2dd95SBruce Richardson int
221399a2dd95SBruce Richardson rte_event_dev_xstats_reset(uint8_t dev_id,
221499a2dd95SBruce Richardson 			   enum rte_event_dev_xstats_mode mode,
221599a2dd95SBruce Richardson 			   int16_t queue_port_id,
22161bdfe4d7SPavan Nikhilesh 			   const uint64_t ids[],
221799a2dd95SBruce Richardson 			   uint32_t nb_ids);
221899a2dd95SBruce Richardson 
221999a2dd95SBruce Richardson /**
222099a2dd95SBruce Richardson  * Trigger the eventdev self test.
222199a2dd95SBruce Richardson  *
222299a2dd95SBruce Richardson  * @param dev_id
222399a2dd95SBruce Richardson  *   The identifier of the device
222499a2dd95SBruce Richardson  * @return
222599a2dd95SBruce Richardson  *   - 0: Selftest successful
222699a2dd95SBruce Richardson  *   - -ENOTSUP if the device doesn't support selftest
222799a2dd95SBruce Richardson  *   - other values < 0 on failure.
222899a2dd95SBruce Richardson  */
222999a2dd95SBruce Richardson int rte_event_dev_selftest(uint8_t dev_id);
223099a2dd95SBruce Richardson 
223199a2dd95SBruce Richardson /**
223299a2dd95SBruce Richardson  * Get the memory required per event vector based on the number of elements per
223399a2dd95SBruce Richardson  * vector.
223499a2dd95SBruce Richardson  * This should be used to create the mempool that holds the event vectors.
223599a2dd95SBruce Richardson  *
223699a2dd95SBruce Richardson  * @param name
223799a2dd95SBruce Richardson  *   The name of the vector pool.
223899a2dd95SBruce Richardson  * @param n
223999a2dd95SBruce Richardson  *   The number of elements in the mbuf pool.
224099a2dd95SBruce Richardson  * @param cache_size
224199a2dd95SBruce Richardson  *   Size of the per-core object cache. See rte_mempool_create() for
224299a2dd95SBruce Richardson  *   details.
224399a2dd95SBruce Richardson  * @param nb_elem
224499a2dd95SBruce Richardson  *   The number of elements that a single event vector should be able to hold.
224599a2dd95SBruce Richardson  * @param socket_id
224699a2dd95SBruce Richardson  *   The socket identifier where the memory should be allocated. The
224799a2dd95SBruce Richardson  *   value can be *SOCKET_ID_ANY* if there is no NUMA constraint for the
224899a2dd95SBruce Richardson  *   reserved zone
224999a2dd95SBruce Richardson  *
225099a2dd95SBruce Richardson  * @return
225199a2dd95SBruce Richardson  *   The pointer to the newly allocated mempool, on success. NULL on error
225299a2dd95SBruce Richardson  *   with rte_errno set appropriately. Possible rte_errno values include:
225399a2dd95SBruce Richardson  *    - E_RTE_NO_CONFIG - function could not get pointer to rte_config structure
225499a2dd95SBruce Richardson  *    - E_RTE_SECONDARY - function was called from a secondary process instance
225599a2dd95SBruce Richardson  *    - EINVAL - cache size provided is too large, or priv_size is not aligned.
225699a2dd95SBruce Richardson  *    - ENOSPC - the maximum number of memzones has already been allocated
225799a2dd95SBruce Richardson  *    - EEXIST - a memzone with the same name already exists
225899a2dd95SBruce Richardson  *    - ENOMEM - no appropriate memory area found in which to create memzone
225999a2dd95SBruce Richardson  *    - ENAMETOOLONG - mempool name requested is too long.
226099a2dd95SBruce Richardson  */
226199a2dd95SBruce Richardson struct rte_mempool *
226299a2dd95SBruce Richardson rte_event_vector_pool_create(const char *name, unsigned int n,
226399a2dd95SBruce Richardson 			     unsigned int cache_size, uint16_t nb_elem,
226499a2dd95SBruce Richardson 			     int socket_id);
226599a2dd95SBruce Richardson 
226626f14535SPavan Nikhilesh #include <rte_eventdev_core.h>
226726f14535SPavan Nikhilesh 
226826f14535SPavan Nikhilesh static __rte_always_inline uint16_t
226926f14535SPavan Nikhilesh __rte_event_enqueue_burst(uint8_t dev_id, uint8_t port_id,
227026f14535SPavan Nikhilesh 			  const struct rte_event ev[], uint16_t nb_events,
227126f14535SPavan Nikhilesh 			  const event_enqueue_burst_t fn)
227226f14535SPavan Nikhilesh {
2273052e25d9SPavan Nikhilesh 	const struct rte_event_fp_ops *fp_ops;
2274052e25d9SPavan Nikhilesh 	void *port;
227526f14535SPavan Nikhilesh 
2276052e25d9SPavan Nikhilesh 	fp_ops = &rte_event_fp_ops[dev_id];
2277052e25d9SPavan Nikhilesh 	port = fp_ops->data[port_id];
227826f14535SPavan Nikhilesh #ifdef RTE_LIBRTE_EVENTDEV_DEBUG
2279052e25d9SPavan Nikhilesh 	if (dev_id >= RTE_EVENT_MAX_DEVS ||
2280052e25d9SPavan Nikhilesh 	    port_id >= RTE_EVENT_MAX_PORTS_PER_DEV) {
228126f14535SPavan Nikhilesh 		rte_errno = EINVAL;
228226f14535SPavan Nikhilesh 		return 0;
228326f14535SPavan Nikhilesh 	}
228426f14535SPavan Nikhilesh 
2285052e25d9SPavan Nikhilesh 	if (port == NULL) {
228626f14535SPavan Nikhilesh 		rte_errno = EINVAL;
228726f14535SPavan Nikhilesh 		return 0;
228826f14535SPavan Nikhilesh 	}
228926f14535SPavan Nikhilesh #endif
2290153e7d88SBruce Richardson 	rte_eventdev_trace_enq_burst(dev_id, port_id, ev, nb_events, (void *)fn);
229126f14535SPavan Nikhilesh 	/*
229226f14535SPavan Nikhilesh 	 * Allow zero cost non burst mode routine invocation if application
229326f14535SPavan Nikhilesh 	 * requests nb_events as const one
229426f14535SPavan Nikhilesh 	 */
229526f14535SPavan Nikhilesh 	if (nb_events == 1)
2296052e25d9SPavan Nikhilesh 		return (fp_ops->enqueue)(port, ev);
229726f14535SPavan Nikhilesh 	else
2298052e25d9SPavan Nikhilesh 		return fn(port, ev, nb_events);
229926f14535SPavan Nikhilesh }
230026f14535SPavan Nikhilesh 
230126f14535SPavan Nikhilesh /**
230226f14535SPavan Nikhilesh  * Enqueue a burst of events objects or an event object supplied in *rte_event*
230326f14535SPavan Nikhilesh  * structure on an  event device designated by its *dev_id* through the event
230426f14535SPavan Nikhilesh  * port specified by *port_id*. Each event object specifies the event queue on
230526f14535SPavan Nikhilesh  * which it will be enqueued.
230626f14535SPavan Nikhilesh  *
230726f14535SPavan Nikhilesh  * The *nb_events* parameter is the number of event objects to enqueue which are
230826f14535SPavan Nikhilesh  * supplied in the *ev* array of *rte_event* structure.
230926f14535SPavan Nikhilesh  *
231026f14535SPavan Nikhilesh  * Event operations RTE_EVENT_OP_FORWARD and RTE_EVENT_OP_RELEASE must only be
231126f14535SPavan Nikhilesh  * enqueued to the same port that their associated events were dequeued from.
231226f14535SPavan Nikhilesh  *
231326f14535SPavan Nikhilesh  * The rte_event_enqueue_burst() function returns the number of
231426f14535SPavan Nikhilesh  * events objects it actually enqueued. A return value equal to *nb_events*
231526f14535SPavan Nikhilesh  * means that all event objects have been enqueued.
231626f14535SPavan Nikhilesh  *
231726f14535SPavan Nikhilesh  * @param dev_id
231826f14535SPavan Nikhilesh  *   The identifier of the device.
231926f14535SPavan Nikhilesh  * @param port_id
232026f14535SPavan Nikhilesh  *   The identifier of the event port.
232126f14535SPavan Nikhilesh  * @param ev
232226f14535SPavan Nikhilesh  *   Points to an array of *nb_events* objects of type *rte_event* structure
232326f14535SPavan Nikhilesh  *   which contain the event object enqueue operations to be processed.
232426f14535SPavan Nikhilesh  * @param nb_events
232526f14535SPavan Nikhilesh  *   The number of event objects to enqueue, typically number of
232626f14535SPavan Nikhilesh  *   rte_event_port_attr_get(...RTE_EVENT_PORT_ATTR_ENQ_DEPTH...)
232726f14535SPavan Nikhilesh  *   available for this port.
232826f14535SPavan Nikhilesh  *
232926f14535SPavan Nikhilesh  * @return
233026f14535SPavan Nikhilesh  *   The number of event objects actually enqueued on the event device. The
233126f14535SPavan Nikhilesh  *   return value can be less than the value of the *nb_events* parameter when
233226f14535SPavan Nikhilesh  *   the event devices queue is full or if invalid parameters are specified in a
233326f14535SPavan Nikhilesh  *   *rte_event*. If the return value is less than *nb_events*, the remaining
233426f14535SPavan Nikhilesh  *   events at the end of ev[] are not consumed and the caller has to take care
233526f14535SPavan Nikhilesh  *   of them, and rte_errno is set accordingly. Possible errno values include:
233626f14535SPavan Nikhilesh  *   - EINVAL   The port ID is invalid, device ID is invalid, an event's queue
233726f14535SPavan Nikhilesh  *              ID is invalid, or an event's sched type doesn't match the
233826f14535SPavan Nikhilesh  *              capabilities of the destination queue.
233926f14535SPavan Nikhilesh  *   - ENOSPC   The event port was backpressured and unable to enqueue
234026f14535SPavan Nikhilesh  *              one or more events. This error code is only applicable to
234126f14535SPavan Nikhilesh  *              closed systems.
234226f14535SPavan Nikhilesh  * @see rte_event_port_attr_get(), RTE_EVENT_PORT_ATTR_ENQ_DEPTH
234326f14535SPavan Nikhilesh  */
234426f14535SPavan Nikhilesh static inline uint16_t
234526f14535SPavan Nikhilesh rte_event_enqueue_burst(uint8_t dev_id, uint8_t port_id,
234626f14535SPavan Nikhilesh 			const struct rte_event ev[], uint16_t nb_events)
234726f14535SPavan Nikhilesh {
2348052e25d9SPavan Nikhilesh 	const struct rte_event_fp_ops *fp_ops;
234926f14535SPavan Nikhilesh 
2350052e25d9SPavan Nikhilesh 	fp_ops = &rte_event_fp_ops[dev_id];
235126f14535SPavan Nikhilesh 	return __rte_event_enqueue_burst(dev_id, port_id, ev, nb_events,
2352052e25d9SPavan Nikhilesh 					 fp_ops->enqueue_burst);
235326f14535SPavan Nikhilesh }
235426f14535SPavan Nikhilesh 
235526f14535SPavan Nikhilesh /**
235626f14535SPavan Nikhilesh  * Enqueue a burst of events objects of operation type *RTE_EVENT_OP_NEW* on
235726f14535SPavan Nikhilesh  * an event device designated by its *dev_id* through the event port specified
235826f14535SPavan Nikhilesh  * by *port_id*.
235926f14535SPavan Nikhilesh  *
236026f14535SPavan Nikhilesh  * Provides the same functionality as rte_event_enqueue_burst(), expect that
236126f14535SPavan Nikhilesh  * application can use this API when the all objects in the burst contains
236226f14535SPavan Nikhilesh  * the enqueue operation of the type *RTE_EVENT_OP_NEW*. This specialized
236326f14535SPavan Nikhilesh  * function can provide the additional hint to the PMD and optimize if possible.
236426f14535SPavan Nikhilesh  *
236526f14535SPavan Nikhilesh  * The rte_event_enqueue_new_burst() result is undefined if the enqueue burst
236626f14535SPavan Nikhilesh  * has event object of operation type != RTE_EVENT_OP_NEW.
236726f14535SPavan Nikhilesh  *
236826f14535SPavan Nikhilesh  * @param dev_id
236926f14535SPavan Nikhilesh  *   The identifier of the device.
237026f14535SPavan Nikhilesh  * @param port_id
237126f14535SPavan Nikhilesh  *   The identifier of the event port.
237226f14535SPavan Nikhilesh  * @param ev
237326f14535SPavan Nikhilesh  *   Points to an array of *nb_events* objects of type *rte_event* structure
237426f14535SPavan Nikhilesh  *   which contain the event object enqueue operations to be processed.
237526f14535SPavan Nikhilesh  * @param nb_events
237626f14535SPavan Nikhilesh  *   The number of event objects to enqueue, typically number of
237726f14535SPavan Nikhilesh  *   rte_event_port_attr_get(...RTE_EVENT_PORT_ATTR_ENQ_DEPTH...)
237826f14535SPavan Nikhilesh  *   available for this port.
237926f14535SPavan Nikhilesh  *
238026f14535SPavan Nikhilesh  * @return
238126f14535SPavan Nikhilesh  *   The number of event objects actually enqueued on the event device. The
238226f14535SPavan Nikhilesh  *   return value can be less than the value of the *nb_events* parameter when
238326f14535SPavan Nikhilesh  *   the event devices queue is full or if invalid parameters are specified in a
238426f14535SPavan Nikhilesh  *   *rte_event*. If the return value is less than *nb_events*, the remaining
238526f14535SPavan Nikhilesh  *   events at the end of ev[] are not consumed and the caller has to take care
238626f14535SPavan Nikhilesh  *   of them, and rte_errno is set accordingly. Possible errno values include:
238726f14535SPavan Nikhilesh  *   - EINVAL   The port ID is invalid, device ID is invalid, an event's queue
238826f14535SPavan Nikhilesh  *              ID is invalid, or an event's sched type doesn't match the
238926f14535SPavan Nikhilesh  *              capabilities of the destination queue.
239026f14535SPavan Nikhilesh  *   - ENOSPC   The event port was backpressured and unable to enqueue
239126f14535SPavan Nikhilesh  *              one or more events. This error code is only applicable to
239226f14535SPavan Nikhilesh  *              closed systems.
239326f14535SPavan Nikhilesh  * @see rte_event_port_attr_get(), RTE_EVENT_PORT_ATTR_ENQ_DEPTH
239426f14535SPavan Nikhilesh  * @see rte_event_enqueue_burst()
239526f14535SPavan Nikhilesh  */
239626f14535SPavan Nikhilesh static inline uint16_t
239726f14535SPavan Nikhilesh rte_event_enqueue_new_burst(uint8_t dev_id, uint8_t port_id,
239826f14535SPavan Nikhilesh 			    const struct rte_event ev[], uint16_t nb_events)
239926f14535SPavan Nikhilesh {
2400052e25d9SPavan Nikhilesh 	const struct rte_event_fp_ops *fp_ops;
240126f14535SPavan Nikhilesh 
2402052e25d9SPavan Nikhilesh 	fp_ops = &rte_event_fp_ops[dev_id];
240326f14535SPavan Nikhilesh 	return __rte_event_enqueue_burst(dev_id, port_id, ev, nb_events,
2404052e25d9SPavan Nikhilesh 					 fp_ops->enqueue_new_burst);
240526f14535SPavan Nikhilesh }
240626f14535SPavan Nikhilesh 
240726f14535SPavan Nikhilesh /**
240826f14535SPavan Nikhilesh  * Enqueue a burst of events objects of operation type *RTE_EVENT_OP_FORWARD*
240926f14535SPavan Nikhilesh  * on an event device designated by its *dev_id* through the event port
241026f14535SPavan Nikhilesh  * specified by *port_id*.
241126f14535SPavan Nikhilesh  *
241226f14535SPavan Nikhilesh  * Provides the same functionality as rte_event_enqueue_burst(), expect that
241326f14535SPavan Nikhilesh  * application can use this API when the all objects in the burst contains
241426f14535SPavan Nikhilesh  * the enqueue operation of the type *RTE_EVENT_OP_FORWARD*. This specialized
241526f14535SPavan Nikhilesh  * function can provide the additional hint to the PMD and optimize if possible.
241626f14535SPavan Nikhilesh  *
241726f14535SPavan Nikhilesh  * The rte_event_enqueue_new_burst() result is undefined if the enqueue burst
241826f14535SPavan Nikhilesh  * has event object of operation type != RTE_EVENT_OP_FORWARD.
241926f14535SPavan Nikhilesh  *
242026f14535SPavan Nikhilesh  * @param dev_id
242126f14535SPavan Nikhilesh  *   The identifier of the device.
242226f14535SPavan Nikhilesh  * @param port_id
242326f14535SPavan Nikhilesh  *   The identifier of the event port.
242426f14535SPavan Nikhilesh  * @param ev
242526f14535SPavan Nikhilesh  *   Points to an array of *nb_events* objects of type *rte_event* structure
242626f14535SPavan Nikhilesh  *   which contain the event object enqueue operations to be processed.
242726f14535SPavan Nikhilesh  * @param nb_events
242826f14535SPavan Nikhilesh  *   The number of event objects to enqueue, typically number of
242926f14535SPavan Nikhilesh  *   rte_event_port_attr_get(...RTE_EVENT_PORT_ATTR_ENQ_DEPTH...)
243026f14535SPavan Nikhilesh  *   available for this port.
243126f14535SPavan Nikhilesh  *
243226f14535SPavan Nikhilesh  * @return
243326f14535SPavan Nikhilesh  *   The number of event objects actually enqueued on the event device. The
243426f14535SPavan Nikhilesh  *   return value can be less than the value of the *nb_events* parameter when
243526f14535SPavan Nikhilesh  *   the event devices queue is full or if invalid parameters are specified in a
243626f14535SPavan Nikhilesh  *   *rte_event*. If the return value is less than *nb_events*, the remaining
243726f14535SPavan Nikhilesh  *   events at the end of ev[] are not consumed and the caller has to take care
243826f14535SPavan Nikhilesh  *   of them, and rte_errno is set accordingly. Possible errno values include:
243926f14535SPavan Nikhilesh  *   - EINVAL   The port ID is invalid, device ID is invalid, an event's queue
244026f14535SPavan Nikhilesh  *              ID is invalid, or an event's sched type doesn't match the
244126f14535SPavan Nikhilesh  *              capabilities of the destination queue.
244226f14535SPavan Nikhilesh  *   - ENOSPC   The event port was backpressured and unable to enqueue
244326f14535SPavan Nikhilesh  *              one or more events. This error code is only applicable to
244426f14535SPavan Nikhilesh  *              closed systems.
244526f14535SPavan Nikhilesh  * @see rte_event_port_attr_get(), RTE_EVENT_PORT_ATTR_ENQ_DEPTH
244626f14535SPavan Nikhilesh  * @see rte_event_enqueue_burst()
244726f14535SPavan Nikhilesh  */
244826f14535SPavan Nikhilesh static inline uint16_t
244926f14535SPavan Nikhilesh rte_event_enqueue_forward_burst(uint8_t dev_id, uint8_t port_id,
245026f14535SPavan Nikhilesh 				const struct rte_event ev[], uint16_t nb_events)
245126f14535SPavan Nikhilesh {
2452052e25d9SPavan Nikhilesh 	const struct rte_event_fp_ops *fp_ops;
245326f14535SPavan Nikhilesh 
2454052e25d9SPavan Nikhilesh 	fp_ops = &rte_event_fp_ops[dev_id];
245526f14535SPavan Nikhilesh 	return __rte_event_enqueue_burst(dev_id, port_id, ev, nb_events,
2456052e25d9SPavan Nikhilesh 					 fp_ops->enqueue_forward_burst);
245726f14535SPavan Nikhilesh }
245826f14535SPavan Nikhilesh 
245926f14535SPavan Nikhilesh /**
246026f14535SPavan Nikhilesh  * Dequeue a burst of events objects or an event object from the event port
246126f14535SPavan Nikhilesh  * designated by its *event_port_id*, on an event device designated
246226f14535SPavan Nikhilesh  * by its *dev_id*.
246326f14535SPavan Nikhilesh  *
246426f14535SPavan Nikhilesh  * rte_event_dequeue_burst() does not dictate the specifics of scheduling
246526f14535SPavan Nikhilesh  * algorithm as each eventdev driver may have different criteria to schedule
246626f14535SPavan Nikhilesh  * an event. However, in general, from an application perspective scheduler may
246726f14535SPavan Nikhilesh  * use the following scheme to dispatch an event to the port.
246826f14535SPavan Nikhilesh  *
246926f14535SPavan Nikhilesh  * 1) Selection of event queue based on
247026f14535SPavan Nikhilesh  *   a) The list of event queues are linked to the event port.
247126f14535SPavan Nikhilesh  *   b) If the device has RTE_EVENT_DEV_CAP_QUEUE_QOS capability then event
247226f14535SPavan Nikhilesh  *   queue selection from list is based on event queue priority relative to
247326f14535SPavan Nikhilesh  *   other event queue supplied as *priority* in rte_event_queue_setup()
247426f14535SPavan Nikhilesh  *   c) If the device has RTE_EVENT_DEV_CAP_EVENT_QOS capability then event
247526f14535SPavan Nikhilesh  *   queue selection from the list is based on event priority supplied as
247626f14535SPavan Nikhilesh  *   *priority* in rte_event_enqueue_burst()
247726f14535SPavan Nikhilesh  * 2) Selection of event
247826f14535SPavan Nikhilesh  *   a) The number of flows available in selected event queue.
247926f14535SPavan Nikhilesh  *   b) Schedule type method associated with the event
248026f14535SPavan Nikhilesh  *
248126f14535SPavan Nikhilesh  * The *nb_events* parameter is the maximum number of event objects to dequeue
248226f14535SPavan Nikhilesh  * which are returned in the *ev* array of *rte_event* structure.
248326f14535SPavan Nikhilesh  *
248426f14535SPavan Nikhilesh  * The rte_event_dequeue_burst() function returns the number of events objects
248526f14535SPavan Nikhilesh  * it actually dequeued. A return value equal to *nb_events* means that all
248626f14535SPavan Nikhilesh  * event objects have been dequeued.
248726f14535SPavan Nikhilesh  *
248826f14535SPavan Nikhilesh  * The number of events dequeued is the number of scheduler contexts held by
248926f14535SPavan Nikhilesh  * this port. These contexts are automatically released in the next
249026f14535SPavan Nikhilesh  * rte_event_dequeue_burst() invocation if the port supports implicit
249126f14535SPavan Nikhilesh  * releases, or invoking rte_event_enqueue_burst() with RTE_EVENT_OP_RELEASE
249226f14535SPavan Nikhilesh  * operation can be used to release the contexts early.
249326f14535SPavan Nikhilesh  *
249426f14535SPavan Nikhilesh  * Event operations RTE_EVENT_OP_FORWARD and RTE_EVENT_OP_RELEASE must only be
249526f14535SPavan Nikhilesh  * enqueued to the same port that their associated events were dequeued from.
249626f14535SPavan Nikhilesh  *
249726f14535SPavan Nikhilesh  * @param dev_id
249826f14535SPavan Nikhilesh  *   The identifier of the device.
249926f14535SPavan Nikhilesh  * @param port_id
250026f14535SPavan Nikhilesh  *   The identifier of the event port.
250126f14535SPavan Nikhilesh  * @param[out] ev
250226f14535SPavan Nikhilesh  *   Points to an array of *nb_events* objects of type *rte_event* structure
250326f14535SPavan Nikhilesh  *   for output to be populated with the dequeued event objects.
250426f14535SPavan Nikhilesh  * @param nb_events
250526f14535SPavan Nikhilesh  *   The maximum number of event objects to dequeue, typically number of
250626f14535SPavan Nikhilesh  *   rte_event_port_dequeue_depth() available for this port.
250726f14535SPavan Nikhilesh  *
250826f14535SPavan Nikhilesh  * @param timeout_ticks
250926f14535SPavan Nikhilesh  *   - 0 no-wait, returns immediately if there is no event.
251026f14535SPavan Nikhilesh  *   - >0 wait for the event, if the device is configured with
251126f14535SPavan Nikhilesh  *   RTE_EVENT_DEV_CFG_PER_DEQUEUE_TIMEOUT then this function will wait until
251226f14535SPavan Nikhilesh  *   at least one event is available or *timeout_ticks* time.
251326f14535SPavan Nikhilesh  *   if the device is not configured with RTE_EVENT_DEV_CFG_PER_DEQUEUE_TIMEOUT
251426f14535SPavan Nikhilesh  *   then this function will wait until the event available or
251526f14535SPavan Nikhilesh  *   *dequeue_timeout_ns* ns which was previously supplied to
251626f14535SPavan Nikhilesh  *   rte_event_dev_configure()
251726f14535SPavan Nikhilesh  *
251826f14535SPavan Nikhilesh  * @return
251926f14535SPavan Nikhilesh  * The number of event objects actually dequeued from the port. The return
252026f14535SPavan Nikhilesh  * value can be less than the value of the *nb_events* parameter when the
252126f14535SPavan Nikhilesh  * event port's queue is not full.
252226f14535SPavan Nikhilesh  *
252326f14535SPavan Nikhilesh  * @see rte_event_port_dequeue_depth()
252426f14535SPavan Nikhilesh  */
252526f14535SPavan Nikhilesh static inline uint16_t
252626f14535SPavan Nikhilesh rte_event_dequeue_burst(uint8_t dev_id, uint8_t port_id, struct rte_event ev[],
252726f14535SPavan Nikhilesh 			uint16_t nb_events, uint64_t timeout_ticks)
252826f14535SPavan Nikhilesh {
2529052e25d9SPavan Nikhilesh 	const struct rte_event_fp_ops *fp_ops;
2530052e25d9SPavan Nikhilesh 	void *port;
253126f14535SPavan Nikhilesh 
2532052e25d9SPavan Nikhilesh 	fp_ops = &rte_event_fp_ops[dev_id];
2533052e25d9SPavan Nikhilesh 	port = fp_ops->data[port_id];
253426f14535SPavan Nikhilesh #ifdef RTE_LIBRTE_EVENTDEV_DEBUG
2535052e25d9SPavan Nikhilesh 	if (dev_id >= RTE_EVENT_MAX_DEVS ||
2536052e25d9SPavan Nikhilesh 	    port_id >= RTE_EVENT_MAX_PORTS_PER_DEV) {
253726f14535SPavan Nikhilesh 		rte_errno = EINVAL;
253826f14535SPavan Nikhilesh 		return 0;
253926f14535SPavan Nikhilesh 	}
254026f14535SPavan Nikhilesh 
2541052e25d9SPavan Nikhilesh 	if (port == NULL) {
254226f14535SPavan Nikhilesh 		rte_errno = EINVAL;
254326f14535SPavan Nikhilesh 		return 0;
254426f14535SPavan Nikhilesh 	}
254526f14535SPavan Nikhilesh #endif
254626f14535SPavan Nikhilesh 	rte_eventdev_trace_deq_burst(dev_id, port_id, ev, nb_events);
254726f14535SPavan Nikhilesh 	/*
254826f14535SPavan Nikhilesh 	 * Allow zero cost non burst mode routine invocation if application
254926f14535SPavan Nikhilesh 	 * requests nb_events as const one
255026f14535SPavan Nikhilesh 	 */
255126f14535SPavan Nikhilesh 	if (nb_events == 1)
2552052e25d9SPavan Nikhilesh 		return (fp_ops->dequeue)(port, ev, timeout_ticks);
255326f14535SPavan Nikhilesh 	else
2554052e25d9SPavan Nikhilesh 		return (fp_ops->dequeue_burst)(port, ev, nb_events,
2555052e25d9SPavan Nikhilesh 					       timeout_ticks);
255626f14535SPavan Nikhilesh }
255726f14535SPavan Nikhilesh 
255854f17843SMattias Rönnblom #define RTE_EVENT_DEV_MAINT_OP_FLUSH          (1 << 0)
255954f17843SMattias Rönnblom /**< Force an immediately flush of any buffered events in the port,
256054f17843SMattias Rönnblom  * potentially at the cost of additional overhead.
256154f17843SMattias Rönnblom  *
256254f17843SMattias Rönnblom  * @see rte_event_maintain()
256354f17843SMattias Rönnblom  */
256454f17843SMattias Rönnblom 
256554f17843SMattias Rönnblom /**
256654f17843SMattias Rönnblom  * Maintain an event device.
256754f17843SMattias Rönnblom  *
2568bd991897SMattias Rönnblom  * This function is only relevant for event devices which do not have
2569bd991897SMattias Rönnblom  * the @ref RTE_EVENT_DEV_CAP_MAINTENANCE_FREE flag set. Such devices
257054f17843SMattias Rönnblom  * require an application thread using a particular port to
257154f17843SMattias Rönnblom  * periodically call rte_event_maintain() on that port during periods
257254f17843SMattias Rönnblom  * which it is neither attempting to enqueue events to nor dequeue
257354f17843SMattias Rönnblom  * events from the port. rte_event_maintain() is a low-overhead
257454f17843SMattias Rönnblom  * function and should be called at a high rate (e.g., in the
257554f17843SMattias Rönnblom  * application's poll loop).
257654f17843SMattias Rönnblom  *
257754f17843SMattias Rönnblom  * No port may be left unmaintained.
257854f17843SMattias Rönnblom  *
257954f17843SMattias Rönnblom  * At the application thread's convenience, rte_event_maintain() may
258054f17843SMattias Rönnblom  * (but is not required to) be called even during periods when enqueue
258154f17843SMattias Rönnblom  * or dequeue functions are being called, at the cost of a slight
258254f17843SMattias Rönnblom  * increase in overhead.
258354f17843SMattias Rönnblom  *
2584bd991897SMattias Rönnblom  * rte_event_maintain() may be called on event devices which have set
2585bd991897SMattias Rönnblom  * @ref RTE_EVENT_DEV_CAP_MAINTENANCE_FREE, in which case it is a
2586bd991897SMattias Rönnblom  * no-operation.
258754f17843SMattias Rönnblom  *
258854f17843SMattias Rönnblom  * @param dev_id
258954f17843SMattias Rönnblom  *   The identifier of the device.
259054f17843SMattias Rönnblom  * @param port_id
259154f17843SMattias Rönnblom  *   The identifier of the event port.
259254f17843SMattias Rönnblom  * @param op
259354f17843SMattias Rönnblom  *   0, or @ref RTE_EVENT_DEV_MAINT_OP_FLUSH.
259454f17843SMattias Rönnblom  * @return
259554f17843SMattias Rönnblom  *  - 0 on success.
259654f17843SMattias Rönnblom  *  - -EINVAL if *dev_id*,  *port_id*, or *op* is invalid.
259754f17843SMattias Rönnblom  *
2598bd991897SMattias Rönnblom  * @see RTE_EVENT_DEV_CAP_MAINTENANCE_FREE
259954f17843SMattias Rönnblom  */
260054f17843SMattias Rönnblom static inline int
260154f17843SMattias Rönnblom rte_event_maintain(uint8_t dev_id, uint8_t port_id, int op)
260254f17843SMattias Rönnblom {
260354f17843SMattias Rönnblom 	const struct rte_event_fp_ops *fp_ops;
260454f17843SMattias Rönnblom 	void *port;
260554f17843SMattias Rönnblom 
260654f17843SMattias Rönnblom 	fp_ops = &rte_event_fp_ops[dev_id];
260754f17843SMattias Rönnblom 	port = fp_ops->data[port_id];
260854f17843SMattias Rönnblom #ifdef RTE_LIBRTE_EVENTDEV_DEBUG
260954f17843SMattias Rönnblom 	if (dev_id >= RTE_EVENT_MAX_DEVS ||
261054f17843SMattias Rönnblom 	    port_id >= RTE_EVENT_MAX_PORTS_PER_DEV)
261154f17843SMattias Rönnblom 		return -EINVAL;
261254f17843SMattias Rönnblom 
261354f17843SMattias Rönnblom 	if (port == NULL)
261454f17843SMattias Rönnblom 		return -EINVAL;
261554f17843SMattias Rönnblom 
261654f17843SMattias Rönnblom 	if (op & (~RTE_EVENT_DEV_MAINT_OP_FLUSH))
261754f17843SMattias Rönnblom 		return -EINVAL;
261854f17843SMattias Rönnblom #endif
261954f17843SMattias Rönnblom 	rte_eventdev_trace_maintain(dev_id, port_id, op);
262054f17843SMattias Rönnblom 
262154f17843SMattias Rönnblom 	if (fp_ops->maintain != NULL)
262254f17843SMattias Rönnblom 		fp_ops->maintain(port, op);
262354f17843SMattias Rönnblom 
262454f17843SMattias Rönnblom 	return 0;
262554f17843SMattias Rönnblom }
262654f17843SMattias Rönnblom 
2627d007a7f3SPavan Nikhilesh /**
2628d007a7f3SPavan Nikhilesh  * Change the active profile on an event port.
2629d007a7f3SPavan Nikhilesh  *
2630d007a7f3SPavan Nikhilesh  * This function is used to change the current active profile on an event port
2631d007a7f3SPavan Nikhilesh  * when multiple link profiles are configured on an event port through the
2632d007a7f3SPavan Nikhilesh  * function call ``rte_event_port_profile_links_set``.
2633d007a7f3SPavan Nikhilesh  *
2634d007a7f3SPavan Nikhilesh  * On the subsequent ``rte_event_dequeue_burst`` call, only the event queues
2635d007a7f3SPavan Nikhilesh  * that were associated with the newly active profile will participate in
2636d007a7f3SPavan Nikhilesh  * scheduling.
2637d007a7f3SPavan Nikhilesh  *
2638d007a7f3SPavan Nikhilesh  * @param dev_id
2639d007a7f3SPavan Nikhilesh  *   The identifier of the device.
2640d007a7f3SPavan Nikhilesh  * @param port_id
2641d007a7f3SPavan Nikhilesh  *   The identifier of the event port.
2642d007a7f3SPavan Nikhilesh  * @param profile_id
2643d007a7f3SPavan Nikhilesh  *   The identifier of the profile.
2644d007a7f3SPavan Nikhilesh  * @return
2645d007a7f3SPavan Nikhilesh  *  - 0 on success.
2646d007a7f3SPavan Nikhilesh  *  - -EINVAL if *dev_id*,  *port_id*, or *profile_id* is invalid.
2647d007a7f3SPavan Nikhilesh  */
2648d007a7f3SPavan Nikhilesh static inline uint8_t
2649d007a7f3SPavan Nikhilesh rte_event_port_profile_switch(uint8_t dev_id, uint8_t port_id, uint8_t profile_id)
2650d007a7f3SPavan Nikhilesh {
2651d007a7f3SPavan Nikhilesh 	const struct rte_event_fp_ops *fp_ops;
2652d007a7f3SPavan Nikhilesh 	void *port;
2653d007a7f3SPavan Nikhilesh 
2654d007a7f3SPavan Nikhilesh 	fp_ops = &rte_event_fp_ops[dev_id];
2655d007a7f3SPavan Nikhilesh 	port = fp_ops->data[port_id];
2656d007a7f3SPavan Nikhilesh 
2657d007a7f3SPavan Nikhilesh #ifdef RTE_LIBRTE_EVENTDEV_DEBUG
2658d007a7f3SPavan Nikhilesh 	if (dev_id >= RTE_EVENT_MAX_DEVS ||
2659d007a7f3SPavan Nikhilesh 	    port_id >= RTE_EVENT_MAX_PORTS_PER_DEV)
2660d007a7f3SPavan Nikhilesh 		return -EINVAL;
2661d007a7f3SPavan Nikhilesh 
2662d007a7f3SPavan Nikhilesh 	if (port == NULL)
2663d007a7f3SPavan Nikhilesh 		return -EINVAL;
2664d007a7f3SPavan Nikhilesh 
2665d007a7f3SPavan Nikhilesh 	if (profile_id >= RTE_EVENT_MAX_PROFILES_PER_PORT)
2666d007a7f3SPavan Nikhilesh 		return -EINVAL;
2667d007a7f3SPavan Nikhilesh #endif
2668d007a7f3SPavan Nikhilesh 	rte_eventdev_trace_port_profile_switch(dev_id, port_id, profile_id);
2669d007a7f3SPavan Nikhilesh 
2670d007a7f3SPavan Nikhilesh 	return fp_ops->profile_switch(port, profile_id);
2671d007a7f3SPavan Nikhilesh }
2672d007a7f3SPavan Nikhilesh 
267399a2dd95SBruce Richardson #ifdef __cplusplus
267499a2dd95SBruce Richardson }
267599a2dd95SBruce Richardson #endif
267699a2dd95SBruce Richardson 
267799a2dd95SBruce Richardson #endif /* _RTE_EVENTDEV_H_ */
2678