DPDK  23.03.0
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 
110 #ifdef __cplusplus
111 extern "C" {
112 #endif
113 
114 
115 #include "rte_eventdev.h"
116 #include "rte_eventdev_trace_fp.h"
117 
132 };
133 
134 #define RTE_EVENT_TIMER_ADAPTER_F_ADJUST_RES (1ULL << 0)
135 
146 #define RTE_EVENT_TIMER_ADAPTER_F_SP_PUT (1ULL << 1)
147 
152 #define RTE_EVENT_TIMER_ADAPTER_F_PERIODIC (1ULL << 2)
153 
164  uint8_t event_dev_id;
168  uint32_t socket_id;
172  uint64_t timer_tick_ns;
174  uint64_t max_tmo_ns;
176  uint64_t nb_timers;
178  uint64_t flags;
180 };
181 
186  uint64_t evtim_exp_count;
188  uint64_t ev_enq_count;
190  uint64_t ev_inv_count;
198 };
199 
200 struct rte_event_timer_adapter;
201 
205 typedef 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 
246 struct rte_event_timer_adapter *
248 
273 struct 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 
315 int
317  const struct rte_event_timer_adapter *adapter,
318  struct rte_event_timer_adapter_info *adapter_info);
319 
344 int
346  const struct rte_event_timer_adapter *adapter);
347 
362 int
363 rte_event_timer_adapter_stop(const struct rte_event_timer_adapter *adapter);
364 
381 struct rte_event_timer_adapter *
382 rte_event_timer_adapter_lookup(uint16_t adapter_id);
383 
402 int
403 rte_event_timer_adapter_free(struct rte_event_timer_adapter *adapter);
404 
420 int
421 rte_event_timer_adapter_service_id_get(struct rte_event_timer_adapter *adapter,
422  uint32_t *service_id);
423 
436 int
437 rte_event_timer_adapter_stats_get(struct rte_event_timer_adapter *adapter,
438  struct rte_event_timer_adapter_stats *stats);
439 
450 int
451 rte_event_timer_adapter_stats_reset(struct rte_event_timer_adapter *adapter);
452 
471 };
472 
479  struct rte_event ev;
492  uint64_t timeout_ticks;
497  uint64_t impl_opaque[2];
505  uint8_t user_meta[];
510 
511 typedef uint16_t (*rte_event_timer_arm_burst_t)(
512  const struct rte_event_timer_adapter *adapter,
513  struct rte_event_timer **tims,
514  uint16_t nb_tims);
516 typedef uint16_t (*rte_event_timer_arm_tmo_tick_burst_t)(
517  const struct rte_event_timer_adapter *adapter,
518  struct rte_event_timer **tims,
519  uint64_t timeout_tick,
520  uint16_t nb_tims);
522 typedef uint16_t (*rte_event_timer_cancel_burst_t)(
523  const struct rte_event_timer_adapter *adapter,
524  struct rte_event_timer **tims,
525  uint16_t nb_tims);
531 struct rte_event_timer_adapter {
532  rte_event_timer_arm_burst_t arm_burst;
534  rte_event_timer_arm_tmo_tick_burst_t arm_tmo_tick_burst;
536  rte_event_timer_cancel_burst_t cancel_burst;
538  struct rte_event_timer_adapter_data *data;
540  const struct event_timer_adapter_ops *ops;
544  uint8_t allocated : 1;
547 
548 #define ADAPTER_VALID_OR_ERR_RET(adapter, retval) do { \
549  if (adapter == NULL || !adapter->allocated) \
550  return retval; \
551 } while (0)
552 
553 #define FUNC_PTR_OR_ERR_RET(func, errval) do { \
554  if ((func) == NULL) \
555  return errval; \
556 } while (0)
557 
558 #define FUNC_PTR_OR_NULL_RET_WITH_ERRNO(func, errval) do { \
559  if ((func) == NULL) { \
560  rte_errno = errval; \
561  return NULL; \
562  } \
563 } while (0)
564 
601 static inline uint16_t
602 rte_event_timer_arm_burst(const struct rte_event_timer_adapter *adapter,
603  struct rte_event_timer **evtims,
604  uint16_t nb_evtims)
605 {
606 #ifdef RTE_LIBRTE_EVENTDEV_DEBUG
607  ADAPTER_VALID_OR_ERR_RET(adapter, -EINVAL);
608  FUNC_PTR_OR_ERR_RET(adapter->arm_burst, -EINVAL);
609 #endif
610  rte_eventdev_trace_timer_arm_burst(adapter, (void **)evtims,
611  nb_evtims);
612  return adapter->arm_burst(adapter, evtims, nb_evtims);
613 }
614 
644 static inline uint16_t
646  const struct rte_event_timer_adapter *adapter,
647  struct rte_event_timer **evtims,
648  const uint64_t timeout_ticks,
649  const uint16_t nb_evtims)
650 {
651 #ifdef RTE_LIBRTE_EVENTDEV_DEBUG
652  ADAPTER_VALID_OR_ERR_RET(adapter, -EINVAL);
653  FUNC_PTR_OR_ERR_RET(adapter->arm_tmo_tick_burst, -EINVAL);
654 #endif
655  rte_eventdev_trace_timer_arm_tmo_tick_burst(adapter, timeout_ticks,
656  (void **)evtims, nb_evtims);
657  return adapter->arm_tmo_tick_burst(adapter, evtims, timeout_ticks,
658  nb_evtims);
659 }
660 
681 static inline uint16_t
682 rte_event_timer_cancel_burst(const struct rte_event_timer_adapter *adapter,
683  struct rte_event_timer **evtims,
684  uint16_t nb_evtims)
685 {
686 #ifdef RTE_LIBRTE_EVENTDEV_DEBUG
687  ADAPTER_VALID_OR_ERR_RET(adapter, -EINVAL);
688  FUNC_PTR_OR_ERR_RET(adapter->cancel_burst, -EINVAL);
689 #endif
690  rte_eventdev_trace_timer_cancel_burst(adapter, (void **)evtims,
691  nb_evtims);
692  return adapter->cancel_burst(adapter, evtims, nb_evtims);
693 }
694 
715 __rte_experimental
716 int
718  const struct rte_event_timer_adapter *adapter,
719  const struct rte_event_timer *evtim,
720  uint64_t *ticks_remaining);
721 
722 #ifdef __cplusplus
723 }
724 #endif
725 
726 #endif /* __RTE_EVENT_TIMER_ADAPTER_H__ */
struct rte_event_timer_adapter * rte_event_timer_adapter_create(const struct rte_event_timer_adapter_conf *conf)
int rte_event_timer_adapter_service_id_get(struct rte_event_timer_adapter *adapter, uint32_t *service_id)
__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_port_conf_cb_t)(uint16_t id, uint8_t event_dev_id, uint8_t *event_port_id, void *conf_arg)
struct rte_event_timer_adapter * rte_event_timer_adapter_lookup(uint16_t adapter_id)
int rte_event_timer_adapter_start(const struct rte_event_timer_adapter *adapter)
int rte_event_timer_adapter_stats_reset(struct rte_event_timer_adapter *adapter)
int rte_event_timer_adapter_stats_get(struct rte_event_timer_adapter *adapter, struct rte_event_timer_adapter_stats *stats)
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)
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)
uint8_t impl_opaque
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)
#define __rte_cache_aligned
Definition: rte_common.h:440
#define RTE_STD_C11
Definition: rte_common.h:39
rte_event_timer_adapter_clk_src
enum rte_event_timer_adapter_clk_src clk_src
static uint16_t rte_event_timer_cancel_burst(const struct rte_event_timer_adapter *adapter, struct rte_event_timer **evtims, uint16_t nb_evtims)
int rte_event_timer_adapter_stop(const struct rte_event_timer_adapter *adapter)
int rte_event_timer_adapter_get_info(const struct rte_event_timer_adapter *adapter, struct rte_event_timer_adapter_info *adapter_info)