xref: /dpdk/lib/eventdev/rte_event_timer_adapter.h (revision 719834a6849e1daf4a70ff7742bbcc3ae7e25607)
199a2dd95SBruce Richardson /* SPDX-License-Identifier: BSD-3-Clause
299a2dd95SBruce Richardson  * Copyright(c) 2017 Cavium, Inc.
399a2dd95SBruce Richardson  * Copyright(c) 2017-2018 Intel Corporation.
499a2dd95SBruce Richardson  * All rights reserved.
599a2dd95SBruce Richardson  */
699a2dd95SBruce Richardson 
799a2dd95SBruce Richardson #ifndef __RTE_EVENT_TIMER_ADAPTER_H__
899a2dd95SBruce Richardson #define __RTE_EVENT_TIMER_ADAPTER_H__
999a2dd95SBruce Richardson 
1099a2dd95SBruce Richardson /**
1199a2dd95SBruce Richardson  * @file
1299a2dd95SBruce Richardson  *
1399a2dd95SBruce Richardson  * RTE Event Timer Adapter
1499a2dd95SBruce Richardson  *
1599a2dd95SBruce Richardson  * An event timer adapter has the following abstract working model:
1699a2dd95SBruce Richardson  *
1799a2dd95SBruce Richardson  *                               timer_tick_ns
1899a2dd95SBruce Richardson  *                                   +
1999a2dd95SBruce Richardson  *                      +-------+    |
2099a2dd95SBruce Richardson  *                      |       |    |
2199a2dd95SBruce Richardson  *              +-------+ bkt 0 +----v---+
2299a2dd95SBruce Richardson  *              |       |       |        |
2399a2dd95SBruce Richardson  *              |       +-------+        |
2499a2dd95SBruce Richardson  *          +---+---+                +---+---+  +---+---+---+---+
2599a2dd95SBruce Richardson  *          |       |                |       |  |   |   |   |   |
2699a2dd95SBruce Richardson  *          | bkt n |                | bkt 1 |<-> t0| t1| t2| tn|
2799a2dd95SBruce Richardson  *          |       |                |       |  |   |   |   |   |
2899a2dd95SBruce Richardson  *          +---+---+                +---+---+  +---+---+---+---+
2999a2dd95SBruce Richardson  *              |     Timer adapter      |
3099a2dd95SBruce Richardson  *          +---+---+                +---+---+
3199a2dd95SBruce Richardson  *          |       |                |       |
3299a2dd95SBruce Richardson  *          | bkt 4 |                | bkt 2 |<--- Current bucket
3399a2dd95SBruce Richardson  *          |       |                |       |
3499a2dd95SBruce Richardson  *          +---+---+                +---+---+
3599a2dd95SBruce Richardson  *               |      +-------+       |
3699a2dd95SBruce Richardson  *               |      |       |       |
3799a2dd95SBruce Richardson  *               +------+ bkt 3 +-------+
3899a2dd95SBruce Richardson  *                      |       |
3999a2dd95SBruce Richardson  *                      +-------+
4099a2dd95SBruce Richardson  *
4199a2dd95SBruce Richardson  * - It has a virtual monotonically increasing 64-bit timer adapter clock based
4299a2dd95SBruce Richardson  *   on *enum rte_event_timer_adapter_clk_src* clock source. The clock source
4399a2dd95SBruce Richardson  *   could be a CPU clock, or a platform dependent external clock.
4499a2dd95SBruce Richardson  *
4599a2dd95SBruce Richardson  * - The application creates a timer adapter instance with given the clock
4699a2dd95SBruce Richardson  *   source, the total number of event timers, and a resolution(expressed in ns)
4799a2dd95SBruce Richardson  *   to traverse between the buckets.
4899a2dd95SBruce Richardson  *
4999a2dd95SBruce Richardson  * - Each timer adapter may have 0 to n buckets based on the configured
5099a2dd95SBruce Richardson  *   max timeout(max_tmo_ns) and resolution(timer_tick_ns). Upon starting the
5199a2dd95SBruce Richardson  *   timer adapter, the adapter starts ticking at *timer_tick_ns* resolution.
5299a2dd95SBruce Richardson  *
5399a2dd95SBruce Richardson  * - The application arms an event timer that will expire *timer_tick_ns*
5499a2dd95SBruce Richardson  *   from now.
5599a2dd95SBruce Richardson  *
5699a2dd95SBruce Richardson  * - The application can cancel an armed timer and no timer expiry event will be
5799a2dd95SBruce Richardson  *   generated.
5899a2dd95SBruce Richardson  *
5999a2dd95SBruce Richardson  * - If a timer expires then the library injects the timer expiry event in
6099a2dd95SBruce Richardson  *   the designated event queue.
6199a2dd95SBruce Richardson  *
6299a2dd95SBruce Richardson  * - The timer expiry event will be received through *rte_event_dequeue_burst*.
6399a2dd95SBruce Richardson  *
6499a2dd95SBruce Richardson  * - The application frees the timer adapter instance.
6599a2dd95SBruce Richardson  *
6699a2dd95SBruce Richardson  * Multiple timer adapters can be created with a varying level of resolution
6799a2dd95SBruce Richardson  * for various expiry use cases that run in parallel.
6899a2dd95SBruce Richardson  *
6999a2dd95SBruce Richardson  * Before using the timer adapter, the application has to create and configure
7099a2dd95SBruce Richardson  * an event device along with the event port. Based on the event device
7199a2dd95SBruce Richardson  * capability it might require creating an additional event port to be used
7299a2dd95SBruce Richardson  * by the timer adapter.
7399a2dd95SBruce Richardson  *
7499a2dd95SBruce Richardson  * The application creates the event timer adapter using the
7599a2dd95SBruce Richardson  * ``rte_event_timer_adapter_create()``. The event device id is passed to this
7699a2dd95SBruce Richardson  * function, inside this function the event device capability is checked,
7799a2dd95SBruce Richardson  * and if an in-built port is absent the application uses the default
7899a2dd95SBruce Richardson  * function to create a new producer port.
7999a2dd95SBruce Richardson  *
8099a2dd95SBruce Richardson  * The application may also use the function
8199a2dd95SBruce Richardson  * ``rte_event_timer_adapter_create_ext()`` to have granular control over
8299a2dd95SBruce Richardson  * producer port creation in a case where the in-built port is absent.
8399a2dd95SBruce Richardson  *
8499a2dd95SBruce Richardson  * After creating the timer adapter, the application has to start it
8599a2dd95SBruce Richardson  * using ``rte_event_timer_adapter_start()``. The buckets are traversed from
8699a2dd95SBruce Richardson  * 0 to n; when the adapter ticks, the next bucket is visited. Each time,
8799a2dd95SBruce Richardson  * the list per bucket is processed, and timer expiry events are sent to the
8899a2dd95SBruce Richardson  * designated event queue.
8999a2dd95SBruce Richardson  *
9099a2dd95SBruce Richardson  * The application can arm one or more event timers using the
9199a2dd95SBruce Richardson  * ``rte_event_timer_arm_burst()``. The *timeout_ticks* represents the number
9299a2dd95SBruce Richardson  * of *timer_tick_ns* after which the timer has to expire. The timeout at
9399a2dd95SBruce Richardson  * which the timers expire can be grouped or be independent of each
9499a2dd95SBruce Richardson  * event timer instance. ``rte_event_timer_arm_tmo_tick_burst()`` addresses the
9599a2dd95SBruce Richardson  * former case and ``rte_event_timer_arm_burst()`` addresses the latter case.
9699a2dd95SBruce Richardson  *
9799a2dd95SBruce Richardson  * The application can cancel the timers from expiring using the
9899a2dd95SBruce Richardson  * ``rte_event_timer_cancel_burst()``.
9999a2dd95SBruce Richardson  *
10099a2dd95SBruce Richardson  * On the secondary process, ``rte_event_timer_adapter_lookup()`` can be used
10199a2dd95SBruce Richardson  * to get the timer adapter pointer from its id and use it to invoke fastpath
10299a2dd95SBruce Richardson  * operations such as arm and cancel.
10399a2dd95SBruce Richardson  *
10499a2dd95SBruce Richardson  * Some of the use cases of event timer adapter are Beacon Timers,
10599a2dd95SBruce Richardson  * Generic SW Timeout, Wireless MAC Scheduling, 3G Frame Protocols,
10699a2dd95SBruce Richardson  * Packet Scheduling, Protocol Retransmission Timers, Supervision Timers.
10799a2dd95SBruce Richardson  * All these use cases require high resolution and low time drift.
10899a2dd95SBruce Richardson  */
10999a2dd95SBruce Richardson 
11099a2dd95SBruce Richardson 
11199a2dd95SBruce Richardson #include "rte_eventdev.h"
11299a2dd95SBruce Richardson #include "rte_eventdev_trace_fp.h"
11399a2dd95SBruce Richardson 
114*719834a6SMattias Rönnblom #ifdef __cplusplus
115*719834a6SMattias Rönnblom extern "C" {
116*719834a6SMattias Rönnblom #endif
117*719834a6SMattias Rönnblom 
11899a2dd95SBruce Richardson /**
11999a2dd95SBruce Richardson  * Timer adapter clock source
12099a2dd95SBruce Richardson  */
12199a2dd95SBruce Richardson enum rte_event_timer_adapter_clk_src {
12299a2dd95SBruce Richardson 	RTE_EVENT_TIMER_ADAPTER_CPU_CLK,
12399a2dd95SBruce Richardson 	/**< Use CPU clock as the clock source. */
12499a2dd95SBruce Richardson 	RTE_EVENT_TIMER_ADAPTER_EXT_CLK0,
12599a2dd95SBruce Richardson 	/**< Platform dependent external clock source 0. */
12699a2dd95SBruce Richardson 	RTE_EVENT_TIMER_ADAPTER_EXT_CLK1,
12799a2dd95SBruce Richardson 	/**< Platform dependent external clock source 1. */
12899a2dd95SBruce Richardson 	RTE_EVENT_TIMER_ADAPTER_EXT_CLK2,
12999a2dd95SBruce Richardson 	/**< Platform dependent external clock source 2. */
13099a2dd95SBruce Richardson 	RTE_EVENT_TIMER_ADAPTER_EXT_CLK3,
13199a2dd95SBruce Richardson 	/**< Platform dependent external clock source 3. */
13299a2dd95SBruce Richardson };
13399a2dd95SBruce Richardson 
13499a2dd95SBruce Richardson #define RTE_EVENT_TIMER_ADAPTER_F_ADJUST_RES	(1ULL << 0)
13599a2dd95SBruce Richardson /**< The event timer adapter implementation may have constraints on the
13699a2dd95SBruce Richardson  * resolution (timer_tick_ns) and maximum timer expiry timeout(max_tmo_ns)
13799a2dd95SBruce Richardson  * based on the given timer adapter or system. If this flag is set, the
13899a2dd95SBruce Richardson  * implementation adjusts the resolution and maximum timeout to the best
13999a2dd95SBruce Richardson  * possible configuration. On successful timer adapter creation, the
14099a2dd95SBruce Richardson  * application can get the configured resolution and max timeout with
14199a2dd95SBruce Richardson  * ``rte_event_timer_adapter_get_info()``.
14299a2dd95SBruce Richardson  *
14399a2dd95SBruce Richardson  * @see struct rte_event_timer_adapter_info::min_resolution_ns
14499a2dd95SBruce Richardson  * @see struct rte_event_timer_adapter_info::max_tmo_ns
14599a2dd95SBruce Richardson  */
14699a2dd95SBruce Richardson #define RTE_EVENT_TIMER_ADAPTER_F_SP_PUT	(1ULL << 1)
14799a2dd95SBruce Richardson /**< ``rte_event_timer_arm_burst()`` API to be used in single producer mode.
14899a2dd95SBruce Richardson  *
14999a2dd95SBruce Richardson  * @see struct rte_event_timer_adapter_conf::flags
15099a2dd95SBruce Richardson  */
15199a2dd95SBruce Richardson 
15299a2dd95SBruce Richardson #define RTE_EVENT_TIMER_ADAPTER_F_PERIODIC	(1ULL << 2)
15399a2dd95SBruce Richardson /**< Flag to configure an event timer adapter in periodic mode; non-periodic
15499a2dd95SBruce Richardson  * mode is the default. A timer will fire once or periodically until the timer
15599a2dd95SBruce Richardson  * is cancelled based on the adapter mode.
15699a2dd95SBruce Richardson  *
15799a2dd95SBruce Richardson  * @see struct rte_event_timer_adapter_conf::flags
15899a2dd95SBruce Richardson  */
15999a2dd95SBruce Richardson 
16099a2dd95SBruce Richardson /**
16199a2dd95SBruce Richardson  * Timer adapter configuration structure
16299a2dd95SBruce Richardson  */
16399a2dd95SBruce Richardson struct rte_event_timer_adapter_conf {
16499a2dd95SBruce Richardson 	uint8_t event_dev_id;
16599a2dd95SBruce Richardson 	/**< Event device identifier */
16699a2dd95SBruce Richardson 	uint16_t timer_adapter_id;
16799a2dd95SBruce Richardson 	/**< Event timer adapter identifier */
16899a2dd95SBruce Richardson 	uint32_t socket_id;
16999a2dd95SBruce Richardson 	/**< Identifier of socket from which to allocate memory for adapter */
17099a2dd95SBruce Richardson 	enum rte_event_timer_adapter_clk_src clk_src;
17199a2dd95SBruce Richardson 	/**< Clock source for timer adapter */
17299a2dd95SBruce Richardson 	uint64_t timer_tick_ns;
17399a2dd95SBruce Richardson 	/**< Timer adapter resolution in ns */
17499a2dd95SBruce Richardson 	uint64_t max_tmo_ns;
17599a2dd95SBruce Richardson 	/**< Maximum timer timeout(expiry) in ns */
17699a2dd95SBruce Richardson 	uint64_t nb_timers;
17799a2dd95SBruce Richardson 	/**< Total number of timers per adapter */
17899a2dd95SBruce Richardson 	uint64_t flags;
17999a2dd95SBruce Richardson 	/**< Timer adapter config flags (RTE_EVENT_TIMER_ADAPTER_F_*) */
18099a2dd95SBruce Richardson };
18199a2dd95SBruce Richardson 
18299a2dd95SBruce Richardson /**
18399a2dd95SBruce Richardson  * Event timer adapter stats structure
18499a2dd95SBruce Richardson  */
18599a2dd95SBruce Richardson struct rte_event_timer_adapter_stats {
18699a2dd95SBruce Richardson 	uint64_t evtim_exp_count;
18799a2dd95SBruce Richardson 	/**< Number of event timers that have expired. */
18899a2dd95SBruce Richardson 	uint64_t ev_enq_count;
18999a2dd95SBruce Richardson 	/**< Eventdev enqueue count */
19099a2dd95SBruce Richardson 	uint64_t ev_inv_count;
19199a2dd95SBruce Richardson 	/**< Invalid expiry event count */
19299a2dd95SBruce Richardson 	uint64_t evtim_retry_count;
19399a2dd95SBruce Richardson 	/**< Event timer retry count */
19499a2dd95SBruce Richardson 	uint64_t adapter_tick_count;
19599a2dd95SBruce Richardson 	/**< Tick count for the adapter, at its resolution */
1963d9d8adfSNaga Harish K S V 	uint64_t evtim_drop_count;
1973d9d8adfSNaga Harish K S V 	/**< event timer expiries dropped */
19899a2dd95SBruce Richardson };
19999a2dd95SBruce Richardson 
20099a2dd95SBruce Richardson struct rte_event_timer_adapter;
20199a2dd95SBruce Richardson 
20299a2dd95SBruce Richardson /**
20399a2dd95SBruce Richardson  * Callback function type for producer port creation.
20499a2dd95SBruce Richardson  */
20599a2dd95SBruce Richardson typedef int (*rte_event_timer_adapter_port_conf_cb_t)(uint16_t id,
20699a2dd95SBruce Richardson 						      uint8_t event_dev_id,
20799a2dd95SBruce Richardson 						      uint8_t *event_port_id,
20899a2dd95SBruce Richardson 						      void *conf_arg);
20999a2dd95SBruce Richardson 
21099a2dd95SBruce Richardson /**
21199a2dd95SBruce Richardson  * Create an event timer adapter.
21299a2dd95SBruce Richardson  *
21399a2dd95SBruce Richardson  * This function must be invoked first before any other function in the API.
21499a2dd95SBruce Richardson  *
215850ae162SNaga Harish K S V  * When this API is used for creating adapter instance,
216850ae162SNaga Harish K S V  * ``rte_event_dev_config::nb_event_ports`` is automatically incremented,
217850ae162SNaga Harish K S V  * and the event device is reconfigured with additional event port during
218850ae162SNaga Harish K S V  * service initialization. This event device reconfigure logic also increments
219850ae162SNaga Harish K S V  * the ``rte_event_dev_config::nb_single_link_event_port_queues``
220850ae162SNaga Harish K S V  * parameter if the adapter event port config is of type
221850ae162SNaga Harish K S V  * ``RTE_EVENT_PORT_CFG_SINGLE_LINK``.
222850ae162SNaga Harish K S V  *
223850ae162SNaga Harish K S V  * Application no longer needs to account for
224850ae162SNaga Harish K S V  * ``rte_event_dev_config::nb_event_ports`` and
225850ae162SNaga Harish K S V  * ``rte_event_dev_config::nb_single_link_event_port_queues``
226850ae162SNaga Harish K S V  * parameters required for Timer adapter in event device configuration
227850ae162SNaga Harish K S V  * when the adapter is created with this API.
228850ae162SNaga Harish K S V  *
22999a2dd95SBruce Richardson  * @param conf
23099a2dd95SBruce Richardson  *   The event timer adapter configuration structure.
23199a2dd95SBruce Richardson  *
23299a2dd95SBruce Richardson  * @return
23399a2dd95SBruce Richardson  *   A pointer to the new allocated event timer adapter on success.
23499a2dd95SBruce Richardson  *   NULL on error with rte_errno set appropriately.
23599a2dd95SBruce Richardson  *   Possible rte_errno values include:
23699a2dd95SBruce Richardson  *   - ERANGE: timer_tick_ns is not in supported range.
23799a2dd95SBruce Richardson  *   - ENOMEM: unable to allocate sufficient memory for adapter instances
23899a2dd95SBruce Richardson  *   - EINVAL: invalid event device identifier specified in config
23999a2dd95SBruce Richardson  *   - ENOSPC: maximum number of adapters already created
24099a2dd95SBruce Richardson  *   - EIO: event device reconfiguration and restart error.  The adapter
24199a2dd95SBruce Richardson  *   reconfigures the event device with an additional port by default if it is
24299a2dd95SBruce Richardson  *   required to use a service to manage timers. If the device had been started
24399a2dd95SBruce Richardson  *   before this call, this error code indicates an error in restart following
24499a2dd95SBruce Richardson  *   an error in reconfiguration, i.e., a combination of the two error codes.
24599a2dd95SBruce Richardson  */
24699a2dd95SBruce Richardson struct rte_event_timer_adapter *
24799a2dd95SBruce Richardson rte_event_timer_adapter_create(const struct rte_event_timer_adapter_conf *conf);
24899a2dd95SBruce Richardson 
24999a2dd95SBruce Richardson /**
25099a2dd95SBruce Richardson  * Create a timer adapter with the supplied callback.
25199a2dd95SBruce Richardson  *
25299a2dd95SBruce Richardson  * This function can be used to have a more granular control over the timer
25399a2dd95SBruce Richardson  * adapter creation.  If a built-in port is absent, then the function uses the
25499a2dd95SBruce Richardson  * callback provided to create and get the port id to be used as a producer
25599a2dd95SBruce Richardson  * port.
25699a2dd95SBruce Richardson  *
25799a2dd95SBruce Richardson  * @param conf
25899a2dd95SBruce Richardson  *   The timer adapter configuration structure
25999a2dd95SBruce Richardson  * @param conf_cb
26099a2dd95SBruce Richardson  *   The port config callback function.
26199a2dd95SBruce Richardson  * @param conf_arg
26299a2dd95SBruce Richardson  *   Opaque pointer to the argument for the callback function
26399a2dd95SBruce Richardson  *
26499a2dd95SBruce Richardson  * @return
26599a2dd95SBruce Richardson  *   A pointer to the new allocated event timer adapter on success.
26699a2dd95SBruce Richardson  *   NULL on error with rte_errno set appropriately.
26799a2dd95SBruce Richardson  *   Possible rte_errno values include:
26899a2dd95SBruce Richardson  *   - ERANGE: timer_tick_ns is not in supported range.
26999a2dd95SBruce Richardson  *   - ENOMEM: unable to allocate sufficient memory for adapter instances
27099a2dd95SBruce Richardson  *   - EINVAL: invalid event device identifier specified in config
27199a2dd95SBruce Richardson  *   - ENOSPC: maximum number of adapters already created
27299a2dd95SBruce Richardson  */
27399a2dd95SBruce Richardson struct rte_event_timer_adapter *
27499a2dd95SBruce Richardson rte_event_timer_adapter_create_ext(
27599a2dd95SBruce Richardson 		const struct rte_event_timer_adapter_conf *conf,
27699a2dd95SBruce Richardson 		rte_event_timer_adapter_port_conf_cb_t conf_cb,
27799a2dd95SBruce Richardson 		void *conf_arg);
27899a2dd95SBruce Richardson 
27999a2dd95SBruce Richardson /**
28099a2dd95SBruce Richardson  * Timer adapter info structure.
28199a2dd95SBruce Richardson  */
28299a2dd95SBruce Richardson struct rte_event_timer_adapter_info {
28399a2dd95SBruce Richardson 	uint64_t min_resolution_ns;
28499a2dd95SBruce Richardson 	/**< Minimum timer adapter resolution in ns */
28599a2dd95SBruce Richardson 	uint64_t max_tmo_ns;
28699a2dd95SBruce Richardson 	/**< Maximum timer timeout(expire) in ns */
28799a2dd95SBruce Richardson 	struct rte_event_timer_adapter_conf conf;
28899a2dd95SBruce Richardson 	/**< Configured timer adapter attributes */
28999a2dd95SBruce Richardson 	uint32_t caps;
29099a2dd95SBruce Richardson 	/**< Event timer adapter capabilities */
29199a2dd95SBruce Richardson 	int16_t event_dev_port_id;
29299a2dd95SBruce Richardson 	/**< Event device port ID, if applicable */
29399a2dd95SBruce Richardson };
29499a2dd95SBruce Richardson 
29599a2dd95SBruce Richardson /**
29699a2dd95SBruce Richardson  * Retrieve the contextual information of an event timer adapter.
29799a2dd95SBruce Richardson  *
29899a2dd95SBruce Richardson  * @param adapter
29999a2dd95SBruce Richardson  *   A pointer to the event timer adapter structure.
30099a2dd95SBruce Richardson  *
30199a2dd95SBruce Richardson  * @param[out] adapter_info
30299a2dd95SBruce Richardson  *   A pointer to a structure of type *rte_event_timer_adapter_info* to be
30399a2dd95SBruce Richardson  *   filled with the contextual information of the adapter.
30499a2dd95SBruce Richardson  *
30599a2dd95SBruce Richardson  * @return
30699a2dd95SBruce Richardson  *   - 0: Success, driver updates the contextual information of the
30799a2dd95SBruce Richardson  *   timer adapter
30899a2dd95SBruce Richardson  *   - <0: Error code returned by the driver info get function.
30999a2dd95SBruce Richardson  *   - -EINVAL: adapter identifier invalid
31099a2dd95SBruce Richardson  *
31199a2dd95SBruce Richardson  * @see RTE_EVENT_TIMER_ADAPTER_F_ADJUST_RES,
31299a2dd95SBruce Richardson  *   struct rte_event_timer_adapter_info
31399a2dd95SBruce Richardson  */
31499a2dd95SBruce Richardson int
31599a2dd95SBruce Richardson rte_event_timer_adapter_get_info(
31699a2dd95SBruce Richardson 		const struct rte_event_timer_adapter *adapter,
31799a2dd95SBruce Richardson 		struct rte_event_timer_adapter_info *adapter_info);
31899a2dd95SBruce Richardson 
31999a2dd95SBruce Richardson /**
32099a2dd95SBruce Richardson  * Start a timer adapter.
32199a2dd95SBruce Richardson  *
32299a2dd95SBruce Richardson  * The adapter start step is the last one and consists of setting the timer
32399a2dd95SBruce Richardson  * adapter to start accepting the timers and schedules to event queues.
32499a2dd95SBruce Richardson  *
32599a2dd95SBruce Richardson  * On success, all basic functions exported by the API (timer arm,
32699a2dd95SBruce Richardson  * timer cancel and so on) can be invoked.
32799a2dd95SBruce Richardson  *
32899a2dd95SBruce Richardson  * @param adapter
32999a2dd95SBruce Richardson  *   A pointer to the event timer adapter structure.
33099a2dd95SBruce Richardson  *
33199a2dd95SBruce Richardson  * @return
33299a2dd95SBruce Richardson  *   - 0: Success, adapter started.
33399a2dd95SBruce Richardson  *   - <0: Error code returned by the driver start function.
33499a2dd95SBruce Richardson  *   - -EINVAL if adapter identifier invalid
33599a2dd95SBruce Richardson  *   - -ENOENT if software adapter but no service core mapped
33699a2dd95SBruce Richardson  *   - -ENOTSUP if software adapter and more than one service core mapped
33799a2dd95SBruce Richardson  *   - -EALREADY if adapter has already been started
33899a2dd95SBruce Richardson  *
33999a2dd95SBruce Richardson  * @note
34099a2dd95SBruce Richardson  *  The eventdev to which the event_timer_adapter is connected needs to
34199a2dd95SBruce Richardson  *  be started before calling rte_event_timer_adapter_start().
34299a2dd95SBruce Richardson  */
34399a2dd95SBruce Richardson int
34499a2dd95SBruce Richardson rte_event_timer_adapter_start(
34599a2dd95SBruce Richardson 		const struct rte_event_timer_adapter *adapter);
34699a2dd95SBruce Richardson 
34799a2dd95SBruce Richardson /**
34899a2dd95SBruce Richardson  * Stop an event timer adapter.
34999a2dd95SBruce Richardson  *
35099a2dd95SBruce Richardson  * The adapter can be restarted with a call to
35199a2dd95SBruce Richardson  * ``rte_event_timer_adapter_start()``.
35299a2dd95SBruce Richardson  *
35399a2dd95SBruce Richardson  * @param adapter
35499a2dd95SBruce Richardson  *   A pointer to the event timer adapter structure.
35599a2dd95SBruce Richardson  *
35699a2dd95SBruce Richardson  * @return
35799a2dd95SBruce Richardson  *   - 0: Success, adapter stopped.
35899a2dd95SBruce Richardson  *   - <0: Error code returned by the driver stop function.
35999a2dd95SBruce Richardson  *   - -EINVAL if adapter identifier invalid
36099a2dd95SBruce Richardson  */
36199a2dd95SBruce Richardson int
36299a2dd95SBruce Richardson rte_event_timer_adapter_stop(const struct rte_event_timer_adapter *adapter);
36399a2dd95SBruce Richardson 
36499a2dd95SBruce Richardson /**
36599a2dd95SBruce Richardson  * Lookup an event timer adapter using its identifier.
36699a2dd95SBruce Richardson  *
36799a2dd95SBruce Richardson  * If an event timer adapter was created in another process with the same
36899a2dd95SBruce Richardson  * identifier, this function will locate its state and set up access to it
36999a2dd95SBruce Richardson  * so that it can be used in this process.
37099a2dd95SBruce Richardson  *
37199a2dd95SBruce Richardson  * @param adapter_id
37299a2dd95SBruce Richardson  *  The event timer adapter identifier.
37399a2dd95SBruce Richardson  *
37499a2dd95SBruce Richardson  * @return
37599a2dd95SBruce Richardson  *  A pointer to the event timer adapter matching the identifier on success.
37699a2dd95SBruce Richardson  *  NULL on error with rte_errno set appropriately.
37799a2dd95SBruce Richardson  *  Possible rte_errno values include:
37899a2dd95SBruce Richardson  *   - ENOENT - requested entry not available to return.
37999a2dd95SBruce Richardson  */
38099a2dd95SBruce Richardson struct rte_event_timer_adapter *
38199a2dd95SBruce Richardson rte_event_timer_adapter_lookup(uint16_t adapter_id);
38299a2dd95SBruce Richardson 
38399a2dd95SBruce Richardson /**
38499a2dd95SBruce Richardson  * Free an event timer adapter.
38599a2dd95SBruce Richardson  *
38699a2dd95SBruce Richardson  * Destroy an event timer adapter, freeing all resources.
38799a2dd95SBruce Richardson  *
38899a2dd95SBruce Richardson  * Before invoking this function, the application must wait for all the
38999a2dd95SBruce Richardson  * armed timers to expire or cancel the outstanding armed timers.
39099a2dd95SBruce Richardson  *
39199a2dd95SBruce Richardson  * @param adapter
39299a2dd95SBruce Richardson  *   A pointer to an event timer adapter structure.
39399a2dd95SBruce Richardson  *
39499a2dd95SBruce Richardson  * @return
39599a2dd95SBruce Richardson  *   - 0: Successfully freed the event timer adapter resources.
39699a2dd95SBruce Richardson  *   - <0: Failed to free the event timer adapter resources.
39799a2dd95SBruce Richardson  *   - -EAGAIN:  adapter is busy; timers outstanding
39899a2dd95SBruce Richardson  *   - -EBUSY: stop hasn't been called for this adapter yet
39999a2dd95SBruce Richardson  *   - -EINVAL: adapter id invalid, or adapter invalid
40099a2dd95SBruce Richardson  */
40199a2dd95SBruce Richardson int
40299a2dd95SBruce Richardson rte_event_timer_adapter_free(struct rte_event_timer_adapter *adapter);
40399a2dd95SBruce Richardson 
40499a2dd95SBruce Richardson /**
40599a2dd95SBruce Richardson  * Retrieve the service ID of the event timer adapter. If the adapter doesn't
40699a2dd95SBruce Richardson  * use an rte_service function, this function returns -ESRCH.
40799a2dd95SBruce Richardson  *
40899a2dd95SBruce Richardson  * @param adapter
40999a2dd95SBruce Richardson  *   A pointer to an event timer adapter.
41099a2dd95SBruce Richardson  *
41199a2dd95SBruce Richardson  * @param [out] service_id
41299a2dd95SBruce Richardson  *   A pointer to a uint32_t, to be filled in with the service id.
41399a2dd95SBruce Richardson  *
41499a2dd95SBruce Richardson  * @return
41599a2dd95SBruce Richardson  *   - 0: Success
41699a2dd95SBruce Richardson  *   - <0: Error code on failure
41799a2dd95SBruce Richardson  *   - -ESRCH: the adapter does not require a service to operate
41899a2dd95SBruce Richardson  */
41999a2dd95SBruce Richardson int
42099a2dd95SBruce Richardson rte_event_timer_adapter_service_id_get(struct rte_event_timer_adapter *adapter,
42199a2dd95SBruce Richardson 				       uint32_t *service_id);
42299a2dd95SBruce Richardson 
42399a2dd95SBruce Richardson /**
42499a2dd95SBruce Richardson  * Retrieve statistics for an event timer adapter instance.
42599a2dd95SBruce Richardson  *
42699a2dd95SBruce Richardson  * @param adapter
42799a2dd95SBruce Richardson  *   A pointer to an event timer adapter structure.
42899a2dd95SBruce Richardson  * @param[out] stats
42999a2dd95SBruce Richardson  *   A pointer to a structure to fill with statistics.
43099a2dd95SBruce Richardson  *
43199a2dd95SBruce Richardson  * @return
43299a2dd95SBruce Richardson  *   - 0: Successfully retrieved.
43399a2dd95SBruce Richardson  *   - <0: Failure; error code returned.
43499a2dd95SBruce Richardson  */
43599a2dd95SBruce Richardson int
43699a2dd95SBruce Richardson rte_event_timer_adapter_stats_get(struct rte_event_timer_adapter *adapter,
43799a2dd95SBruce Richardson 		struct rte_event_timer_adapter_stats *stats);
43899a2dd95SBruce Richardson 
43999a2dd95SBruce Richardson /**
44099a2dd95SBruce Richardson  * Reset statistics for an event timer adapter instance.
44199a2dd95SBruce Richardson  *
44299a2dd95SBruce Richardson  * @param adapter
44399a2dd95SBruce Richardson  *   A pointer to an event timer adapter structure.
44499a2dd95SBruce Richardson  *
44599a2dd95SBruce Richardson  * @return
44699a2dd95SBruce Richardson  *   - 0: Successfully reset;
44799a2dd95SBruce Richardson  *   - <0: Failure; error code returned.
44899a2dd95SBruce Richardson  */
44999a2dd95SBruce Richardson int
45099a2dd95SBruce Richardson rte_event_timer_adapter_stats_reset(struct rte_event_timer_adapter *adapter);
45199a2dd95SBruce Richardson 
45299a2dd95SBruce Richardson /**
45399a2dd95SBruce Richardson  * Event timer state.
45499a2dd95SBruce Richardson  */
45599a2dd95SBruce Richardson enum rte_event_timer_state {
45699a2dd95SBruce Richardson 	RTE_EVENT_TIMER_NOT_ARMED	= 0,
45799a2dd95SBruce Richardson 	/**< Event timer not armed. */
45899a2dd95SBruce Richardson 	RTE_EVENT_TIMER_ARMED		= 1,
45999a2dd95SBruce Richardson 	/**< Event timer successfully armed. */
46099a2dd95SBruce Richardson 	RTE_EVENT_TIMER_CANCELED	= 2,
46199a2dd95SBruce Richardson 	/**< Event timer successfully canceled. */
46299a2dd95SBruce Richardson 	RTE_EVENT_TIMER_ERROR		= -1,
46399a2dd95SBruce Richardson 	/**< Generic event timer error. */
46499a2dd95SBruce Richardson 	RTE_EVENT_TIMER_ERROR_TOOEARLY	= -2,
46599a2dd95SBruce Richardson 	/**< Event timer timeout tick value is too small for the adapter to
46699a2dd95SBruce Richardson 	 * handle, given its configured resolution.
46799a2dd95SBruce Richardson 	 */
46899a2dd95SBruce Richardson 	RTE_EVENT_TIMER_ERROR_TOOLATE	= -3,
46999a2dd95SBruce Richardson 	/**< Event timer timeout tick is greater than the maximum timeout.*/
47099a2dd95SBruce Richardson };
47199a2dd95SBruce Richardson 
47299a2dd95SBruce Richardson /**
47399a2dd95SBruce Richardson  * The generic *rte_event_timer* structure to hold the event timer attributes
47499a2dd95SBruce Richardson  * for arm and cancel operations.
47599a2dd95SBruce Richardson  */
476c6552d9aSTyler Retzlaff struct __rte_cache_aligned rte_event_timer {
47799a2dd95SBruce Richardson 	struct rte_event ev;
47899a2dd95SBruce Richardson 	/**<
47999a2dd95SBruce Richardson 	 * Expiry event attributes.  On successful event timer timeout,
48099a2dd95SBruce Richardson 	 * the following attributes will be used to inject the expiry event to
48199a2dd95SBruce Richardson 	 * the eventdev:
48299a2dd95SBruce Richardson 	 *  - event_queue_id: Targeted event queue id for expiry events.
48399a2dd95SBruce Richardson 	 *  - event_priority: Event priority of the event expiry event in the
48499a2dd95SBruce Richardson 	 *  event queue relative to other events.
48599a2dd95SBruce Richardson 	 *  - sched_type: Scheduling type of the expiry event.
48699a2dd95SBruce Richardson 	 *  - flow_id: Flow id of the expiry event.
48799a2dd95SBruce Richardson 	 *  - op: RTE_EVENT_OP_NEW
48899a2dd95SBruce Richardson 	 *  - event_type: RTE_EVENT_TYPE_TIMER
48999a2dd95SBruce Richardson 	 */
49099a2dd95SBruce Richardson 	uint64_t timeout_ticks;
49199a2dd95SBruce Richardson 	/**< Expiry timer ticks expressed in number of *timer_ticks_ns* from
49299a2dd95SBruce Richardson 	 * now.
49399a2dd95SBruce Richardson 	 * @see struct rte_event_timer_adapter_info::adapter_conf::timer_tick_ns
49499a2dd95SBruce Richardson 	 */
49599a2dd95SBruce Richardson 	uint64_t impl_opaque[2];
49699a2dd95SBruce Richardson 	/**< Implementation-specific opaque data.
49799a2dd95SBruce Richardson 	 * An event timer adapter implementation use this field to hold
49899a2dd95SBruce Richardson 	 * implementation specific values to share between the arm and cancel
49999a2dd95SBruce Richardson 	 * operations.  The application should not modify this field.
50099a2dd95SBruce Richardson 	 */
501253de9a8STyler Retzlaff 	RTE_ATOMIC(enum rte_event_timer_state) state;
5021dcd67baSPavan Nikhilesh 	/**< State of the event timer. */
503013b4c52SBruce Richardson 	uint8_t user_meta[];
50499a2dd95SBruce Richardson 	/**< Memory to store user specific metadata.
50599a2dd95SBruce Richardson 	 * The event timer adapter implementation should not modify this area.
50699a2dd95SBruce Richardson 	 */
507c6552d9aSTyler Retzlaff };
50899a2dd95SBruce Richardson 
50999a2dd95SBruce Richardson typedef uint16_t (*rte_event_timer_arm_burst_t)(
51099a2dd95SBruce Richardson 		const struct rte_event_timer_adapter *adapter,
51199a2dd95SBruce Richardson 		struct rte_event_timer **tims,
51299a2dd95SBruce Richardson 		uint16_t nb_tims);
51399a2dd95SBruce Richardson /**< @internal Enable event timers to enqueue timer events upon expiry */
51499a2dd95SBruce Richardson typedef uint16_t (*rte_event_timer_arm_tmo_tick_burst_t)(
51599a2dd95SBruce Richardson 		const struct rte_event_timer_adapter *adapter,
51699a2dd95SBruce Richardson 		struct rte_event_timer **tims,
51799a2dd95SBruce Richardson 		uint64_t timeout_tick,
51899a2dd95SBruce Richardson 		uint16_t nb_tims);
51999a2dd95SBruce Richardson /**< @internal Enable event timers with common expiration time */
52099a2dd95SBruce Richardson typedef uint16_t (*rte_event_timer_cancel_burst_t)(
52199a2dd95SBruce Richardson 		const struct rte_event_timer_adapter *adapter,
52299a2dd95SBruce Richardson 		struct rte_event_timer **tims,
52399a2dd95SBruce Richardson 		uint16_t nb_tims);
52499a2dd95SBruce Richardson /**< @internal Prevent event timers from enqueuing timer events */
52599a2dd95SBruce Richardson 
52699a2dd95SBruce Richardson /**
52799a2dd95SBruce Richardson  * @internal Data structure associated with each event timer adapter.
52899a2dd95SBruce Richardson  */
529c6552d9aSTyler Retzlaff struct __rte_cache_aligned rte_event_timer_adapter {
53099a2dd95SBruce Richardson 	rte_event_timer_arm_burst_t arm_burst;
53199a2dd95SBruce Richardson 	/**< Pointer to driver arm_burst function. */
53299a2dd95SBruce Richardson 	rte_event_timer_arm_tmo_tick_burst_t arm_tmo_tick_burst;
53399a2dd95SBruce Richardson 	/**< Pointer to driver arm_tmo_tick_burst function. */
53499a2dd95SBruce Richardson 	rte_event_timer_cancel_burst_t cancel_burst;
53599a2dd95SBruce Richardson 	/**< Pointer to driver cancel function. */
53699a2dd95SBruce Richardson 	struct rte_event_timer_adapter_data *data;
53799a2dd95SBruce Richardson 	/**< Pointer to shared adapter data */
53853548ad3SPavan Nikhilesh 	const struct event_timer_adapter_ops *ops;
53999a2dd95SBruce Richardson 	/**< Functions exported by adapter driver */
54099a2dd95SBruce Richardson 
54199a2dd95SBruce Richardson 	uint8_t allocated : 1;
54299a2dd95SBruce Richardson 	/**< Flag to indicate that this adapter has been allocated */
543c6552d9aSTyler Retzlaff };
54499a2dd95SBruce Richardson 
54599a2dd95SBruce Richardson #define ADAPTER_VALID_OR_ERR_RET(adapter, retval) do {		\
54699a2dd95SBruce Richardson 	if (adapter == NULL || !adapter->allocated)		\
54799a2dd95SBruce Richardson 		return retval;					\
54899a2dd95SBruce Richardson } while (0)
54999a2dd95SBruce Richardson 
55099a2dd95SBruce Richardson #define FUNC_PTR_OR_ERR_RET(func, errval) do { 			\
55199a2dd95SBruce Richardson 	if ((func) == NULL)					\
55299a2dd95SBruce Richardson 		return errval;					\
55399a2dd95SBruce Richardson } while (0)
55499a2dd95SBruce Richardson 
55599a2dd95SBruce Richardson #define FUNC_PTR_OR_NULL_RET_WITH_ERRNO(func, errval) do { 	\
55699a2dd95SBruce Richardson 	if ((func) == NULL) {					\
55799a2dd95SBruce Richardson 		rte_errno = errval;				\
55899a2dd95SBruce Richardson 		return NULL;					\
55999a2dd95SBruce Richardson 	}							\
56099a2dd95SBruce Richardson } while (0)
56199a2dd95SBruce Richardson 
56299a2dd95SBruce Richardson /**
56399a2dd95SBruce Richardson  * Arm a burst of event timers with separate expiration timeout tick for each
56499a2dd95SBruce Richardson  * event timer.
56599a2dd95SBruce Richardson  *
56699a2dd95SBruce Richardson  * Before calling this function, the application allocates
56799a2dd95SBruce Richardson  * ``struct rte_event_timer`` objects from mempool or huge page backed
56899a2dd95SBruce Richardson  * application buffers of desired size. On successful allocation,
56999a2dd95SBruce Richardson  * application updates the `struct rte_event_timer`` attributes such as
57099a2dd95SBruce Richardson  * expiry event attributes, timeout ticks from now.
57199a2dd95SBruce Richardson  * This function submits the event timer arm requests to the event timer adapter
57299a2dd95SBruce Richardson  * and on expiry, the events will be injected to designated event queue.
57399a2dd95SBruce Richardson  * Timer expiry events will be generated once or periodically until cancellation
57499a2dd95SBruce Richardson  * based on the adapter mode.
57599a2dd95SBruce Richardson  *
57699a2dd95SBruce Richardson  * @param adapter
57799a2dd95SBruce Richardson  *   A pointer to an event timer adapter structure.
57899a2dd95SBruce Richardson  * @param evtims
57999a2dd95SBruce Richardson  *   Pointer to an array of objects of type *rte_event_timer* structure.
58099a2dd95SBruce Richardson  * @param nb_evtims
58199a2dd95SBruce Richardson  *   Number of event timers in the supplied array.
58299a2dd95SBruce Richardson  *
58399a2dd95SBruce Richardson  * @return
58499a2dd95SBruce Richardson  *   The number of successfully armed event timers. The return value can be less
58599a2dd95SBruce Richardson  *   than the value of the *nb_evtims* parameter. If the return value is less
58699a2dd95SBruce Richardson  *   than *nb_evtims*, the remaining event timers at the end of *evtims*
58799a2dd95SBruce Richardson  *   are not consumed, and the caller has to take care of them, and rte_errno
58899a2dd95SBruce Richardson  *   is set accordingly. Possible errno values include:
58999a2dd95SBruce Richardson  *   - EINVAL Invalid timer adapter, expiry event queue ID is invalid, or an
59099a2dd95SBruce Richardson  *   expiry event's sched type doesn't match the capabilities of the
59199a2dd95SBruce Richardson  *   destination event queue.
59299a2dd95SBruce Richardson  *   - EAGAIN Specified timer adapter is not running
59399a2dd95SBruce Richardson  *   - EALREADY A timer was encountered that was already armed
59499a2dd95SBruce Richardson  *
59599a2dd95SBruce Richardson  * @see RTE_EVENT_TIMER_ADAPTER_F_PERIODIC
59699a2dd95SBruce Richardson  */
59799a2dd95SBruce Richardson static inline uint16_t
59899a2dd95SBruce Richardson rte_event_timer_arm_burst(const struct rte_event_timer_adapter *adapter,
59999a2dd95SBruce Richardson 			  struct rte_event_timer **evtims,
60099a2dd95SBruce Richardson 			  uint16_t nb_evtims)
60199a2dd95SBruce Richardson {
60299a2dd95SBruce Richardson #ifdef RTE_LIBRTE_EVENTDEV_DEBUG
60399a2dd95SBruce Richardson 	ADAPTER_VALID_OR_ERR_RET(adapter, -EINVAL);
60499a2dd95SBruce Richardson 	FUNC_PTR_OR_ERR_RET(adapter->arm_burst, -EINVAL);
60599a2dd95SBruce Richardson #endif
60699a2dd95SBruce Richardson 	rte_eventdev_trace_timer_arm_burst(adapter, (void **)evtims,
60799a2dd95SBruce Richardson 		nb_evtims);
60899a2dd95SBruce Richardson 	return adapter->arm_burst(adapter, evtims, nb_evtims);
60999a2dd95SBruce Richardson }
61099a2dd95SBruce Richardson 
61199a2dd95SBruce Richardson /**
61299a2dd95SBruce Richardson  * Arm a burst of event timers with same expiration timeout tick.
61399a2dd95SBruce Richardson  *
61499a2dd95SBruce Richardson  * Provides the same functionality as ``rte_event_timer_arm_burst()``, except
61599a2dd95SBruce Richardson  * that application can use this API when all the event timers have the
61699a2dd95SBruce Richardson  * same timeout expiration tick. This specialized function can provide the
61799a2dd95SBruce Richardson  * additional hint to the adapter implementation and optimize if possible.
61899a2dd95SBruce Richardson  *
61999a2dd95SBruce Richardson  * @param adapter
62099a2dd95SBruce Richardson  *   A pointer to an event timer adapter structure.
62199a2dd95SBruce Richardson  * @param evtims
62299a2dd95SBruce Richardson  *   Points to an array of objects of type *rte_event_timer* structure.
62399a2dd95SBruce Richardson  * @param timeout_ticks
62499a2dd95SBruce Richardson  *   The number of ticks in which the timers should expire.
62599a2dd95SBruce Richardson  * @param nb_evtims
62699a2dd95SBruce Richardson  *   Number of event timers in the supplied array.
62799a2dd95SBruce Richardson  *
62899a2dd95SBruce Richardson  * @return
62999a2dd95SBruce Richardson  *   The number of successfully armed event timers. The return value can be less
63099a2dd95SBruce Richardson  *   than the value of the *nb_evtims* parameter. If the return value is less
63199a2dd95SBruce Richardson  *   than *nb_evtims*, the remaining event timers at the end of *evtims*
63299a2dd95SBruce Richardson  *   are not consumed, and the caller has to take care of them, and rte_errno
63399a2dd95SBruce Richardson  *   is set accordingly. Possible errno values include:
63499a2dd95SBruce Richardson  *   - EINVAL Invalid timer adapter, expiry event queue ID is invalid, or an
63599a2dd95SBruce Richardson  *   expiry event's sched type doesn't match the capabilities of the
63699a2dd95SBruce Richardson  *   destination event queue.
63799a2dd95SBruce Richardson  *   - EAGAIN Specified event timer adapter is not running
63899a2dd95SBruce Richardson  *   - EALREADY A timer was encountered that was already armed
63999a2dd95SBruce Richardson  */
64099a2dd95SBruce Richardson static inline uint16_t
64199a2dd95SBruce Richardson rte_event_timer_arm_tmo_tick_burst(
64299a2dd95SBruce Richardson 			const struct rte_event_timer_adapter *adapter,
64399a2dd95SBruce Richardson 			struct rte_event_timer **evtims,
64499a2dd95SBruce Richardson 			const uint64_t timeout_ticks,
64599a2dd95SBruce Richardson 			const uint16_t nb_evtims)
64699a2dd95SBruce Richardson {
64799a2dd95SBruce Richardson #ifdef RTE_LIBRTE_EVENTDEV_DEBUG
64899a2dd95SBruce Richardson 	ADAPTER_VALID_OR_ERR_RET(adapter, -EINVAL);
64999a2dd95SBruce Richardson 	FUNC_PTR_OR_ERR_RET(adapter->arm_tmo_tick_burst, -EINVAL);
65099a2dd95SBruce Richardson #endif
65199a2dd95SBruce Richardson 	rte_eventdev_trace_timer_arm_tmo_tick_burst(adapter, timeout_ticks,
65299a2dd95SBruce Richardson 		(void **)evtims, nb_evtims);
65399a2dd95SBruce Richardson 	return adapter->arm_tmo_tick_burst(adapter, evtims, timeout_ticks,
65499a2dd95SBruce Richardson 					   nb_evtims);
65599a2dd95SBruce Richardson }
65699a2dd95SBruce Richardson 
65799a2dd95SBruce Richardson /**
65899a2dd95SBruce Richardson  * Cancel a burst of event timers from being scheduled to the event device.
65999a2dd95SBruce Richardson  *
66099a2dd95SBruce Richardson  * @param adapter
66199a2dd95SBruce Richardson  *   A pointer to an event timer adapter structure.
66299a2dd95SBruce Richardson  * @param evtims
66399a2dd95SBruce Richardson  *   Points to an array of objects of type *rte_event_timer* structure
66499a2dd95SBruce Richardson  * @param nb_evtims
66599a2dd95SBruce Richardson  *   Number of event timer instances in the supplied array.
66699a2dd95SBruce Richardson  *
66799a2dd95SBruce Richardson  * @return
66899a2dd95SBruce Richardson  *   The number of successfully canceled event timers. The return value can be
66999a2dd95SBruce Richardson  *   less than the value of the *nb_evtims* parameter. If the return value is
67099a2dd95SBruce Richardson  *   less than *nb_evtims*, the remaining event timers at the end of *evtims*
67199a2dd95SBruce Richardson  *   are not consumed, and the caller has to take care of them, and rte_errno
67299a2dd95SBruce Richardson  *   is set accordingly. Possible errno values include:
67399a2dd95SBruce Richardson  *   - EINVAL Invalid timer adapter identifier
67499a2dd95SBruce Richardson  *   - EAGAIN Specified timer adapter is not running
67599a2dd95SBruce Richardson  *   - EALREADY  A timer was encountered that was already canceled
67699a2dd95SBruce Richardson  */
67799a2dd95SBruce Richardson static inline uint16_t
67899a2dd95SBruce Richardson rte_event_timer_cancel_burst(const struct rte_event_timer_adapter *adapter,
67999a2dd95SBruce Richardson 			     struct rte_event_timer **evtims,
68099a2dd95SBruce Richardson 			     uint16_t nb_evtims)
68199a2dd95SBruce Richardson {
68299a2dd95SBruce Richardson #ifdef RTE_LIBRTE_EVENTDEV_DEBUG
68399a2dd95SBruce Richardson 	ADAPTER_VALID_OR_ERR_RET(adapter, -EINVAL);
68499a2dd95SBruce Richardson 	FUNC_PTR_OR_ERR_RET(adapter->cancel_burst, -EINVAL);
68599a2dd95SBruce Richardson #endif
68699a2dd95SBruce Richardson 	rte_eventdev_trace_timer_cancel_burst(adapter, (void **)evtims,
68799a2dd95SBruce Richardson 		nb_evtims);
68899a2dd95SBruce Richardson 	return adapter->cancel_burst(adapter, evtims, nb_evtims);
68999a2dd95SBruce Richardson }
69099a2dd95SBruce Richardson 
6910727ff34SErik Gabriel Carrillo /**
6920727ff34SErik Gabriel Carrillo  * Get the number of ticks remaining until event timer expiry.
6930727ff34SErik Gabriel Carrillo  *
6940727ff34SErik Gabriel Carrillo  * @param adapter
6950727ff34SErik Gabriel Carrillo  *   A pointer to an event timer adapter structure
6960727ff34SErik Gabriel Carrillo  * @param evtim
6970727ff34SErik Gabriel Carrillo  *   A pointer to an rte_event_timer structure
6980727ff34SErik Gabriel Carrillo  * @param[out] ticks_remaining
6990727ff34SErik Gabriel Carrillo  *   Pointer to variable into which to write the number of ticks remaining
7000727ff34SErik Gabriel Carrillo  *   until event timer expiry
7010727ff34SErik Gabriel Carrillo  *
7020727ff34SErik Gabriel Carrillo  * @return
7030727ff34SErik Gabriel Carrillo  *   - 0: Success
7040727ff34SErik Gabriel Carrillo  *   - -EINVAL Invalid timer adapter identifier or the event timer is not in
7050727ff34SErik Gabriel Carrillo  *   the armed state or ticks_remaining is NULL
7060727ff34SErik Gabriel Carrillo  *   - -ENOTSUP The timer adapter implementation does not support this API.
7070727ff34SErik Gabriel Carrillo  */
7080727ff34SErik Gabriel Carrillo __rte_experimental
7090727ff34SErik Gabriel Carrillo int
7100727ff34SErik Gabriel Carrillo rte_event_timer_remaining_ticks_get(
7110727ff34SErik Gabriel Carrillo 			const struct rte_event_timer_adapter *adapter,
7120727ff34SErik Gabriel Carrillo 			const struct rte_event_timer *evtim,
7130727ff34SErik Gabriel Carrillo 			uint64_t *ticks_remaining);
7140727ff34SErik Gabriel Carrillo 
715153e7d88SBruce Richardson #ifdef __cplusplus
716153e7d88SBruce Richardson }
717153e7d88SBruce Richardson #endif
718153e7d88SBruce Richardson 
71999a2dd95SBruce Richardson #endif /* __RTE_EVENT_TIMER_ADAPTER_H__ */
720