DPDK  19.11.14
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 
133 };
134 
135 #define RTE_EVENT_TIMER_ADAPTER_F_ADJUST_RES (1ULL << 0)
136 
147 #define RTE_EVENT_TIMER_ADAPTER_F_SP_PUT (1ULL << 1)
148 
157  uint8_t event_dev_id;
161  uint32_t socket_id;
165  uint64_t timer_tick_ns;
167  uint64_t max_tmo_ns;
169  uint64_t nb_timers;
171  uint64_t flags;
173 };
174 
179  uint64_t evtim_exp_count;
181  uint64_t ev_enq_count;
183  uint64_t ev_inv_count;
189 };
190 
191 struct rte_event_timer_adapter;
192 
196 typedef int (*rte_event_timer_adapter_port_conf_cb_t)(uint16_t id,
197  uint8_t event_dev_id,
198  uint8_t *event_port_id,
199  void *conf_arg);
200 
223 struct rte_event_timer_adapter *
225 
250 struct rte_event_timer_adapter *
252  const struct rte_event_timer_adapter_conf *conf,
254  void *conf_arg);
255 
262  uint64_t max_tmo_ns;
266  uint32_t caps;
270 };
271 
292 int
294  const struct rte_event_timer_adapter *adapter,
295  struct rte_event_timer_adapter_info *adapter_info);
296 
321 int
323  const struct rte_event_timer_adapter *adapter);
324 
339 int
340 rte_event_timer_adapter_stop(const struct rte_event_timer_adapter *adapter);
341 
358 struct rte_event_timer_adapter *
359 rte_event_timer_adapter_lookup(uint16_t adapter_id);
360 
379 int
380 rte_event_timer_adapter_free(struct rte_event_timer_adapter *adapter);
381 
397 int
398 rte_event_timer_adapter_service_id_get(struct rte_event_timer_adapter *adapter,
399  uint32_t *service_id);
400 
413 int
414 rte_event_timer_adapter_stats_get(struct rte_event_timer_adapter *adapter,
415  struct rte_event_timer_adapter_stats *stats);
416 
427 int
428 rte_event_timer_adapter_stats_reset(struct rte_event_timer_adapter *adapter);
429 
448 };
449 
456  struct rte_event ev;
469  volatile enum rte_event_timer_state state;
471  uint64_t timeout_ticks;
476  uint64_t impl_opaque[2];
482  uint8_t user_meta[0];
487 
488 typedef uint16_t (*rte_event_timer_arm_burst_t)(
489  const struct rte_event_timer_adapter *adapter,
490  struct rte_event_timer **tims,
491  uint16_t nb_tims);
493 typedef uint16_t (*rte_event_timer_arm_tmo_tick_burst_t)(
494  const struct rte_event_timer_adapter *adapter,
495  struct rte_event_timer **tims,
496  uint64_t timeout_tick,
497  uint16_t nb_tims);
499 typedef uint16_t (*rte_event_timer_cancel_burst_t)(
500  const struct rte_event_timer_adapter *adapter,
501  struct rte_event_timer **tims,
502  uint16_t nb_tims);
508 struct rte_event_timer_adapter {
509  rte_event_timer_arm_burst_t arm_burst;
511  rte_event_timer_arm_tmo_tick_burst_t arm_tmo_tick_burst;
513  rte_event_timer_cancel_burst_t cancel_burst;
515  struct rte_event_timer_adapter_data *data;
517  const struct rte_event_timer_adapter_ops *ops;
521  uint8_t allocated : 1;
524 
525 #define ADAPTER_VALID_OR_ERR_RET(adapter, retval) do { \
526  if (adapter == NULL || !adapter->allocated) \
527  return retval; \
528 } while (0)
529 
530 #define FUNC_PTR_OR_ERR_RET(func, errval) do { \
531  if ((func) == NULL) \
532  return errval; \
533 } while (0)
534 
535 #define FUNC_PTR_OR_NULL_RET_WITH_ERRNO(func, errval) do { \
536  if ((func) == NULL) { \
537  rte_errno = errval; \
538  return NULL; \
539  } \
540 } while (0)
541 
573 static inline uint16_t
574 rte_event_timer_arm_burst(const struct rte_event_timer_adapter *adapter,
575  struct rte_event_timer **evtims,
576  uint16_t nb_evtims)
577 {
578 #ifdef RTE_LIBRTE_EVENTDEV_DEBUG
579  ADAPTER_VALID_OR_ERR_RET(adapter, -EINVAL);
580  FUNC_PTR_OR_ERR_RET(adapter->arm_burst, -EINVAL);
581 #endif
582  return adapter->arm_burst(adapter, evtims, nb_evtims);
583 }
584 
614 static inline uint16_t
616  const struct rte_event_timer_adapter *adapter,
617  struct rte_event_timer **evtims,
618  const uint64_t timeout_ticks,
619  const uint16_t nb_evtims)
620 {
621 #ifdef RTE_LIBRTE_EVENTDEV_DEBUG
622  ADAPTER_VALID_OR_ERR_RET(adapter, -EINVAL);
623  FUNC_PTR_OR_ERR_RET(adapter->arm_tmo_tick_burst, -EINVAL);
624 #endif
625  return adapter->arm_tmo_tick_burst(adapter, evtims, timeout_ticks,
626  nb_evtims);
627 }
628 
649 static inline uint16_t
650 rte_event_timer_cancel_burst(const struct rte_event_timer_adapter *adapter,
651  struct rte_event_timer **evtims,
652  uint16_t nb_evtims)
653 {
654 #ifdef RTE_LIBRTE_EVENTDEV_DEBUG
655  ADAPTER_VALID_OR_ERR_RET(adapter, -EINVAL);
656  FUNC_PTR_OR_ERR_RET(adapter->cancel_burst, -EINVAL);
657 #endif
658  return adapter->cancel_burst(adapter, evtims, nb_evtims);
659 }
660 
661 #ifdef __cplusplus
662 }
663 #endif
664 
665 #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_STD_C11
Definition: rte_common.h:40
rte_event_timer_adapter_clk_src
#define __rte_cache_aligned
Definition: rte_common.h:322
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)