Branch data Line data Source code
1 : : /* SPDX-License-Identifier: BSD-3-Clause
2 : : * Copyright(C) 2021 Marvell.
3 : : */
4 : :
5 : : #ifndef __CNXK_EVENTDEV_H__
6 : : #define __CNXK_EVENTDEV_H__
7 : :
8 : : #include <string.h>
9 : :
10 : : #include <cryptodev_pmd.h>
11 : : #include <rte_devargs.h>
12 : : #include <rte_ethdev.h>
13 : : #include <rte_event_crypto_adapter.h>
14 : : #include <rte_event_eth_rx_adapter.h>
15 : : #include <rte_event_eth_tx_adapter.h>
16 : : #include <rte_kvargs.h>
17 : : #include <rte_mbuf_pool_ops.h>
18 : : #include <rte_pci.h>
19 : :
20 : : #include <eventdev_pmd_pci.h>
21 : :
22 : : #include "cnxk_eventdev_dp.h"
23 : :
24 : : #include "cnxk_tim_evdev.h"
25 : :
26 : : #define CNXK_SSO_XAE_CNT "xae_cnt"
27 : : #define CNXK_SSO_GGRP_QOS "qos"
28 : : #define CNXK_SSO_FORCE_BP "force_rx_bp"
29 : : #define CN9K_SSO_SINGLE_WS "single_ws"
30 : : #define CNXK_SSO_STASH "stash"
31 : :
32 : : #define CNXK_SSO_MAX_PROFILES 2
33 : :
34 : : #define NSEC2USEC(__ns) ((__ns) / 1E3)
35 : : #define USEC2NSEC(__us) ((__us)*1E3)
36 : : #define NSEC2TICK(__ns, __freq) (((__ns) * (__freq)) / 1E9)
37 : :
38 : : #define CN9K_SSOW_GET_BASE_ADDR(_GW) ((_GW)-SSOW_LF_GWS_OP_GET_WORK0)
39 : : #define CN9K_DUAL_WS_NB_WS 2
40 : :
41 : : #define CNXK_GW_MODE_NONE 0
42 : : #define CNXK_GW_MODE_PREF 1
43 : : #define CNXK_GW_MODE_PREF_WFE 2
44 : :
45 : : #define CNXK_QOS_NORMALIZE(val, min, max, cnt) \
46 : : (min + val / ((max + cnt - 1) / cnt))
47 : : #define CNXK_SSO_FLUSH_RETRY_MAX 0xfff
48 : :
49 : : #define CNXK_VALID_DEV_OR_ERR_RET(dev, drv_name, err_val) \
50 : : do { \
51 : : if (strncmp(dev->driver->name, drv_name, strlen(drv_name))) \
52 : : return -err_val; \
53 : : } while (0)
54 : :
55 : : typedef void *(*cnxk_sso_init_hws_mem_t)(void *dev, uint8_t port_id);
56 : : typedef void (*cnxk_sso_hws_setup_t)(void *dev, void *ws, uintptr_t grp_base);
57 : : typedef void (*cnxk_sso_hws_release_t)(void *dev, void *ws);
58 : : typedef int (*cnxk_sso_link_t)(void *dev, void *ws, uint16_t *map, uint16_t nb_link,
59 : : uint8_t profile);
60 : : typedef int (*cnxk_sso_unlink_t)(void *dev, void *ws, uint16_t *map, uint16_t nb_link,
61 : : uint8_t profile);
62 : : typedef void (*cnxk_handle_event_t)(void *arg, struct rte_event ev);
63 : : typedef void (*cnxk_sso_hws_reset_t)(void *arg, void *ws);
64 : : typedef int (*cnxk_sso_hws_flush_t)(void *ws, uint8_t queue_id, uintptr_t base,
65 : : cnxk_handle_event_t fn, void *arg);
66 : :
67 : : struct cnxk_sso_qos {
68 : : uint16_t queue;
69 : : uint16_t taq_prcnt;
70 : : uint16_t iaq_prcnt;
71 : : };
72 : :
73 : : struct cnxk_sso_stash {
74 : : uint16_t queue;
75 : : uint16_t stash_offset;
76 : : uint16_t stash_length;
77 : : };
78 : :
79 : : struct __rte_cache_aligned cnxk_sso_evdev {
80 : : struct roc_sso sso;
81 : : uint8_t max_event_queues;
82 : : uint8_t max_event_ports;
83 : : uint8_t is_timeout_deq;
84 : : uint8_t nb_event_queues;
85 : : uint8_t nb_event_ports;
86 : : uint8_t configured;
87 : : uint32_t deq_tmo_ns;
88 : : uint32_t min_dequeue_timeout_ns;
89 : : uint32_t max_dequeue_timeout_ns;
90 : : int32_t max_num_events;
91 : : int32_t num_events;
92 : : uint64_t xaq_lmt;
93 : : int64_t *fc_cache_space;
94 : : rte_iova_t fc_iova;
95 : : uint64_t rx_offloads;
96 : : uint64_t tx_offloads;
97 : : uint64_t adptr_xae_cnt;
98 : : uint16_t rx_adptr_pool_cnt;
99 : : uint64_t *rx_adptr_pools;
100 : : uint64_t *tx_adptr_data;
101 : : size_t tx_adptr_data_sz;
102 : : uint16_t max_port_id;
103 : : uint16_t max_queue_id[RTE_MAX_ETHPORTS];
104 : : uint8_t tx_adptr_configured;
105 : : uint32_t tx_adptr_active_mask;
106 : : uint16_t tim_adptr_ring_cnt;
107 : : uint16_t *timer_adptr_rings;
108 : : uint64_t *timer_adptr_sz;
109 : : uint16_t vec_pool_cnt;
110 : : uint64_t *vec_pools;
111 : : struct cnxk_timesync_info *tstamp[RTE_MAX_ETHPORTS];
112 : : /* Dev args */
113 : : uint32_t xae_cnt;
114 : : uint16_t qos_queue_cnt;
115 : : struct cnxk_sso_qos *qos_parse_data;
116 : : uint8_t force_ena_bp;
117 : : /* CN9K */
118 : : uint8_t dual_ws;
119 : : /* CN10K */
120 : : uint32_t gw_mode;
121 : : uint16_t stash_cnt;
122 : : struct cnxk_sso_stash *stash_parse_data;
123 : : };
124 : :
125 : : /* Event port a.k.a GWS */
126 : : struct __rte_cache_aligned cn9k_sso_hws {
127 : : uint64_t base;
128 : : uint64_t gw_wdata;
129 : : void *lookup_mem;
130 : : uint8_t swtag_req;
131 : : uint8_t hws_id;
132 : : /* PTP timestamp */
133 : : struct cnxk_timesync_info **tstamp;
134 : : /* Add Work Fastpath data */
135 : : alignas(RTE_CACHE_LINE_SIZE) uint64_t xaq_lmt;
136 : : uint64_t __rte_atomic *fc_mem;
137 : : uintptr_t grp_base;
138 : : /* Tx Fastpath data */
139 : : alignas(RTE_CACHE_LINE_SIZE) uint64_t lso_tun_fmt;
140 : : uint8_t tx_adptr_data[];
141 : : };
142 : :
143 : : struct __rte_cache_aligned cn9k_sso_hws_dual {
144 : : uint64_t base[2]; /* Ping and Pong */
145 : : uint64_t gw_wdata;
146 : : void *lookup_mem;
147 : : uint8_t swtag_req;
148 : : uint8_t vws; /* Ping pong bit */
149 : : uint8_t hws_id;
150 : : /* PTP timestamp */
151 : : struct cnxk_timesync_info **tstamp;
152 : : /* Add Work Fastpath data */
153 : : alignas(RTE_CACHE_LINE_SIZE) uint64_t xaq_lmt;
154 : : uint64_t __rte_atomic *fc_mem;
155 : : uintptr_t grp_base;
156 : : /* Tx Fastpath data */
157 : : alignas(RTE_CACHE_LINE_SIZE) uint64_t lso_tun_fmt;
158 : : uint8_t tx_adptr_data[];
159 : : };
160 : :
161 : : struct __rte_cache_aligned cnxk_sso_hws_cookie {
162 : : const struct rte_eventdev *event_dev;
163 : : bool configured;
164 : : };
165 : :
166 : : static inline int
167 : 0 : parse_kvargs_flag(const char *key, const char *value, void *opaque)
168 : : {
169 : : RTE_SET_USED(key);
170 : :
171 : 0 : *(uint8_t *)opaque = !!atoi(value);
172 : 0 : return 0;
173 : : }
174 : :
175 : : static inline int
176 : 0 : parse_kvargs_value(const char *key, const char *value, void *opaque)
177 : : {
178 : : RTE_SET_USED(key);
179 : :
180 : 0 : *(uint32_t *)opaque = (uint32_t)atoi(value);
181 : 0 : return 0;
182 : : }
183 : :
184 : : static inline struct cnxk_sso_evdev *
185 : : cnxk_sso_pmd_priv(const struct rte_eventdev *event_dev)
186 : : {
187 [ # # # # : 0 : return event_dev->data->dev_private;
# # # # #
# # # # #
# # ]
188 : : }
189 : :
190 : : static inline struct cnxk_sso_hws_cookie *
191 : : cnxk_sso_hws_get_cookie(void *ws)
192 : : {
193 [ # # ]: 0 : return RTE_PTR_SUB(ws, sizeof(struct cnxk_sso_hws_cookie));
194 : : }
195 : :
196 : : /* Configuration functions */
197 : : int cnxk_sso_xae_reconfigure(struct rte_eventdev *event_dev);
198 : : int cnxk_sso_xaq_allocate(struct cnxk_sso_evdev *dev);
199 : : void cnxk_sso_updt_xae_cnt(struct cnxk_sso_evdev *dev, void *data,
200 : : uint32_t event_type);
201 : :
202 : : /* Common ops API. */
203 : : int cnxk_sso_init(struct rte_eventdev *event_dev);
204 : : int cnxk_sso_fini(struct rte_eventdev *event_dev);
205 : : int cnxk_sso_remove(struct rte_pci_device *pci_dev);
206 : : void cnxk_sso_info_get(struct cnxk_sso_evdev *dev,
207 : : struct rte_event_dev_info *dev_info);
208 : : int cnxk_sso_dev_validate(const struct rte_eventdev *event_dev,
209 : : uint32_t deq_depth, uint32_t enq_depth);
210 : : int cnxk_setup_event_ports(const struct rte_eventdev *event_dev,
211 : : cnxk_sso_init_hws_mem_t init_hws_mem,
212 : : cnxk_sso_hws_setup_t hws_setup);
213 : : void cnxk_sso_restore_links(const struct rte_eventdev *event_dev,
214 : : cnxk_sso_link_t link_fn);
215 : : void cnxk_sso_queue_def_conf(struct rte_eventdev *event_dev, uint8_t queue_id,
216 : : struct rte_event_queue_conf *queue_conf);
217 : : int cnxk_sso_queue_setup(struct rte_eventdev *event_dev, uint8_t queue_id,
218 : : const struct rte_event_queue_conf *queue_conf);
219 : : void cnxk_sso_queue_release(struct rte_eventdev *event_dev, uint8_t queue_id);
220 : : int cnxk_sso_queue_attribute_set(struct rte_eventdev *event_dev,
221 : : uint8_t queue_id, uint32_t attr_id,
222 : : uint64_t attr_value);
223 : : void cnxk_sso_port_def_conf(struct rte_eventdev *event_dev, uint8_t port_id,
224 : : struct rte_event_port_conf *port_conf);
225 : : int cnxk_sso_port_setup(struct rte_eventdev *event_dev, uint8_t port_id,
226 : : cnxk_sso_hws_setup_t hws_setup_fn);
227 : : int cnxk_sso_timeout_ticks(struct rte_eventdev *event_dev, uint64_t ns,
228 : : uint64_t *tmo_ticks);
229 : : int cnxk_sso_start(struct rte_eventdev *event_dev,
230 : : cnxk_sso_hws_reset_t reset_fn,
231 : : cnxk_sso_hws_flush_t flush_fn);
232 : : void cnxk_sso_stop(struct rte_eventdev *event_dev,
233 : : cnxk_sso_hws_reset_t reset_fn,
234 : : cnxk_sso_hws_flush_t flush_fn);
235 : : int cnxk_sso_close(struct rte_eventdev *event_dev, cnxk_sso_unlink_t unlink_fn);
236 : : int cnxk_sso_selftest(const char *dev_name);
237 : : void cnxk_sso_dump(struct rte_eventdev *event_dev, FILE *f);
238 : :
239 : : /* Stats API. */
240 : : int cnxk_sso_xstats_get_names(const struct rte_eventdev *event_dev,
241 : : enum rte_event_dev_xstats_mode mode,
242 : : uint8_t queue_port_id,
243 : : struct rte_event_dev_xstats_name *xstats_names,
244 : : uint64_t *ids, unsigned int size);
245 : : int cnxk_sso_xstats_get(const struct rte_eventdev *event_dev,
246 : : enum rte_event_dev_xstats_mode mode,
247 : : uint8_t queue_port_id, const uint64_t ids[],
248 : : uint64_t values[], unsigned int n);
249 : : int cnxk_sso_xstats_reset(struct rte_eventdev *event_dev,
250 : : enum rte_event_dev_xstats_mode mode,
251 : : int16_t queue_port_id, const uint64_t ids[],
252 : : uint32_t n);
253 : :
254 : : /* CN9K */
255 : : void cn9k_sso_set_rsrc(void *arg);
256 : :
257 : : /* Common adapter ops */
258 : : int cnxk_sso_rx_adapter_queue_add(
259 : : const struct rte_eventdev *event_dev, const struct rte_eth_dev *eth_dev,
260 : : int32_t rx_queue_id,
261 : : const struct rte_event_eth_rx_adapter_queue_conf *queue_conf);
262 : : int cnxk_sso_rx_adapter_queue_del(const struct rte_eventdev *event_dev,
263 : : const struct rte_eth_dev *eth_dev,
264 : : int32_t rx_queue_id);
265 : : int cnxk_sso_rx_adapter_start(const struct rte_eventdev *event_dev,
266 : : const struct rte_eth_dev *eth_dev);
267 : : int cnxk_sso_rx_adapter_stop(const struct rte_eventdev *event_dev,
268 : : const struct rte_eth_dev *eth_dev);
269 : : void cnxk_sso_tstamp_cfg(uint16_t port_id, const struct rte_eth_dev *eth_dev,
270 : : struct cnxk_sso_evdev *dev);
271 : : int cnxk_sso_rxq_disable(const struct rte_eth_dev *eth_dev, uint16_t rq_id);
272 : : int cnxk_sso_tx_adapter_queue_add(const struct rte_eventdev *event_dev,
273 : : const struct rte_eth_dev *eth_dev,
274 : : int32_t tx_queue_id);
275 : : int cnxk_sso_tx_adapter_queue_del(const struct rte_eventdev *event_dev,
276 : : const struct rte_eth_dev *eth_dev,
277 : : int32_t tx_queue_id);
278 : : int cnxk_sso_tx_adapter_start(uint8_t id, const struct rte_eventdev *event_dev);
279 : : int cnxk_sso_tx_adapter_stop(uint8_t id, const struct rte_eventdev *event_dev);
280 : : int cnxk_sso_tx_adapter_free(uint8_t id, const struct rte_eventdev *event_dev);
281 : : int cnxk_crypto_adapter_qp_add(const struct rte_eventdev *event_dev,
282 : : const struct rte_cryptodev *cdev, int32_t queue_pair_id,
283 : : const struct rte_event_crypto_adapter_queue_conf *conf);
284 : : int cnxk_crypto_adapter_qp_del(const struct rte_cryptodev *cdev, int32_t queue_pair_id);
285 : :
286 : : int cnxk_dma_adapter_vchan_add(const struct rte_eventdev *event_dev,
287 : : const int16_t dma_dev_id, uint16_t vchan_id);
288 : : int cnxk_dma_adapter_vchan_del(const int16_t dma_dev_id, uint16_t vchan_id);
289 : : #endif /* __CNXK_EVENTDEV_H__ */
|