DPDK  23.07.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 
314 int
316  const struct rte_event_timer_adapter *adapter,
317  struct rte_event_timer_adapter_info *adapter_info);
318 
343 int
345  const struct rte_event_timer_adapter *adapter);
346 
361 int
362 rte_event_timer_adapter_stop(const struct rte_event_timer_adapter *adapter);
363 
380 struct rte_event_timer_adapter *
381 rte_event_timer_adapter_lookup(uint16_t adapter_id);
382 
401 int
402 rte_event_timer_adapter_free(struct rte_event_timer_adapter *adapter);
403 
419 int
420 rte_event_timer_adapter_service_id_get(struct rte_event_timer_adapter *adapter,
421  uint32_t *service_id);
422 
435 int
436 rte_event_timer_adapter_stats_get(struct rte_event_timer_adapter *adapter,
437  struct rte_event_timer_adapter_stats *stats);
438 
449 int
450 rte_event_timer_adapter_stats_reset(struct rte_event_timer_adapter *adapter);
451 
470 };
471 
478  struct rte_event ev;
491  uint64_t timeout_ticks;
496  uint64_t impl_opaque[2];
504  uint8_t user_meta[];
509 
510 typedef uint16_t (*rte_event_timer_arm_burst_t)(
511  const struct rte_event_timer_adapter *adapter,
512  struct rte_event_timer **tims,
513  uint16_t nb_tims);
515 typedef uint16_t (*rte_event_timer_arm_tmo_tick_burst_t)(
516  const struct rte_event_timer_adapter *adapter,
517  struct rte_event_timer **tims,
518  uint64_t timeout_tick,
519  uint16_t nb_tims);
521 typedef uint16_t (*rte_event_timer_cancel_burst_t)(
522  const struct rte_event_timer_adapter *adapter,
523  struct rte_event_timer **tims,
524  uint16_t nb_tims);
530 struct rte_event_timer_adapter {
531  rte_event_timer_arm_burst_t arm_burst;
533  rte_event_timer_arm_tmo_tick_burst_t arm_tmo_tick_burst;
535  rte_event_timer_cancel_burst_t cancel_burst;
537  struct rte_event_timer_adapter_data *data;
539  const struct event_timer_adapter_ops *ops;
543  uint8_t allocated : 1;
546 
547 #define ADAPTER_VALID_OR_ERR_RET(adapter, retval) do { \
548  if (adapter == NULL || !adapter->allocated) \
549  return retval; \
550 } while (0)
551 
552 #define FUNC_PTR_OR_ERR_RET(func, errval) do { \
553  if ((func) == NULL) \
554  return errval; \
555 } while (0)
556 
557 #define FUNC_PTR_OR_NULL_RET_WITH_ERRNO(func, errval) do { \
558  if ((func) == NULL) { \
559  rte_errno = errval; \
560  return NULL; \
561  } \
562 } while (0)
563 
599 static inline uint16_t
600 rte_event_timer_arm_burst(const struct rte_event_timer_adapter *adapter,
601  struct rte_event_timer **evtims,
602  uint16_t nb_evtims)
603 {
604 #ifdef RTE_LIBRTE_EVENTDEV_DEBUG
605  ADAPTER_VALID_OR_ERR_RET(adapter, -EINVAL);
606  FUNC_PTR_OR_ERR_RET(adapter->arm_burst, -EINVAL);
607 #endif
608  rte_eventdev_trace_timer_arm_burst(adapter, (void **)evtims,
609  nb_evtims);
610  return adapter->arm_burst(adapter, evtims, nb_evtims);
611 }
612 
642 static inline uint16_t
644  const struct rte_event_timer_adapter *adapter,
645  struct rte_event_timer **evtims,
646  const uint64_t timeout_ticks,
647  const uint16_t nb_evtims)
648 {
649 #ifdef RTE_LIBRTE_EVENTDEV_DEBUG
650  ADAPTER_VALID_OR_ERR_RET(adapter, -EINVAL);
651  FUNC_PTR_OR_ERR_RET(adapter->arm_tmo_tick_burst, -EINVAL);
652 #endif
653  rte_eventdev_trace_timer_arm_tmo_tick_burst(adapter, timeout_ticks,
654  (void **)evtims, nb_evtims);
655  return adapter->arm_tmo_tick_burst(adapter, evtims, timeout_ticks,
656  nb_evtims);
657 }
658 
679 static inline uint16_t
680 rte_event_timer_cancel_burst(const struct rte_event_timer_adapter *adapter,
681  struct rte_event_timer **evtims,
682  uint16_t nb_evtims)
683 {
684 #ifdef RTE_LIBRTE_EVENTDEV_DEBUG
685  ADAPTER_VALID_OR_ERR_RET(adapter, -EINVAL);
686  FUNC_PTR_OR_ERR_RET(adapter->cancel_burst, -EINVAL);
687 #endif
688  rte_eventdev_trace_timer_cancel_burst(adapter, (void **)evtims,
689  nb_evtims);
690  return adapter->cancel_burst(adapter, evtims, nb_evtims);
691 }
692 
713 __rte_experimental
714 int
716  const struct rte_event_timer_adapter *adapter,
717  const struct rte_event_timer *evtim,
718  uint64_t *ticks_remaining);
719 
720 #ifdef __cplusplus
721 }
722 #endif
723 
724 #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)