xref: /dpdk/lib/eventdev/rte_eventdev.h (revision a256a743cf1cb40c9c98ebba87e6b7478fb9d2fc)
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
1599a2dd95SBruce Richardson  *
1699a2dd95SBruce Richardson  * In a polling model, lcores poll ethdev ports and associated rx queues
1799a2dd95SBruce Richardson  * directly to look for packet. In an event driven model, by contrast, lcores
1899a2dd95SBruce Richardson  * call the scheduler that selects packets for them based on programmer
1999a2dd95SBruce Richardson  * specified criteria. Eventdev library adds support for event driven
2099a2dd95SBruce Richardson  * programming model, which offer applications automatic multicore scaling,
2199a2dd95SBruce Richardson  * dynamic load balancing, pipelining, packet ingress order maintenance and
2299a2dd95SBruce Richardson  * synchronization services to simplify application packet processing.
2399a2dd95SBruce Richardson  *
2499a2dd95SBruce Richardson  * The Event Device API is composed of two parts:
2599a2dd95SBruce Richardson  *
2699a2dd95SBruce Richardson  * - The application-oriented Event API that includes functions to setup
2799a2dd95SBruce Richardson  *   an event device (configure it, setup its queues, ports and start it), to
2899a2dd95SBruce Richardson  *   establish the link between queues to port and to receive events, and so on.
2999a2dd95SBruce Richardson  *
3099a2dd95SBruce Richardson  * - The driver-oriented Event API that exports a function allowing
3199a2dd95SBruce Richardson  *   an event poll Mode Driver (PMD) to simultaneously register itself as
3299a2dd95SBruce Richardson  *   an event device driver.
3399a2dd95SBruce Richardson  *
3499a2dd95SBruce Richardson  * Event device components:
3599a2dd95SBruce Richardson  *
3699a2dd95SBruce Richardson  *                     +-----------------+
3799a2dd95SBruce Richardson  *                     | +-------------+ |
3899a2dd95SBruce Richardson  *        +-------+    | |    flow 0   | |
3999a2dd95SBruce Richardson  *        |Packet |    | +-------------+ |
4099a2dd95SBruce Richardson  *        |event  |    | +-------------+ |
4199a2dd95SBruce Richardson  *        |       |    | |    flow 1   | |port_link(port0, queue0)
4299a2dd95SBruce Richardson  *        +-------+    | +-------------+ |     |     +--------+
4399a2dd95SBruce Richardson  *        +-------+    | +-------------+ o-----v-----o        |dequeue +------+
4499a2dd95SBruce Richardson  *        |Crypto |    | |    flow n   | |           | event  +------->|Core 0|
4599a2dd95SBruce Richardson  *        |work   |    | +-------------+ o----+      | port 0 |        |      |
4699a2dd95SBruce Richardson  *        |done ev|    |  event queue 0  |    |      +--------+        +------+
4799a2dd95SBruce Richardson  *        +-------+    +-----------------+    |
4899a2dd95SBruce Richardson  *        +-------+                           |
4999a2dd95SBruce Richardson  *        |Timer  |    +-----------------+    |      +--------+
5099a2dd95SBruce Richardson  *        |expiry |    | +-------------+ |    +------o        |dequeue +------+
5199a2dd95SBruce Richardson  *        |event  |    | |    flow 0   | o-----------o event  +------->|Core 1|
5299a2dd95SBruce Richardson  *        +-------+    | +-------------+ |      +----o port 1 |        |      |
5399a2dd95SBruce Richardson  *       Event enqueue | +-------------+ |      |    +--------+        +------+
5499a2dd95SBruce Richardson  *     o-------------> | |    flow 1   | |      |
5599a2dd95SBruce Richardson  *        enqueue(     | +-------------+ |      |
5699a2dd95SBruce Richardson  *        queue_id,    |                 |      |    +--------+        +------+
5799a2dd95SBruce Richardson  *        flow_id,     | +-------------+ |      |    |        |dequeue |Core 2|
5899a2dd95SBruce Richardson  *        sched_type,  | |    flow n   | o-----------o event  +------->|      |
5999a2dd95SBruce Richardson  *        event_type,  | +-------------+ |      |    | port 2 |        +------+
6099a2dd95SBruce Richardson  *        subev_type,  |  event queue 1  |      |    +--------+
6199a2dd95SBruce Richardson  *        event)       +-----------------+      |    +--------+
6299a2dd95SBruce Richardson  *                                              |    |        |dequeue +------+
6399a2dd95SBruce Richardson  *        +-------+    +-----------------+      |    | event  +------->|Core n|
6499a2dd95SBruce Richardson  *        |Core   |    | +-------------+ o-----------o port n |        |      |
6599a2dd95SBruce Richardson  *        |(SW)   |    | |    flow 0   | |      |    +--------+        +--+---+
6699a2dd95SBruce Richardson  *        |event  |    | +-------------+ |      |                         |
6799a2dd95SBruce Richardson  *        +-------+    | +-------------+ |      |                         |
6899a2dd95SBruce Richardson  *            ^        | |    flow 1   | |      |                         |
6999a2dd95SBruce Richardson  *            |        | +-------------+ o------+                         |
7099a2dd95SBruce Richardson  *            |        | +-------------+ |                                |
7199a2dd95SBruce Richardson  *            |        | |    flow n   | |                                |
7299a2dd95SBruce Richardson  *            |        | +-------------+ |                                |
7399a2dd95SBruce Richardson  *            |        |  event queue n  |                                |
7499a2dd95SBruce Richardson  *            |        +-----------------+                                |
7599a2dd95SBruce Richardson  *            |                                                           |
7699a2dd95SBruce Richardson  *            +-----------------------------------------------------------+
7799a2dd95SBruce Richardson  *
7899a2dd95SBruce Richardson  * Event device: A hardware or software-based event scheduler.
7999a2dd95SBruce Richardson  *
8099a2dd95SBruce Richardson  * Event: A unit of scheduling that encapsulates a packet or other datatype
8199a2dd95SBruce Richardson  * like SW generated event from the CPU, Crypto work completion notification,
8299a2dd95SBruce Richardson  * Timer expiry event notification etc as well as metadata.
8399a2dd95SBruce Richardson  * The metadata includes flow ID, scheduling type, event priority, event_type,
8499a2dd95SBruce Richardson  * sub_event_type etc.
8599a2dd95SBruce Richardson  *
8699a2dd95SBruce Richardson  * Event queue: A queue containing events that are scheduled by the event dev.
8799a2dd95SBruce Richardson  * An event queue contains events of different flows associated with scheduling
8899a2dd95SBruce Richardson  * types, such as atomic, ordered, or parallel.
8999a2dd95SBruce Richardson  *
9099a2dd95SBruce Richardson  * Event port: An application's interface into the event dev for enqueue and
9199a2dd95SBruce Richardson  * dequeue operations. Each event port can be linked with one or more
9299a2dd95SBruce Richardson  * event queues for dequeue operations.
9399a2dd95SBruce Richardson  *
9499a2dd95SBruce Richardson  * By default, all the functions of the Event Device API exported by a PMD
9599a2dd95SBruce Richardson  * are lock-free functions which assume to not be invoked in parallel on
9699a2dd95SBruce Richardson  * different logical cores to work on the same target object. For instance,
9799a2dd95SBruce Richardson  * the dequeue function of a PMD cannot be invoked in parallel on two logical
9899a2dd95SBruce Richardson  * cores to operates on same  event port. Of course, this function
9999a2dd95SBruce Richardson  * can be invoked in parallel by different logical cores on different ports.
10099a2dd95SBruce Richardson  * It is the responsibility of the upper level application to enforce this rule.
10199a2dd95SBruce Richardson  *
10299a2dd95SBruce Richardson  * In all functions of the Event API, the Event device is
10399a2dd95SBruce Richardson  * designated by an integer >= 0 named the device identifier *dev_id*
10499a2dd95SBruce Richardson  *
10599a2dd95SBruce Richardson  * At the Event driver level, Event devices are represented by a generic
10699a2dd95SBruce Richardson  * data structure of type *rte_event_dev*.
10799a2dd95SBruce Richardson  *
10899a2dd95SBruce Richardson  * Event devices are dynamically registered during the PCI/SoC device probing
10999a2dd95SBruce Richardson  * phase performed at EAL initialization time.
11099a2dd95SBruce Richardson  * When an Event device is being probed, a *rte_event_dev* structure and
11199a2dd95SBruce Richardson  * a new device identifier are allocated for that device. Then, the
11299a2dd95SBruce Richardson  * event_dev_init() function supplied by the Event driver matching the probed
11399a2dd95SBruce Richardson  * device is invoked to properly initialize the device.
11499a2dd95SBruce Richardson  *
11599a2dd95SBruce Richardson  * The role of the device init function consists of resetting the hardware or
11699a2dd95SBruce Richardson  * software event driver implementations.
11799a2dd95SBruce Richardson  *
11899a2dd95SBruce Richardson  * If the device init operation is successful, the correspondence between
11999a2dd95SBruce Richardson  * the device identifier assigned to the new device and its associated
12099a2dd95SBruce Richardson  * *rte_event_dev* structure is effectively registered.
12199a2dd95SBruce Richardson  * Otherwise, both the *rte_event_dev* structure and the device identifier are
12299a2dd95SBruce Richardson  * freed.
12399a2dd95SBruce Richardson  *
12499a2dd95SBruce Richardson  * The functions exported by the application Event API to setup a device
12599a2dd95SBruce Richardson  * designated by its device identifier must be invoked in the following order:
12699a2dd95SBruce Richardson  *     - rte_event_dev_configure()
12799a2dd95SBruce Richardson  *     - rte_event_queue_setup()
12899a2dd95SBruce Richardson  *     - rte_event_port_setup()
12999a2dd95SBruce Richardson  *     - rte_event_port_link()
13099a2dd95SBruce Richardson  *     - rte_event_dev_start()
13199a2dd95SBruce Richardson  *
13299a2dd95SBruce Richardson  * Then, the application can invoke, in any order, the functions
13399a2dd95SBruce Richardson  * exported by the Event API to schedule events, dequeue events, enqueue events,
13499a2dd95SBruce Richardson  * change event queue(s) to event port [un]link establishment and so on.
13599a2dd95SBruce Richardson  *
13699a2dd95SBruce Richardson  * Application may use rte_event_[queue/port]_default_conf_get() to get the
13799a2dd95SBruce Richardson  * default configuration to set up an event queue or event port by
13899a2dd95SBruce Richardson  * overriding few default values.
13999a2dd95SBruce Richardson  *
14099a2dd95SBruce Richardson  * If the application wants to change the configuration (i.e. call
14199a2dd95SBruce Richardson  * rte_event_dev_configure(), rte_event_queue_setup(), or
14299a2dd95SBruce Richardson  * rte_event_port_setup()), it must call rte_event_dev_stop() first to stop the
14399a2dd95SBruce Richardson  * device and then do the reconfiguration before calling rte_event_dev_start()
14499a2dd95SBruce Richardson  * again. The schedule, enqueue and dequeue functions should not be invoked
14599a2dd95SBruce Richardson  * when the device is stopped.
14699a2dd95SBruce Richardson  *
14799a2dd95SBruce Richardson  * Finally, an application can close an Event device by invoking the
14899a2dd95SBruce Richardson  * rte_event_dev_close() function.
14999a2dd95SBruce Richardson  *
15099a2dd95SBruce Richardson  * Each function of the application Event API invokes a specific function
15199a2dd95SBruce Richardson  * of the PMD that controls the target device designated by its device
15299a2dd95SBruce Richardson  * identifier.
15399a2dd95SBruce Richardson  *
15499a2dd95SBruce Richardson  * For this purpose, all device-specific functions of an Event driver are
15599a2dd95SBruce Richardson  * supplied through a set of pointers contained in a generic structure of type
15699a2dd95SBruce Richardson  * *event_dev_ops*.
15799a2dd95SBruce Richardson  * The address of the *event_dev_ops* structure is stored in the *rte_event_dev*
15899a2dd95SBruce Richardson  * structure by the device init function of the Event driver, which is
15999a2dd95SBruce Richardson  * invoked during the PCI/SoC device probing phase, as explained earlier.
16099a2dd95SBruce Richardson  *
16199a2dd95SBruce Richardson  * In other words, each function of the Event API simply retrieves the
16299a2dd95SBruce Richardson  * *rte_event_dev* structure associated with the device identifier and
16399a2dd95SBruce Richardson  * performs an indirect invocation of the corresponding driver function
16499a2dd95SBruce Richardson  * supplied in the *event_dev_ops* structure of the *rte_event_dev* structure.
16599a2dd95SBruce Richardson  *
16699a2dd95SBruce Richardson  * For performance reasons, the address of the fast-path functions of the
16799a2dd95SBruce Richardson  * Event driver is not contained in the *event_dev_ops* structure.
16899a2dd95SBruce Richardson  * Instead, they are directly stored at the beginning of the *rte_event_dev*
16999a2dd95SBruce Richardson  * structure to avoid an extra indirect memory access during their invocation.
17099a2dd95SBruce Richardson  *
17199a2dd95SBruce Richardson  * RTE event device drivers do not use interrupts for enqueue or dequeue
17299a2dd95SBruce Richardson  * operation. Instead, Event drivers export Poll-Mode enqueue and dequeue
17399a2dd95SBruce Richardson  * functions to applications.
17499a2dd95SBruce Richardson  *
17599a2dd95SBruce Richardson  * The events are injected to event device through *enqueue* operation by
17699a2dd95SBruce Richardson  * event producers in the system. The typical event producers are ethdev
17799a2dd95SBruce Richardson  * subsystem for generating packet events, CPU(SW) for generating events based
17899a2dd95SBruce Richardson  * on different stages of application processing, cryptodev for generating
17999a2dd95SBruce Richardson  * crypto work completion notification etc
18099a2dd95SBruce Richardson  *
18199a2dd95SBruce Richardson  * The *dequeue* operation gets one or more events from the event ports.
18299a2dd95SBruce Richardson  * The application process the events and send to downstream event queue through
18399a2dd95SBruce Richardson  * rte_event_enqueue_burst() if it is an intermediate stage of event processing,
18499a2dd95SBruce Richardson  * on the final stage, the application may use Tx adapter API for maintaining
18599a2dd95SBruce Richardson  * the ingress order and then send the packet/event on the wire.
18699a2dd95SBruce Richardson  *
18799a2dd95SBruce Richardson  * The point at which events are scheduled to ports depends on the device.
18899a2dd95SBruce Richardson  * For hardware devices, scheduling occurs asynchronously without any software
18999a2dd95SBruce Richardson  * intervention. Software schedulers can either be distributed
19099a2dd95SBruce Richardson  * (each worker thread schedules events to its own port) or centralized
19199a2dd95SBruce Richardson  * (a dedicated thread schedules to all ports). Distributed software schedulers
19299a2dd95SBruce Richardson  * perform the scheduling in rte_event_dequeue_burst(), whereas centralized
19399a2dd95SBruce Richardson  * scheduler logic need a dedicated service core for scheduling.
19499a2dd95SBruce Richardson  * The RTE_EVENT_DEV_CAP_DISTRIBUTED_SCHED capability flag is not set
19599a2dd95SBruce Richardson  * indicates the device is centralized and thus needs a dedicated scheduling
19699a2dd95SBruce Richardson  * thread that repeatedly calls software specific scheduling function.
19799a2dd95SBruce Richardson  *
19899a2dd95SBruce Richardson  * An event driven worker thread has following typical workflow on fastpath:
19999a2dd95SBruce Richardson  * \code{.c}
20099a2dd95SBruce Richardson  *	while (1) {
20199a2dd95SBruce Richardson  *		rte_event_dequeue_burst(...);
20299a2dd95SBruce Richardson  *		(event processing)
20399a2dd95SBruce Richardson  *		rte_event_enqueue_burst(...);
20499a2dd95SBruce Richardson  *	}
20599a2dd95SBruce Richardson  * \endcode
20699a2dd95SBruce Richardson  *
20799a2dd95SBruce Richardson  */
20899a2dd95SBruce Richardson 
20999a2dd95SBruce Richardson #ifdef __cplusplus
21099a2dd95SBruce Richardson extern "C" {
21199a2dd95SBruce Richardson #endif
21299a2dd95SBruce Richardson 
21399a2dd95SBruce Richardson #include <rte_common.h>
21499a2dd95SBruce Richardson #include <rte_config.h>
21599a2dd95SBruce Richardson #include <rte_errno.h>
21699a2dd95SBruce Richardson #include <rte_mbuf_pool_ops.h>
21799a2dd95SBruce Richardson #include <rte_memory.h>
21899a2dd95SBruce Richardson #include <rte_mempool.h>
21999a2dd95SBruce Richardson 
22099a2dd95SBruce Richardson #include "rte_eventdev_trace_fp.h"
22199a2dd95SBruce Richardson 
22299a2dd95SBruce Richardson struct rte_mbuf; /* we just use mbuf pointers; no need to include rte_mbuf.h */
22399a2dd95SBruce Richardson struct rte_event;
22499a2dd95SBruce Richardson 
22599a2dd95SBruce Richardson /* Event device capability bitmap flags */
22699a2dd95SBruce Richardson #define RTE_EVENT_DEV_CAP_QUEUE_QOS           (1ULL << 0)
22799a2dd95SBruce Richardson /**< Event scheduling prioritization is based on the priority associated with
22899a2dd95SBruce Richardson  *  each event queue.
22999a2dd95SBruce Richardson  *
23099a2dd95SBruce Richardson  *  @see rte_event_queue_setup()
23199a2dd95SBruce Richardson  */
23299a2dd95SBruce Richardson #define RTE_EVENT_DEV_CAP_EVENT_QOS           (1ULL << 1)
23399a2dd95SBruce Richardson /**< Event scheduling prioritization is based on the priority associated with
23499a2dd95SBruce Richardson  *  each event. Priority of each event is supplied in *rte_event* structure
23599a2dd95SBruce Richardson  *  on each enqueue operation.
23699a2dd95SBruce Richardson  *
23799a2dd95SBruce Richardson  *  @see rte_event_enqueue_burst()
23899a2dd95SBruce Richardson  */
23999a2dd95SBruce Richardson #define RTE_EVENT_DEV_CAP_DISTRIBUTED_SCHED   (1ULL << 2)
24099a2dd95SBruce Richardson /**< Event device operates in distributed scheduling mode.
24199a2dd95SBruce Richardson  * In distributed scheduling mode, event scheduling happens in HW or
24299a2dd95SBruce Richardson  * rte_event_dequeue_burst() or the combination of these two.
24399a2dd95SBruce Richardson  * If the flag is not set then eventdev is centralized and thus needs a
24499a2dd95SBruce Richardson  * dedicated service core that acts as a scheduling thread .
24599a2dd95SBruce Richardson  *
24699a2dd95SBruce Richardson  * @see rte_event_dequeue_burst()
24799a2dd95SBruce Richardson  */
24899a2dd95SBruce Richardson #define RTE_EVENT_DEV_CAP_QUEUE_ALL_TYPES     (1ULL << 3)
24999a2dd95SBruce Richardson /**< Event device is capable of enqueuing events of any type to any queue.
25099a2dd95SBruce Richardson  * If this capability is not set, the queue only supports events of the
25199a2dd95SBruce Richardson  *  *RTE_SCHED_TYPE_* type that it was created with.
25299a2dd95SBruce Richardson  *
25399a2dd95SBruce Richardson  * @see RTE_SCHED_TYPE_* values
25499a2dd95SBruce Richardson  */
25599a2dd95SBruce Richardson #define RTE_EVENT_DEV_CAP_BURST_MODE          (1ULL << 4)
25699a2dd95SBruce Richardson /**< Event device is capable of operating in burst mode for enqueue(forward,
25799a2dd95SBruce Richardson  * release) and dequeue operation. If this capability is not set, application
25899a2dd95SBruce Richardson  * still uses the rte_event_dequeue_burst() and rte_event_enqueue_burst() but
25999a2dd95SBruce Richardson  * PMD accepts only one event at a time.
26099a2dd95SBruce Richardson  *
26199a2dd95SBruce Richardson  * @see rte_event_dequeue_burst() rte_event_enqueue_burst()
26299a2dd95SBruce Richardson  */
26399a2dd95SBruce Richardson #define RTE_EVENT_DEV_CAP_IMPLICIT_RELEASE_DISABLE    (1ULL << 5)
26499a2dd95SBruce Richardson /**< Event device ports support disabling the implicit release feature, in
26599a2dd95SBruce Richardson  * which the port will release all unreleased events in its dequeue operation.
26699a2dd95SBruce Richardson  * If this capability is set and the port is configured with implicit release
26799a2dd95SBruce Richardson  * disabled, the application is responsible for explicitly releasing events
26899a2dd95SBruce Richardson  * using either the RTE_EVENT_OP_FORWARD or the RTE_EVENT_OP_RELEASE event
26999a2dd95SBruce Richardson  * enqueue operations.
27099a2dd95SBruce Richardson  *
27199a2dd95SBruce Richardson  * @see rte_event_dequeue_burst() rte_event_enqueue_burst()
27299a2dd95SBruce Richardson  */
27399a2dd95SBruce Richardson 
27499a2dd95SBruce Richardson #define RTE_EVENT_DEV_CAP_NONSEQ_MODE         (1ULL << 6)
27599a2dd95SBruce Richardson /**< Event device is capable of operating in none sequential mode. The path
27699a2dd95SBruce Richardson  * of the event is not necessary to be sequential. Application can change
27799a2dd95SBruce Richardson  * the path of event at runtime. If the flag is not set, then event each event
27899a2dd95SBruce Richardson  * will follow a path from queue 0 to queue 1 to queue 2 etc. If the flag is
27999a2dd95SBruce Richardson  * set, events may be sent to queues in any order. If the flag is not set, the
28099a2dd95SBruce Richardson  * eventdev will return an error when the application enqueues an event for a
28199a2dd95SBruce Richardson  * qid which is not the next in the sequence.
28299a2dd95SBruce Richardson  */
28399a2dd95SBruce Richardson 
28499a2dd95SBruce Richardson #define RTE_EVENT_DEV_CAP_RUNTIME_PORT_LINK   (1ULL << 7)
28599a2dd95SBruce Richardson /**< Event device is capable of configuring the queue/port link at runtime.
28699a2dd95SBruce Richardson  * If the flag is not set, the eventdev queue/port link is only can be
28799a2dd95SBruce Richardson  * configured during  initialization.
28899a2dd95SBruce Richardson  */
28999a2dd95SBruce Richardson 
29099a2dd95SBruce Richardson #define RTE_EVENT_DEV_CAP_MULTIPLE_QUEUE_PORT (1ULL << 8)
29199a2dd95SBruce Richardson /**< Event device is capable of setting up the link between multiple queue
29299a2dd95SBruce Richardson  * with single port. If the flag is not set, the eventdev can only map a
29399a2dd95SBruce Richardson  * single queue to each port or map a single queue to many port.
29499a2dd95SBruce Richardson  */
29599a2dd95SBruce Richardson 
29699a2dd95SBruce Richardson #define RTE_EVENT_DEV_CAP_CARRY_FLOW_ID (1ULL << 9)
29799a2dd95SBruce Richardson /**< Event device preserves the flow ID from the enqueued
29899a2dd95SBruce Richardson  * event to the dequeued event if the flag is set. Otherwise,
29999a2dd95SBruce Richardson  * the content of this field is implementation dependent.
30099a2dd95SBruce Richardson  */
30199a2dd95SBruce Richardson 
30299a2dd95SBruce Richardson /* Event device priority levels */
30399a2dd95SBruce Richardson #define RTE_EVENT_DEV_PRIORITY_HIGHEST   0
30499a2dd95SBruce Richardson /**< Highest priority expressed across eventdev subsystem
30599a2dd95SBruce Richardson  * @see rte_event_queue_setup(), rte_event_enqueue_burst()
30699a2dd95SBruce Richardson  * @see rte_event_port_link()
30799a2dd95SBruce Richardson  */
30899a2dd95SBruce Richardson #define RTE_EVENT_DEV_PRIORITY_NORMAL    128
30999a2dd95SBruce Richardson /**< Normal priority expressed across eventdev subsystem
31099a2dd95SBruce Richardson  * @see rte_event_queue_setup(), rte_event_enqueue_burst()
31199a2dd95SBruce Richardson  * @see rte_event_port_link()
31299a2dd95SBruce Richardson  */
31399a2dd95SBruce Richardson #define RTE_EVENT_DEV_PRIORITY_LOWEST    255
31499a2dd95SBruce Richardson /**< Lowest priority expressed across eventdev subsystem
31599a2dd95SBruce Richardson  * @see rte_event_queue_setup(), rte_event_enqueue_burst()
31699a2dd95SBruce Richardson  * @see rte_event_port_link()
31799a2dd95SBruce Richardson  */
31899a2dd95SBruce Richardson 
31999a2dd95SBruce Richardson /**
32099a2dd95SBruce Richardson  * Get the total number of event devices that have been successfully
32199a2dd95SBruce Richardson  * initialised.
32299a2dd95SBruce Richardson  *
32399a2dd95SBruce Richardson  * @return
32499a2dd95SBruce Richardson  *   The total number of usable event devices.
32599a2dd95SBruce Richardson  */
32699a2dd95SBruce Richardson uint8_t
32799a2dd95SBruce Richardson rte_event_dev_count(void);
32899a2dd95SBruce Richardson 
32999a2dd95SBruce Richardson /**
33099a2dd95SBruce Richardson  * Get the device identifier for the named event device.
33199a2dd95SBruce Richardson  *
33299a2dd95SBruce Richardson  * @param name
33399a2dd95SBruce Richardson  *   Event device name to select the event device identifier.
33499a2dd95SBruce Richardson  *
33599a2dd95SBruce Richardson  * @return
33699a2dd95SBruce Richardson  *   Returns event device identifier on success.
33799a2dd95SBruce Richardson  *   - <0: Failure to find named event device.
33899a2dd95SBruce Richardson  */
33999a2dd95SBruce Richardson int
34099a2dd95SBruce Richardson rte_event_dev_get_dev_id(const char *name);
34199a2dd95SBruce Richardson 
34299a2dd95SBruce Richardson /**
34399a2dd95SBruce Richardson  * Return the NUMA socket to which a device is connected.
34499a2dd95SBruce Richardson  *
34599a2dd95SBruce Richardson  * @param dev_id
34699a2dd95SBruce Richardson  *   The identifier of the device.
34799a2dd95SBruce Richardson  * @return
34899a2dd95SBruce Richardson  *   The NUMA socket id to which the device is connected or
34999a2dd95SBruce Richardson  *   a default of zero if the socket could not be determined.
35099a2dd95SBruce Richardson  *   -(-EINVAL)  dev_id value is out of range.
35199a2dd95SBruce Richardson  */
35299a2dd95SBruce Richardson int
35399a2dd95SBruce Richardson rte_event_dev_socket_id(uint8_t dev_id);
35499a2dd95SBruce Richardson 
35599a2dd95SBruce Richardson /**
35699a2dd95SBruce Richardson  * Event device information
35799a2dd95SBruce Richardson  */
35899a2dd95SBruce Richardson struct rte_event_dev_info {
35999a2dd95SBruce Richardson 	const char *driver_name;	/**< Event driver name */
36099a2dd95SBruce Richardson 	struct rte_device *dev;	/**< Device information */
36199a2dd95SBruce Richardson 	uint32_t min_dequeue_timeout_ns;
36299a2dd95SBruce Richardson 	/**< Minimum supported global dequeue timeout(ns) by this device */
36399a2dd95SBruce Richardson 	uint32_t max_dequeue_timeout_ns;
36499a2dd95SBruce Richardson 	/**< Maximum supported global dequeue timeout(ns) by this device */
36599a2dd95SBruce Richardson 	uint32_t dequeue_timeout_ns;
36699a2dd95SBruce Richardson 	/**< Configured global dequeue timeout(ns) for this device */
36799a2dd95SBruce Richardson 	uint8_t max_event_queues;
36899a2dd95SBruce Richardson 	/**< Maximum event_queues supported by this device */
36999a2dd95SBruce Richardson 	uint32_t max_event_queue_flows;
37099a2dd95SBruce Richardson 	/**< Maximum supported flows in an event queue by this device*/
37199a2dd95SBruce Richardson 	uint8_t max_event_queue_priority_levels;
37299a2dd95SBruce Richardson 	/**< Maximum number of event queue priority levels by this device.
37399a2dd95SBruce Richardson 	 * Valid when the device has RTE_EVENT_DEV_CAP_QUEUE_QOS capability
37499a2dd95SBruce Richardson 	 */
37599a2dd95SBruce Richardson 	uint8_t max_event_priority_levels;
37699a2dd95SBruce Richardson 	/**< Maximum number of event priority levels by this device.
37799a2dd95SBruce Richardson 	 * Valid when the device has RTE_EVENT_DEV_CAP_EVENT_QOS capability
37899a2dd95SBruce Richardson 	 */
37999a2dd95SBruce Richardson 	uint8_t max_event_ports;
38099a2dd95SBruce Richardson 	/**< Maximum number of event ports supported by this device */
38199a2dd95SBruce Richardson 	uint8_t max_event_port_dequeue_depth;
38299a2dd95SBruce Richardson 	/**< Maximum number of events can be dequeued at a time from an
38399a2dd95SBruce Richardson 	 * event port by this device.
38499a2dd95SBruce Richardson 	 * A device that does not support bulk dequeue will set this as 1.
38599a2dd95SBruce Richardson 	 */
38699a2dd95SBruce Richardson 	uint32_t max_event_port_enqueue_depth;
38799a2dd95SBruce Richardson 	/**< Maximum number of events can be enqueued at a time from an
38899a2dd95SBruce Richardson 	 * event port by this device.
38999a2dd95SBruce Richardson 	 * A device that does not support bulk enqueue will set this as 1.
39099a2dd95SBruce Richardson 	 */
39199a2dd95SBruce Richardson 	uint8_t max_event_port_links;
39299a2dd95SBruce Richardson 	/**< Maximum number of queues that can be linked to a single event
39399a2dd95SBruce Richardson 	 * port by this device.
39499a2dd95SBruce Richardson 	 */
39599a2dd95SBruce Richardson 	int32_t max_num_events;
39699a2dd95SBruce Richardson 	/**< A *closed system* event dev has a limit on the number of events it
39799a2dd95SBruce Richardson 	 * can manage at a time. An *open system* event dev does not have a
39899a2dd95SBruce Richardson 	 * limit and will specify this as -1.
39999a2dd95SBruce Richardson 	 */
40099a2dd95SBruce Richardson 	uint32_t event_dev_cap;
40199a2dd95SBruce Richardson 	/**< Event device capabilities(RTE_EVENT_DEV_CAP_)*/
40299a2dd95SBruce Richardson 	uint8_t max_single_link_event_port_queue_pairs;
40399a2dd95SBruce Richardson 	/**< Maximum number of event ports and queues that are optimized for
40499a2dd95SBruce Richardson 	 * (and only capable of) single-link configurations supported by this
40599a2dd95SBruce Richardson 	 * device. These ports and queues are not accounted for in
40699a2dd95SBruce Richardson 	 * max_event_ports or max_event_queues.
40799a2dd95SBruce Richardson 	 */
40899a2dd95SBruce Richardson };
40999a2dd95SBruce Richardson 
41099a2dd95SBruce Richardson /**
41199a2dd95SBruce Richardson  * Retrieve the contextual information of an event device.
41299a2dd95SBruce Richardson  *
41399a2dd95SBruce Richardson  * @param dev_id
41499a2dd95SBruce Richardson  *   The identifier of the device.
41599a2dd95SBruce Richardson  *
41699a2dd95SBruce Richardson  * @param[out] dev_info
41799a2dd95SBruce Richardson  *   A pointer to a structure of type *rte_event_dev_info* to be filled with the
41899a2dd95SBruce Richardson  *   contextual information of the device.
41999a2dd95SBruce Richardson  *
42099a2dd95SBruce Richardson  * @return
42199a2dd95SBruce Richardson  *   - 0: Success, driver updates the contextual information of the event device
42299a2dd95SBruce Richardson  *   - <0: Error code returned by the driver info get function.
42399a2dd95SBruce Richardson  *
42499a2dd95SBruce Richardson  */
42599a2dd95SBruce Richardson int
42699a2dd95SBruce Richardson rte_event_dev_info_get(uint8_t dev_id, struct rte_event_dev_info *dev_info);
42799a2dd95SBruce Richardson 
42899a2dd95SBruce Richardson /**
42999a2dd95SBruce Richardson  * The count of ports.
43099a2dd95SBruce Richardson  */
43199a2dd95SBruce Richardson #define RTE_EVENT_DEV_ATTR_PORT_COUNT 0
43299a2dd95SBruce Richardson /**
43399a2dd95SBruce Richardson  * The count of queues.
43499a2dd95SBruce Richardson  */
43599a2dd95SBruce Richardson #define RTE_EVENT_DEV_ATTR_QUEUE_COUNT 1
43699a2dd95SBruce Richardson /**
43799a2dd95SBruce Richardson  * The status of the device, zero for stopped, non-zero for started.
43899a2dd95SBruce Richardson  */
43999a2dd95SBruce Richardson #define RTE_EVENT_DEV_ATTR_STARTED 2
44099a2dd95SBruce Richardson 
44199a2dd95SBruce Richardson /**
44299a2dd95SBruce Richardson  * Get an attribute from a device.
44399a2dd95SBruce Richardson  *
44499a2dd95SBruce Richardson  * @param dev_id Eventdev id
44599a2dd95SBruce Richardson  * @param attr_id The attribute ID to retrieve
44699a2dd95SBruce Richardson  * @param[out] attr_value A pointer that will be filled in with the attribute
44799a2dd95SBruce Richardson  *             value if successful.
44899a2dd95SBruce Richardson  *
44999a2dd95SBruce Richardson  * @return
45099a2dd95SBruce Richardson  *   - 0: Successfully retrieved attribute value
45199a2dd95SBruce Richardson  *   - -EINVAL: Invalid device or  *attr_id* provided, or *attr_value* is NULL
45299a2dd95SBruce Richardson  */
45399a2dd95SBruce Richardson int
45499a2dd95SBruce Richardson rte_event_dev_attr_get(uint8_t dev_id, uint32_t attr_id,
45599a2dd95SBruce Richardson 		       uint32_t *attr_value);
45699a2dd95SBruce Richardson 
45799a2dd95SBruce Richardson 
45899a2dd95SBruce Richardson /* Event device configuration bitmap flags */
45999a2dd95SBruce Richardson #define RTE_EVENT_DEV_CFG_PER_DEQUEUE_TIMEOUT (1ULL << 0)
46099a2dd95SBruce Richardson /**< Override the global *dequeue_timeout_ns* and use per dequeue timeout in ns.
46199a2dd95SBruce Richardson  *  @see rte_event_dequeue_timeout_ticks(), rte_event_dequeue_burst()
46299a2dd95SBruce Richardson  */
46399a2dd95SBruce Richardson 
46499a2dd95SBruce Richardson /** Event device configuration structure */
46599a2dd95SBruce Richardson struct rte_event_dev_config {
46699a2dd95SBruce Richardson 	uint32_t dequeue_timeout_ns;
46799a2dd95SBruce Richardson 	/**< rte_event_dequeue_burst() timeout on this device.
46899a2dd95SBruce Richardson 	 * This value should be in the range of *min_dequeue_timeout_ns* and
46999a2dd95SBruce Richardson 	 * *max_dequeue_timeout_ns* which previously provided in
47099a2dd95SBruce Richardson 	 * rte_event_dev_info_get()
47199a2dd95SBruce Richardson 	 * The value 0 is allowed, in which case, default dequeue timeout used.
47299a2dd95SBruce Richardson 	 * @see RTE_EVENT_DEV_CFG_PER_DEQUEUE_TIMEOUT
47399a2dd95SBruce Richardson 	 */
47499a2dd95SBruce Richardson 	int32_t nb_events_limit;
47599a2dd95SBruce Richardson 	/**< In a *closed system* this field is the limit on maximum number of
47699a2dd95SBruce Richardson 	 * events that can be inflight in the eventdev at a given time. The
47799a2dd95SBruce Richardson 	 * limit is required to ensure that the finite space in a closed system
47899a2dd95SBruce Richardson 	 * is not overwhelmed. The value cannot exceed the *max_num_events*
47999a2dd95SBruce Richardson 	 * as provided by rte_event_dev_info_get().
48099a2dd95SBruce Richardson 	 * This value should be set to -1 for *open system*.
48199a2dd95SBruce Richardson 	 */
48299a2dd95SBruce Richardson 	uint8_t nb_event_queues;
48399a2dd95SBruce Richardson 	/**< Number of event queues to configure on this device.
48499a2dd95SBruce Richardson 	 * This value cannot exceed the *max_event_queues* which previously
48599a2dd95SBruce Richardson 	 * provided in rte_event_dev_info_get()
48699a2dd95SBruce Richardson 	 */
48799a2dd95SBruce Richardson 	uint8_t nb_event_ports;
48899a2dd95SBruce Richardson 	/**< Number of event ports to configure on this device.
48999a2dd95SBruce Richardson 	 * This value cannot exceed the *max_event_ports* which previously
49099a2dd95SBruce Richardson 	 * provided in rte_event_dev_info_get()
49199a2dd95SBruce Richardson 	 */
49299a2dd95SBruce Richardson 	uint32_t nb_event_queue_flows;
49399a2dd95SBruce Richardson 	/**< Number of flows for any event queue on this device.
49499a2dd95SBruce Richardson 	 * This value cannot exceed the *max_event_queue_flows* which previously
49599a2dd95SBruce Richardson 	 * provided in rte_event_dev_info_get()
49699a2dd95SBruce Richardson 	 */
49799a2dd95SBruce Richardson 	uint32_t nb_event_port_dequeue_depth;
49899a2dd95SBruce Richardson 	/**< Maximum number of events can be dequeued at a time from an
49999a2dd95SBruce Richardson 	 * event port by this device.
50099a2dd95SBruce Richardson 	 * This value cannot exceed the *max_event_port_dequeue_depth*
50199a2dd95SBruce Richardson 	 * which previously provided in rte_event_dev_info_get().
50299a2dd95SBruce Richardson 	 * Ignored when device is not RTE_EVENT_DEV_CAP_BURST_MODE capable.
50399a2dd95SBruce Richardson 	 * @see rte_event_port_setup()
50499a2dd95SBruce Richardson 	 */
50599a2dd95SBruce Richardson 	uint32_t nb_event_port_enqueue_depth;
50699a2dd95SBruce Richardson 	/**< Maximum number of events can be enqueued at a time from an
50799a2dd95SBruce Richardson 	 * event port by this device.
50899a2dd95SBruce Richardson 	 * This value cannot exceed the *max_event_port_enqueue_depth*
50999a2dd95SBruce Richardson 	 * which previously provided in rte_event_dev_info_get().
51099a2dd95SBruce Richardson 	 * Ignored when device is not RTE_EVENT_DEV_CAP_BURST_MODE capable.
51199a2dd95SBruce Richardson 	 * @see rte_event_port_setup()
51299a2dd95SBruce Richardson 	 */
51399a2dd95SBruce Richardson 	uint32_t event_dev_cfg;
51499a2dd95SBruce Richardson 	/**< Event device config flags(RTE_EVENT_DEV_CFG_)*/
51599a2dd95SBruce Richardson 	uint8_t nb_single_link_event_port_queues;
51699a2dd95SBruce Richardson 	/**< Number of event ports and queues that will be singly-linked to
51799a2dd95SBruce Richardson 	 * each other. These are a subset of the overall event ports and
51899a2dd95SBruce Richardson 	 * queues; this value cannot exceed *nb_event_ports* or
51999a2dd95SBruce Richardson 	 * *nb_event_queues*. If the device has ports and queues that are
52099a2dd95SBruce Richardson 	 * optimized for single-link usage, this field is a hint for how many
52199a2dd95SBruce Richardson 	 * to allocate; otherwise, regular event ports and queues can be used.
52299a2dd95SBruce Richardson 	 */
52399a2dd95SBruce Richardson };
52499a2dd95SBruce Richardson 
52599a2dd95SBruce Richardson /**
52699a2dd95SBruce Richardson  * Configure an event device.
52799a2dd95SBruce Richardson  *
52899a2dd95SBruce Richardson  * This function must be invoked first before any other function in the
52999a2dd95SBruce Richardson  * API. This function can also be re-invoked when a device is in the
53099a2dd95SBruce Richardson  * stopped state.
53199a2dd95SBruce Richardson  *
53299a2dd95SBruce Richardson  * The caller may use rte_event_dev_info_get() to get the capability of each
53399a2dd95SBruce Richardson  * resources available for this event device.
53499a2dd95SBruce Richardson  *
53599a2dd95SBruce Richardson  * @param dev_id
53699a2dd95SBruce Richardson  *   The identifier of the device to configure.
53799a2dd95SBruce Richardson  * @param dev_conf
53899a2dd95SBruce Richardson  *   The event device configuration structure.
53999a2dd95SBruce Richardson  *
54099a2dd95SBruce Richardson  * @return
54199a2dd95SBruce Richardson  *   - 0: Success, device configured.
54299a2dd95SBruce Richardson  *   - <0: Error code returned by the driver configuration function.
54399a2dd95SBruce Richardson  */
54499a2dd95SBruce Richardson int
54599a2dd95SBruce Richardson rte_event_dev_configure(uint8_t dev_id,
54699a2dd95SBruce Richardson 			const struct rte_event_dev_config *dev_conf);
54799a2dd95SBruce Richardson 
54899a2dd95SBruce Richardson /* Event queue specific APIs */
54999a2dd95SBruce Richardson 
55099a2dd95SBruce Richardson /* Event queue configuration bitmap flags */
55199a2dd95SBruce Richardson #define RTE_EVENT_QUEUE_CFG_ALL_TYPES          (1ULL << 0)
55299a2dd95SBruce Richardson /**< Allow ATOMIC,ORDERED,PARALLEL schedule type enqueue
55399a2dd95SBruce Richardson  *
55499a2dd95SBruce Richardson  * @see RTE_SCHED_TYPE_ORDERED, RTE_SCHED_TYPE_ATOMIC, RTE_SCHED_TYPE_PARALLEL
55599a2dd95SBruce Richardson  * @see rte_event_enqueue_burst()
55699a2dd95SBruce Richardson  */
55799a2dd95SBruce Richardson #define RTE_EVENT_QUEUE_CFG_SINGLE_LINK        (1ULL << 1)
55899a2dd95SBruce Richardson /**< This event queue links only to a single event port.
55999a2dd95SBruce Richardson  *
56099a2dd95SBruce Richardson  *  @see rte_event_port_setup(), rte_event_port_link()
56199a2dd95SBruce Richardson  */
56299a2dd95SBruce Richardson 
56399a2dd95SBruce Richardson /** Event queue configuration structure */
56499a2dd95SBruce Richardson struct rte_event_queue_conf {
56599a2dd95SBruce Richardson 	uint32_t nb_atomic_flows;
56699a2dd95SBruce Richardson 	/**< The maximum number of active flows this queue can track at any
56799a2dd95SBruce Richardson 	 * given time. If the queue is configured for atomic scheduling (by
56899a2dd95SBruce Richardson 	 * applying the RTE_EVENT_QUEUE_CFG_ALL_TYPES flag to event_queue_cfg
56999a2dd95SBruce Richardson 	 * or RTE_SCHED_TYPE_ATOMIC flag to schedule_type), then the
57099a2dd95SBruce Richardson 	 * value must be in the range of [1, nb_event_queue_flows], which was
57199a2dd95SBruce Richardson 	 * previously provided in rte_event_dev_configure().
57299a2dd95SBruce Richardson 	 */
57399a2dd95SBruce Richardson 	uint32_t nb_atomic_order_sequences;
57499a2dd95SBruce Richardson 	/**< The maximum number of outstanding events waiting to be
57599a2dd95SBruce Richardson 	 * reordered by this queue. In other words, the number of entries in
57699a2dd95SBruce Richardson 	 * this queue’s reorder buffer.When the number of events in the
57799a2dd95SBruce Richardson 	 * reorder buffer reaches to *nb_atomic_order_sequences* then the
57899a2dd95SBruce Richardson 	 * scheduler cannot schedule the events from this queue and invalid
57999a2dd95SBruce Richardson 	 * event will be returned from dequeue until one or more entries are
58099a2dd95SBruce Richardson 	 * freed up/released.
58199a2dd95SBruce Richardson 	 * If the queue is configured for ordered scheduling (by applying the
58299a2dd95SBruce Richardson 	 * RTE_EVENT_QUEUE_CFG_ALL_TYPES flag to event_queue_cfg or
58399a2dd95SBruce Richardson 	 * RTE_SCHED_TYPE_ORDERED flag to schedule_type), then the value must
58499a2dd95SBruce Richardson 	 * be in the range of [1, nb_event_queue_flows], which was
58599a2dd95SBruce Richardson 	 * previously supplied to rte_event_dev_configure().
58699a2dd95SBruce Richardson 	 */
58799a2dd95SBruce Richardson 	uint32_t event_queue_cfg;
58899a2dd95SBruce Richardson 	/**< Queue cfg flags(EVENT_QUEUE_CFG_) */
58999a2dd95SBruce Richardson 	uint8_t schedule_type;
59099a2dd95SBruce Richardson 	/**< Queue schedule type(RTE_SCHED_TYPE_*).
59199a2dd95SBruce Richardson 	 * Valid when RTE_EVENT_QUEUE_CFG_ALL_TYPES bit is not set in
59299a2dd95SBruce Richardson 	 * event_queue_cfg.
59399a2dd95SBruce Richardson 	 */
59499a2dd95SBruce Richardson 	uint8_t priority;
59599a2dd95SBruce Richardson 	/**< Priority for this event queue relative to other event queues.
59699a2dd95SBruce Richardson 	 * The requested priority should in the range of
59799a2dd95SBruce Richardson 	 * [RTE_EVENT_DEV_PRIORITY_HIGHEST, RTE_EVENT_DEV_PRIORITY_LOWEST].
59899a2dd95SBruce Richardson 	 * The implementation shall normalize the requested priority to
59999a2dd95SBruce Richardson 	 * event device supported priority value.
60099a2dd95SBruce Richardson 	 * Valid when the device has RTE_EVENT_DEV_CAP_QUEUE_QOS capability
60199a2dd95SBruce Richardson 	 */
60299a2dd95SBruce Richardson };
60399a2dd95SBruce Richardson 
60499a2dd95SBruce Richardson /**
60599a2dd95SBruce Richardson  * Retrieve the default configuration information of an event queue designated
60699a2dd95SBruce Richardson  * by its *queue_id* from the event driver for an event device.
60799a2dd95SBruce Richardson  *
60899a2dd95SBruce Richardson  * This function intended to be used in conjunction with rte_event_queue_setup()
60999a2dd95SBruce Richardson  * where caller needs to set up the queue by overriding few default values.
61099a2dd95SBruce Richardson  *
61199a2dd95SBruce Richardson  * @param dev_id
61299a2dd95SBruce Richardson  *   The identifier of the device.
61399a2dd95SBruce Richardson  * @param queue_id
61499a2dd95SBruce Richardson  *   The index of the event queue to get the configuration information.
61599a2dd95SBruce Richardson  *   The value must be in the range [0, nb_event_queues - 1]
61699a2dd95SBruce Richardson  *   previously supplied to rte_event_dev_configure().
61799a2dd95SBruce Richardson  * @param[out] queue_conf
61899a2dd95SBruce Richardson  *   The pointer to the default event queue configuration data.
61999a2dd95SBruce Richardson  * @return
62099a2dd95SBruce Richardson  *   - 0: Success, driver updates the default event queue configuration data.
62199a2dd95SBruce Richardson  *   - <0: Error code returned by the driver info get function.
62299a2dd95SBruce Richardson  *
62399a2dd95SBruce Richardson  * @see rte_event_queue_setup()
62499a2dd95SBruce Richardson  *
62599a2dd95SBruce Richardson  */
62699a2dd95SBruce Richardson int
62799a2dd95SBruce Richardson rte_event_queue_default_conf_get(uint8_t dev_id, uint8_t queue_id,
62899a2dd95SBruce Richardson 				 struct rte_event_queue_conf *queue_conf);
62999a2dd95SBruce Richardson 
63099a2dd95SBruce Richardson /**
63199a2dd95SBruce Richardson  * Allocate and set up an event queue for an event device.
63299a2dd95SBruce Richardson  *
63399a2dd95SBruce Richardson  * @param dev_id
63499a2dd95SBruce Richardson  *   The identifier of the device.
63599a2dd95SBruce Richardson  * @param queue_id
63699a2dd95SBruce Richardson  *   The index of the event queue to setup. The value must be in the range
63799a2dd95SBruce Richardson  *   [0, nb_event_queues - 1] previously supplied to rte_event_dev_configure().
63899a2dd95SBruce Richardson  * @param queue_conf
63999a2dd95SBruce Richardson  *   The pointer to the configuration data to be used for the event queue.
64099a2dd95SBruce Richardson  *   NULL value is allowed, in which case default configuration	used.
64199a2dd95SBruce Richardson  *
64299a2dd95SBruce Richardson  * @see rte_event_queue_default_conf_get()
64399a2dd95SBruce Richardson  *
64499a2dd95SBruce Richardson  * @return
64599a2dd95SBruce Richardson  *   - 0: Success, event queue correctly set up.
64699a2dd95SBruce Richardson  *   - <0: event queue configuration failed
64799a2dd95SBruce Richardson  */
64899a2dd95SBruce Richardson int
64999a2dd95SBruce Richardson rte_event_queue_setup(uint8_t dev_id, uint8_t queue_id,
65099a2dd95SBruce Richardson 		      const struct rte_event_queue_conf *queue_conf);
65199a2dd95SBruce Richardson 
65299a2dd95SBruce Richardson /**
65399a2dd95SBruce Richardson  * The priority of the queue.
65499a2dd95SBruce Richardson  */
65599a2dd95SBruce Richardson #define RTE_EVENT_QUEUE_ATTR_PRIORITY 0
65699a2dd95SBruce Richardson /**
65799a2dd95SBruce Richardson  * The number of atomic flows configured for the queue.
65899a2dd95SBruce Richardson  */
65999a2dd95SBruce Richardson #define RTE_EVENT_QUEUE_ATTR_NB_ATOMIC_FLOWS 1
66099a2dd95SBruce Richardson /**
66199a2dd95SBruce Richardson  * The number of atomic order sequences configured for the queue.
66299a2dd95SBruce Richardson  */
66399a2dd95SBruce Richardson #define RTE_EVENT_QUEUE_ATTR_NB_ATOMIC_ORDER_SEQUENCES 2
66499a2dd95SBruce Richardson /**
66599a2dd95SBruce Richardson  * The cfg flags for the queue.
66699a2dd95SBruce Richardson  */
66799a2dd95SBruce Richardson #define RTE_EVENT_QUEUE_ATTR_EVENT_QUEUE_CFG 3
66899a2dd95SBruce Richardson /**
66999a2dd95SBruce Richardson  * The schedule type of the queue.
67099a2dd95SBruce Richardson  */
67199a2dd95SBruce Richardson #define RTE_EVENT_QUEUE_ATTR_SCHEDULE_TYPE 4
67299a2dd95SBruce Richardson 
67399a2dd95SBruce Richardson /**
67499a2dd95SBruce Richardson  * Get an attribute from a queue.
67599a2dd95SBruce Richardson  *
67699a2dd95SBruce Richardson  * @param dev_id
67799a2dd95SBruce Richardson  *   Eventdev id
67899a2dd95SBruce Richardson  * @param queue_id
67999a2dd95SBruce Richardson  *   Eventdev queue id
68099a2dd95SBruce Richardson  * @param attr_id
68199a2dd95SBruce Richardson  *   The attribute ID to retrieve
68299a2dd95SBruce Richardson  * @param[out] attr_value
68399a2dd95SBruce Richardson  *   A pointer that will be filled in with the attribute value if successful
68499a2dd95SBruce Richardson  *
68599a2dd95SBruce Richardson  * @return
68699a2dd95SBruce Richardson  *   - 0: Successfully returned value
68799a2dd95SBruce Richardson  *   - -EINVAL: invalid device, queue or attr_id provided, or attr_value was
68899a2dd95SBruce Richardson  *		NULL
68999a2dd95SBruce Richardson  *   - -EOVERFLOW: returned when attr_id is set to
69099a2dd95SBruce Richardson  *   RTE_EVENT_QUEUE_ATTR_SCHEDULE_TYPE and event_queue_cfg is set to
69199a2dd95SBruce Richardson  *   RTE_EVENT_QUEUE_CFG_ALL_TYPES
69299a2dd95SBruce Richardson  */
69399a2dd95SBruce Richardson int
69499a2dd95SBruce Richardson rte_event_queue_attr_get(uint8_t dev_id, uint8_t queue_id, uint32_t attr_id,
69599a2dd95SBruce Richardson 			uint32_t *attr_value);
69699a2dd95SBruce Richardson 
69799a2dd95SBruce Richardson /* Event port specific APIs */
69899a2dd95SBruce Richardson 
69999a2dd95SBruce Richardson /* Event port configuration bitmap flags */
70099a2dd95SBruce Richardson #define RTE_EVENT_PORT_CFG_DISABLE_IMPL_REL    (1ULL << 0)
70199a2dd95SBruce Richardson /**< Configure the port not to release outstanding events in
70299a2dd95SBruce Richardson  * rte_event_dev_dequeue_burst(). If set, all events received through
70399a2dd95SBruce Richardson  * the port must be explicitly released with RTE_EVENT_OP_RELEASE or
70499a2dd95SBruce Richardson  * RTE_EVENT_OP_FORWARD. Must be unset if the device is not
70599a2dd95SBruce Richardson  * RTE_EVENT_DEV_CAP_IMPLICIT_RELEASE_DISABLE capable.
70699a2dd95SBruce Richardson  */
70799a2dd95SBruce Richardson #define RTE_EVENT_PORT_CFG_SINGLE_LINK         (1ULL << 1)
70899a2dd95SBruce Richardson /**< This event port links only to a single event queue.
70999a2dd95SBruce Richardson  *
71099a2dd95SBruce Richardson  *  @see rte_event_port_setup(), rte_event_port_link()
71199a2dd95SBruce Richardson  */
71299a2dd95SBruce Richardson 
71399a2dd95SBruce Richardson /** Event port configuration structure */
71499a2dd95SBruce Richardson struct rte_event_port_conf {
71599a2dd95SBruce Richardson 	int32_t new_event_threshold;
71699a2dd95SBruce Richardson 	/**< A backpressure threshold for new event enqueues on this port.
71799a2dd95SBruce Richardson 	 * Use for *closed system* event dev where event capacity is limited,
71899a2dd95SBruce Richardson 	 * and cannot exceed the capacity of the event dev.
71999a2dd95SBruce Richardson 	 * Configuring ports with different thresholds can make higher priority
72099a2dd95SBruce Richardson 	 * traffic less likely to  be backpressured.
72199a2dd95SBruce Richardson 	 * For example, a port used to inject NIC Rx packets into the event dev
72299a2dd95SBruce Richardson 	 * can have a lower threshold so as not to overwhelm the device,
72399a2dd95SBruce Richardson 	 * while ports used for worker pools can have a higher threshold.
72499a2dd95SBruce Richardson 	 * This value cannot exceed the *nb_events_limit*
72599a2dd95SBruce Richardson 	 * which was previously supplied to rte_event_dev_configure().
72699a2dd95SBruce Richardson 	 * This should be set to '-1' for *open system*.
72799a2dd95SBruce Richardson 	 */
72899a2dd95SBruce Richardson 	uint16_t dequeue_depth;
72999a2dd95SBruce Richardson 	/**< Configure number of bulk dequeues for this event port.
73099a2dd95SBruce Richardson 	 * This value cannot exceed the *nb_event_port_dequeue_depth*
73199a2dd95SBruce Richardson 	 * which previously supplied to rte_event_dev_configure().
73299a2dd95SBruce Richardson 	 * Ignored when device is not RTE_EVENT_DEV_CAP_BURST_MODE capable.
73399a2dd95SBruce Richardson 	 */
73499a2dd95SBruce Richardson 	uint16_t enqueue_depth;
73599a2dd95SBruce Richardson 	/**< Configure number of bulk enqueues for this event port.
73699a2dd95SBruce Richardson 	 * This value cannot exceed the *nb_event_port_enqueue_depth*
73799a2dd95SBruce Richardson 	 * which previously supplied to rte_event_dev_configure().
73899a2dd95SBruce Richardson 	 * Ignored when device is not RTE_EVENT_DEV_CAP_BURST_MODE capable.
73999a2dd95SBruce Richardson 	 */
74099a2dd95SBruce Richardson 	uint32_t event_port_cfg; /**< Port cfg flags(EVENT_PORT_CFG_) */
74199a2dd95SBruce Richardson };
74299a2dd95SBruce Richardson 
74399a2dd95SBruce Richardson /**
74499a2dd95SBruce Richardson  * Retrieve the default configuration information of an event port designated
74599a2dd95SBruce Richardson  * by its *port_id* from the event driver for an event device.
74699a2dd95SBruce Richardson  *
74799a2dd95SBruce Richardson  * This function intended to be used in conjunction with rte_event_port_setup()
74899a2dd95SBruce Richardson  * where caller needs to set up the port by overriding few default values.
74999a2dd95SBruce Richardson  *
75099a2dd95SBruce Richardson  * @param dev_id
75199a2dd95SBruce Richardson  *   The identifier of the device.
75299a2dd95SBruce Richardson  * @param port_id
75399a2dd95SBruce Richardson  *   The index of the event port to get the configuration information.
75499a2dd95SBruce Richardson  *   The value must be in the range [0, nb_event_ports - 1]
75599a2dd95SBruce Richardson  *   previously supplied to rte_event_dev_configure().
75699a2dd95SBruce Richardson  * @param[out] port_conf
75799a2dd95SBruce Richardson  *   The pointer to the default event port configuration data
75899a2dd95SBruce Richardson  * @return
75999a2dd95SBruce Richardson  *   - 0: Success, driver updates the default event port configuration data.
76099a2dd95SBruce Richardson  *   - <0: Error code returned by the driver info get function.
76199a2dd95SBruce Richardson  *
76299a2dd95SBruce Richardson  * @see rte_event_port_setup()
76399a2dd95SBruce Richardson  *
76499a2dd95SBruce Richardson  */
76599a2dd95SBruce Richardson int
76699a2dd95SBruce Richardson rte_event_port_default_conf_get(uint8_t dev_id, uint8_t port_id,
76799a2dd95SBruce Richardson 				struct rte_event_port_conf *port_conf);
76899a2dd95SBruce Richardson 
76999a2dd95SBruce Richardson /**
77099a2dd95SBruce Richardson  * Allocate and set up an event port for an event device.
77199a2dd95SBruce Richardson  *
77299a2dd95SBruce Richardson  * @param dev_id
77399a2dd95SBruce Richardson  *   The identifier of the device.
77499a2dd95SBruce Richardson  * @param port_id
77599a2dd95SBruce Richardson  *   The index of the event port to setup. The value must be in the range
77699a2dd95SBruce Richardson  *   [0, nb_event_ports - 1] previously supplied to rte_event_dev_configure().
77799a2dd95SBruce Richardson  * @param port_conf
77899a2dd95SBruce Richardson  *   The pointer to the configuration data to be used for the queue.
77999a2dd95SBruce Richardson  *   NULL value is allowed, in which case default configuration	used.
78099a2dd95SBruce Richardson  *
78199a2dd95SBruce Richardson  * @see rte_event_port_default_conf_get()
78299a2dd95SBruce Richardson  *
78399a2dd95SBruce Richardson  * @return
78499a2dd95SBruce Richardson  *   - 0: Success, event port correctly set up.
78599a2dd95SBruce Richardson  *   - <0: Port configuration failed
78699a2dd95SBruce Richardson  *   - (-EDQUOT) Quota exceeded(Application tried to link the queue configured
78799a2dd95SBruce Richardson  *   with RTE_EVENT_QUEUE_CFG_SINGLE_LINK to more than one event ports)
78899a2dd95SBruce Richardson  */
78999a2dd95SBruce Richardson int
79099a2dd95SBruce Richardson rte_event_port_setup(uint8_t dev_id, uint8_t port_id,
79199a2dd95SBruce Richardson 		     const struct rte_event_port_conf *port_conf);
79299a2dd95SBruce Richardson 
79399a2dd95SBruce Richardson /**
79499a2dd95SBruce Richardson  * The queue depth of the port on the enqueue side
79599a2dd95SBruce Richardson  */
79699a2dd95SBruce Richardson #define RTE_EVENT_PORT_ATTR_ENQ_DEPTH 0
79799a2dd95SBruce Richardson /**
79899a2dd95SBruce Richardson  * The queue depth of the port on the dequeue side
79999a2dd95SBruce Richardson  */
80099a2dd95SBruce Richardson #define RTE_EVENT_PORT_ATTR_DEQ_DEPTH 1
80199a2dd95SBruce Richardson /**
80299a2dd95SBruce Richardson  * The new event threshold of the port
80399a2dd95SBruce Richardson  */
80499a2dd95SBruce Richardson #define RTE_EVENT_PORT_ATTR_NEW_EVENT_THRESHOLD 2
80599a2dd95SBruce Richardson /**
80699a2dd95SBruce Richardson  * The implicit release disable attribute of the port
80799a2dd95SBruce Richardson  */
80899a2dd95SBruce Richardson #define RTE_EVENT_PORT_ATTR_IMPLICIT_RELEASE_DISABLE 3
80999a2dd95SBruce Richardson 
81099a2dd95SBruce Richardson /**
81199a2dd95SBruce Richardson  * Get an attribute from a port.
81299a2dd95SBruce Richardson  *
81399a2dd95SBruce Richardson  * @param dev_id
81499a2dd95SBruce Richardson  *   Eventdev id
81599a2dd95SBruce Richardson  * @param port_id
81699a2dd95SBruce Richardson  *   Eventdev port id
81799a2dd95SBruce Richardson  * @param attr_id
81899a2dd95SBruce Richardson  *   The attribute ID to retrieve
81999a2dd95SBruce Richardson  * @param[out] attr_value
82099a2dd95SBruce Richardson  *   A pointer that will be filled in with the attribute value if successful
82199a2dd95SBruce Richardson  *
82299a2dd95SBruce Richardson  * @return
82399a2dd95SBruce Richardson  *   - 0: Successfully returned value
82499a2dd95SBruce Richardson  *   - (-EINVAL) Invalid device, port or attr_id, or attr_value was NULL
82599a2dd95SBruce Richardson  */
82699a2dd95SBruce Richardson int
82799a2dd95SBruce Richardson rte_event_port_attr_get(uint8_t dev_id, uint8_t port_id, uint32_t attr_id,
82899a2dd95SBruce Richardson 			uint32_t *attr_value);
82999a2dd95SBruce Richardson 
83099a2dd95SBruce Richardson /**
83199a2dd95SBruce Richardson  * Start an event device.
83299a2dd95SBruce Richardson  *
83399a2dd95SBruce Richardson  * The device start step is the last one and consists of setting the event
83499a2dd95SBruce Richardson  * queues to start accepting the events and schedules to event ports.
83599a2dd95SBruce Richardson  *
83699a2dd95SBruce Richardson  * On success, all basic functions exported by the API (event enqueue,
83799a2dd95SBruce Richardson  * event dequeue and so on) can be invoked.
83899a2dd95SBruce Richardson  *
83999a2dd95SBruce Richardson  * @param dev_id
84099a2dd95SBruce Richardson  *   Event device identifier
84199a2dd95SBruce Richardson  * @return
84299a2dd95SBruce Richardson  *   - 0: Success, device started.
84399a2dd95SBruce Richardson  *   - -ESTALE : Not all ports of the device are configured
84499a2dd95SBruce Richardson  *   - -ENOLINK: Not all queues are linked, which could lead to deadlock.
84599a2dd95SBruce Richardson  */
84699a2dd95SBruce Richardson int
84799a2dd95SBruce Richardson rte_event_dev_start(uint8_t dev_id);
84899a2dd95SBruce Richardson 
84999a2dd95SBruce Richardson /**
85099a2dd95SBruce Richardson  * Stop an event device.
85199a2dd95SBruce Richardson  *
85299a2dd95SBruce Richardson  * This function causes all queued events to be drained, including those
85399a2dd95SBruce Richardson  * residing in event ports. While draining events out of the device, this
85499a2dd95SBruce Richardson  * function calls the user-provided flush callback (if one was registered) once
85599a2dd95SBruce Richardson  * per event.
85699a2dd95SBruce Richardson  *
85799a2dd95SBruce Richardson  * The device can be restarted with a call to rte_event_dev_start(). Threads
85899a2dd95SBruce Richardson  * that continue to enqueue/dequeue while the device is stopped, or being
85999a2dd95SBruce Richardson  * stopped, will result in undefined behavior. This includes event adapters,
86099a2dd95SBruce Richardson  * which must be stopped prior to stopping the eventdev.
86199a2dd95SBruce Richardson  *
86299a2dd95SBruce Richardson  * @param dev_id
86399a2dd95SBruce Richardson  *   Event device identifier.
86499a2dd95SBruce Richardson  *
86599a2dd95SBruce Richardson  * @see rte_event_dev_stop_flush_callback_register()
86699a2dd95SBruce Richardson  */
86799a2dd95SBruce Richardson void
86899a2dd95SBruce Richardson rte_event_dev_stop(uint8_t dev_id);
86999a2dd95SBruce Richardson 
87099a2dd95SBruce Richardson typedef void (*eventdev_stop_flush_t)(uint8_t dev_id, struct rte_event event,
87199a2dd95SBruce Richardson 		void *arg);
87299a2dd95SBruce Richardson /**< Callback function called during rte_event_dev_stop(), invoked once per
87399a2dd95SBruce Richardson  * flushed event.
87499a2dd95SBruce Richardson  */
87599a2dd95SBruce Richardson 
87699a2dd95SBruce Richardson /**
87799a2dd95SBruce Richardson  * Registers a callback function to be invoked during rte_event_dev_stop() for
87899a2dd95SBruce Richardson  * each flushed event. This function can be used to properly dispose of queued
87999a2dd95SBruce Richardson  * events, for example events containing memory pointers.
88099a2dd95SBruce Richardson  *
88199a2dd95SBruce Richardson  * The callback function is only registered for the calling process. The
88299a2dd95SBruce Richardson  * callback function must be registered in every process that can call
88399a2dd95SBruce Richardson  * rte_event_dev_stop().
88499a2dd95SBruce Richardson  *
88599a2dd95SBruce Richardson  * To unregister a callback, call this function with a NULL callback pointer.
88699a2dd95SBruce Richardson  *
88799a2dd95SBruce Richardson  * @param dev_id
88899a2dd95SBruce Richardson  *   The identifier of the device.
88999a2dd95SBruce Richardson  * @param callback
89099a2dd95SBruce Richardson  *   Callback function invoked once per flushed event.
89199a2dd95SBruce Richardson  * @param userdata
89299a2dd95SBruce Richardson  *   Argument supplied to callback.
89399a2dd95SBruce Richardson  *
89499a2dd95SBruce Richardson  * @return
89599a2dd95SBruce Richardson  *  - 0 on success.
89699a2dd95SBruce Richardson  *  - -EINVAL if *dev_id* is invalid
89799a2dd95SBruce Richardson  *
89899a2dd95SBruce Richardson  * @see rte_event_dev_stop()
89999a2dd95SBruce Richardson  */
90099a2dd95SBruce Richardson int
90199a2dd95SBruce Richardson rte_event_dev_stop_flush_callback_register(uint8_t dev_id,
90299a2dd95SBruce Richardson 		eventdev_stop_flush_t callback, void *userdata);
90399a2dd95SBruce Richardson 
90499a2dd95SBruce Richardson /**
90599a2dd95SBruce Richardson  * Close an event device. The device cannot be restarted!
90699a2dd95SBruce Richardson  *
90799a2dd95SBruce Richardson  * @param dev_id
90899a2dd95SBruce Richardson  *   Event device identifier
90999a2dd95SBruce Richardson  *
91099a2dd95SBruce Richardson  * @return
91199a2dd95SBruce Richardson  *  - 0 on successfully closing device
91299a2dd95SBruce Richardson  *  - <0 on failure to close device
91399a2dd95SBruce Richardson  *  - (-EAGAIN) if device is busy
91499a2dd95SBruce Richardson  */
91599a2dd95SBruce Richardson int
91699a2dd95SBruce Richardson rte_event_dev_close(uint8_t dev_id);
91799a2dd95SBruce Richardson 
91899a2dd95SBruce Richardson /**
91999a2dd95SBruce Richardson  * Event vector structure.
92099a2dd95SBruce Richardson  */
92199a2dd95SBruce Richardson struct rte_event_vector {
92299a2dd95SBruce Richardson 	uint16_t nb_elem;
92399a2dd95SBruce Richardson 	/**< Number of elements in this event vector. */
92499a2dd95SBruce Richardson 	uint16_t rsvd : 15;
92599a2dd95SBruce Richardson 	/**< Reserved for future use */
92699a2dd95SBruce Richardson 	uint16_t attr_valid : 1;
92799a2dd95SBruce Richardson 	/**< Indicates that the below union attributes have valid information.
92899a2dd95SBruce Richardson 	 */
92999a2dd95SBruce Richardson 	union {
93099a2dd95SBruce Richardson 		/* Used by Rx/Tx adapter.
93199a2dd95SBruce Richardson 		 * Indicates that all the elements in this vector belong to the
93299a2dd95SBruce Richardson 		 * same port and queue pair when originating from Rx adapter,
93399a2dd95SBruce Richardson 		 * valid only when event type is ETHDEV_VECTOR or
93499a2dd95SBruce Richardson 		 * ETH_RX_ADAPTER_VECTOR.
93599a2dd95SBruce Richardson 		 * Can also be used to indicate the Tx adapter the destination
93699a2dd95SBruce Richardson 		 * port and queue of the mbufs in the vector
93799a2dd95SBruce Richardson 		 */
93899a2dd95SBruce Richardson 		struct {
93999a2dd95SBruce Richardson 			uint16_t port;
94099a2dd95SBruce Richardson 			/* Ethernet device port id. */
94199a2dd95SBruce Richardson 			uint16_t queue;
94299a2dd95SBruce Richardson 			/* Ethernet device queue id. */
94399a2dd95SBruce Richardson 		};
94499a2dd95SBruce Richardson 	};
94599a2dd95SBruce Richardson 	/**< Union to hold common attributes of the vector array. */
94699a2dd95SBruce Richardson 	uint64_t impl_opaque;
94799a2dd95SBruce Richardson 	/**< Implementation specific opaque value.
94899a2dd95SBruce Richardson 	 * An implementation may use this field to hold implementation specific
94999a2dd95SBruce Richardson 	 * value to share between dequeue and enqueue operation.
95099a2dd95SBruce Richardson 	 * The application should not modify this field.
95199a2dd95SBruce Richardson 	 */
95299a2dd95SBruce Richardson 	union {
95399a2dd95SBruce Richardson 		struct rte_mbuf *mbufs[0];
95499a2dd95SBruce Richardson 		void *ptrs[0];
95599a2dd95SBruce Richardson 		uint64_t *u64s[0];
95699a2dd95SBruce Richardson 	} __rte_aligned(16);
95799a2dd95SBruce Richardson 	/**< Start of the vector array union. Depending upon the event type the
95899a2dd95SBruce Richardson 	 * vector array can be an array of mbufs or pointers or opaque u64
95999a2dd95SBruce Richardson 	 * values.
96099a2dd95SBruce Richardson 	 */
96199a2dd95SBruce Richardson };
96299a2dd95SBruce Richardson 
96399a2dd95SBruce Richardson /* Scheduler type definitions */
96499a2dd95SBruce Richardson #define RTE_SCHED_TYPE_ORDERED          0
96599a2dd95SBruce Richardson /**< Ordered scheduling
96699a2dd95SBruce Richardson  *
96799a2dd95SBruce Richardson  * Events from an ordered flow of an event queue can be scheduled to multiple
96899a2dd95SBruce Richardson  * ports for concurrent processing while maintaining the original event order.
96999a2dd95SBruce Richardson  * This scheme enables the user to achieve high single flow throughput by
97099a2dd95SBruce Richardson  * avoiding SW synchronization for ordering between ports which bound to cores.
97199a2dd95SBruce Richardson  *
97299a2dd95SBruce Richardson  * The source flow ordering from an event queue is maintained when events are
97399a2dd95SBruce Richardson  * enqueued to their destination queue within the same ordered flow context.
97499a2dd95SBruce Richardson  * An event port holds the context until application call
97599a2dd95SBruce Richardson  * rte_event_dequeue_burst() from the same port, which implicitly releases
97699a2dd95SBruce Richardson  * the context.
97799a2dd95SBruce Richardson  * User may allow the scheduler to release the context earlier than that
97899a2dd95SBruce Richardson  * by invoking rte_event_enqueue_burst() with RTE_EVENT_OP_RELEASE operation.
97999a2dd95SBruce Richardson  *
98099a2dd95SBruce Richardson  * Events from the source queue appear in their original order when dequeued
98199a2dd95SBruce Richardson  * from a destination queue.
98299a2dd95SBruce Richardson  * Event ordering is based on the received event(s), but also other
98399a2dd95SBruce Richardson  * (newly allocated or stored) events are ordered when enqueued within the same
98499a2dd95SBruce Richardson  * ordered context. Events not enqueued (e.g. released or stored) within the
98599a2dd95SBruce Richardson  * context are  considered missing from reordering and are skipped at this time
98699a2dd95SBruce Richardson  * (but can be ordered again within another context).
98799a2dd95SBruce Richardson  *
98899a2dd95SBruce Richardson  * @see rte_event_queue_setup(), rte_event_dequeue_burst(), RTE_EVENT_OP_RELEASE
98999a2dd95SBruce Richardson  */
99099a2dd95SBruce Richardson 
99199a2dd95SBruce Richardson #define RTE_SCHED_TYPE_ATOMIC           1
99299a2dd95SBruce Richardson /**< Atomic scheduling
99399a2dd95SBruce Richardson  *
99499a2dd95SBruce Richardson  * Events from an atomic flow of an event queue can be scheduled only to a
99599a2dd95SBruce Richardson  * single port at a time. The port is guaranteed to have exclusive (atomic)
99699a2dd95SBruce Richardson  * access to the associated flow context, which enables the user to avoid SW
99799a2dd95SBruce Richardson  * synchronization. Atomic flows also help to maintain event ordering
99899a2dd95SBruce Richardson  * since only one port at a time can process events from a flow of an
99999a2dd95SBruce Richardson  * event queue.
100099a2dd95SBruce Richardson  *
100199a2dd95SBruce Richardson  * The atomic queue synchronization context is dedicated to the port until
100299a2dd95SBruce Richardson  * application call rte_event_dequeue_burst() from the same port,
100399a2dd95SBruce Richardson  * which implicitly releases the context. User may allow the scheduler to
100499a2dd95SBruce Richardson  * release the context earlier than that by invoking rte_event_enqueue_burst()
100599a2dd95SBruce Richardson  * with RTE_EVENT_OP_RELEASE operation.
100699a2dd95SBruce Richardson  *
100799a2dd95SBruce Richardson  * @see rte_event_queue_setup(), rte_event_dequeue_burst(), RTE_EVENT_OP_RELEASE
100899a2dd95SBruce Richardson  */
100999a2dd95SBruce Richardson 
101099a2dd95SBruce Richardson #define RTE_SCHED_TYPE_PARALLEL         2
101199a2dd95SBruce Richardson /**< Parallel scheduling
101299a2dd95SBruce Richardson  *
101399a2dd95SBruce Richardson  * The scheduler performs priority scheduling, load balancing, etc. functions
101499a2dd95SBruce Richardson  * but does not provide additional event synchronization or ordering.
101599a2dd95SBruce Richardson  * It is free to schedule events from a single parallel flow of an event queue
101699a2dd95SBruce Richardson  * to multiple events ports for concurrent processing.
101799a2dd95SBruce Richardson  * The application is responsible for flow context synchronization and
101899a2dd95SBruce Richardson  * event ordering (SW synchronization).
101999a2dd95SBruce Richardson  *
102099a2dd95SBruce Richardson  * @see rte_event_queue_setup(), rte_event_dequeue_burst()
102199a2dd95SBruce Richardson  */
102299a2dd95SBruce Richardson 
102399a2dd95SBruce Richardson /* Event types to classify the event source */
102499a2dd95SBruce Richardson #define RTE_EVENT_TYPE_ETHDEV           0x0
102599a2dd95SBruce Richardson /**< The event generated from ethdev subsystem */
102699a2dd95SBruce Richardson #define RTE_EVENT_TYPE_CRYPTODEV        0x1
102799a2dd95SBruce Richardson /**< The event generated from crypodev subsystem */
102899a2dd95SBruce Richardson #define RTE_EVENT_TYPE_TIMER		0x2
102999a2dd95SBruce Richardson /**< The event generated from event timer adapter */
103099a2dd95SBruce Richardson #define RTE_EVENT_TYPE_CPU              0x3
103199a2dd95SBruce Richardson /**< The event generated from cpu for pipelining.
103299a2dd95SBruce Richardson  * Application may use *sub_event_type* to further classify the event
103399a2dd95SBruce Richardson  */
103499a2dd95SBruce Richardson #define RTE_EVENT_TYPE_ETH_RX_ADAPTER   0x4
103599a2dd95SBruce Richardson /**< The event generated from event eth Rx adapter */
103699a2dd95SBruce Richardson #define RTE_EVENT_TYPE_VECTOR           0x8
103799a2dd95SBruce Richardson /**< Indicates that event is a vector.
103899a2dd95SBruce Richardson  * All vector event types should be a logical OR of EVENT_TYPE_VECTOR.
103999a2dd95SBruce Richardson  * This simplifies the pipeline design as one can split processing the events
104099a2dd95SBruce Richardson  * between vector events and normal event across event types.
104199a2dd95SBruce Richardson  * Example:
104299a2dd95SBruce Richardson  *	if (ev.event_type & RTE_EVENT_TYPE_VECTOR) {
104399a2dd95SBruce Richardson  *		// Classify and handle vector event.
104499a2dd95SBruce Richardson  *	} else {
104599a2dd95SBruce Richardson  *		// Classify and handle event.
104699a2dd95SBruce Richardson  *	}
104799a2dd95SBruce Richardson  */
104899a2dd95SBruce Richardson #define RTE_EVENT_TYPE_ETHDEV_VECTOR                                           \
104999a2dd95SBruce Richardson 	(RTE_EVENT_TYPE_VECTOR | RTE_EVENT_TYPE_ETHDEV)
105099a2dd95SBruce Richardson /**< The event vector generated from ethdev subsystem */
105199a2dd95SBruce Richardson #define RTE_EVENT_TYPE_CPU_VECTOR (RTE_EVENT_TYPE_VECTOR | RTE_EVENT_TYPE_CPU)
105299a2dd95SBruce Richardson /**< The event vector generated from cpu for pipelining. */
105399a2dd95SBruce Richardson #define RTE_EVENT_TYPE_ETH_RX_ADAPTER_VECTOR                                   \
105499a2dd95SBruce Richardson 	(RTE_EVENT_TYPE_VECTOR | RTE_EVENT_TYPE_ETH_RX_ADAPTER)
105599a2dd95SBruce Richardson /**< The event vector generated from eth Rx adapter. */
105699a2dd95SBruce Richardson 
105799a2dd95SBruce Richardson #define RTE_EVENT_TYPE_MAX              0x10
105899a2dd95SBruce Richardson /**< Maximum number of event types */
105999a2dd95SBruce Richardson 
106099a2dd95SBruce Richardson /* Event enqueue operations */
106199a2dd95SBruce Richardson #define RTE_EVENT_OP_NEW                0
106299a2dd95SBruce Richardson /**< The event producers use this operation to inject a new event to the
106399a2dd95SBruce Richardson  * event device.
106499a2dd95SBruce Richardson  */
106599a2dd95SBruce Richardson #define RTE_EVENT_OP_FORWARD            1
106699a2dd95SBruce Richardson /**< The CPU use this operation to forward the event to different event queue or
106799a2dd95SBruce Richardson  * change to new application specific flow or schedule type to enable
106899a2dd95SBruce Richardson  * pipelining.
106999a2dd95SBruce Richardson  *
107099a2dd95SBruce Richardson  * This operation must only be enqueued to the same port that the
107199a2dd95SBruce Richardson  * event to be forwarded was dequeued from.
107299a2dd95SBruce Richardson  */
107399a2dd95SBruce Richardson #define RTE_EVENT_OP_RELEASE            2
107499a2dd95SBruce Richardson /**< Release the flow context associated with the schedule type.
107599a2dd95SBruce Richardson  *
107699a2dd95SBruce Richardson  * If current flow's scheduler type method is *RTE_SCHED_TYPE_ATOMIC*
107799a2dd95SBruce Richardson  * then this function hints the scheduler that the user has completed critical
107899a2dd95SBruce Richardson  * section processing in the current atomic context.
107999a2dd95SBruce Richardson  * The scheduler is now allowed to schedule events from the same flow from
108099a2dd95SBruce Richardson  * an event queue to another port. However, the context may be still held
108199a2dd95SBruce Richardson  * until the next rte_event_dequeue_burst() call, this call allows but does not
108299a2dd95SBruce Richardson  * force the scheduler to release the context early.
108399a2dd95SBruce Richardson  *
108499a2dd95SBruce Richardson  * Early atomic context release may increase parallelism and thus system
108599a2dd95SBruce Richardson  * performance, but the user needs to design carefully the split into critical
108699a2dd95SBruce Richardson  * vs non-critical sections.
108799a2dd95SBruce Richardson  *
108899a2dd95SBruce Richardson  * If current flow's scheduler type method is *RTE_SCHED_TYPE_ORDERED*
108999a2dd95SBruce Richardson  * then this function hints the scheduler that the user has done all that need
109099a2dd95SBruce Richardson  * to maintain event order in the current ordered context.
109199a2dd95SBruce Richardson  * The scheduler is allowed to release the ordered context of this port and
109299a2dd95SBruce Richardson  * avoid reordering any following enqueues.
109399a2dd95SBruce Richardson  *
109499a2dd95SBruce Richardson  * Early ordered context release may increase parallelism and thus system
109599a2dd95SBruce Richardson  * performance.
109699a2dd95SBruce Richardson  *
109799a2dd95SBruce Richardson  * If current flow's scheduler type method is *RTE_SCHED_TYPE_PARALLEL*
109899a2dd95SBruce Richardson  * or no scheduling context is held then this function may be an NOOP,
109999a2dd95SBruce Richardson  * depending on the implementation.
110099a2dd95SBruce Richardson  *
110199a2dd95SBruce Richardson  * This operation must only be enqueued to the same port that the
110299a2dd95SBruce Richardson  * event to be released was dequeued from.
110399a2dd95SBruce Richardson  *
110499a2dd95SBruce Richardson  */
110599a2dd95SBruce Richardson 
110699a2dd95SBruce Richardson /**
110799a2dd95SBruce Richardson  * The generic *rte_event* structure to hold the event attributes
110899a2dd95SBruce Richardson  * for dequeue and enqueue operation
110999a2dd95SBruce Richardson  */
111099a2dd95SBruce Richardson RTE_STD_C11
111199a2dd95SBruce Richardson struct rte_event {
111299a2dd95SBruce Richardson 	/** WORD0 */
111399a2dd95SBruce Richardson 	union {
111499a2dd95SBruce Richardson 		uint64_t event;
111599a2dd95SBruce Richardson 		/** Event attributes for dequeue or enqueue operation */
111699a2dd95SBruce Richardson 		struct {
111799a2dd95SBruce Richardson 			uint32_t flow_id:20;
111899a2dd95SBruce Richardson 			/**< Targeted flow identifier for the enqueue and
111999a2dd95SBruce Richardson 			 * dequeue operation.
112099a2dd95SBruce Richardson 			 * The value must be in the range of
112199a2dd95SBruce Richardson 			 * [0, nb_event_queue_flows - 1] which
112299a2dd95SBruce Richardson 			 * previously supplied to rte_event_dev_configure().
112399a2dd95SBruce Richardson 			 */
112499a2dd95SBruce Richardson 			uint32_t sub_event_type:8;
112599a2dd95SBruce Richardson 			/**< Sub-event types based on the event source.
112699a2dd95SBruce Richardson 			 * @see RTE_EVENT_TYPE_CPU
112799a2dd95SBruce Richardson 			 */
112899a2dd95SBruce Richardson 			uint32_t event_type:4;
112999a2dd95SBruce Richardson 			/**< Event type to classify the event source.
113099a2dd95SBruce Richardson 			 * @see RTE_EVENT_TYPE_ETHDEV, (RTE_EVENT_TYPE_*)
113199a2dd95SBruce Richardson 			 */
113299a2dd95SBruce Richardson 			uint8_t op:2;
113399a2dd95SBruce Richardson 			/**< The type of event enqueue operation - new/forward/
113499a2dd95SBruce Richardson 			 * etc.This field is not preserved across an instance
113599a2dd95SBruce Richardson 			 * and is undefined on dequeue.
113699a2dd95SBruce Richardson 			 * @see RTE_EVENT_OP_NEW, (RTE_EVENT_OP_*)
113799a2dd95SBruce Richardson 			 */
113899a2dd95SBruce Richardson 			uint8_t rsvd:4;
113999a2dd95SBruce Richardson 			/**< Reserved for future use */
114099a2dd95SBruce Richardson 			uint8_t sched_type:2;
114199a2dd95SBruce Richardson 			/**< Scheduler synchronization type (RTE_SCHED_TYPE_*)
114299a2dd95SBruce Richardson 			 * associated with flow id on a given event queue
114399a2dd95SBruce Richardson 			 * for the enqueue and dequeue operation.
114499a2dd95SBruce Richardson 			 */
114599a2dd95SBruce Richardson 			uint8_t queue_id;
114699a2dd95SBruce Richardson 			/**< Targeted event queue identifier for the enqueue or
114799a2dd95SBruce Richardson 			 * dequeue operation.
114899a2dd95SBruce Richardson 			 * The value must be in the range of
114999a2dd95SBruce Richardson 			 * [0, nb_event_queues - 1] which previously supplied to
115099a2dd95SBruce Richardson 			 * rte_event_dev_configure().
115199a2dd95SBruce Richardson 			 */
115299a2dd95SBruce Richardson 			uint8_t priority;
115399a2dd95SBruce Richardson 			/**< Event priority relative to other events in the
115499a2dd95SBruce Richardson 			 * event queue. The requested priority should in the
115599a2dd95SBruce Richardson 			 * range of  [RTE_EVENT_DEV_PRIORITY_HIGHEST,
115699a2dd95SBruce Richardson 			 * RTE_EVENT_DEV_PRIORITY_LOWEST].
115799a2dd95SBruce Richardson 			 * The implementation shall normalize the requested
115899a2dd95SBruce Richardson 			 * priority to supported priority value.
115999a2dd95SBruce Richardson 			 * Valid when the device has
116099a2dd95SBruce Richardson 			 * RTE_EVENT_DEV_CAP_EVENT_QOS capability.
116199a2dd95SBruce Richardson 			 */
116299a2dd95SBruce Richardson 			uint8_t impl_opaque;
116399a2dd95SBruce Richardson 			/**< Implementation specific opaque value.
116499a2dd95SBruce Richardson 			 * An implementation may use this field to hold
116599a2dd95SBruce Richardson 			 * implementation specific value to share between
116699a2dd95SBruce Richardson 			 * dequeue and enqueue operation.
116799a2dd95SBruce Richardson 			 * The application should not modify this field.
116899a2dd95SBruce Richardson 			 */
116999a2dd95SBruce Richardson 		};
117099a2dd95SBruce Richardson 	};
117199a2dd95SBruce Richardson 	/** WORD1 */
117299a2dd95SBruce Richardson 	union {
117399a2dd95SBruce Richardson 		uint64_t u64;
117499a2dd95SBruce Richardson 		/**< Opaque 64-bit value */
117599a2dd95SBruce Richardson 		void *event_ptr;
117699a2dd95SBruce Richardson 		/**< Opaque event pointer */
117799a2dd95SBruce Richardson 		struct rte_mbuf *mbuf;
117899a2dd95SBruce Richardson 		/**< mbuf pointer if dequeued event is associated with mbuf */
117999a2dd95SBruce Richardson 		struct rte_event_vector *vec;
118099a2dd95SBruce Richardson 		/**< Event vector pointer. */
118199a2dd95SBruce Richardson 	};
118299a2dd95SBruce Richardson };
118399a2dd95SBruce Richardson 
118499a2dd95SBruce Richardson /* Ethdev Rx adapter capability bitmap flags */
118599a2dd95SBruce Richardson #define RTE_EVENT_ETH_RX_ADAPTER_CAP_INTERNAL_PORT	0x1
118699a2dd95SBruce Richardson /**< This flag is sent when the packet transfer mechanism is in HW.
118799a2dd95SBruce Richardson  * Ethdev can send packets to the event device using internal event port.
118899a2dd95SBruce Richardson  */
118999a2dd95SBruce Richardson #define RTE_EVENT_ETH_RX_ADAPTER_CAP_MULTI_EVENTQ	0x2
119099a2dd95SBruce Richardson /**< Adapter supports multiple event queues per ethdev. Every ethdev
119199a2dd95SBruce Richardson  * Rx queue can be connected to a unique event queue.
119299a2dd95SBruce Richardson  */
119399a2dd95SBruce Richardson #define RTE_EVENT_ETH_RX_ADAPTER_CAP_OVERRIDE_FLOW_ID	0x4
119499a2dd95SBruce Richardson /**< The application can override the adapter generated flow ID in the
119599a2dd95SBruce Richardson  * event. This flow ID can be specified when adding an ethdev Rx queue
1196*a256a743SPavan Nikhilesh  * to the adapter using the ev.flow_id member.
119799a2dd95SBruce Richardson  * @see struct rte_event_eth_rx_adapter_queue_conf::ev
119899a2dd95SBruce Richardson  * @see struct rte_event_eth_rx_adapter_queue_conf::rx_queue_flags
119999a2dd95SBruce Richardson  */
120099a2dd95SBruce Richardson #define RTE_EVENT_ETH_RX_ADAPTER_CAP_EVENT_VECTOR	0x8
120199a2dd95SBruce Richardson /**< Adapter supports event vectorization per ethdev. */
120299a2dd95SBruce Richardson 
120399a2dd95SBruce Richardson /**
120499a2dd95SBruce Richardson  * Retrieve the event device's ethdev Rx adapter capabilities for the
120599a2dd95SBruce Richardson  * specified ethernet port
120699a2dd95SBruce Richardson  *
120799a2dd95SBruce Richardson  * @param dev_id
120899a2dd95SBruce Richardson  *   The identifier of the device.
120999a2dd95SBruce Richardson  *
121099a2dd95SBruce Richardson  * @param eth_port_id
121199a2dd95SBruce Richardson  *   The identifier of the ethernet device.
121299a2dd95SBruce Richardson  *
121399a2dd95SBruce Richardson  * @param[out] caps
121499a2dd95SBruce Richardson  *   A pointer to memory filled with Rx event adapter capabilities.
121599a2dd95SBruce Richardson  *
121699a2dd95SBruce Richardson  * @return
121799a2dd95SBruce Richardson  *   - 0: Success, driver provides Rx event adapter capabilities for the
121899a2dd95SBruce Richardson  *	ethernet device.
121999a2dd95SBruce Richardson  *   - <0: Error code returned by the driver function.
122099a2dd95SBruce Richardson  *
122199a2dd95SBruce Richardson  */
122299a2dd95SBruce Richardson int
122399a2dd95SBruce Richardson rte_event_eth_rx_adapter_caps_get(uint8_t dev_id, uint16_t eth_port_id,
122499a2dd95SBruce Richardson 				uint32_t *caps);
122599a2dd95SBruce Richardson 
122699a2dd95SBruce Richardson #define RTE_EVENT_TIMER_ADAPTER_CAP_INTERNAL_PORT (1ULL << 0)
122799a2dd95SBruce Richardson /**< This flag is set when the timer mechanism is in HW. */
122899a2dd95SBruce Richardson 
122999a2dd95SBruce Richardson #define RTE_EVENT_TIMER_ADAPTER_CAP_PERIODIC      (1ULL << 1)
123099a2dd95SBruce Richardson /**< This flag is set if periodic mode is supported. */
123199a2dd95SBruce Richardson 
123299a2dd95SBruce Richardson /**
123399a2dd95SBruce Richardson  * Retrieve the event device's timer adapter capabilities.
123499a2dd95SBruce Richardson  *
123599a2dd95SBruce Richardson  * @param dev_id
123699a2dd95SBruce Richardson  *   The identifier of the device.
123799a2dd95SBruce Richardson  *
123899a2dd95SBruce Richardson  * @param[out] caps
123999a2dd95SBruce Richardson  *   A pointer to memory to be filled with event timer adapter capabilities.
124099a2dd95SBruce Richardson  *
124199a2dd95SBruce Richardson  * @return
124299a2dd95SBruce Richardson  *   - 0: Success, driver provided event timer adapter capabilities.
124399a2dd95SBruce Richardson  *   - <0: Error code returned by the driver function.
124499a2dd95SBruce Richardson  */
124599a2dd95SBruce Richardson int
124699a2dd95SBruce Richardson rte_event_timer_adapter_caps_get(uint8_t dev_id, uint32_t *caps);
124799a2dd95SBruce Richardson 
124899a2dd95SBruce Richardson /* Crypto adapter capability bitmap flag */
124999a2dd95SBruce Richardson #define RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_NEW   0x1
125099a2dd95SBruce Richardson /**< Flag indicates HW is capable of generating events in
125199a2dd95SBruce Richardson  * RTE_EVENT_OP_NEW enqueue operation. Cryptodev will send
125299a2dd95SBruce Richardson  * packets to the event device as new events using an internal
125399a2dd95SBruce Richardson  * event port.
125499a2dd95SBruce Richardson  */
125599a2dd95SBruce Richardson 
125699a2dd95SBruce Richardson #define RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_FWD   0x2
125799a2dd95SBruce Richardson /**< Flag indicates HW is capable of generating events in
125899a2dd95SBruce Richardson  * RTE_EVENT_OP_FORWARD enqueue operation. Cryptodev will send
125999a2dd95SBruce Richardson  * packets to the event device as forwarded event using an
126099a2dd95SBruce Richardson  * internal event port.
126199a2dd95SBruce Richardson  */
126299a2dd95SBruce Richardson 
126399a2dd95SBruce Richardson #define RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_QP_EV_BIND  0x4
126499a2dd95SBruce Richardson /**< Flag indicates HW is capable of mapping crypto queue pair to
126599a2dd95SBruce Richardson  * event queue.
126699a2dd95SBruce Richardson  */
126799a2dd95SBruce Richardson 
126899a2dd95SBruce Richardson #define RTE_EVENT_CRYPTO_ADAPTER_CAP_SESSION_PRIVATE_DATA   0x8
126999a2dd95SBruce Richardson /**< Flag indicates HW/SW supports a mechanism to store and retrieve
127099a2dd95SBruce Richardson  * the private data information along with the crypto session.
127199a2dd95SBruce Richardson  */
127299a2dd95SBruce Richardson 
127399a2dd95SBruce Richardson /**
127499a2dd95SBruce Richardson  * Retrieve the event device's crypto adapter capabilities for the
127599a2dd95SBruce Richardson  * specified cryptodev device
127699a2dd95SBruce Richardson  *
127799a2dd95SBruce Richardson  * @param dev_id
127899a2dd95SBruce Richardson  *   The identifier of the device.
127999a2dd95SBruce Richardson  *
128099a2dd95SBruce Richardson  * @param cdev_id
128199a2dd95SBruce Richardson  *   The identifier of the cryptodev device.
128299a2dd95SBruce Richardson  *
128399a2dd95SBruce Richardson  * @param[out] caps
128499a2dd95SBruce Richardson  *   A pointer to memory filled with event adapter capabilities.
128599a2dd95SBruce Richardson  *   It is expected to be pre-allocated & initialized by caller.
128699a2dd95SBruce Richardson  *
128799a2dd95SBruce Richardson  * @return
128899a2dd95SBruce Richardson  *   - 0: Success, driver provides event adapter capabilities for the
128999a2dd95SBruce Richardson  *     cryptodev device.
129099a2dd95SBruce Richardson  *   - <0: Error code returned by the driver function.
129199a2dd95SBruce Richardson  *
129299a2dd95SBruce Richardson  */
129399a2dd95SBruce Richardson int
129499a2dd95SBruce Richardson rte_event_crypto_adapter_caps_get(uint8_t dev_id, uint8_t cdev_id,
129599a2dd95SBruce Richardson 				  uint32_t *caps);
129699a2dd95SBruce Richardson 
129799a2dd95SBruce Richardson /* Ethdev Tx adapter capability bitmap flags */
129899a2dd95SBruce Richardson #define RTE_EVENT_ETH_TX_ADAPTER_CAP_INTERNAL_PORT	0x1
129999a2dd95SBruce Richardson /**< This flag is sent when the PMD supports a packet transmit callback
130099a2dd95SBruce Richardson  */
130199a2dd95SBruce Richardson #define RTE_EVENT_ETH_TX_ADAPTER_CAP_EVENT_VECTOR	0x2
130299a2dd95SBruce Richardson /**< Indicates that the Tx adapter is capable of handling event vector of
130399a2dd95SBruce Richardson  * mbufs.
130499a2dd95SBruce Richardson  */
130599a2dd95SBruce Richardson 
130699a2dd95SBruce Richardson /**
130799a2dd95SBruce Richardson  * Retrieve the event device's eth Tx adapter capabilities
130899a2dd95SBruce Richardson  *
130999a2dd95SBruce Richardson  * @param dev_id
131099a2dd95SBruce Richardson  *   The identifier of the device.
131199a2dd95SBruce Richardson  *
131299a2dd95SBruce Richardson  * @param eth_port_id
131399a2dd95SBruce Richardson  *   The identifier of the ethernet device.
131499a2dd95SBruce Richardson  *
131599a2dd95SBruce Richardson  * @param[out] caps
131699a2dd95SBruce Richardson  *   A pointer to memory filled with eth Tx adapter capabilities.
131799a2dd95SBruce Richardson  *
131899a2dd95SBruce Richardson  * @return
131999a2dd95SBruce Richardson  *   - 0: Success, driver provides eth Tx adapter capabilities.
132099a2dd95SBruce Richardson  *   - <0: Error code returned by the driver function.
132199a2dd95SBruce Richardson  *
132299a2dd95SBruce Richardson  */
132399a2dd95SBruce Richardson int
132499a2dd95SBruce Richardson rte_event_eth_tx_adapter_caps_get(uint8_t dev_id, uint16_t eth_port_id,
132599a2dd95SBruce Richardson 				uint32_t *caps);
132699a2dd95SBruce Richardson 
132799a2dd95SBruce Richardson /**
132899a2dd95SBruce Richardson  * Converts nanoseconds to *timeout_ticks* value for rte_event_dequeue_burst()
132999a2dd95SBruce Richardson  *
133099a2dd95SBruce Richardson  * If the device is configured with RTE_EVENT_DEV_CFG_PER_DEQUEUE_TIMEOUT flag
133199a2dd95SBruce Richardson  * then application can use this function to convert timeout value in
133299a2dd95SBruce Richardson  * nanoseconds to implementations specific timeout value supplied in
133399a2dd95SBruce Richardson  * rte_event_dequeue_burst()
133499a2dd95SBruce Richardson  *
133599a2dd95SBruce Richardson  * @param dev_id
133699a2dd95SBruce Richardson  *   The identifier of the device.
133799a2dd95SBruce Richardson  * @param ns
133899a2dd95SBruce Richardson  *   Wait time in nanosecond
133999a2dd95SBruce Richardson  * @param[out] timeout_ticks
134099a2dd95SBruce Richardson  *   Value for the *timeout_ticks* parameter in rte_event_dequeue_burst()
134199a2dd95SBruce Richardson  *
134299a2dd95SBruce Richardson  * @return
134399a2dd95SBruce Richardson  *  - 0 on success.
134499a2dd95SBruce Richardson  *  - -ENOTSUP if the device doesn't support timeouts
134599a2dd95SBruce Richardson  *  - -EINVAL if *dev_id* is invalid or *timeout_ticks* is NULL
134699a2dd95SBruce Richardson  *  - other values < 0 on failure.
134799a2dd95SBruce Richardson  *
134899a2dd95SBruce Richardson  * @see rte_event_dequeue_burst(), RTE_EVENT_DEV_CFG_PER_DEQUEUE_TIMEOUT
134999a2dd95SBruce Richardson  * @see rte_event_dev_configure()
135099a2dd95SBruce Richardson  *
135199a2dd95SBruce Richardson  */
135299a2dd95SBruce Richardson int
135399a2dd95SBruce Richardson rte_event_dequeue_timeout_ticks(uint8_t dev_id, uint64_t ns,
135499a2dd95SBruce Richardson 					uint64_t *timeout_ticks);
135599a2dd95SBruce Richardson 
135699a2dd95SBruce Richardson /**
135799a2dd95SBruce Richardson  * Link multiple source event queues supplied in *queues* to the destination
135899a2dd95SBruce Richardson  * event port designated by its *port_id* with associated service priority
135999a2dd95SBruce Richardson  * supplied in *priorities* on the event device designated by its *dev_id*.
136099a2dd95SBruce Richardson  *
136199a2dd95SBruce Richardson  * The link establishment shall enable the event port *port_id* from
136299a2dd95SBruce Richardson  * receiving events from the specified event queue(s) supplied in *queues*
136399a2dd95SBruce Richardson  *
136499a2dd95SBruce Richardson  * An event queue may link to one or more event ports.
136599a2dd95SBruce Richardson  * The number of links can be established from an event queue to event port is
136699a2dd95SBruce Richardson  * implementation defined.
136799a2dd95SBruce Richardson  *
136899a2dd95SBruce Richardson  * Event queue(s) to event port link establishment can be changed at runtime
136999a2dd95SBruce Richardson  * without re-configuring the device to support scaling and to reduce the
137099a2dd95SBruce Richardson  * latency of critical work by establishing the link with more event ports
137199a2dd95SBruce Richardson  * at runtime.
137299a2dd95SBruce Richardson  *
137399a2dd95SBruce Richardson  * @param dev_id
137499a2dd95SBruce Richardson  *   The identifier of the device.
137599a2dd95SBruce Richardson  *
137699a2dd95SBruce Richardson  * @param port_id
137799a2dd95SBruce Richardson  *   Event port identifier to select the destination port to link.
137899a2dd95SBruce Richardson  *
137999a2dd95SBruce Richardson  * @param queues
138099a2dd95SBruce Richardson  *   Points to an array of *nb_links* event queues to be linked
138199a2dd95SBruce Richardson  *   to the event port.
138299a2dd95SBruce Richardson  *   NULL value is allowed, in which case this function links all the configured
138399a2dd95SBruce Richardson  *   event queues *nb_event_queues* which previously supplied to
138499a2dd95SBruce Richardson  *   rte_event_dev_configure() to the event port *port_id*
138599a2dd95SBruce Richardson  *
138699a2dd95SBruce Richardson  * @param priorities
138799a2dd95SBruce Richardson  *   Points to an array of *nb_links* service priorities associated with each
138899a2dd95SBruce Richardson  *   event queue link to event port.
138999a2dd95SBruce Richardson  *   The priority defines the event port's servicing priority for
139099a2dd95SBruce Richardson  *   event queue, which may be ignored by an implementation.
139199a2dd95SBruce Richardson  *   The requested priority should in the range of
139299a2dd95SBruce Richardson  *   [RTE_EVENT_DEV_PRIORITY_HIGHEST, RTE_EVENT_DEV_PRIORITY_LOWEST].
139399a2dd95SBruce Richardson  *   The implementation shall normalize the requested priority to
139499a2dd95SBruce Richardson  *   implementation supported priority value.
139599a2dd95SBruce Richardson  *   NULL value is allowed, in which case this function links the event queues
139699a2dd95SBruce Richardson  *   with RTE_EVENT_DEV_PRIORITY_NORMAL servicing priority
139799a2dd95SBruce Richardson  *
139899a2dd95SBruce Richardson  * @param nb_links
139999a2dd95SBruce Richardson  *   The number of links to establish. This parameter is ignored if queues is
140099a2dd95SBruce Richardson  *   NULL.
140199a2dd95SBruce Richardson  *
140299a2dd95SBruce Richardson  * @return
140399a2dd95SBruce Richardson  * The number of links actually established. The return value can be less than
140499a2dd95SBruce Richardson  * the value of the *nb_links* parameter when the implementation has the
140599a2dd95SBruce Richardson  * limitation on specific queue to port link establishment or if invalid
140699a2dd95SBruce Richardson  * parameters are specified in *queues*
140799a2dd95SBruce Richardson  * If the return value is less than *nb_links*, the remaining links at the end
140899a2dd95SBruce Richardson  * of link[] are not established, and the caller has to take care of them.
140999a2dd95SBruce Richardson  * If return value is less than *nb_links* then implementation shall update the
141099a2dd95SBruce Richardson  * rte_errno accordingly, Possible rte_errno values are
141199a2dd95SBruce Richardson  * (EDQUOT) Quota exceeded(Application tried to link the queue configured with
141299a2dd95SBruce Richardson  *  RTE_EVENT_QUEUE_CFG_SINGLE_LINK to more than one event ports)
141399a2dd95SBruce Richardson  * (EINVAL) Invalid parameter
141499a2dd95SBruce Richardson  *
141599a2dd95SBruce Richardson  */
141699a2dd95SBruce Richardson int
141799a2dd95SBruce Richardson rte_event_port_link(uint8_t dev_id, uint8_t port_id,
141899a2dd95SBruce Richardson 		    const uint8_t queues[], const uint8_t priorities[],
141999a2dd95SBruce Richardson 		    uint16_t nb_links);
142099a2dd95SBruce Richardson 
142199a2dd95SBruce Richardson /**
142299a2dd95SBruce Richardson  * Unlink multiple source event queues supplied in *queues* from the destination
142399a2dd95SBruce Richardson  * event port designated by its *port_id* on the event device designated
142499a2dd95SBruce Richardson  * by its *dev_id*.
142599a2dd95SBruce Richardson  *
142699a2dd95SBruce Richardson  * The unlink call issues an async request to disable the event port *port_id*
142799a2dd95SBruce Richardson  * from receiving events from the specified event queue *queue_id*.
142899a2dd95SBruce Richardson  * Event queue(s) to event port unlink establishment can be changed at runtime
142999a2dd95SBruce Richardson  * without re-configuring the device.
143099a2dd95SBruce Richardson  *
143199a2dd95SBruce Richardson  * @see rte_event_port_unlinks_in_progress() to poll for completed unlinks.
143299a2dd95SBruce Richardson  *
143399a2dd95SBruce Richardson  * @param dev_id
143499a2dd95SBruce Richardson  *   The identifier of the device.
143599a2dd95SBruce Richardson  *
143699a2dd95SBruce Richardson  * @param port_id
143799a2dd95SBruce Richardson  *   Event port identifier to select the destination port to unlink.
143899a2dd95SBruce Richardson  *
143999a2dd95SBruce Richardson  * @param queues
144099a2dd95SBruce Richardson  *   Points to an array of *nb_unlinks* event queues to be unlinked
144199a2dd95SBruce Richardson  *   from the event port.
144299a2dd95SBruce Richardson  *   NULL value is allowed, in which case this function unlinks all the
144399a2dd95SBruce Richardson  *   event queue(s) from the event port *port_id*.
144499a2dd95SBruce Richardson  *
144599a2dd95SBruce Richardson  * @param nb_unlinks
144699a2dd95SBruce Richardson  *   The number of unlinks to establish. This parameter is ignored if queues is
144799a2dd95SBruce Richardson  *   NULL.
144899a2dd95SBruce Richardson  *
144999a2dd95SBruce Richardson  * @return
145099a2dd95SBruce Richardson  * The number of unlinks successfully requested. The return value can be less
145199a2dd95SBruce Richardson  * than the value of the *nb_unlinks* parameter when the implementation has the
145299a2dd95SBruce Richardson  * limitation on specific queue to port unlink establishment or
145399a2dd95SBruce Richardson  * if invalid parameters are specified.
145499a2dd95SBruce Richardson  * If the return value is less than *nb_unlinks*, the remaining queues at the
145599a2dd95SBruce Richardson  * end of queues[] are not unlinked, and the caller has to take care of them.
145699a2dd95SBruce Richardson  * If return value is less than *nb_unlinks* then implementation shall update
145799a2dd95SBruce Richardson  * the rte_errno accordingly, Possible rte_errno values are
145899a2dd95SBruce Richardson  * (EINVAL) Invalid parameter
145999a2dd95SBruce Richardson  */
146099a2dd95SBruce Richardson int
146199a2dd95SBruce Richardson rte_event_port_unlink(uint8_t dev_id, uint8_t port_id,
146299a2dd95SBruce Richardson 		      uint8_t queues[], uint16_t nb_unlinks);
146399a2dd95SBruce Richardson 
146499a2dd95SBruce Richardson /**
146599a2dd95SBruce Richardson  * Returns the number of unlinks in progress.
146699a2dd95SBruce Richardson  *
146799a2dd95SBruce Richardson  * This function provides the application with a method to detect when an
146899a2dd95SBruce Richardson  * unlink has been completed by the implementation.
146999a2dd95SBruce Richardson  *
147099a2dd95SBruce Richardson  * @see rte_event_port_unlink() to issue unlink requests.
147199a2dd95SBruce Richardson  *
147299a2dd95SBruce Richardson  * @param dev_id
147399a2dd95SBruce Richardson  *   The identifier of the device.
147499a2dd95SBruce Richardson  *
147599a2dd95SBruce Richardson  * @param port_id
147699a2dd95SBruce Richardson  *   Event port identifier to select port to check for unlinks in progress.
147799a2dd95SBruce Richardson  *
147899a2dd95SBruce Richardson  * @return
147999a2dd95SBruce Richardson  * The number of unlinks that are in progress. A return of zero indicates that
148099a2dd95SBruce Richardson  * there are no outstanding unlink requests. A positive return value indicates
148199a2dd95SBruce Richardson  * the number of unlinks that are in progress, but are not yet complete.
148299a2dd95SBruce Richardson  * A negative return value indicates an error, -EINVAL indicates an invalid
148399a2dd95SBruce Richardson  * parameter passed for *dev_id* or *port_id*.
148499a2dd95SBruce Richardson  */
148599a2dd95SBruce Richardson int
148699a2dd95SBruce Richardson rte_event_port_unlinks_in_progress(uint8_t dev_id, uint8_t port_id);
148799a2dd95SBruce Richardson 
148899a2dd95SBruce Richardson /**
148999a2dd95SBruce Richardson  * Retrieve the list of source event queues and its associated service priority
149099a2dd95SBruce Richardson  * linked to the destination event port designated by its *port_id*
149199a2dd95SBruce Richardson  * on the event device designated by its *dev_id*.
149299a2dd95SBruce Richardson  *
149399a2dd95SBruce Richardson  * @param dev_id
149499a2dd95SBruce Richardson  *   The identifier of the device.
149599a2dd95SBruce Richardson  *
149699a2dd95SBruce Richardson  * @param port_id
149799a2dd95SBruce Richardson  *   Event port identifier.
149899a2dd95SBruce Richardson  *
149999a2dd95SBruce Richardson  * @param[out] queues
150099a2dd95SBruce Richardson  *   Points to an array of *queues* for output.
150199a2dd95SBruce Richardson  *   The caller has to allocate *RTE_EVENT_MAX_QUEUES_PER_DEV* bytes to
150299a2dd95SBruce Richardson  *   store the event queue(s) linked with event port *port_id*
150399a2dd95SBruce Richardson  *
150499a2dd95SBruce Richardson  * @param[out] priorities
150599a2dd95SBruce Richardson  *   Points to an array of *priorities* for output.
150699a2dd95SBruce Richardson  *   The caller has to allocate *RTE_EVENT_MAX_QUEUES_PER_DEV* bytes to
150799a2dd95SBruce Richardson  *   store the service priority associated with each event queue linked
150899a2dd95SBruce Richardson  *
150999a2dd95SBruce Richardson  * @return
151099a2dd95SBruce Richardson  * The number of links established on the event port designated by its
151199a2dd95SBruce Richardson  *  *port_id*.
151299a2dd95SBruce Richardson  * - <0 on failure.
151399a2dd95SBruce Richardson  *
151499a2dd95SBruce Richardson  */
151599a2dd95SBruce Richardson int
151699a2dd95SBruce Richardson rte_event_port_links_get(uint8_t dev_id, uint8_t port_id,
151799a2dd95SBruce Richardson 			 uint8_t queues[], uint8_t priorities[]);
151899a2dd95SBruce Richardson 
151999a2dd95SBruce Richardson /**
152099a2dd95SBruce Richardson  * Retrieve the service ID of the event dev. If the adapter doesn't use
152199a2dd95SBruce Richardson  * a rte_service function, this function returns -ESRCH.
152299a2dd95SBruce Richardson  *
152399a2dd95SBruce Richardson  * @param dev_id
152499a2dd95SBruce Richardson  *   The identifier of the device.
152599a2dd95SBruce Richardson  *
152699a2dd95SBruce Richardson  * @param [out] service_id
152799a2dd95SBruce Richardson  *   A pointer to a uint32_t, to be filled in with the service id.
152899a2dd95SBruce Richardson  *
152999a2dd95SBruce Richardson  * @return
153099a2dd95SBruce Richardson  *   - 0: Success
153199a2dd95SBruce Richardson  *   - <0: Error code on failure, if the event dev doesn't use a rte_service
153299a2dd95SBruce Richardson  *   function, this function returns -ESRCH.
153399a2dd95SBruce Richardson  */
153499a2dd95SBruce Richardson int
153599a2dd95SBruce Richardson rte_event_dev_service_id_get(uint8_t dev_id, uint32_t *service_id);
153699a2dd95SBruce Richardson 
153799a2dd95SBruce Richardson /**
153899a2dd95SBruce Richardson  * Dump internal information about *dev_id* to the FILE* provided in *f*.
153999a2dd95SBruce Richardson  *
154099a2dd95SBruce Richardson  * @param dev_id
154199a2dd95SBruce Richardson  *   The identifier of the device.
154299a2dd95SBruce Richardson  *
154399a2dd95SBruce Richardson  * @param f
154499a2dd95SBruce Richardson  *   A pointer to a file for output
154599a2dd95SBruce Richardson  *
154699a2dd95SBruce Richardson  * @return
154799a2dd95SBruce Richardson  *   - 0: on success
154899a2dd95SBruce Richardson  *   - <0: on failure.
154999a2dd95SBruce Richardson  */
155099a2dd95SBruce Richardson int
155199a2dd95SBruce Richardson rte_event_dev_dump(uint8_t dev_id, FILE *f);
155299a2dd95SBruce Richardson 
155399a2dd95SBruce Richardson /** Maximum name length for extended statistics counters */
155499a2dd95SBruce Richardson #define RTE_EVENT_DEV_XSTATS_NAME_SIZE 64
155599a2dd95SBruce Richardson 
155699a2dd95SBruce Richardson /**
155799a2dd95SBruce Richardson  * Selects the component of the eventdev to retrieve statistics from.
155899a2dd95SBruce Richardson  */
155999a2dd95SBruce Richardson enum rte_event_dev_xstats_mode {
156099a2dd95SBruce Richardson 	RTE_EVENT_DEV_XSTATS_DEVICE,
156199a2dd95SBruce Richardson 	RTE_EVENT_DEV_XSTATS_PORT,
156299a2dd95SBruce Richardson 	RTE_EVENT_DEV_XSTATS_QUEUE,
156399a2dd95SBruce Richardson };
156499a2dd95SBruce Richardson 
156599a2dd95SBruce Richardson /**
156699a2dd95SBruce Richardson  * A name-key lookup element for extended statistics.
156799a2dd95SBruce Richardson  *
156899a2dd95SBruce Richardson  * This structure is used to map between names and ID numbers
156999a2dd95SBruce Richardson  * for extended ethdev statistics.
157099a2dd95SBruce Richardson  */
157199a2dd95SBruce Richardson struct rte_event_dev_xstats_name {
157299a2dd95SBruce Richardson 	char name[RTE_EVENT_DEV_XSTATS_NAME_SIZE];
157399a2dd95SBruce Richardson };
157499a2dd95SBruce Richardson 
157599a2dd95SBruce Richardson /**
157699a2dd95SBruce Richardson  * Retrieve names of extended statistics of an event device.
157799a2dd95SBruce Richardson  *
157899a2dd95SBruce Richardson  * @param dev_id
157999a2dd95SBruce Richardson  *   The identifier of the event device.
158099a2dd95SBruce Richardson  * @param mode
158199a2dd95SBruce Richardson  *   The mode of statistics to retrieve. Choices include the device statistics,
158299a2dd95SBruce Richardson  *   port statistics or queue statistics.
158399a2dd95SBruce Richardson  * @param queue_port_id
158499a2dd95SBruce Richardson  *   Used to specify the port or queue number in queue or port mode, and is
158599a2dd95SBruce Richardson  *   ignored in device mode.
158699a2dd95SBruce Richardson  * @param[out] xstats_names
158799a2dd95SBruce Richardson  *   Block of memory to insert names into. Must be at least size in capacity.
158899a2dd95SBruce Richardson  *   If set to NULL, function returns required capacity.
158999a2dd95SBruce Richardson  * @param[out] ids
159099a2dd95SBruce Richardson  *   Block of memory to insert ids into. Must be at least size in capacity.
159199a2dd95SBruce Richardson  *   If set to NULL, function returns required capacity. The id values returned
159299a2dd95SBruce Richardson  *   can be passed to *rte_event_dev_xstats_get* to select statistics.
159399a2dd95SBruce Richardson  * @param size
159499a2dd95SBruce Richardson  *   Capacity of xstats_names (number of names).
159599a2dd95SBruce Richardson  * @return
159699a2dd95SBruce Richardson  *   - positive value lower or equal to size: success. The return value
159799a2dd95SBruce Richardson  *     is the number of entries filled in the stats table.
159899a2dd95SBruce Richardson  *   - positive value higher than size: error, the given statistics table
159999a2dd95SBruce Richardson  *     is too small. The return value corresponds to the size that should
160099a2dd95SBruce Richardson  *     be given to succeed. The entries in the table are not valid and
160199a2dd95SBruce Richardson  *     shall not be used by the caller.
160299a2dd95SBruce Richardson  *   - negative value on error:
160399a2dd95SBruce Richardson  *        -ENODEV for invalid *dev_id*
160499a2dd95SBruce Richardson  *        -EINVAL for invalid mode, queue port or id parameters
160599a2dd95SBruce Richardson  *        -ENOTSUP if the device doesn't support this function.
160699a2dd95SBruce Richardson  */
160799a2dd95SBruce Richardson int
160899a2dd95SBruce Richardson rte_event_dev_xstats_names_get(uint8_t dev_id,
160999a2dd95SBruce Richardson 			       enum rte_event_dev_xstats_mode mode,
161099a2dd95SBruce Richardson 			       uint8_t queue_port_id,
161199a2dd95SBruce Richardson 			       struct rte_event_dev_xstats_name *xstats_names,
161299a2dd95SBruce Richardson 			       unsigned int *ids,
161399a2dd95SBruce Richardson 			       unsigned int size);
161499a2dd95SBruce Richardson 
161599a2dd95SBruce Richardson /**
161699a2dd95SBruce Richardson  * Retrieve extended statistics of an event device.
161799a2dd95SBruce Richardson  *
161899a2dd95SBruce Richardson  * @param dev_id
161999a2dd95SBruce Richardson  *   The identifier of the device.
162099a2dd95SBruce Richardson  * @param mode
162199a2dd95SBruce Richardson  *  The mode of statistics to retrieve. Choices include the device statistics,
162299a2dd95SBruce Richardson  *  port statistics or queue statistics.
162399a2dd95SBruce Richardson  * @param queue_port_id
162499a2dd95SBruce Richardson  *   Used to specify the port or queue number in queue or port mode, and is
162599a2dd95SBruce Richardson  *   ignored in device mode.
162699a2dd95SBruce Richardson  * @param ids
162799a2dd95SBruce Richardson  *   The id numbers of the stats to get. The ids can be got from the stat
162899a2dd95SBruce Richardson  *   position in the stat list from rte_event_dev_get_xstats_names(), or
162999a2dd95SBruce Richardson  *   by using rte_event_dev_xstats_by_name_get().
163099a2dd95SBruce Richardson  * @param[out] values
163199a2dd95SBruce Richardson  *   The values for each stats request by ID.
163299a2dd95SBruce Richardson  * @param n
163399a2dd95SBruce Richardson  *   The number of stats requested
163499a2dd95SBruce Richardson  * @return
163599a2dd95SBruce Richardson  *   - positive value: number of stat entries filled into the values array
163699a2dd95SBruce Richardson  *   - negative value on error:
163799a2dd95SBruce Richardson  *        -ENODEV for invalid *dev_id*
163899a2dd95SBruce Richardson  *        -EINVAL for invalid mode, queue port or id parameters
163999a2dd95SBruce Richardson  *        -ENOTSUP if the device doesn't support this function.
164099a2dd95SBruce Richardson  */
164199a2dd95SBruce Richardson int
164299a2dd95SBruce Richardson rte_event_dev_xstats_get(uint8_t dev_id,
164399a2dd95SBruce Richardson 			 enum rte_event_dev_xstats_mode mode,
164499a2dd95SBruce Richardson 			 uint8_t queue_port_id,
164599a2dd95SBruce Richardson 			 const unsigned int ids[],
164699a2dd95SBruce Richardson 			 uint64_t values[], unsigned int n);
164799a2dd95SBruce Richardson 
164899a2dd95SBruce Richardson /**
164999a2dd95SBruce Richardson  * Retrieve the value of a single stat by requesting it by name.
165099a2dd95SBruce Richardson  *
165199a2dd95SBruce Richardson  * @param dev_id
165299a2dd95SBruce Richardson  *   The identifier of the device
165399a2dd95SBruce Richardson  * @param name
165499a2dd95SBruce Richardson  *   The stat name to retrieve
165599a2dd95SBruce Richardson  * @param[out] id
165699a2dd95SBruce Richardson  *   If non-NULL, the numerical id of the stat will be returned, so that further
165799a2dd95SBruce Richardson  *   requests for the stat can be got using rte_event_dev_xstats_get, which will
165899a2dd95SBruce Richardson  *   be faster as it doesn't need to scan a list of names for the stat.
165999a2dd95SBruce Richardson  *   If the stat cannot be found, the id returned will be (unsigned)-1.
166099a2dd95SBruce Richardson  * @return
166199a2dd95SBruce Richardson  *   - positive value or zero: the stat value
166299a2dd95SBruce Richardson  *   - negative value: -EINVAL if stat not found, -ENOTSUP if not supported.
166399a2dd95SBruce Richardson  */
166499a2dd95SBruce Richardson uint64_t
166599a2dd95SBruce Richardson rte_event_dev_xstats_by_name_get(uint8_t dev_id, const char *name,
166699a2dd95SBruce Richardson 				 unsigned int *id);
166799a2dd95SBruce Richardson 
166899a2dd95SBruce Richardson /**
166999a2dd95SBruce Richardson  * Reset the values of the xstats of the selected component in the device.
167099a2dd95SBruce Richardson  *
167199a2dd95SBruce Richardson  * @param dev_id
167299a2dd95SBruce Richardson  *   The identifier of the device
167399a2dd95SBruce Richardson  * @param mode
167499a2dd95SBruce Richardson  *   The mode of the statistics to reset. Choose from device, queue or port.
167599a2dd95SBruce Richardson  * @param queue_port_id
167699a2dd95SBruce Richardson  *   The queue or port to reset. 0 and positive values select ports and queues,
167799a2dd95SBruce Richardson  *   while -1 indicates all ports or queues.
167899a2dd95SBruce Richardson  * @param ids
167999a2dd95SBruce Richardson  *   Selects specific statistics to be reset. When NULL, all statistics selected
168099a2dd95SBruce Richardson  *   by *mode* will be reset. If non-NULL, must point to array of at least
168199a2dd95SBruce Richardson  *   *nb_ids* size.
168299a2dd95SBruce Richardson  * @param nb_ids
168399a2dd95SBruce Richardson  *   The number of ids available from the *ids* array. Ignored when ids is NULL.
168499a2dd95SBruce Richardson  * @return
168599a2dd95SBruce Richardson  *   - zero: successfully reset the statistics to zero
168699a2dd95SBruce Richardson  *   - negative value: -EINVAL invalid parameters, -ENOTSUP if not supported.
168799a2dd95SBruce Richardson  */
168899a2dd95SBruce Richardson int
168999a2dd95SBruce Richardson rte_event_dev_xstats_reset(uint8_t dev_id,
169099a2dd95SBruce Richardson 			   enum rte_event_dev_xstats_mode mode,
169199a2dd95SBruce Richardson 			   int16_t queue_port_id,
169299a2dd95SBruce Richardson 			   const uint32_t ids[],
169399a2dd95SBruce Richardson 			   uint32_t nb_ids);
169499a2dd95SBruce Richardson 
169599a2dd95SBruce Richardson /**
169699a2dd95SBruce Richardson  * Trigger the eventdev self test.
169799a2dd95SBruce Richardson  *
169899a2dd95SBruce Richardson  * @param dev_id
169999a2dd95SBruce Richardson  *   The identifier of the device
170099a2dd95SBruce Richardson  * @return
170199a2dd95SBruce Richardson  *   - 0: Selftest successful
170299a2dd95SBruce Richardson  *   - -ENOTSUP if the device doesn't support selftest
170399a2dd95SBruce Richardson  *   - other values < 0 on failure.
170499a2dd95SBruce Richardson  */
170599a2dd95SBruce Richardson int rte_event_dev_selftest(uint8_t dev_id);
170699a2dd95SBruce Richardson 
170799a2dd95SBruce Richardson /**
170899a2dd95SBruce Richardson  * Get the memory required per event vector based on the number of elements per
170999a2dd95SBruce Richardson  * vector.
171099a2dd95SBruce Richardson  * This should be used to create the mempool that holds the event vectors.
171199a2dd95SBruce Richardson  *
171299a2dd95SBruce Richardson  * @param name
171399a2dd95SBruce Richardson  *   The name of the vector pool.
171499a2dd95SBruce Richardson  * @param n
171599a2dd95SBruce Richardson  *   The number of elements in the mbuf pool.
171699a2dd95SBruce Richardson  * @param cache_size
171799a2dd95SBruce Richardson  *   Size of the per-core object cache. See rte_mempool_create() for
171899a2dd95SBruce Richardson  *   details.
171999a2dd95SBruce Richardson  * @param nb_elem
172099a2dd95SBruce Richardson  *   The number of elements that a single event vector should be able to hold.
172199a2dd95SBruce Richardson  * @param socket_id
172299a2dd95SBruce Richardson  *   The socket identifier where the memory should be allocated. The
172399a2dd95SBruce Richardson  *   value can be *SOCKET_ID_ANY* if there is no NUMA constraint for the
172499a2dd95SBruce Richardson  *   reserved zone
172599a2dd95SBruce Richardson  *
172699a2dd95SBruce Richardson  * @return
172799a2dd95SBruce Richardson  *   The pointer to the newly allocated mempool, on success. NULL on error
172899a2dd95SBruce Richardson  *   with rte_errno set appropriately. Possible rte_errno values include:
172999a2dd95SBruce Richardson  *    - E_RTE_NO_CONFIG - function could not get pointer to rte_config structure
173099a2dd95SBruce Richardson  *    - E_RTE_SECONDARY - function was called from a secondary process instance
173199a2dd95SBruce Richardson  *    - EINVAL - cache size provided is too large, or priv_size is not aligned.
173299a2dd95SBruce Richardson  *    - ENOSPC - the maximum number of memzones has already been allocated
173399a2dd95SBruce Richardson  *    - EEXIST - a memzone with the same name already exists
173499a2dd95SBruce Richardson  *    - ENOMEM - no appropriate memory area found in which to create memzone
173599a2dd95SBruce Richardson  *    - ENAMETOOLONG - mempool name requested is too long.
173699a2dd95SBruce Richardson  */
173799a2dd95SBruce Richardson __rte_experimental
173899a2dd95SBruce Richardson struct rte_mempool *
173999a2dd95SBruce Richardson rte_event_vector_pool_create(const char *name, unsigned int n,
174099a2dd95SBruce Richardson 			     unsigned int cache_size, uint16_t nb_elem,
174199a2dd95SBruce Richardson 			     int socket_id);
174299a2dd95SBruce Richardson 
174326f14535SPavan Nikhilesh #include <rte_eventdev_core.h>
174426f14535SPavan Nikhilesh 
174526f14535SPavan Nikhilesh static __rte_always_inline uint16_t
174626f14535SPavan Nikhilesh __rte_event_enqueue_burst(uint8_t dev_id, uint8_t port_id,
174726f14535SPavan Nikhilesh 			  const struct rte_event ev[], uint16_t nb_events,
174826f14535SPavan Nikhilesh 			  const event_enqueue_burst_t fn)
174926f14535SPavan Nikhilesh {
1750052e25d9SPavan Nikhilesh 	const struct rte_event_fp_ops *fp_ops;
1751052e25d9SPavan Nikhilesh 	void *port;
175226f14535SPavan Nikhilesh 
1753052e25d9SPavan Nikhilesh 	fp_ops = &rte_event_fp_ops[dev_id];
1754052e25d9SPavan Nikhilesh 	port = fp_ops->data[port_id];
175526f14535SPavan Nikhilesh #ifdef RTE_LIBRTE_EVENTDEV_DEBUG
1756052e25d9SPavan Nikhilesh 	if (dev_id >= RTE_EVENT_MAX_DEVS ||
1757052e25d9SPavan Nikhilesh 	    port_id >= RTE_EVENT_MAX_PORTS_PER_DEV) {
175826f14535SPavan Nikhilesh 		rte_errno = EINVAL;
175926f14535SPavan Nikhilesh 		return 0;
176026f14535SPavan Nikhilesh 	}
176126f14535SPavan Nikhilesh 
1762052e25d9SPavan Nikhilesh 	if (port == NULL) {
176326f14535SPavan Nikhilesh 		rte_errno = EINVAL;
176426f14535SPavan Nikhilesh 		return 0;
176526f14535SPavan Nikhilesh 	}
176626f14535SPavan Nikhilesh #endif
176726f14535SPavan Nikhilesh 	rte_eventdev_trace_enq_burst(dev_id, port_id, ev, nb_events, fn);
176826f14535SPavan Nikhilesh 	/*
176926f14535SPavan Nikhilesh 	 * Allow zero cost non burst mode routine invocation if application
177026f14535SPavan Nikhilesh 	 * requests nb_events as const one
177126f14535SPavan Nikhilesh 	 */
177226f14535SPavan Nikhilesh 	if (nb_events == 1)
1773052e25d9SPavan Nikhilesh 		return (fp_ops->enqueue)(port, ev);
177426f14535SPavan Nikhilesh 	else
1775052e25d9SPavan Nikhilesh 		return fn(port, ev, nb_events);
177626f14535SPavan Nikhilesh }
177726f14535SPavan Nikhilesh 
177826f14535SPavan Nikhilesh /**
177926f14535SPavan Nikhilesh  * Enqueue a burst of events objects or an event object supplied in *rte_event*
178026f14535SPavan Nikhilesh  * structure on an  event device designated by its *dev_id* through the event
178126f14535SPavan Nikhilesh  * port specified by *port_id*. Each event object specifies the event queue on
178226f14535SPavan Nikhilesh  * which it will be enqueued.
178326f14535SPavan Nikhilesh  *
178426f14535SPavan Nikhilesh  * The *nb_events* parameter is the number of event objects to enqueue which are
178526f14535SPavan Nikhilesh  * supplied in the *ev* array of *rte_event* structure.
178626f14535SPavan Nikhilesh  *
178726f14535SPavan Nikhilesh  * Event operations RTE_EVENT_OP_FORWARD and RTE_EVENT_OP_RELEASE must only be
178826f14535SPavan Nikhilesh  * enqueued to the same port that their associated events were dequeued from.
178926f14535SPavan Nikhilesh  *
179026f14535SPavan Nikhilesh  * The rte_event_enqueue_burst() function returns the number of
179126f14535SPavan Nikhilesh  * events objects it actually enqueued. A return value equal to *nb_events*
179226f14535SPavan Nikhilesh  * means that all event objects have been enqueued.
179326f14535SPavan Nikhilesh  *
179426f14535SPavan Nikhilesh  * @param dev_id
179526f14535SPavan Nikhilesh  *   The identifier of the device.
179626f14535SPavan Nikhilesh  * @param port_id
179726f14535SPavan Nikhilesh  *   The identifier of the event port.
179826f14535SPavan Nikhilesh  * @param ev
179926f14535SPavan Nikhilesh  *   Points to an array of *nb_events* objects of type *rte_event* structure
180026f14535SPavan Nikhilesh  *   which contain the event object enqueue operations to be processed.
180126f14535SPavan Nikhilesh  * @param nb_events
180226f14535SPavan Nikhilesh  *   The number of event objects to enqueue, typically number of
180326f14535SPavan Nikhilesh  *   rte_event_port_attr_get(...RTE_EVENT_PORT_ATTR_ENQ_DEPTH...)
180426f14535SPavan Nikhilesh  *   available for this port.
180526f14535SPavan Nikhilesh  *
180626f14535SPavan Nikhilesh  * @return
180726f14535SPavan Nikhilesh  *   The number of event objects actually enqueued on the event device. The
180826f14535SPavan Nikhilesh  *   return value can be less than the value of the *nb_events* parameter when
180926f14535SPavan Nikhilesh  *   the event devices queue is full or if invalid parameters are specified in a
181026f14535SPavan Nikhilesh  *   *rte_event*. If the return value is less than *nb_events*, the remaining
181126f14535SPavan Nikhilesh  *   events at the end of ev[] are not consumed and the caller has to take care
181226f14535SPavan Nikhilesh  *   of them, and rte_errno is set accordingly. Possible errno values include:
181326f14535SPavan Nikhilesh  *   - EINVAL   The port ID is invalid, device ID is invalid, an event's queue
181426f14535SPavan Nikhilesh  *              ID is invalid, or an event's sched type doesn't match the
181526f14535SPavan Nikhilesh  *              capabilities of the destination queue.
181626f14535SPavan Nikhilesh  *   - ENOSPC   The event port was backpressured and unable to enqueue
181726f14535SPavan Nikhilesh  *              one or more events. This error code is only applicable to
181826f14535SPavan Nikhilesh  *              closed systems.
181926f14535SPavan Nikhilesh  * @see rte_event_port_attr_get(), RTE_EVENT_PORT_ATTR_ENQ_DEPTH
182026f14535SPavan Nikhilesh  */
182126f14535SPavan Nikhilesh static inline uint16_t
182226f14535SPavan Nikhilesh rte_event_enqueue_burst(uint8_t dev_id, uint8_t port_id,
182326f14535SPavan Nikhilesh 			const struct rte_event ev[], uint16_t nb_events)
182426f14535SPavan Nikhilesh {
1825052e25d9SPavan Nikhilesh 	const struct rte_event_fp_ops *fp_ops;
182626f14535SPavan Nikhilesh 
1827052e25d9SPavan Nikhilesh 	fp_ops = &rte_event_fp_ops[dev_id];
182826f14535SPavan Nikhilesh 	return __rte_event_enqueue_burst(dev_id, port_id, ev, nb_events,
1829052e25d9SPavan Nikhilesh 					 fp_ops->enqueue_burst);
183026f14535SPavan Nikhilesh }
183126f14535SPavan Nikhilesh 
183226f14535SPavan Nikhilesh /**
183326f14535SPavan Nikhilesh  * Enqueue a burst of events objects of operation type *RTE_EVENT_OP_NEW* on
183426f14535SPavan Nikhilesh  * an event device designated by its *dev_id* through the event port specified
183526f14535SPavan Nikhilesh  * by *port_id*.
183626f14535SPavan Nikhilesh  *
183726f14535SPavan Nikhilesh  * Provides the same functionality as rte_event_enqueue_burst(), expect that
183826f14535SPavan Nikhilesh  * application can use this API when the all objects in the burst contains
183926f14535SPavan Nikhilesh  * the enqueue operation of the type *RTE_EVENT_OP_NEW*. This specialized
184026f14535SPavan Nikhilesh  * function can provide the additional hint to the PMD and optimize if possible.
184126f14535SPavan Nikhilesh  *
184226f14535SPavan Nikhilesh  * The rte_event_enqueue_new_burst() result is undefined if the enqueue burst
184326f14535SPavan Nikhilesh  * has event object of operation type != RTE_EVENT_OP_NEW.
184426f14535SPavan Nikhilesh  *
184526f14535SPavan Nikhilesh  * @param dev_id
184626f14535SPavan Nikhilesh  *   The identifier of the device.
184726f14535SPavan Nikhilesh  * @param port_id
184826f14535SPavan Nikhilesh  *   The identifier of the event port.
184926f14535SPavan Nikhilesh  * @param ev
185026f14535SPavan Nikhilesh  *   Points to an array of *nb_events* objects of type *rte_event* structure
185126f14535SPavan Nikhilesh  *   which contain the event object enqueue operations to be processed.
185226f14535SPavan Nikhilesh  * @param nb_events
185326f14535SPavan Nikhilesh  *   The number of event objects to enqueue, typically number of
185426f14535SPavan Nikhilesh  *   rte_event_port_attr_get(...RTE_EVENT_PORT_ATTR_ENQ_DEPTH...)
185526f14535SPavan Nikhilesh  *   available for this port.
185626f14535SPavan Nikhilesh  *
185726f14535SPavan Nikhilesh  * @return
185826f14535SPavan Nikhilesh  *   The number of event objects actually enqueued on the event device. The
185926f14535SPavan Nikhilesh  *   return value can be less than the value of the *nb_events* parameter when
186026f14535SPavan Nikhilesh  *   the event devices queue is full or if invalid parameters are specified in a
186126f14535SPavan Nikhilesh  *   *rte_event*. If the return value is less than *nb_events*, the remaining
186226f14535SPavan Nikhilesh  *   events at the end of ev[] are not consumed and the caller has to take care
186326f14535SPavan Nikhilesh  *   of them, and rte_errno is set accordingly. Possible errno values include:
186426f14535SPavan Nikhilesh  *   - EINVAL   The port ID is invalid, device ID is invalid, an event's queue
186526f14535SPavan Nikhilesh  *              ID is invalid, or an event's sched type doesn't match the
186626f14535SPavan Nikhilesh  *              capabilities of the destination queue.
186726f14535SPavan Nikhilesh  *   - ENOSPC   The event port was backpressured and unable to enqueue
186826f14535SPavan Nikhilesh  *              one or more events. This error code is only applicable to
186926f14535SPavan Nikhilesh  *              closed systems.
187026f14535SPavan Nikhilesh  * @see rte_event_port_attr_get(), RTE_EVENT_PORT_ATTR_ENQ_DEPTH
187126f14535SPavan Nikhilesh  * @see rte_event_enqueue_burst()
187226f14535SPavan Nikhilesh  */
187326f14535SPavan Nikhilesh static inline uint16_t
187426f14535SPavan Nikhilesh rte_event_enqueue_new_burst(uint8_t dev_id, uint8_t port_id,
187526f14535SPavan Nikhilesh 			    const struct rte_event ev[], uint16_t nb_events)
187626f14535SPavan Nikhilesh {
1877052e25d9SPavan Nikhilesh 	const struct rte_event_fp_ops *fp_ops;
187826f14535SPavan Nikhilesh 
1879052e25d9SPavan Nikhilesh 	fp_ops = &rte_event_fp_ops[dev_id];
188026f14535SPavan Nikhilesh 	return __rte_event_enqueue_burst(dev_id, port_id, ev, nb_events,
1881052e25d9SPavan Nikhilesh 					 fp_ops->enqueue_new_burst);
188226f14535SPavan Nikhilesh }
188326f14535SPavan Nikhilesh 
188426f14535SPavan Nikhilesh /**
188526f14535SPavan Nikhilesh  * Enqueue a burst of events objects of operation type *RTE_EVENT_OP_FORWARD*
188626f14535SPavan Nikhilesh  * on an event device designated by its *dev_id* through the event port
188726f14535SPavan Nikhilesh  * specified by *port_id*.
188826f14535SPavan Nikhilesh  *
188926f14535SPavan Nikhilesh  * Provides the same functionality as rte_event_enqueue_burst(), expect that
189026f14535SPavan Nikhilesh  * application can use this API when the all objects in the burst contains
189126f14535SPavan Nikhilesh  * the enqueue operation of the type *RTE_EVENT_OP_FORWARD*. This specialized
189226f14535SPavan Nikhilesh  * function can provide the additional hint to the PMD and optimize if possible.
189326f14535SPavan Nikhilesh  *
189426f14535SPavan Nikhilesh  * The rte_event_enqueue_new_burst() result is undefined if the enqueue burst
189526f14535SPavan Nikhilesh  * has event object of operation type != RTE_EVENT_OP_FORWARD.
189626f14535SPavan Nikhilesh  *
189726f14535SPavan Nikhilesh  * @param dev_id
189826f14535SPavan Nikhilesh  *   The identifier of the device.
189926f14535SPavan Nikhilesh  * @param port_id
190026f14535SPavan Nikhilesh  *   The identifier of the event port.
190126f14535SPavan Nikhilesh  * @param ev
190226f14535SPavan Nikhilesh  *   Points to an array of *nb_events* objects of type *rte_event* structure
190326f14535SPavan Nikhilesh  *   which contain the event object enqueue operations to be processed.
190426f14535SPavan Nikhilesh  * @param nb_events
190526f14535SPavan Nikhilesh  *   The number of event objects to enqueue, typically number of
190626f14535SPavan Nikhilesh  *   rte_event_port_attr_get(...RTE_EVENT_PORT_ATTR_ENQ_DEPTH...)
190726f14535SPavan Nikhilesh  *   available for this port.
190826f14535SPavan Nikhilesh  *
190926f14535SPavan Nikhilesh  * @return
191026f14535SPavan Nikhilesh  *   The number of event objects actually enqueued on the event device. The
191126f14535SPavan Nikhilesh  *   return value can be less than the value of the *nb_events* parameter when
191226f14535SPavan Nikhilesh  *   the event devices queue is full or if invalid parameters are specified in a
191326f14535SPavan Nikhilesh  *   *rte_event*. If the return value is less than *nb_events*, the remaining
191426f14535SPavan Nikhilesh  *   events at the end of ev[] are not consumed and the caller has to take care
191526f14535SPavan Nikhilesh  *   of them, and rte_errno is set accordingly. Possible errno values include:
191626f14535SPavan Nikhilesh  *   - EINVAL   The port ID is invalid, device ID is invalid, an event's queue
191726f14535SPavan Nikhilesh  *              ID is invalid, or an event's sched type doesn't match the
191826f14535SPavan Nikhilesh  *              capabilities of the destination queue.
191926f14535SPavan Nikhilesh  *   - ENOSPC   The event port was backpressured and unable to enqueue
192026f14535SPavan Nikhilesh  *              one or more events. This error code is only applicable to
192126f14535SPavan Nikhilesh  *              closed systems.
192226f14535SPavan Nikhilesh  * @see rte_event_port_attr_get(), RTE_EVENT_PORT_ATTR_ENQ_DEPTH
192326f14535SPavan Nikhilesh  * @see rte_event_enqueue_burst()
192426f14535SPavan Nikhilesh  */
192526f14535SPavan Nikhilesh static inline uint16_t
192626f14535SPavan Nikhilesh rte_event_enqueue_forward_burst(uint8_t dev_id, uint8_t port_id,
192726f14535SPavan Nikhilesh 				const struct rte_event ev[], uint16_t nb_events)
192826f14535SPavan Nikhilesh {
1929052e25d9SPavan Nikhilesh 	const struct rte_event_fp_ops *fp_ops;
193026f14535SPavan Nikhilesh 
1931052e25d9SPavan Nikhilesh 	fp_ops = &rte_event_fp_ops[dev_id];
193226f14535SPavan Nikhilesh 	return __rte_event_enqueue_burst(dev_id, port_id, ev, nb_events,
1933052e25d9SPavan Nikhilesh 					 fp_ops->enqueue_forward_burst);
193426f14535SPavan Nikhilesh }
193526f14535SPavan Nikhilesh 
193626f14535SPavan Nikhilesh /**
193726f14535SPavan Nikhilesh  * Dequeue a burst of events objects or an event object from the event port
193826f14535SPavan Nikhilesh  * designated by its *event_port_id*, on an event device designated
193926f14535SPavan Nikhilesh  * by its *dev_id*.
194026f14535SPavan Nikhilesh  *
194126f14535SPavan Nikhilesh  * rte_event_dequeue_burst() does not dictate the specifics of scheduling
194226f14535SPavan Nikhilesh  * algorithm as each eventdev driver may have different criteria to schedule
194326f14535SPavan Nikhilesh  * an event. However, in general, from an application perspective scheduler may
194426f14535SPavan Nikhilesh  * use the following scheme to dispatch an event to the port.
194526f14535SPavan Nikhilesh  *
194626f14535SPavan Nikhilesh  * 1) Selection of event queue based on
194726f14535SPavan Nikhilesh  *   a) The list of event queues are linked to the event port.
194826f14535SPavan Nikhilesh  *   b) If the device has RTE_EVENT_DEV_CAP_QUEUE_QOS capability then event
194926f14535SPavan Nikhilesh  *   queue selection from list is based on event queue priority relative to
195026f14535SPavan Nikhilesh  *   other event queue supplied as *priority* in rte_event_queue_setup()
195126f14535SPavan Nikhilesh  *   c) If the device has RTE_EVENT_DEV_CAP_EVENT_QOS capability then event
195226f14535SPavan Nikhilesh  *   queue selection from the list is based on event priority supplied as
195326f14535SPavan Nikhilesh  *   *priority* in rte_event_enqueue_burst()
195426f14535SPavan Nikhilesh  * 2) Selection of event
195526f14535SPavan Nikhilesh  *   a) The number of flows available in selected event queue.
195626f14535SPavan Nikhilesh  *   b) Schedule type method associated with the event
195726f14535SPavan Nikhilesh  *
195826f14535SPavan Nikhilesh  * The *nb_events* parameter is the maximum number of event objects to dequeue
195926f14535SPavan Nikhilesh  * which are returned in the *ev* array of *rte_event* structure.
196026f14535SPavan Nikhilesh  *
196126f14535SPavan Nikhilesh  * The rte_event_dequeue_burst() function returns the number of events objects
196226f14535SPavan Nikhilesh  * it actually dequeued. A return value equal to *nb_events* means that all
196326f14535SPavan Nikhilesh  * event objects have been dequeued.
196426f14535SPavan Nikhilesh  *
196526f14535SPavan Nikhilesh  * The number of events dequeued is the number of scheduler contexts held by
196626f14535SPavan Nikhilesh  * this port. These contexts are automatically released in the next
196726f14535SPavan Nikhilesh  * rte_event_dequeue_burst() invocation if the port supports implicit
196826f14535SPavan Nikhilesh  * releases, or invoking rte_event_enqueue_burst() with RTE_EVENT_OP_RELEASE
196926f14535SPavan Nikhilesh  * operation can be used to release the contexts early.
197026f14535SPavan Nikhilesh  *
197126f14535SPavan Nikhilesh  * Event operations RTE_EVENT_OP_FORWARD and RTE_EVENT_OP_RELEASE must only be
197226f14535SPavan Nikhilesh  * enqueued to the same port that their associated events were dequeued from.
197326f14535SPavan Nikhilesh  *
197426f14535SPavan Nikhilesh  * @param dev_id
197526f14535SPavan Nikhilesh  *   The identifier of the device.
197626f14535SPavan Nikhilesh  * @param port_id
197726f14535SPavan Nikhilesh  *   The identifier of the event port.
197826f14535SPavan Nikhilesh  * @param[out] ev
197926f14535SPavan Nikhilesh  *   Points to an array of *nb_events* objects of type *rte_event* structure
198026f14535SPavan Nikhilesh  *   for output to be populated with the dequeued event objects.
198126f14535SPavan Nikhilesh  * @param nb_events
198226f14535SPavan Nikhilesh  *   The maximum number of event objects to dequeue, typically number of
198326f14535SPavan Nikhilesh  *   rte_event_port_dequeue_depth() available for this port.
198426f14535SPavan Nikhilesh  *
198526f14535SPavan Nikhilesh  * @param timeout_ticks
198626f14535SPavan Nikhilesh  *   - 0 no-wait, returns immediately if there is no event.
198726f14535SPavan Nikhilesh  *   - >0 wait for the event, if the device is configured with
198826f14535SPavan Nikhilesh  *   RTE_EVENT_DEV_CFG_PER_DEQUEUE_TIMEOUT then this function will wait until
198926f14535SPavan Nikhilesh  *   at least one event is available or *timeout_ticks* time.
199026f14535SPavan Nikhilesh  *   if the device is not configured with RTE_EVENT_DEV_CFG_PER_DEQUEUE_TIMEOUT
199126f14535SPavan Nikhilesh  *   then this function will wait until the event available or
199226f14535SPavan Nikhilesh  *   *dequeue_timeout_ns* ns which was previously supplied to
199326f14535SPavan Nikhilesh  *   rte_event_dev_configure()
199426f14535SPavan Nikhilesh  *
199526f14535SPavan Nikhilesh  * @return
199626f14535SPavan Nikhilesh  * The number of event objects actually dequeued from the port. The return
199726f14535SPavan Nikhilesh  * value can be less than the value of the *nb_events* parameter when the
199826f14535SPavan Nikhilesh  * event port's queue is not full.
199926f14535SPavan Nikhilesh  *
200026f14535SPavan Nikhilesh  * @see rte_event_port_dequeue_depth()
200126f14535SPavan Nikhilesh  */
200226f14535SPavan Nikhilesh static inline uint16_t
200326f14535SPavan Nikhilesh rte_event_dequeue_burst(uint8_t dev_id, uint8_t port_id, struct rte_event ev[],
200426f14535SPavan Nikhilesh 			uint16_t nb_events, uint64_t timeout_ticks)
200526f14535SPavan Nikhilesh {
2006052e25d9SPavan Nikhilesh 	const struct rte_event_fp_ops *fp_ops;
2007052e25d9SPavan Nikhilesh 	void *port;
200826f14535SPavan Nikhilesh 
2009052e25d9SPavan Nikhilesh 	fp_ops = &rte_event_fp_ops[dev_id];
2010052e25d9SPavan Nikhilesh 	port = fp_ops->data[port_id];
201126f14535SPavan Nikhilesh #ifdef RTE_LIBRTE_EVENTDEV_DEBUG
2012052e25d9SPavan Nikhilesh 	if (dev_id >= RTE_EVENT_MAX_DEVS ||
2013052e25d9SPavan Nikhilesh 	    port_id >= RTE_EVENT_MAX_PORTS_PER_DEV) {
201426f14535SPavan Nikhilesh 		rte_errno = EINVAL;
201526f14535SPavan Nikhilesh 		return 0;
201626f14535SPavan Nikhilesh 	}
201726f14535SPavan Nikhilesh 
2018052e25d9SPavan Nikhilesh 	if (port == NULL) {
201926f14535SPavan Nikhilesh 		rte_errno = EINVAL;
202026f14535SPavan Nikhilesh 		return 0;
202126f14535SPavan Nikhilesh 	}
202226f14535SPavan Nikhilesh #endif
202326f14535SPavan Nikhilesh 	rte_eventdev_trace_deq_burst(dev_id, port_id, ev, nb_events);
202426f14535SPavan Nikhilesh 	/*
202526f14535SPavan Nikhilesh 	 * Allow zero cost non burst mode routine invocation if application
202626f14535SPavan Nikhilesh 	 * requests nb_events as const one
202726f14535SPavan Nikhilesh 	 */
202826f14535SPavan Nikhilesh 	if (nb_events == 1)
2029052e25d9SPavan Nikhilesh 		return (fp_ops->dequeue)(port, ev, timeout_ticks);
203026f14535SPavan Nikhilesh 	else
2031052e25d9SPavan Nikhilesh 		return (fp_ops->dequeue_burst)(port, ev, nb_events,
2032052e25d9SPavan Nikhilesh 					       timeout_ticks);
203326f14535SPavan Nikhilesh }
203426f14535SPavan Nikhilesh 
203599a2dd95SBruce Richardson #ifdef __cplusplus
203699a2dd95SBruce Richardson }
203799a2dd95SBruce Richardson #endif
203899a2dd95SBruce Richardson 
203999a2dd95SBruce Richardson #endif /* _RTE_EVENTDEV_H_ */
2040