DPDK 21.11.9
|
#include <rte_spinlock.h>
#include <rte_memory.h>
#include "rte_eventdev.h"
#include "rte_eventdev_trace_fp.h"
Go to the source code of this file.
Data Structures | |
struct | rte_event_timer_adapter_conf |
struct | rte_event_timer_adapter_stats |
struct | rte_event_timer_adapter_info |
struct | rte_event_timer |
Macros | |
#define | RTE_EVENT_TIMER_ADAPTER_F_ADJUST_RES (1ULL << 0) |
#define | RTE_EVENT_TIMER_ADAPTER_F_SP_PUT (1ULL << 1) |
#define | RTE_EVENT_TIMER_ADAPTER_F_PERIODIC (1ULL << 2) |
Typedefs | |
typedef int(* | rte_event_timer_adapter_port_conf_cb_t) (uint16_t id, uint8_t event_dev_id, uint8_t *event_port_id, void *conf_arg) |
Functions | |
struct rte_event_timer_adapter * | rte_event_timer_adapter_create (const struct rte_event_timer_adapter_conf *conf) |
struct rte_event_timer_adapter * | rte_event_timer_adapter_create_ext (const struct rte_event_timer_adapter_conf *conf, rte_event_timer_adapter_port_conf_cb_t conf_cb, void *conf_arg) |
int | rte_event_timer_adapter_get_info (const struct rte_event_timer_adapter *adapter, struct rte_event_timer_adapter_info *adapter_info) |
int | rte_event_timer_adapter_start (const struct rte_event_timer_adapter *adapter) |
int | rte_event_timer_adapter_stop (const struct rte_event_timer_adapter *adapter) |
struct rte_event_timer_adapter * | rte_event_timer_adapter_lookup (uint16_t adapter_id) |
int | rte_event_timer_adapter_free (struct rte_event_timer_adapter *adapter) |
int | rte_event_timer_adapter_service_id_get (struct rte_event_timer_adapter *adapter, uint32_t *service_id) |
int | rte_event_timer_adapter_stats_get (struct rte_event_timer_adapter *adapter, struct rte_event_timer_adapter_stats *stats) |
int | rte_event_timer_adapter_stats_reset (struct rte_event_timer_adapter *adapter) |
static uint16_t | rte_event_timer_arm_burst (const struct rte_event_timer_adapter *adapter, struct rte_event_timer **evtims, uint16_t nb_evtims) |
static uint16_t | rte_event_timer_arm_tmo_tick_burst (const struct rte_event_timer_adapter *adapter, struct rte_event_timer **evtims, const uint64_t timeout_ticks, const uint16_t nb_evtims) |
static uint16_t | rte_event_timer_cancel_burst (const struct rte_event_timer_adapter *adapter, struct rte_event_timer **evtims, uint16_t nb_evtims) |
RTE Event Timer Adapter
An event timer adapter has the following abstract working model:
timer_tick_ns + +-------+ | | | | +-------+ bkt 0 +----v---+ | | | | | +-------+ | +---+---+ +---+---+ +---+---+---+---+ | | | | | | | | | | bkt n | | bkt 1 |<-> t0| t1| t2| tn| | | | | | | | | | +---+---+ +---+---+ +---+---+---+---+ | Timer adapter | +---+---+ +---+---+ | | | | | bkt 4 | | bkt 2 |<--- Current bucket | | | | +---+---+ +---+---+ | +-------+ | | | | | +------+ bkt 3 +-------+ | | +-------+
Multiple timer adapters can be created with a varying level of resolution for various expiry use cases that run in parallel.
Before using the timer adapter, the application has to create and configure an event device along with the event port. Based on the event device capability it might require creating an additional event port to be used by the timer adapter.
The application creates the event timer adapter using the rte_event_timer_adapter_create()
. The event device id is passed to this function, inside this function the event device capability is checked, and if an in-built port is absent the application uses the default function to create a new producer port.
The application may also use the function rte_event_timer_adapter_create_ext()
to have granular control over producer port creation in a case where the in-built port is absent.
After creating the timer adapter, the application has to start it using rte_event_timer_adapter_start()
. The buckets are traversed from 0 to n; when the adapter ticks, the next bucket is visited. Each time, the list per bucket is processed, and timer expiry events are sent to the designated event queue.
The application can arm one or more event timers using the rte_event_timer_arm_burst()
. The timeout_ticks represents the number of timer_tick_ns after which the timer has to expire. The timeout at which the timers expire can be grouped or be independent of each event timer instance. rte_event_timer_arm_tmo_tick_burst()
addresses the former case and rte_event_timer_arm_burst()
addresses the latter case.
The application can cancel the timers from expiring using the rte_event_timer_cancel_burst()
.
On the secondary process, rte_event_timer_adapter_lookup()
can be used to get the timer adapter pointer from its id and use it to invoke fastpath operations such as arm and cancel.
Some of the use cases of event timer adapter are Beacon Timers, Generic SW Timeout, Wireless MAC Scheduling, 3G Frame Protocols, Packet Scheduling, Protocol Retransmission Timers, Supervision Timers. All these use cases require high resolution and low time drift.
Definition in file rte_event_timer_adapter.h.
#define RTE_EVENT_TIMER_ADAPTER_F_ADJUST_RES (1ULL << 0) |
The event timer adapter implementation may have constraints on the resolution (timer_tick_ns) and maximum timer expiry timeout(max_tmo_ns) based on the given timer adapter or system. If this flag is set, the implementation adjusts the resolution and maximum timeout to the best possible configuration. On successful timer adapter creation, the application can get the configured resolution and max timeout with rte_event_timer_adapter_get_info()
.
Definition at line 147 of file rte_event_timer_adapter.h.
#define RTE_EVENT_TIMER_ADAPTER_F_SP_PUT (1ULL << 1) |
rte_event_timer_arm_burst()
API to be used in single producer mode.
Definition at line 152 of file rte_event_timer_adapter.h.
#define RTE_EVENT_TIMER_ADAPTER_F_PERIODIC (1ULL << 2) |
Flag to configure an event timer adapter in periodic mode; non-periodic mode is the default. A timer will fire once or periodically until the timer is cancelled based on the adapter mode.
Definition at line 160 of file rte_event_timer_adapter.h.
typedef int(* rte_event_timer_adapter_port_conf_cb_t) (uint16_t id, uint8_t event_dev_id, uint8_t *event_port_id, void *conf_arg) |
Callback function type for producer port creation.
Definition at line 205 of file rte_event_timer_adapter.h.
Timer adapter clock source
Definition at line 123 of file rte_event_timer_adapter.h.
Event timer state.
Definition at line 442 of file rte_event_timer_adapter.h.
struct rte_event_timer_adapter * rte_event_timer_adapter_create | ( | const struct rte_event_timer_adapter_conf * | conf | ) |
Create an event timer adapter.
This function must be invoked first before any other function in the API.
conf | The event timer adapter configuration structure. |
struct rte_event_timer_adapter * rte_event_timer_adapter_create_ext | ( | const struct rte_event_timer_adapter_conf * | conf, |
rte_event_timer_adapter_port_conf_cb_t | conf_cb, | ||
void * | conf_arg | ||
) |
Create a timer adapter with the supplied callback.
This function can be used to have a more granular control over the timer adapter creation. If a built-in port is absent, then the function uses the callback provided to create and get the port id to be used as a producer port.
conf | The timer adapter configuration structure |
conf_cb | The port config callback function. |
conf_arg | Opaque pointer to the argument for the callback function |
int rte_event_timer_adapter_get_info | ( | const struct rte_event_timer_adapter * | adapter, |
struct rte_event_timer_adapter_info * | adapter_info | ||
) |
Retrieve the contextual information of an event timer adapter.
adapter | A pointer to the event timer adapter structure. | |
[out] | adapter_info | A pointer to a structure of type rte_event_timer_adapter_info to be filled with the contextual information of the adapter. |
int rte_event_timer_adapter_start | ( | const struct rte_event_timer_adapter * | adapter | ) |
Start a timer adapter.
The adapter start step is the last one and consists of setting the timer adapter to start accepting the timers and schedules to event queues.
On success, all basic functions exported by the API (timer arm, timer cancel and so on) can be invoked.
adapter | A pointer to the event timer adapter structure. |
int rte_event_timer_adapter_stop | ( | const struct rte_event_timer_adapter * | adapter | ) |
Stop an event timer adapter.
The adapter can be restarted with a call to rte_event_timer_adapter_start()
.
adapter | A pointer to the event timer adapter structure. |
struct rte_event_timer_adapter * rte_event_timer_adapter_lookup | ( | uint16_t | adapter_id | ) |
Lookup an event timer adapter using its identifier.
If an event timer adapter was created in another process with the same identifier, this function will locate its state and set up access to it so that it can be used in this process.
adapter_id | The event timer adapter identifier. |
int rte_event_timer_adapter_free | ( | struct rte_event_timer_adapter * | adapter | ) |
Free an event timer adapter.
Destroy an event timer adapter, freeing all resources.
Before invoking this function, the application must wait for all the armed timers to expire or cancel the outstanding armed timers.
adapter | A pointer to an event timer adapter structure. |
int rte_event_timer_adapter_service_id_get | ( | struct rte_event_timer_adapter * | adapter, |
uint32_t * | service_id | ||
) |
Retrieve the service ID of the event timer adapter. If the adapter doesn't use an rte_service function, this function returns -ESRCH.
adapter | A pointer to an event timer adapter. | |
[out] | service_id | A pointer to a uint32_t, to be filled in with the service id. |
int rte_event_timer_adapter_stats_get | ( | struct rte_event_timer_adapter * | adapter, |
struct rte_event_timer_adapter_stats * | stats | ||
) |
Retrieve statistics for an event timer adapter instance.
adapter | A pointer to an event timer adapter structure. | |
[out] | stats | A pointer to a structure to fill with statistics. |
int rte_event_timer_adapter_stats_reset | ( | struct rte_event_timer_adapter * | adapter | ) |
Reset statistics for an event timer adapter instance.
adapter | A pointer to an event timer adapter structure. |
|
inlinestatic |
Arm a burst of event timers with separate expiration timeout tick for each event timer.
Before calling this function, the application allocates struct rte_event_timer
objects from mempool or huge page backed application buffers of desired size. On successful allocation, application updates the struct rte_event_timer
` attributes such as expiry event attributes, timeout ticks from now. This function submits the event timer arm requests to the event timer adapter and on expiry, the events will be injected to designated event queue. Timer expiry events will be generated once or periodically until cancellation based on the adapter mode.
adapter | A pointer to an event timer adapter structure. |
evtims | Pointer to an array of objects of type rte_event_timer structure. |
nb_evtims | Number of event timers in the supplied array. |
Definition at line 588 of file rte_event_timer_adapter.h.
|
inlinestatic |
Arm a burst of event timers with same expiration timeout tick.
Provides the same functionality as rte_event_timer_arm_burst()
, except that application can use this API when all the event timers have the same timeout expiration tick. This specialized function can provide the additional hint to the adapter implementation and optimize if possible.
adapter | A pointer to an event timer adapter structure. |
evtims | Points to an array of objects of type rte_event_timer structure. |
timeout_ticks | The number of ticks in which the timers should expire. |
nb_evtims | Number of event timers in the supplied array. |
Definition at line 631 of file rte_event_timer_adapter.h.
|
inlinestatic |
Cancel a burst of event timers from being scheduled to the event device.
adapter | A pointer to an event timer adapter structure. |
evtims | Points to an array of objects of type rte_event_timer structure |
nb_evtims | Number of event timer instances in the supplied array. |
Definition at line 668 of file rte_event_timer_adapter.h.