DPDK 24.11.1
rte_event_timer_adapter.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2017 Cavium, Inc.
3 * Copyright(c) 2017-2018 Intel Corporation.
4 * All rights reserved.
5 */
6
7#ifndef __RTE_EVENT_TIMER_ADAPTER_H__
8#define __RTE_EVENT_TIMER_ADAPTER_H__
9
111#include "rte_eventdev.h"
113
114#ifdef __cplusplus
115extern "C" {
116#endif
117
132};
133
134#define RTE_EVENT_TIMER_ADAPTER_F_ADJUST_RES (1ULL << 0)
146#define RTE_EVENT_TIMER_ADAPTER_F_SP_PUT (1ULL << 1)
152#define RTE_EVENT_TIMER_ADAPTER_F_PERIODIC (1ULL << 2)
168 uint32_t socket_id;
174 uint64_t max_tmo_ns;
176 uint64_t nb_timers;
178 uint64_t flags;
180};
181
188 uint64_t ev_enq_count;
190 uint64_t ev_inv_count;
198};
199
200struct rte_event_timer_adapter;
201
205typedef int (*rte_event_timer_adapter_port_conf_cb_t)(uint16_t id,
206 uint8_t event_dev_id,
207 uint8_t *event_port_id,
208 void *conf_arg);
209
246struct rte_event_timer_adapter *
248
273struct rte_event_timer_adapter *
275 const struct rte_event_timer_adapter_conf *conf,
277 void *conf_arg);
278
285 uint64_t max_tmo_ns;
289 uint32_t caps;
293};
294
314int
316 const struct rte_event_timer_adapter *adapter,
317 struct rte_event_timer_adapter_info *adapter_info);
318
343int
345 const struct rte_event_timer_adapter *adapter);
346
361int
362rte_event_timer_adapter_stop(const struct rte_event_timer_adapter *adapter);
363
380struct rte_event_timer_adapter *
382
401int
402rte_event_timer_adapter_free(struct rte_event_timer_adapter *adapter);
403
419int
420rte_event_timer_adapter_service_id_get(struct rte_event_timer_adapter *adapter,
421 uint32_t *service_id);
422
435int
436rte_event_timer_adapter_stats_get(struct rte_event_timer_adapter *adapter,
437 struct rte_event_timer_adapter_stats *stats);
438
449int
450rte_event_timer_adapter_stats_reset(struct rte_event_timer_adapter *adapter);
451
470};
471
477 struct rte_event ev;
495 uint64_t impl_opaque[2];
501 RTE_ATOMIC(enum rte_event_timer_state) state;
503 uint8_t user_meta[];
507};
508
509typedef uint16_t (*rte_event_timer_arm_burst_t)(
510 const struct rte_event_timer_adapter *adapter,
511 struct rte_event_timer **tims,
512 uint16_t nb_tims);
514typedef uint16_t (*rte_event_timer_arm_tmo_tick_burst_t)(
515 const struct rte_event_timer_adapter *adapter,
516 struct rte_event_timer **tims,
517 uint64_t timeout_tick,
518 uint16_t nb_tims);
520typedef uint16_t (*rte_event_timer_cancel_burst_t)(
521 const struct rte_event_timer_adapter *adapter,
522 struct rte_event_timer **tims,
523 uint16_t nb_tims);
529struct __rte_cache_aligned rte_event_timer_adapter {
530 rte_event_timer_arm_burst_t arm_burst;
532 rte_event_timer_arm_tmo_tick_burst_t arm_tmo_tick_burst;
534 rte_event_timer_cancel_burst_t cancel_burst;
536 struct rte_event_timer_adapter_data *data;
538 const struct event_timer_adapter_ops *ops;
541 uint8_t allocated : 1;
543};
544
545#define ADAPTER_VALID_OR_ERR_RET(adapter, retval) do { \
546 if (adapter == NULL || !adapter->allocated) \
547 return retval; \
548} while (0)
549
550#define FUNC_PTR_OR_ERR_RET(func, errval) do { \
551 if ((func) == NULL) \
552 return errval; \
553} while (0)
554
555#define FUNC_PTR_OR_NULL_RET_WITH_ERRNO(func, errval) do { \
556 if ((func) == NULL) { \
557 rte_errno = errval; \
558 return NULL; \
559 } \
560} while (0)
561
597static inline uint16_t
598rte_event_timer_arm_burst(const struct rte_event_timer_adapter *adapter,
599 struct rte_event_timer **evtims,
600 uint16_t nb_evtims)
601{
602#ifdef RTE_LIBRTE_EVENTDEV_DEBUG
603 ADAPTER_VALID_OR_ERR_RET(adapter, -EINVAL);
604 FUNC_PTR_OR_ERR_RET(adapter->arm_burst, -EINVAL);
605#endif
606 rte_eventdev_trace_timer_arm_burst(adapter, (void **)evtims,
607 nb_evtims);
608 return adapter->arm_burst(adapter, evtims, nb_evtims);
609}
610
640static inline uint16_t
642 const struct rte_event_timer_adapter *adapter,
643 struct rte_event_timer **evtims,
644 const uint64_t timeout_ticks,
645 const uint16_t nb_evtims)
646{
647#ifdef RTE_LIBRTE_EVENTDEV_DEBUG
648 ADAPTER_VALID_OR_ERR_RET(adapter, -EINVAL);
649 FUNC_PTR_OR_ERR_RET(adapter->arm_tmo_tick_burst, -EINVAL);
650#endif
651 rte_eventdev_trace_timer_arm_tmo_tick_burst(adapter, timeout_ticks,
652 (void **)evtims, nb_evtims);
653 return adapter->arm_tmo_tick_burst(adapter, evtims, timeout_ticks,
654 nb_evtims);
655}
656
677static inline uint16_t
678rte_event_timer_cancel_burst(const struct rte_event_timer_adapter *adapter,
679 struct rte_event_timer **evtims,
680 uint16_t nb_evtims)
681{
682#ifdef RTE_LIBRTE_EVENTDEV_DEBUG
683 ADAPTER_VALID_OR_ERR_RET(adapter, -EINVAL);
684 FUNC_PTR_OR_ERR_RET(adapter->cancel_burst, -EINVAL);
685#endif
686 rte_eventdev_trace_timer_cancel_burst(adapter, (void **)evtims,
687 nb_evtims);
688 return adapter->cancel_burst(adapter, evtims, nb_evtims);
689}
690
708__rte_experimental
709int
711 const struct rte_event_timer_adapter *adapter,
712 const struct rte_event_timer *evtim,
713 uint64_t *ticks_remaining);
714
715#ifdef __cplusplus
716}
717#endif
718
719#endif /* __RTE_EVENT_TIMER_ADAPTER_H__ */
#define __rte_cache_aligned
Definition: rte_common.h:627
int rte_event_timer_adapter_stats_reset(struct rte_event_timer_adapter *adapter)
int rte_event_timer_adapter_service_id_get(struct rte_event_timer_adapter *adapter, uint32_t *service_id)
@ RTE_EVENT_TIMER_ERROR_TOOEARLY
@ RTE_EVENT_TIMER_ARMED
@ RTE_EVENT_TIMER_CANCELED
@ RTE_EVENT_TIMER_ERROR
@ RTE_EVENT_TIMER_NOT_ARMED
@ RTE_EVENT_TIMER_ERROR_TOOLATE
int rte_event_timer_adapter_stop(const struct rte_event_timer_adapter *adapter)
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)
static uint16_t rte_event_timer_cancel_burst(const struct rte_event_timer_adapter *adapter, struct rte_event_timer **evtims, uint16_t nb_evtims)
static uint16_t rte_event_timer_arm_burst(const struct rte_event_timer_adapter *adapter, struct rte_event_timer **evtims, uint16_t nb_evtims)
int rte_event_timer_adapter_free(struct rte_event_timer_adapter *adapter)
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_lookup(uint16_t adapter_id)
rte_event_timer_adapter_clk_src
@ RTE_EVENT_TIMER_ADAPTER_EXT_CLK1
@ RTE_EVENT_TIMER_ADAPTER_CPU_CLK
@ RTE_EVENT_TIMER_ADAPTER_EXT_CLK2
@ RTE_EVENT_TIMER_ADAPTER_EXT_CLK3
@ RTE_EVENT_TIMER_ADAPTER_EXT_CLK0
int rte_event_timer_adapter_stats_get(struct rte_event_timer_adapter *adapter, struct rte_event_timer_adapter_stats *stats)
__rte_experimental int rte_event_timer_remaining_ticks_get(const struct rte_event_timer_adapter *adapter, const struct rte_event_timer *evtim, uint64_t *ticks_remaining)
int rte_event_timer_adapter_start(const struct rte_event_timer_adapter *adapter)
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)
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)
int rte_event_timer_adapter_get_info(const struct rte_event_timer_adapter *adapter, struct rte_event_timer_adapter_info *adapter_info)
enum rte_event_timer_adapter_clk_src clk_src
struct rte_event_timer_adapter_conf conf
enum rte_event_timer_state state
uint8_t impl_opaque