DPDK  22.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;
196 };
197 
198 struct rte_event_timer_adapter;
199 
203 typedef int (*rte_event_timer_adapter_port_conf_cb_t)(uint16_t id,
204  uint8_t event_dev_id,
205  uint8_t *event_port_id,
206  void *conf_arg);
207 
230 struct rte_event_timer_adapter *
232 
257 struct rte_event_timer_adapter *
259  const struct rte_event_timer_adapter_conf *conf,
261  void *conf_arg);
262 
269  uint64_t max_tmo_ns;
273  uint32_t caps;
277 };
278 
299 int
301  const struct rte_event_timer_adapter *adapter,
302  struct rte_event_timer_adapter_info *adapter_info);
303 
328 int
330  const struct rte_event_timer_adapter *adapter);
331 
346 int
347 rte_event_timer_adapter_stop(const struct rte_event_timer_adapter *adapter);
348 
365 struct rte_event_timer_adapter *
366 rte_event_timer_adapter_lookup(uint16_t adapter_id);
367 
386 int
387 rte_event_timer_adapter_free(struct rte_event_timer_adapter *adapter);
388 
404 int
405 rte_event_timer_adapter_service_id_get(struct rte_event_timer_adapter *adapter,
406  uint32_t *service_id);
407 
420 int
421 rte_event_timer_adapter_stats_get(struct rte_event_timer_adapter *adapter,
422  struct rte_event_timer_adapter_stats *stats);
423 
434 int
435 rte_event_timer_adapter_stats_reset(struct rte_event_timer_adapter *adapter);
436 
455 };
456 
463  struct rte_event ev;
476  uint64_t timeout_ticks;
481  uint64_t impl_opaque[2];
489  uint8_t user_meta[];
494 
495 typedef uint16_t (*rte_event_timer_arm_burst_t)(
496  const struct rte_event_timer_adapter *adapter,
497  struct rte_event_timer **tims,
498  uint16_t nb_tims);
500 typedef uint16_t (*rte_event_timer_arm_tmo_tick_burst_t)(
501  const struct rte_event_timer_adapter *adapter,
502  struct rte_event_timer **tims,
503  uint64_t timeout_tick,
504  uint16_t nb_tims);
506 typedef uint16_t (*rte_event_timer_cancel_burst_t)(
507  const struct rte_event_timer_adapter *adapter,
508  struct rte_event_timer **tims,
509  uint16_t nb_tims);
515 struct rte_event_timer_adapter {
516  rte_event_timer_arm_burst_t arm_burst;
518  rte_event_timer_arm_tmo_tick_burst_t arm_tmo_tick_burst;
520  rte_event_timer_cancel_burst_t cancel_burst;
522  struct rte_event_timer_adapter_data *data;
524  const struct event_timer_adapter_ops *ops;
528  uint8_t allocated : 1;
531 
532 #define ADAPTER_VALID_OR_ERR_RET(adapter, retval) do { \
533  if (adapter == NULL || !adapter->allocated) \
534  return retval; \
535 } while (0)
536 
537 #define FUNC_PTR_OR_ERR_RET(func, errval) do { \
538  if ((func) == NULL) \
539  return errval; \
540 } while (0)
541 
542 #define FUNC_PTR_OR_NULL_RET_WITH_ERRNO(func, errval) do { \
543  if ((func) == NULL) { \
544  rte_errno = errval; \
545  return NULL; \
546  } \
547 } while (0)
548 
585 static inline uint16_t
586 rte_event_timer_arm_burst(const struct rte_event_timer_adapter *adapter,
587  struct rte_event_timer **evtims,
588  uint16_t nb_evtims)
589 {
590 #ifdef RTE_LIBRTE_EVENTDEV_DEBUG
591  ADAPTER_VALID_OR_ERR_RET(adapter, -EINVAL);
592  FUNC_PTR_OR_ERR_RET(adapter->arm_burst, -EINVAL);
593 #endif
594  rte_eventdev_trace_timer_arm_burst(adapter, (void **)evtims,
595  nb_evtims);
596  return adapter->arm_burst(adapter, evtims, nb_evtims);
597 }
598 
628 static inline uint16_t
630  const struct rte_event_timer_adapter *adapter,
631  struct rte_event_timer **evtims,
632  const uint64_t timeout_ticks,
633  const uint16_t nb_evtims)
634 {
635 #ifdef RTE_LIBRTE_EVENTDEV_DEBUG
636  ADAPTER_VALID_OR_ERR_RET(adapter, -EINVAL);
637  FUNC_PTR_OR_ERR_RET(adapter->arm_tmo_tick_burst, -EINVAL);
638 #endif
639  rte_eventdev_trace_timer_arm_tmo_tick_burst(adapter, timeout_ticks,
640  (void **)evtims, nb_evtims);
641  return adapter->arm_tmo_tick_burst(adapter, evtims, timeout_ticks,
642  nb_evtims);
643 }
644 
665 static inline uint16_t
666 rte_event_timer_cancel_burst(const struct rte_event_timer_adapter *adapter,
667  struct rte_event_timer **evtims,
668  uint16_t nb_evtims)
669 {
670 #ifdef RTE_LIBRTE_EVENTDEV_DEBUG
671  ADAPTER_VALID_OR_ERR_RET(adapter, -EINVAL);
672  FUNC_PTR_OR_ERR_RET(adapter->cancel_burst, -EINVAL);
673 #endif
674  rte_eventdev_trace_timer_cancel_burst(adapter, (void **)evtims,
675  nb_evtims);
676  return adapter->cancel_burst(adapter, evtims, nb_evtims);
677 }
678 
679 #ifdef __cplusplus
680 }
681 #endif
682 
683 #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:445
#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)