event/octeontx2: add devargs to disable NPA
[dpdk.git] / drivers / event / octeontx2 / otx2_tim_evdev.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(C) 2019 Marvell International Ltd.
3  */
4
5 #ifndef __OTX2_TIM_EVDEV_H__
6 #define __OTX2_TIM_EVDEV_H__
7
8 #include <rte_event_timer_adapter.h>
9 #include <rte_event_timer_adapter_pmd.h>
10
11 #include "otx2_dev.h"
12
13 #define OTX2_TIM_EVDEV_NAME otx2_tim_eventdev
14
15 #define otx2_tim_func_trace otx2_tim_dbg
16
17 #define TIM_LF_RING_AURA                (0x0)
18 #define TIM_LF_RING_BASE                (0x130)
19
20 #define OTX2_MAX_TIM_RINGS              (256)
21 #define OTX2_TIM_MAX_BUCKETS            (0xFFFFF)
22 #define OTX2_TIM_RING_DEF_CHUNK_SZ      (4096)
23 #define OTX2_TIM_CHUNK_ALIGNMENT        (16)
24 #define OTX2_TIM_NB_CHUNK_SLOTS(sz)     (((sz) / OTX2_TIM_CHUNK_ALIGNMENT) - 1)
25 #define OTX2_TIM_MIN_TMO_TKS            (256)
26
27 enum otx2_tim_clk_src {
28         OTX2_TIM_CLK_SRC_10NS = RTE_EVENT_TIMER_ADAPTER_CPU_CLK,
29         OTX2_TIM_CLK_SRC_GPIO = RTE_EVENT_TIMER_ADAPTER_EXT_CLK0,
30         OTX2_TIM_CLK_SRC_GTI  = RTE_EVENT_TIMER_ADAPTER_EXT_CLK1,
31         OTX2_TIM_CLK_SRC_PTP  = RTE_EVENT_TIMER_ADAPTER_EXT_CLK2,
32 };
33
34 struct otx2_tim_bkt {
35         uint64_t first_chunk;
36         union {
37                 uint64_t w1;
38                 struct {
39                         uint32_t nb_entry;
40                         uint8_t sbt:1;
41                         uint8_t hbt:1;
42                         uint8_t bsk:1;
43                         uint8_t rsvd:5;
44                         uint8_t lock;
45                         int16_t chunk_remainder;
46                 };
47         };
48         uint64_t current_chunk;
49         uint64_t pad;
50 } __rte_packed __rte_aligned(32);
51
52 struct otx2_tim_evdev {
53         struct rte_pci_device *pci_dev;
54         struct rte_eventdev *event_dev;
55         struct otx2_mbox *mbox;
56         uint16_t nb_rings;
57         uintptr_t bar2;
58         /* Dev args */
59         uint8_t disable_npa;
60 };
61
62 struct otx2_tim_ring {
63         uintptr_t base;
64         uint16_t nb_chunk_slots;
65         uint32_t nb_bkts;
66         struct otx2_tim_bkt *bkt;
67         struct rte_mempool *chunk_pool;
68         uint64_t tck_int;
69         uint8_t prod_type_sp;
70         uint8_t disable_npa;
71         uint8_t optimized;
72         uint8_t ena_dfb;
73         uint16_t ring_id;
74         uint32_t aura;
75         uint64_t tck_nsec;
76         uint64_t max_tout;
77         uint64_t nb_chunks;
78         uint64_t chunk_sz;
79         uint64_t tenns_clk_freq;
80         enum otx2_tim_clk_src clk_src;
81 } __rte_cache_aligned;
82
83 static inline struct otx2_tim_evdev *
84 tim_priv_get(void)
85 {
86         const struct rte_memzone *mz;
87
88         mz = rte_memzone_lookup(RTE_STR(OTX2_TIM_EVDEV_NAME));
89         if (mz == NULL)
90                 return NULL;
91
92         return mz->addr;
93 }
94
95 int otx2_tim_caps_get(const struct rte_eventdev *dev, uint64_t flags,
96                       uint32_t *caps,
97                       const struct rte_event_timer_adapter_ops **ops);
98
99 void otx2_tim_init(struct rte_pci_device *pci_dev, struct otx2_dev *cmn_dev);
100 void otx2_tim_fini(void);
101
102 #endif /* __OTX2_TIM_EVDEV_H__ */