DPDK  21.08.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 #include <rte_spinlock.h>
115 #include <rte_memory.h>
116 
117 #include "rte_eventdev.h"
118 #include "rte_eventdev_trace_fp.h"
119 
134 };
135 
136 #define RTE_EVENT_TIMER_ADAPTER_F_ADJUST_RES (1ULL << 0)
137 
148 #define RTE_EVENT_TIMER_ADAPTER_F_SP_PUT (1ULL << 1)
149 
154 #define RTE_EVENT_TIMER_ADAPTER_F_PERIODIC (1ULL << 2)
155 
166  uint8_t event_dev_id;
170  uint32_t socket_id;
174  uint64_t timer_tick_ns;
176  uint64_t max_tmo_ns;
178  uint64_t nb_timers;
180  uint64_t flags;
182 };
183 
188  uint64_t evtim_exp_count;
190  uint64_t ev_enq_count;
192  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 
232 struct rte_event_timer_adapter *
234 
259 struct rte_event_timer_adapter *
261  const struct rte_event_timer_adapter_conf *conf,
263  void *conf_arg);
264 
271  uint64_t max_tmo_ns;
275  uint32_t caps;
279 };
280 
301 int
303  const struct rte_event_timer_adapter *adapter,
304  struct rte_event_timer_adapter_info *adapter_info);
305 
330 int
332  const struct rte_event_timer_adapter *adapter);
333 
348 int
349 rte_event_timer_adapter_stop(const struct rte_event_timer_adapter *adapter);
350 
367 struct rte_event_timer_adapter *
368 rte_event_timer_adapter_lookup(uint16_t adapter_id);
369 
388 int
389 rte_event_timer_adapter_free(struct rte_event_timer_adapter *adapter);
390 
406 int
407 rte_event_timer_adapter_service_id_get(struct rte_event_timer_adapter *adapter,
408  uint32_t *service_id);
409 
422 int
423 rte_event_timer_adapter_stats_get(struct rte_event_timer_adapter *adapter,
424  struct rte_event_timer_adapter_stats *stats);
425 
436 int
437 rte_event_timer_adapter_stats_reset(struct rte_event_timer_adapter *adapter);
438 
457 };
458 
465  struct rte_event ev;
478  volatile enum rte_event_timer_state state;
480  uint64_t timeout_ticks;
485  uint64_t impl_opaque[2];
491  uint8_t user_meta[0];
496 
497 typedef uint16_t (*rte_event_timer_arm_burst_t)(
498  const struct rte_event_timer_adapter *adapter,
499  struct rte_event_timer **tims,
500  uint16_t nb_tims);
502 typedef uint16_t (*rte_event_timer_arm_tmo_tick_burst_t)(
503  const struct rte_event_timer_adapter *adapter,
504  struct rte_event_timer **tims,
505  uint64_t timeout_tick,
506  uint16_t nb_tims);
508 typedef uint16_t (*rte_event_timer_cancel_burst_t)(
509  const struct rte_event_timer_adapter *adapter,
510  struct rte_event_timer **tims,
511  uint16_t nb_tims);
517 struct rte_event_timer_adapter {
518  rte_event_timer_arm_burst_t arm_burst;
520  rte_event_timer_arm_tmo_tick_burst_t arm_tmo_tick_burst;
522  rte_event_timer_cancel_burst_t cancel_burst;
524  struct rte_event_timer_adapter_data *data;
526  const struct rte_event_timer_adapter_ops *ops;
530  uint8_t allocated : 1;
533 
534 #define ADAPTER_VALID_OR_ERR_RET(adapter, retval) do { \
535  if (adapter == NULL || !adapter->allocated) \
536  return retval; \
537 } while (0)
538 
539 #define FUNC_PTR_OR_ERR_RET(func, errval) do { \
540  if ((func) == NULL) \
541  return errval; \
542 } while (0)
543 
544 #define FUNC_PTR_OR_NULL_RET_WITH_ERRNO(func, errval) do { \
545  if ((func) == NULL) { \
546  rte_errno = errval; \
547  return NULL; \
548  } \
549 } while (0)
550 
587 static inline uint16_t
588 rte_event_timer_arm_burst(const struct rte_event_timer_adapter *adapter,
589  struct rte_event_timer **evtims,
590  uint16_t nb_evtims)
591 {
592 #ifdef RTE_LIBRTE_EVENTDEV_DEBUG
593  ADAPTER_VALID_OR_ERR_RET(adapter, -EINVAL);
594  FUNC_PTR_OR_ERR_RET(adapter->arm_burst, -EINVAL);
595 #endif
596  rte_eventdev_trace_timer_arm_burst(adapter, (void **)evtims,
597  nb_evtims);
598  return adapter->arm_burst(adapter, evtims, nb_evtims);
599 }
600 
630 static inline uint16_t
632  const struct rte_event_timer_adapter *adapter,
633  struct rte_event_timer **evtims,
634  const uint64_t timeout_ticks,
635  const uint16_t nb_evtims)
636 {
637 #ifdef RTE_LIBRTE_EVENTDEV_DEBUG
638  ADAPTER_VALID_OR_ERR_RET(adapter, -EINVAL);
639  FUNC_PTR_OR_ERR_RET(adapter->arm_tmo_tick_burst, -EINVAL);
640 #endif
641  rte_eventdev_trace_timer_arm_tmo_tick_burst(adapter, timeout_ticks,
642  (void **)evtims, nb_evtims);
643  return adapter->arm_tmo_tick_burst(adapter, evtims, timeout_ticks,
644  nb_evtims);
645 }
646 
667 static inline uint16_t
668 rte_event_timer_cancel_burst(const struct rte_event_timer_adapter *adapter,
669  struct rte_event_timer **evtims,
670  uint16_t nb_evtims)
671 {
672 #ifdef RTE_LIBRTE_EVENTDEV_DEBUG
673  ADAPTER_VALID_OR_ERR_RET(adapter, -EINVAL);
674  FUNC_PTR_OR_ERR_RET(adapter->cancel_burst, -EINVAL);
675 #endif
676  rte_eventdev_trace_timer_cancel_burst(adapter, (void **)evtims,
677  nb_evtims);
678  return adapter->cancel_burst(adapter, evtims, nb_evtims);
679 }
680 
681 #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)
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:402
#define RTE_STD_C11
Definition: rte_common.h:42
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)