1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(C) 2019 Marvell International Ltd.
5 #ifndef __OTX2_TIM_EVDEV_H__
6 #define __OTX2_TIM_EVDEV_H__
8 #include <rte_event_timer_adapter.h>
9 #include <rte_event_timer_adapter_pmd.h>
13 #define OTX2_TIM_EVDEV_NAME otx2_tim_eventdev
15 #define otx2_tim_func_trace otx2_tim_dbg
17 #define TIM_LF_RING_AURA (0x0)
18 #define TIM_LF_RING_BASE (0x130)
19 #define TIM_LF_NRSPERR_INT (0x200)
20 #define TIM_LF_NRSPERR_INT_W1S (0x208)
21 #define TIM_LF_NRSPERR_INT_ENA_W1S (0x210)
22 #define TIM_LF_NRSPERR_INT_ENA_W1C (0x218)
23 #define TIM_LF_RAS_INT (0x300)
24 #define TIM_LF_RAS_INT_W1S (0x308)
25 #define TIM_LF_RAS_INT_ENA_W1S (0x310)
26 #define TIM_LF_RAS_INT_ENA_W1C (0x318)
28 #define OTX2_MAX_TIM_RINGS (256)
29 #define OTX2_TIM_MAX_BUCKETS (0xFFFFF)
30 #define OTX2_TIM_RING_DEF_CHUNK_SZ (4096)
31 #define OTX2_TIM_CHUNK_ALIGNMENT (16)
32 #define OTX2_TIM_NB_CHUNK_SLOTS(sz) (((sz) / OTX2_TIM_CHUNK_ALIGNMENT) - 1)
33 #define OTX2_TIM_MIN_CHUNK_SLOTS (0x1)
34 #define OTX2_TIM_MAX_CHUNK_SLOTS (0x1FFE)
35 #define OTX2_TIM_MIN_TMO_TKS (256)
37 enum otx2_tim_clk_src {
38 OTX2_TIM_CLK_SRC_10NS = RTE_EVENT_TIMER_ADAPTER_CPU_CLK,
39 OTX2_TIM_CLK_SRC_GPIO = RTE_EVENT_TIMER_ADAPTER_EXT_CLK0,
40 OTX2_TIM_CLK_SRC_GTI = RTE_EVENT_TIMER_ADAPTER_EXT_CLK1,
41 OTX2_TIM_CLK_SRC_PTP = RTE_EVENT_TIMER_ADAPTER_EXT_CLK2,
55 int16_t chunk_remainder;
58 uint64_t current_chunk;
60 } __rte_packed __rte_aligned(32);
62 struct otx2_tim_evdev {
63 struct rte_pci_device *pci_dev;
64 struct rte_eventdev *event_dev;
65 struct otx2_mbox *mbox;
73 uint16_t tim_msixoff[OTX2_MAX_TIM_RINGS];
76 struct otx2_tim_ring {
78 uint16_t nb_chunk_slots;
80 struct otx2_tim_bkt *bkt;
81 struct rte_mempool *chunk_pool;
93 uint64_t tenns_clk_freq;
94 enum otx2_tim_clk_src clk_src;
95 } __rte_cache_aligned;
97 static inline struct otx2_tim_evdev *
100 const struct rte_memzone *mz;
102 mz = rte_memzone_lookup(RTE_STR(OTX2_TIM_EVDEV_NAME));
109 int otx2_tim_caps_get(const struct rte_eventdev *dev, uint64_t flags,
111 const struct rte_event_timer_adapter_ops **ops);
113 void otx2_tim_init(struct rte_pci_device *pci_dev, struct otx2_dev *cmn_dev);
114 void otx2_tim_fini(void);
117 int tim_register_irq(uint16_t ring_id);
118 void tim_unregister_irq(uint16_t ring_id);
120 #endif /* __OTX2_TIM_EVDEV_H__ */