DPDK  18.05.1
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 rte_event_timer_adapter_stats_reset(
465  struct rte_event_timer_adapter *adapter);
466 
482 int
483 rte_event_timer_adapter_service_id_get(struct rte_event_timer_adapter *adapter,
484  uint32_t *service_id);
485 
501 int rte_event_timer_adapter_stats_get(struct rte_event_timer_adapter *adapter,
502  struct rte_event_timer_adapter_stats *stats);
503 
518  struct rte_event_timer_adapter *adapter);
519 
541 };
542 
552  struct rte_event ev;
567  uint64_t timeout_ticks;
572  uint64_t impl_opaque[2];
578  uint8_t user_meta[0];
583 
584 typedef uint16_t (*rte_event_timer_arm_burst_t)(
585  const struct rte_event_timer_adapter *adapter,
586  struct rte_event_timer **tims,
587  uint16_t nb_tims);
589 typedef uint16_t (*rte_event_timer_arm_tmo_tick_burst_t)(
590  const struct rte_event_timer_adapter *adapter,
591  struct rte_event_timer **tims,
592  uint64_t timeout_tick,
593  uint16_t nb_tims);
595 typedef uint16_t (*rte_event_timer_cancel_burst_t)(
596  const struct rte_event_timer_adapter *adapter,
597  struct rte_event_timer **tims,
598  uint16_t nb_tims);
604 struct rte_event_timer_adapter {
605  rte_event_timer_arm_burst_t arm_burst;
607  rte_event_timer_arm_tmo_tick_burst_t arm_tmo_tick_burst;
609  rte_event_timer_cancel_burst_t cancel_burst;
611  struct rte_event_timer_adapter_data *data;
613  const struct rte_event_timer_adapter_ops *ops;
617  uint8_t allocated : 1;
620 
621 #define ADAPTER_VALID_OR_ERR_RET(adapter, retval) do { \
622  if (adapter == NULL || !adapter->allocated) \
623  return retval; \
624 } while (0)
625 
626 #define FUNC_PTR_OR_ERR_RET(func, errval) do { \
627  if ((func) == NULL) \
628  return errval; \
629 } while (0)
630 
631 #define FUNC_PTR_OR_NULL_RET_WITH_ERRNO(func, errval) do { \
632  if ((func) == NULL) { \
633  rte_errno = errval; \
634  return NULL; \
635  } \
636 } while (0)
637 
672 static inline uint16_t __rte_experimental
673 rte_event_timer_arm_burst(const struct rte_event_timer_adapter *adapter,
674  struct rte_event_timer **evtims,
675  uint16_t nb_evtims)
676 {
677 #ifdef RTE_LIBRTE_EVENTDEV_DEBUG
678  ADAPTER_VALID_OR_ERR_RET(adapter, -EINVAL);
679  FUNC_PTR_OR_ERR_RET(adapter->arm_burst, -EINVAL);
680 #endif
681  return adapter->arm_burst(adapter, evtims, nb_evtims);
682 }
683 
716 static inline uint16_t __rte_experimental
718  const struct rte_event_timer_adapter *adapter,
719  struct rte_event_timer **evtims,
720  const uint64_t timeout_ticks,
721  const uint16_t nb_evtims)
722 {
723 #ifdef RTE_LIBRTE_EVENTDEV_DEBUG
724  ADAPTER_VALID_OR_ERR_RET(adapter, -EINVAL);
725  FUNC_PTR_OR_ERR_RET(adapter->arm_tmo_tick_burst, -EINVAL);
726 #endif
727  return adapter->arm_tmo_tick_burst(adapter, evtims, timeout_ticks,
728  nb_evtims);
729 }
730 
754 static inline uint16_t __rte_experimental
755 rte_event_timer_cancel_burst(const struct rte_event_timer_adapter *adapter,
756  struct rte_event_timer **evtims,
757  uint16_t nb_evtims)
758 {
759 #ifdef RTE_LIBRTE_EVENTDEV_DEBUG
760  ADAPTER_VALID_OR_ERR_RET(adapter, -EINVAL);
761  FUNC_PTR_OR_ERR_RET(adapter->cancel_burst, -EINVAL);
762 #endif
763  return adapter->cancel_burst(adapter, evtims, nb_evtims);
764 }
765 
766 #endif /* __RTE_EVENT_TIMER_ADAPTER_H__ */