DPDK  19.02.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 
136 };
137 
138 #define RTE_EVENT_TIMER_ADAPTER_F_ADJUST_RES (1ULL << 0)
139 
150 #define RTE_EVENT_TIMER_ADAPTER_F_SP_PUT (1ULL << 1)
151 
163  uint8_t event_dev_id;
165  uint16_t timer_adapter_id;
167  uint32_t socket_id;
171  uint64_t timer_tick_ns;
173  uint64_t max_tmo_ns;
175  uint64_t nb_timers;
177  uint64_t flags;
179 };
180 
188  uint64_t evtim_exp_count;
190  uint64_t ev_enq_count;
192  uint64_t ev_inv_count;
194  uint64_t evtim_retry_count;
196  uint64_t adapter_tick_count;
198 };
199 
200 struct rte_event_timer_adapter;
201 
208 typedef int (*rte_event_timer_adapter_port_conf_cb_t)(uint16_t id,
209  uint8_t event_dev_id,
210  uint8_t *event_port_id,
211  void *conf_arg);
212 
238 struct rte_event_timer_adapter * __rte_experimental
240 
268 struct rte_event_timer_adapter * __rte_experimental
270  const struct rte_event_timer_adapter_conf *conf,
272  void *conf_arg);
273 
281  uint64_t min_resolution_ns;
283  uint64_t max_tmo_ns;
287  uint32_t caps;
289  int16_t event_dev_port_id;
291 };
292 
316 int __rte_experimental
318  const struct rte_event_timer_adapter *adapter,
319  struct rte_event_timer_adapter_info *adapter_info);
320 
343 int __rte_experimental
345  const struct rte_event_timer_adapter *adapter);
346 
364 int __rte_experimental
365 rte_event_timer_adapter_stop(const struct rte_event_timer_adapter *adapter);
366 
386 struct rte_event_timer_adapter * __rte_experimental
387 rte_event_timer_adapter_lookup(uint16_t adapter_id);
388 
410 int __rte_experimental
411 rte_event_timer_adapter_free(struct rte_event_timer_adapter *adapter);
412 
428 int __rte_experimental
429 rte_event_timer_adapter_service_id_get(struct rte_event_timer_adapter *adapter,
430  uint32_t *service_id);
431 
447 int __rte_experimental
448 rte_event_timer_adapter_stats_get(struct rte_event_timer_adapter *adapter,
449  struct rte_event_timer_adapter_stats *stats);
450 
464 int __rte_experimental
465 rte_event_timer_adapter_stats_reset(struct rte_event_timer_adapter *adapter);
466 
488 };
489 
499  struct rte_event ev;
514  uint64_t timeout_ticks;
519  uint64_t impl_opaque[2];
525  uint8_t user_meta[0];
530 
531 typedef uint16_t (*rte_event_timer_arm_burst_t)(
532  const struct rte_event_timer_adapter *adapter,
533  struct rte_event_timer **tims,
534  uint16_t nb_tims);
536 typedef uint16_t (*rte_event_timer_arm_tmo_tick_burst_t)(
537  const struct rte_event_timer_adapter *adapter,
538  struct rte_event_timer **tims,
539  uint64_t timeout_tick,
540  uint16_t nb_tims);
542 typedef uint16_t (*rte_event_timer_cancel_burst_t)(
543  const struct rte_event_timer_adapter *adapter,
544  struct rte_event_timer **tims,
545  uint16_t nb_tims);
551 struct rte_event_timer_adapter {
552  rte_event_timer_arm_burst_t arm_burst;
554  rte_event_timer_arm_tmo_tick_burst_t arm_tmo_tick_burst;
556  rte_event_timer_cancel_burst_t cancel_burst;
558  struct rte_event_timer_adapter_data *data;
560  const struct rte_event_timer_adapter_ops *ops;
564  uint8_t allocated : 1;
567 
568 #define ADAPTER_VALID_OR_ERR_RET(adapter, retval) do { \
569  if (adapter == NULL || !adapter->allocated) \
570  return retval; \
571 } while (0)
572 
573 #define FUNC_PTR_OR_ERR_RET(func, errval) do { \
574  if ((func) == NULL) \
575  return errval; \
576 } while (0)
577 
578 #define FUNC_PTR_OR_NULL_RET_WITH_ERRNO(func, errval) do { \
579  if ((func) == NULL) { \
580  rte_errno = errval; \
581  return NULL; \
582  } \
583 } while (0)
584 
619 static inline uint16_t __rte_experimental
620 rte_event_timer_arm_burst(const struct rte_event_timer_adapter *adapter,
621  struct rte_event_timer **evtims,
622  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_burst, -EINVAL);
627 #endif
628  return adapter->arm_burst(adapter, evtims, nb_evtims);
629 }
630 
663 static inline uint16_t __rte_experimental
665  const struct rte_event_timer_adapter *adapter,
666  struct rte_event_timer **evtims,
667  const uint64_t timeout_ticks,
668  const 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->arm_tmo_tick_burst, -EINVAL);
673 #endif
674  return adapter->arm_tmo_tick_burst(adapter, evtims, timeout_ticks,
675  nb_evtims);
676 }
677 
701 static inline uint16_t __rte_experimental
702 rte_event_timer_cancel_burst(const struct rte_event_timer_adapter *adapter,
703  struct rte_event_timer **evtims,
704  uint16_t nb_evtims)
705 {
706 #ifdef RTE_LIBRTE_EVENTDEV_DEBUG
707  ADAPTER_VALID_OR_ERR_RET(adapter, -EINVAL);
708  FUNC_PTR_OR_ERR_RET(adapter->cancel_burst, -EINVAL);
709 #endif
710  return adapter->cancel_burst(adapter, evtims, nb_evtims);
711 }
712 
713 #endif /* __RTE_EVENT_TIMER_ADAPTER_H__ */