DPDK  20.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 
158  uint8_t event_dev_id;
162  uint32_t socket_id;
166  uint64_t timer_tick_ns;
168  uint64_t max_tmo_ns;
170  uint64_t nb_timers;
172  uint64_t flags;
174 };
175 
180  uint64_t evtim_exp_count;
182  uint64_t ev_enq_count;
184  uint64_t ev_inv_count;
190 };
191 
192 struct rte_event_timer_adapter;
193 
197 typedef int (*rte_event_timer_adapter_port_conf_cb_t)(uint16_t id,
198  uint8_t event_dev_id,
199  uint8_t *event_port_id,
200  void *conf_arg);
201 
224 struct rte_event_timer_adapter *
226 
251 struct rte_event_timer_adapter *
253  const struct rte_event_timer_adapter_conf *conf,
255  void *conf_arg);
256 
263  uint64_t max_tmo_ns;
267  uint32_t caps;
271 };
272 
293 int
295  const struct rte_event_timer_adapter *adapter,
296  struct rte_event_timer_adapter_info *adapter_info);
297 
322 int
324  const struct rte_event_timer_adapter *adapter);
325 
340 int
341 rte_event_timer_adapter_stop(const struct rte_event_timer_adapter *adapter);
342 
359 struct rte_event_timer_adapter *
360 rte_event_timer_adapter_lookup(uint16_t adapter_id);
361 
380 int
381 rte_event_timer_adapter_free(struct rte_event_timer_adapter *adapter);
382 
398 int
399 rte_event_timer_adapter_service_id_get(struct rte_event_timer_adapter *adapter,
400  uint32_t *service_id);
401 
414 int
415 rte_event_timer_adapter_stats_get(struct rte_event_timer_adapter *adapter,
416  struct rte_event_timer_adapter_stats *stats);
417 
428 int
429 rte_event_timer_adapter_stats_reset(struct rte_event_timer_adapter *adapter);
430 
449 };
450 
457  struct rte_event ev;
472  uint64_t timeout_ticks;
477  uint64_t impl_opaque[2];
483  uint8_t user_meta[0];
488 
489 typedef uint16_t (*rte_event_timer_arm_burst_t)(
490  const struct rte_event_timer_adapter *adapter,
491  struct rte_event_timer **tims,
492  uint16_t nb_tims);
494 typedef uint16_t (*rte_event_timer_arm_tmo_tick_burst_t)(
495  const struct rte_event_timer_adapter *adapter,
496  struct rte_event_timer **tims,
497  uint64_t timeout_tick,
498  uint16_t nb_tims);
500 typedef uint16_t (*rte_event_timer_cancel_burst_t)(
501  const struct rte_event_timer_adapter *adapter,
502  struct rte_event_timer **tims,
503  uint16_t nb_tims);
509 struct rte_event_timer_adapter {
510  rte_event_timer_arm_burst_t arm_burst;
512  rte_event_timer_arm_tmo_tick_burst_t arm_tmo_tick_burst;
514  rte_event_timer_cancel_burst_t cancel_burst;
516  struct rte_event_timer_adapter_data *data;
518  const struct rte_event_timer_adapter_ops *ops;
522  uint8_t allocated : 1;
525 
526 #define ADAPTER_VALID_OR_ERR_RET(adapter, retval) do { \
527  if (adapter == NULL || !adapter->allocated) \
528  return retval; \
529 } while (0)
530 
531 #define FUNC_PTR_OR_ERR_RET(func, errval) do { \
532  if ((func) == NULL) \
533  return errval; \
534 } while (0)
535 
536 #define FUNC_PTR_OR_NULL_RET_WITH_ERRNO(func, errval) do { \
537  if ((func) == NULL) { \
538  rte_errno = errval; \
539  return NULL; \
540  } \
541 } while (0)
542 
574 static inline uint16_t
575 rte_event_timer_arm_burst(const struct rte_event_timer_adapter *adapter,
576  struct rte_event_timer **evtims,
577  uint16_t nb_evtims)
578 {
579 #ifdef RTE_LIBRTE_EVENTDEV_DEBUG
580  ADAPTER_VALID_OR_ERR_RET(adapter, -EINVAL);
581  FUNC_PTR_OR_ERR_RET(adapter->arm_burst, -EINVAL);
582 #endif
583  rte_eventdev_trace_timer_arm_burst(adapter, (void **)evtims,
584  nb_evtims);
585  return adapter->arm_burst(adapter, evtims, nb_evtims);
586 }
587 
617 static inline uint16_t
619  const struct rte_event_timer_adapter *adapter,
620  struct rte_event_timer **evtims,
621  const uint64_t timeout_ticks,
622  const uint16_t nb_evtims)
623 {
624 #ifdef RTE_LIBRTE_EVENTDEV_DEBUG
625  ADAPTER_VALID_OR_ERR_RET(adapter, -EINVAL);
626  FUNC_PTR_OR_ERR_RET(adapter->arm_tmo_tick_burst, -EINVAL);
627 #endif
628  rte_eventdev_trace_timer_arm_tmo_tick_burst(adapter, timeout_ticks,
629  (void **)evtims, nb_evtims);
630  return adapter->arm_tmo_tick_burst(adapter, evtims, timeout_ticks,
631  nb_evtims);
632 }
633 
654 static inline uint16_t
655 rte_event_timer_cancel_burst(const struct rte_event_timer_adapter *adapter,
656  struct rte_event_timer **evtims,
657  uint16_t nb_evtims)
658 {
659 #ifdef RTE_LIBRTE_EVENTDEV_DEBUG
660  ADAPTER_VALID_OR_ERR_RET(adapter, -EINVAL);
661  FUNC_PTR_OR_ERR_RET(adapter->cancel_burst, -EINVAL);
662 #endif
663  rte_eventdev_trace_timer_cancel_burst(adapter, (void **)evtims,
664  nb_evtims);
665  return adapter->cancel_burst(adapter, evtims, nb_evtims);
666 }
667 
668 #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)
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)
#define __rte_cache_aligned
Definition: rte_common.h:376
#define RTE_STD_C11
Definition: rte_common.h:40
rte_event_timer_adapter_clk_src
enum rte_event_timer_adapter_clk_src clk_src
enum rte_event_timer_state state
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)