Branch data Line data Source code
1 : : /* SPDX-License-Identifier: BSD-3-Clause
2 : : * Copyright(C) 2021 Marvell.
3 : : */
4 : :
5 : : #include <rte_dmadev_pmd.h>
6 : :
7 : : #include "cn10k_cryptodev_ops.h"
8 : : #include "cn10k_ethdev.h"
9 : : #include "cn10k_tx_worker.h"
10 : : #include "cn10k_worker.h"
11 : : #include "cnxk_common.h"
12 : : #include "cnxk_dma_event_dp.h"
13 : : #include "cnxk_eventdev.h"
14 : : #include "cnxk_worker.h"
15 : :
16 : : #define CN10K_SET_EVDEV_DEQ_OP(dev, deq_op, deq_ops) \
17 : : deq_op = deq_ops[dev->rx_offloads & (NIX_RX_OFFLOAD_MAX - 1)]
18 : :
19 : : #define CN10K_SET_EVDEV_ENQ_OP(dev, enq_op, enq_ops) \
20 : : enq_op = enq_ops[dev->tx_offloads & (NIX_TX_OFFLOAD_MAX - 1)]
21 : :
22 : : static void *
23 : 0 : cn10k_sso_init_hws_mem(void *arg, uint8_t port_id)
24 : : {
25 : : struct cnxk_sso_evdev *dev = arg;
26 : : struct cn10k_sso_hws *ws;
27 : :
28 : : /* Allocate event port memory */
29 : 0 : ws = rte_zmalloc("cn10k_ws",
30 : : sizeof(struct cn10k_sso_hws) + RTE_CACHE_LINE_SIZE,
31 : : RTE_CACHE_LINE_SIZE);
32 [ # # ]: 0 : if (ws == NULL) {
33 : 0 : plt_err("Failed to alloc memory for port=%d", port_id);
34 : 0 : return NULL;
35 : : }
36 : :
37 : : /* First cache line is reserved for cookie */
38 : 0 : ws = (struct cn10k_sso_hws *)((uint8_t *)ws + RTE_CACHE_LINE_SIZE);
39 : 0 : ws->base = roc_sso_hws_base_get(&dev->sso, port_id);
40 : 0 : ws->hws_id = port_id;
41 [ # # ]: 0 : ws->swtag_req = 0;
42 : 0 : ws->gw_wdata = cnxk_sso_hws_prf_wdata(dev);
43 : 0 : ws->gw_rdata = SSO_TT_EMPTY << 32;
44 : 0 : ws->lmt_base = dev->sso.lmt_base;
45 : 0 : ws->xae_waes = dev->sso.feat.xaq_wq_entries;
46 : :
47 : 0 : return ws;
48 : : }
49 : :
50 : : static int
51 : 0 : cn10k_sso_hws_link(void *arg, void *port, uint16_t *map, uint16_t nb_link, uint8_t profile)
52 : : {
53 : : struct cnxk_sso_evdev *dev = arg;
54 : : struct cn10k_sso_hws *ws = port;
55 : :
56 : 0 : return roc_sso_hws_link(&dev->sso, ws->hws_id, map, nb_link, profile, 0);
57 : : }
58 : :
59 : : static int
60 : 0 : cn10k_sso_hws_unlink(void *arg, void *port, uint16_t *map, uint16_t nb_link, uint8_t profile)
61 : : {
62 : : struct cnxk_sso_evdev *dev = arg;
63 : : struct cn10k_sso_hws *ws = port;
64 : :
65 : 0 : return roc_sso_hws_unlink(&dev->sso, ws->hws_id, map, nb_link, profile, 0);
66 : : }
67 : :
68 : : static void
69 : 0 : cn10k_sso_hws_setup(void *arg, void *hws, uintptr_t grp_base)
70 : : {
71 : : struct cnxk_sso_evdev *dev = arg;
72 : : struct cn10k_sso_hws *ws = hws;
73 : : uint64_t val;
74 : :
75 : 0 : ws->grp_base = grp_base;
76 : 0 : ws->fc_mem = (int64_t __rte_atomic *)dev->fc_iova;
77 : 0 : ws->xaq_lmt = dev->xaq_lmt;
78 : 0 : ws->fc_cache_space = (int64_t __rte_atomic *)dev->fc_cache_space;
79 [ # # ]: 0 : ws->aw_lmt = ws->lmt_base;
80 : 0 : ws->gw_wdata = cnxk_sso_hws_prf_wdata(dev);
81 : :
82 : : /* Set get_work timeout for HWS */
83 : 0 : val = NSEC2USEC(dev->deq_tmo_ns);
84 [ # # ]: 0 : val = val ? val - 1 : 0;
85 : 0 : plt_write64(val, ws->base + SSOW_LF_GWS_NW_TIM);
86 : 0 : }
87 : :
88 : : static void
89 : 0 : cn10k_sso_hws_release(void *arg, void *hws)
90 : : {
91 : : struct cnxk_sso_evdev *dev = arg;
92 : : struct cn10k_sso_hws *ws = hws;
93 : : uint16_t i, j;
94 : :
95 [ # # ]: 0 : for (i = 0; i < CNXK_SSO_MAX_PROFILES; i++)
96 [ # # ]: 0 : for (j = 0; j < dev->nb_event_queues; j++)
97 : 0 : roc_sso_hws_unlink(&dev->sso, ws->hws_id, &j, 1, i, 0);
98 : : memset(ws, 0, sizeof(*ws));
99 : 0 : }
100 : :
101 : : static int
102 : 0 : cn10k_sso_hws_flush_events(void *hws, uint8_t queue_id, uintptr_t base,
103 : : cnxk_handle_event_t fn, void *arg)
104 : : {
105 : : struct cnxk_sso_evdev *dev = cnxk_sso_pmd_priv(arg);
106 : : uint64_t retry = CNXK_SSO_FLUSH_RETRY_MAX;
107 : : struct cn10k_sso_hws *ws = hws;
108 : : uint64_t cq_ds_cnt = 1;
109 : : uint64_t aq_cnt = 1;
110 : : uint64_t ds_cnt = 1;
111 : : struct rte_event ev;
112 : : uint64_t val, req;
113 : :
114 : 0 : plt_write64(0, base + SSO_LF_GGRP_QCTL);
115 : :
116 : 0 : roc_sso_hws_gwc_invalidate(&dev->sso, &ws->hws_id, 1);
117 : 0 : plt_write64(0, ws->base + SSOW_LF_GWS_OP_GWC_INVAL);
118 : 0 : req = queue_id; /* GGRP ID */
119 : : req |= BIT_ULL(18); /* Grouped */
120 : 0 : req |= BIT_ULL(16); /* WAIT */
121 : :
122 : 0 : aq_cnt = plt_read64(base + SSO_LF_GGRP_AQ_CNT);
123 : 0 : ds_cnt = plt_read64(base + SSO_LF_GGRP_MISC_CNT);
124 : 0 : cq_ds_cnt = plt_read64(base + SSO_LF_GGRP_INT_CNT);
125 : 0 : cq_ds_cnt &= 0x3FFF3FFF0000;
126 : :
127 [ # # ]: 0 : while (aq_cnt || cq_ds_cnt || ds_cnt) {
128 : 0 : plt_write64(req, ws->base + SSOW_LF_GWS_OP_GET_WORK0);
129 : 0 : cn10k_sso_hws_get_work_empty(ws, &ev, dev->rx_offloads);
130 [ # # # # ]: 0 : if (fn != NULL && ev.u64 != 0)
131 : 0 : fn(arg, ev);
132 [ # # ]: 0 : if (ev.sched_type != SSO_TT_EMPTY)
133 : 0 : cnxk_sso_hws_swtag_flush(ws->base);
134 [ # # ]: 0 : else if (retry-- == 0)
135 : : break;
136 : : do {
137 [ # # ]: 0 : val = plt_read64(ws->base + SSOW_LF_GWS_PENDSTATE);
138 [ # # ]: 0 : } while (val & BIT_ULL(56));
139 : : aq_cnt = plt_read64(base + SSO_LF_GGRP_AQ_CNT);
140 : : ds_cnt = plt_read64(base + SSO_LF_GGRP_MISC_CNT);
141 : : cq_ds_cnt = plt_read64(base + SSO_LF_GGRP_INT_CNT);
142 : : /* Extract cq and ds count */
143 : 0 : cq_ds_cnt &= 0x3FFF3FFF0000;
144 : : }
145 : :
146 [ # # ]: 0 : if (aq_cnt || cq_ds_cnt || ds_cnt)
147 : : return -EAGAIN;
148 : :
149 : 0 : plt_write64(0, ws->base + SSOW_LF_GWS_OP_GWC_INVAL);
150 : 0 : roc_sso_hws_gwc_invalidate(&dev->sso, &ws->hws_id, 1);
151 : : rte_mb();
152 : :
153 : 0 : return 0;
154 : : }
155 : :
156 : : static void
157 : : cn10k_sso_set_rsrc(void *arg)
158 : : {
159 : : struct cnxk_sso_evdev *dev = arg;
160 : :
161 : 0 : dev->max_event_ports = dev->sso.max_hws;
162 : 0 : dev->max_event_queues =
163 : 0 : dev->sso.max_hwgrp > RTE_EVENT_MAX_QUEUES_PER_DEV ?
164 : 0 : RTE_EVENT_MAX_QUEUES_PER_DEV :
165 : : dev->sso.max_hwgrp;
166 : : }
167 : :
168 : : static int
169 : 0 : cn10k_sso_rsrc_init(void *arg, uint8_t hws, uint8_t hwgrp)
170 : : {
171 : : struct cnxk_tim_evdev *tim_dev = cnxk_tim_priv_get();
172 : : struct cnxk_sso_evdev *dev = arg;
173 : : uint16_t nb_tim_lfs;
174 : :
175 [ # # ]: 0 : nb_tim_lfs = tim_dev ? tim_dev->nb_rings : 0;
176 : 0 : return roc_sso_rsrc_init(&dev->sso, hws, hwgrp, nb_tim_lfs);
177 : : }
178 : :
179 : : static int
180 [ # # ]: 0 : cn10k_sso_updt_tx_adptr_data(const struct rte_eventdev *event_dev)
181 : : {
182 : : struct cnxk_sso_evdev *dev = cnxk_sso_pmd_priv(event_dev);
183 : : int i;
184 : :
185 [ # # ]: 0 : if (dev->tx_adptr_data == NULL)
186 : : return 0;
187 : :
188 [ # # ]: 0 : for (i = 0; i < dev->nb_event_ports; i++) {
189 : 0 : struct cn10k_sso_hws *ws = event_dev->data->ports[i];
190 : : void *ws_cookie;
191 : :
192 : : ws_cookie = cnxk_sso_hws_get_cookie(ws);
193 : 0 : ws_cookie = rte_realloc_socket(
194 : : ws_cookie,
195 : : sizeof(struct cnxk_sso_hws_cookie) +
196 : : sizeof(struct cn10k_sso_hws) +
197 : 0 : dev->tx_adptr_data_sz,
198 : : RTE_CACHE_LINE_SIZE, SOCKET_ID_ANY);
199 [ # # ]: 0 : if (ws_cookie == NULL)
200 : : return -ENOMEM;
201 : 0 : ws = RTE_PTR_ADD(ws_cookie, sizeof(struct cnxk_sso_hws_cookie));
202 : 0 : memcpy(&ws->tx_adptr_data, dev->tx_adptr_data,
203 : : dev->tx_adptr_data_sz);
204 : 0 : event_dev->data->ports[i] = ws;
205 : : }
206 : :
207 : : return 0;
208 : : }
209 : :
210 : : #if defined(RTE_ARCH_ARM64)
211 : : static inline void
212 : : cn10k_sso_fp_tmplt_fns_set(struct rte_eventdev *event_dev)
213 : : {
214 : : #if !defined(CNXK_DIS_TMPLT_FUNC)
215 : : struct cnxk_sso_evdev *dev = cnxk_sso_pmd_priv(event_dev);
216 : :
217 : : const event_dequeue_burst_t sso_hws_deq_burst[NIX_RX_OFFLOAD_MAX] = {
218 : : #define R(name, flags)[flags] = cn10k_sso_hws_deq_burst_##name,
219 : : NIX_RX_FASTPATH_MODES
220 : : #undef R
221 : : };
222 : :
223 : : const event_dequeue_burst_t sso_hws_deq_tmo_burst[NIX_RX_OFFLOAD_MAX] = {
224 : : #define R(name, flags)[flags] = cn10k_sso_hws_deq_tmo_burst_##name,
225 : : NIX_RX_FASTPATH_MODES
226 : : #undef R
227 : : };
228 : :
229 : : const event_dequeue_burst_t sso_hws_deq_seg_burst[NIX_RX_OFFLOAD_MAX] = {
230 : : #define R(name, flags)[flags] = cn10k_sso_hws_deq_seg_burst_##name,
231 : : NIX_RX_FASTPATH_MODES
232 : : #undef R
233 : : };
234 : :
235 : : const event_dequeue_burst_t sso_hws_deq_tmo_seg_burst[NIX_RX_OFFLOAD_MAX] = {
236 : : #define R(name, flags)[flags] = cn10k_sso_hws_deq_tmo_seg_burst_##name,
237 : : NIX_RX_FASTPATH_MODES
238 : : #undef R
239 : : };
240 : :
241 : : const event_dequeue_burst_t sso_hws_reas_deq_burst[NIX_RX_OFFLOAD_MAX] = {
242 : : #define R(name, flags)[flags] = cn10k_sso_hws_reas_deq_burst_##name,
243 : : NIX_RX_FASTPATH_MODES
244 : : #undef R
245 : : };
246 : :
247 : : const event_dequeue_burst_t sso_hws_reas_deq_tmo_burst[NIX_RX_OFFLOAD_MAX] = {
248 : : #define R(name, flags)[flags] = cn10k_sso_hws_reas_deq_tmo_burst_##name,
249 : : NIX_RX_FASTPATH_MODES
250 : : #undef R
251 : : };
252 : :
253 : : const event_dequeue_burst_t sso_hws_reas_deq_seg_burst[NIX_RX_OFFLOAD_MAX] = {
254 : : #define R(name, flags)[flags] = cn10k_sso_hws_reas_deq_seg_burst_##name,
255 : : NIX_RX_FASTPATH_MODES
256 : : #undef R
257 : : };
258 : :
259 : : const event_dequeue_burst_t sso_hws_reas_deq_tmo_seg_burst[NIX_RX_OFFLOAD_MAX] = {
260 : : #define R(name, flags)[flags] = cn10k_sso_hws_reas_deq_tmo_seg_burst_##name,
261 : : NIX_RX_FASTPATH_MODES
262 : : #undef R
263 : : };
264 : :
265 : : /* Tx modes */
266 : : const event_tx_adapter_enqueue_t sso_hws_tx_adptr_enq[NIX_TX_OFFLOAD_MAX] = {
267 : : #define T(name, sz, flags)[flags] = cn10k_sso_hws_tx_adptr_enq_##name,
268 : : NIX_TX_FASTPATH_MODES
269 : : #undef T
270 : : };
271 : :
272 : : const event_tx_adapter_enqueue_t sso_hws_tx_adptr_enq_seg[NIX_TX_OFFLOAD_MAX] = {
273 : : #define T(name, sz, flags)[flags] = cn10k_sso_hws_tx_adptr_enq_seg_##name,
274 : : NIX_TX_FASTPATH_MODES
275 : : #undef T
276 : : };
277 : :
278 : : if (dev->rx_offloads & NIX_RX_MULTI_SEG_F) {
279 : : if (dev->rx_offloads & NIX_RX_REAS_F) {
280 : : CN10K_SET_EVDEV_DEQ_OP(dev, event_dev->dequeue_burst,
281 : : sso_hws_reas_deq_seg_burst);
282 : : if (dev->is_timeout_deq)
283 : : CN10K_SET_EVDEV_DEQ_OP(dev, event_dev->dequeue_burst,
284 : : sso_hws_reas_deq_tmo_seg_burst);
285 : : } else {
286 : : CN10K_SET_EVDEV_DEQ_OP(dev, event_dev->dequeue_burst,
287 : : sso_hws_deq_seg_burst);
288 : :
289 : : if (dev->is_timeout_deq)
290 : : CN10K_SET_EVDEV_DEQ_OP(dev, event_dev->dequeue_burst,
291 : : sso_hws_deq_tmo_seg_burst);
292 : : }
293 : : } else {
294 : : if (dev->rx_offloads & NIX_RX_REAS_F) {
295 : : CN10K_SET_EVDEV_DEQ_OP(dev, event_dev->dequeue_burst,
296 : : sso_hws_reas_deq_burst);
297 : :
298 : : if (dev->is_timeout_deq)
299 : : CN10K_SET_EVDEV_DEQ_OP(dev, event_dev->dequeue_burst,
300 : : sso_hws_reas_deq_tmo_burst);
301 : : } else {
302 : : CN10K_SET_EVDEV_DEQ_OP(dev, event_dev->dequeue_burst, sso_hws_deq_burst);
303 : :
304 : : if (dev->is_timeout_deq)
305 : : CN10K_SET_EVDEV_DEQ_OP(dev, event_dev->dequeue_burst,
306 : : sso_hws_deq_tmo_burst);
307 : : }
308 : : }
309 : :
310 : : if (dev->tx_offloads & NIX_TX_MULTI_SEG_F)
311 : : CN10K_SET_EVDEV_ENQ_OP(dev, event_dev->txa_enqueue, sso_hws_tx_adptr_enq_seg);
312 : : else
313 : : CN10K_SET_EVDEV_ENQ_OP(dev, event_dev->txa_enqueue, sso_hws_tx_adptr_enq);
314 : :
315 : : event_dev->txa_enqueue_same_dest = event_dev->txa_enqueue;
316 : : #else
317 : : RTE_SET_USED(event_dev);
318 : : #endif
319 : : }
320 : :
321 : : static inline void
322 : : cn10k_sso_fp_blk_fns_set(struct rte_eventdev *event_dev)
323 : : {
324 : : #if defined(CNXK_DIS_TMPLT_FUNC)
325 : : struct cnxk_sso_evdev *dev = cnxk_sso_pmd_priv(event_dev);
326 : :
327 : : event_dev->dequeue_burst = cn10k_sso_hws_deq_burst_all_offload;
328 : : if (dev->rx_offloads & NIX_RX_OFFLOAD_TSTAMP_F)
329 : : event_dev->dequeue_burst = cn10k_sso_hws_deq_burst_all_offload_tst;
330 : : event_dev->txa_enqueue = cn10k_sso_hws_tx_adptr_enq_seg_all_offload;
331 : : event_dev->txa_enqueue_same_dest = cn10k_sso_hws_tx_adptr_enq_seg_all_offload;
332 : : if (dev->tx_offloads & (NIX_TX_OFFLOAD_OL3_OL4_CSUM_F | NIX_TX_OFFLOAD_VLAN_QINQ_F |
333 : : NIX_TX_OFFLOAD_TSO_F | NIX_TX_OFFLOAD_TSTAMP_F)) {
334 : : event_dev->txa_enqueue = cn10k_sso_hws_tx_adptr_enq_seg_all_offload_tst;
335 : : event_dev->txa_enqueue_same_dest = cn10k_sso_hws_tx_adptr_enq_seg_all_offload_tst;
336 : : }
337 : : #else
338 : : RTE_SET_USED(event_dev);
339 : : #endif
340 : : }
341 : : #endif
342 : :
343 : : static void
344 : : cn10k_sso_fp_fns_set(struct rte_eventdev *event_dev)
345 : : {
346 : : #if defined(RTE_ARCH_ARM64)
347 : : struct roc_cpt *cpt = roc_idev_cpt_get();
348 : :
349 : : cn10k_sso_fp_blk_fns_set(event_dev);
350 : : cn10k_sso_fp_tmplt_fns_set(event_dev);
351 : :
352 : : event_dev->enqueue_burst = cn10k_sso_hws_enq_burst;
353 : : event_dev->enqueue_new_burst = cn10k_sso_hws_enq_new_burst;
354 : : event_dev->enqueue_forward_burst = cn10k_sso_hws_enq_fwd_burst;
355 : :
356 : : if ((cpt != NULL) && cpt->hw_caps[CPT_ENG_TYPE_SE].sg_ver2 &&
357 : : cpt->hw_caps[CPT_ENG_TYPE_IE].sg_ver2)
358 : : event_dev->ca_enqueue = cn10k_cpt_sg_ver2_crypto_adapter_enqueue;
359 : : else
360 : : event_dev->ca_enqueue = cn10k_cpt_sg_ver1_crypto_adapter_enqueue;
361 : :
362 : : event_dev->dma_enqueue = cn10k_dma_adapter_enqueue;
363 : : event_dev->profile_switch = cn10k_sso_hws_profile_switch;
364 : : event_dev->preschedule_modify = cn10k_sso_hws_preschedule_modify;
365 : : #else
366 : : RTE_SET_USED(event_dev);
367 : : #endif
368 : : }
369 : :
370 : : static void
371 : 0 : cn10k_sso_info_get(struct rte_eventdev *event_dev,
372 : : struct rte_event_dev_info *dev_info)
373 : : {
374 : : struct cnxk_sso_evdev *dev = cnxk_sso_pmd_priv(event_dev);
375 : :
376 : 0 : dev_info->driver_name = RTE_STR(EVENTDEV_NAME_CN10K_PMD);
377 : 0 : cnxk_sso_info_get(dev, dev_info);
378 : 0 : dev_info->max_event_port_enqueue_depth = UINT32_MAX;
379 : 0 : dev_info->event_dev_cap |= RTE_EVENT_DEV_CAP_EVENT_PRESCHEDULE |
380 : : RTE_EVENT_DEV_CAP_EVENT_PRESCHEDULE_ADAPTIVE |
381 : : RTE_EVENT_DEV_CAP_PER_PORT_PRESCHEDULE;
382 : 0 : }
383 : :
384 : : static int
385 : 0 : cn10k_sso_dev_configure(const struct rte_eventdev *event_dev)
386 : : {
387 : : struct cnxk_sso_evdev *dev = cnxk_sso_pmd_priv(event_dev);
388 : : int rc;
389 : :
390 : 0 : rc = cnxk_sso_dev_validate(event_dev, 1, UINT32_MAX);
391 [ # # ]: 0 : if (rc < 0) {
392 : 0 : plt_err("Invalid event device configuration");
393 : 0 : return -EINVAL;
394 : : }
395 : :
396 : 0 : rc = cn10k_sso_rsrc_init(dev, dev->nb_event_ports,
397 : 0 : dev->nb_event_queues);
398 [ # # ]: 0 : if (rc < 0) {
399 : 0 : plt_err("Failed to initialize SSO resources");
400 : 0 : return -ENODEV;
401 : : }
402 : :
403 : 0 : rc = cnxk_sso_xaq_allocate(dev);
404 [ # # ]: 0 : if (rc < 0)
405 : 0 : goto cnxk_rsrc_fini;
406 : :
407 [ # # # ]: 0 : dev->gw_mode = cnxk_sso_hws_preschedule_get(event_dev->data->dev_conf.preschedule_type);
408 : :
409 : 0 : rc = cnxk_setup_event_ports(event_dev, cn10k_sso_init_hws_mem,
410 : : cn10k_sso_hws_setup);
411 [ # # ]: 0 : if (rc < 0)
412 : 0 : goto cnxk_rsrc_fini;
413 : :
414 : : /* Restore any prior port-queue mapping. */
415 : 0 : cnxk_sso_restore_links(event_dev, cn10k_sso_hws_link);
416 : :
417 : 0 : dev->configured = 1;
418 : : rte_mb();
419 : :
420 : 0 : return 0;
421 : 0 : cnxk_rsrc_fini:
422 : 0 : roc_sso_rsrc_fini(&dev->sso);
423 : 0 : dev->nb_event_ports = 0;
424 : 0 : return rc;
425 : : }
426 : :
427 : : static int
428 : 0 : cn10k_sso_port_setup(struct rte_eventdev *event_dev, uint8_t port_id,
429 : : const struct rte_event_port_conf *port_conf)
430 : : {
431 : :
432 : : RTE_SET_USED(port_conf);
433 : 0 : return cnxk_sso_port_setup(event_dev, port_id, cn10k_sso_hws_setup);
434 : : }
435 : :
436 : : static void
437 [ # # ]: 0 : cn10k_sso_port_release(void *port)
438 : : {
439 : : struct cnxk_sso_hws_cookie *gws_cookie = cnxk_sso_hws_get_cookie(port);
440 : : struct cnxk_sso_evdev *dev;
441 : :
442 [ # # ]: 0 : if (port == NULL)
443 : : return;
444 : :
445 [ # # ]: 0 : dev = cnxk_sso_pmd_priv(gws_cookie->event_dev);
446 [ # # ]: 0 : if (!gws_cookie->configured)
447 : 0 : goto free;
448 : :
449 : 0 : cn10k_sso_hws_release(dev, port);
450 : : memset(gws_cookie, 0, sizeof(*gws_cookie));
451 : 0 : free:
452 : 0 : rte_free(gws_cookie);
453 : : }
454 : :
455 : : static void
456 [ # # ]: 0 : cn10k_sso_port_quiesce(struct rte_eventdev *event_dev, void *port,
457 : : rte_eventdev_port_flush_t flush_cb, void *args)
458 : : {
459 : : struct cnxk_sso_evdev *dev = cnxk_sso_pmd_priv(event_dev);
460 : : struct cn10k_sso_hws *ws = port;
461 : : struct rte_event ev;
462 : : uint64_t ptag;
463 : : bool is_pend;
464 : :
465 : : is_pend = false;
466 : : /* Work in WQE0 is always consumed, unless its a SWTAG. */
467 [ # # ]: 0 : ptag = plt_read64(ws->base + SSOW_LF_GWS_PENDSTATE);
468 [ # # # # ]: 0 : if (ptag & (BIT_ULL(62) | BIT_ULL(54)) || ws->swtag_req)
469 : : is_pend = true;
470 : : do {
471 : : ptag = plt_read64(ws->base + SSOW_LF_GWS_PENDSTATE);
472 [ # # ]: 0 : } while (ptag &
473 : : (BIT_ULL(62) | BIT_ULL(58) | BIT_ULL(56) | BIT_ULL(54)));
474 : :
475 : 0 : cn10k_sso_hws_get_work_empty(ws, &ev, dev->rx_offloads);
476 [ # # # # ]: 0 : if (is_pend && ev.u64)
477 [ # # ]: 0 : if (flush_cb)
478 : 0 : flush_cb(event_dev->data->dev_id, ev, args);
479 [ # # ]: 0 : ptag = (plt_read64(ws->base + SSOW_LF_GWS_TAG) >> 32) & SSO_TT_EMPTY;
480 [ # # ]: 0 : if (ptag != SSO_TT_EMPTY)
481 : : cnxk_sso_hws_swtag_flush(ws->base);
482 : :
483 : : do {
484 [ # # ]: 0 : ptag = plt_read64(ws->base + SSOW_LF_GWS_PENDSTATE);
485 [ # # ]: 0 : } while (ptag & BIT_ULL(56));
486 : :
487 : : /* Check if we have work in PRF_WQE0, if so extract it. */
488 [ # # ]: 0 : switch (dev->gw_mode) {
489 : : case CNXK_GW_MODE_PREF:
490 : : case CNXK_GW_MODE_PREF_WFE:
491 [ # # ]: 0 : while (plt_read64(ws->base + SSOW_LF_GWS_PRF_WQE0) &
492 : : BIT_ULL(63))
493 : : ;
494 : : break;
495 : : case CNXK_GW_MODE_NONE:
496 : : default:
497 : : break;
498 : : }
499 : :
500 [ # # ]: 0 : if (CNXK_TT_FROM_TAG(plt_read64(ws->base + SSOW_LF_GWS_PRF_WQE0)) !=
501 : : SSO_TT_EMPTY) {
502 : 0 : plt_write64(BIT_ULL(16) | 1,
503 : : ws->base + SSOW_LF_GWS_OP_GET_WORK0);
504 : 0 : cn10k_sso_hws_get_work_empty(ws, &ev, dev->rx_offloads);
505 [ # # ]: 0 : if (ev.u64) {
506 [ # # ]: 0 : if (flush_cb)
507 : 0 : flush_cb(event_dev->data->dev_id, ev, args);
508 : : }
509 : 0 : cnxk_sso_hws_swtag_flush(ws->base);
510 : : do {
511 [ # # ]: 0 : ptag = plt_read64(ws->base + SSOW_LF_GWS_PENDSTATE);
512 [ # # ]: 0 : } while (ptag & BIT_ULL(56));
513 : : }
514 : 0 : ws->swtag_req = 0;
515 : 0 : plt_write64(0, ws->base + SSOW_LF_GWS_OP_GWC_INVAL);
516 : 0 : }
517 : :
518 : : static int
519 : 0 : cn10k_sso_port_link_profile(struct rte_eventdev *event_dev, void *port, const uint8_t queues[],
520 : : const uint8_t priorities[], uint16_t nb_links, uint8_t profile)
521 : 0 : {
522 : : struct cnxk_sso_evdev *dev = cnxk_sso_pmd_priv(event_dev);
523 : 0 : uint16_t hwgrp_ids[nb_links];
524 : : uint16_t link;
525 : :
526 : : RTE_SET_USED(priorities);
527 [ # # ]: 0 : for (link = 0; link < nb_links; link++)
528 : 0 : hwgrp_ids[link] = queues[link];
529 : 0 : nb_links = cn10k_sso_hws_link(dev, port, hwgrp_ids, nb_links, profile);
530 : :
531 : 0 : return (int)nb_links;
532 : : }
533 : :
534 : : static int
535 : 0 : cn10k_sso_port_unlink_profile(struct rte_eventdev *event_dev, void *port, uint8_t queues[],
536 : : uint16_t nb_unlinks, uint8_t profile)
537 : 0 : {
538 : : struct cnxk_sso_evdev *dev = cnxk_sso_pmd_priv(event_dev);
539 : 0 : uint16_t hwgrp_ids[nb_unlinks];
540 : : uint16_t unlink;
541 : :
542 [ # # ]: 0 : for (unlink = 0; unlink < nb_unlinks; unlink++)
543 : 0 : hwgrp_ids[unlink] = queues[unlink];
544 : 0 : nb_unlinks = cn10k_sso_hws_unlink(dev, port, hwgrp_ids, nb_unlinks, profile);
545 : :
546 : 0 : return (int)nb_unlinks;
547 : : }
548 : :
549 : : static int
550 : 0 : cn10k_sso_port_link(struct rte_eventdev *event_dev, void *port, const uint8_t queues[],
551 : : const uint8_t priorities[], uint16_t nb_links)
552 : : {
553 : 0 : return cn10k_sso_port_link_profile(event_dev, port, queues, priorities, nb_links, 0);
554 : : }
555 : :
556 : : static int
557 : 0 : cn10k_sso_port_unlink(struct rte_eventdev *event_dev, void *port, uint8_t queues[],
558 : : uint16_t nb_unlinks)
559 : : {
560 : 0 : return cn10k_sso_port_unlink_profile(event_dev, port, queues, nb_unlinks, 0);
561 : : }
562 : :
563 : : static int
564 : 0 : cn10k_sso_start(struct rte_eventdev *event_dev)
565 : : {
566 : : struct cnxk_sso_evdev *dev = cnxk_sso_pmd_priv(event_dev);
567 : : uint8_t hws[RTE_EVENT_MAX_PORTS_PER_DEV];
568 : : int rc, i;
569 : :
570 : 0 : rc = cn10k_sso_updt_tx_adptr_data(event_dev);
571 [ # # ]: 0 : if (rc < 0)
572 : : return rc;
573 : :
574 : 0 : cnxk_sso_configure_queue_stash(event_dev);
575 : 0 : rc = cnxk_sso_start(event_dev, cnxk_sso_hws_reset, cn10k_sso_hws_flush_events);
576 [ # # ]: 0 : if (rc < 0)
577 : : return rc;
578 : : cn10k_sso_fp_fns_set(event_dev);
579 [ # # ]: 0 : for (i = 0; i < event_dev->data->nb_ports; i++)
580 : 0 : hws[i] = i;
581 : 0 : roc_sso_hws_gwc_invalidate(&dev->sso, hws, event_dev->data->nb_ports);
582 : :
583 : 0 : return rc;
584 : : }
585 : :
586 : : static void
587 : 0 : cn10k_sso_stop(struct rte_eventdev *event_dev)
588 : : {
589 : : struct cnxk_sso_evdev *dev = cnxk_sso_pmd_priv(event_dev);
590 : : uint8_t hws[RTE_EVENT_MAX_PORTS_PER_DEV];
591 : : int i;
592 : :
593 [ # # ]: 0 : for (i = 0; i < event_dev->data->nb_ports; i++)
594 : 0 : hws[i] = i;
595 : 0 : roc_sso_hws_gwc_invalidate(&dev->sso, hws, event_dev->data->nb_ports);
596 : 0 : cnxk_sso_stop(event_dev, cnxk_sso_hws_reset, cn10k_sso_hws_flush_events);
597 : 0 : }
598 : :
599 : : static int
600 : 0 : cn10k_sso_close(struct rte_eventdev *event_dev)
601 : : {
602 : 0 : return cnxk_sso_close(event_dev, cn10k_sso_hws_unlink);
603 : : }
604 : :
605 : : static int
606 : 0 : cn10k_sso_selftest(void)
607 : : {
608 : 0 : return cnxk_sso_selftest(RTE_STR(event_cn10k));
609 : : }
610 : :
611 : : static int
612 : 0 : cn10k_sso_rx_adapter_caps_get(const struct rte_eventdev *event_dev,
613 : : const struct rte_eth_dev *eth_dev, uint32_t *caps)
614 : : {
615 : : int rc;
616 : :
617 : : RTE_SET_USED(event_dev);
618 : 0 : rc = strncmp(eth_dev->device->driver->name, "net_cn10k", 9);
619 [ # # ]: 0 : if (rc)
620 : 0 : *caps = RTE_EVENT_ETH_RX_ADAPTER_SW_CAP;
621 : : else
622 : 0 : *caps = RTE_EVENT_ETH_RX_ADAPTER_CAP_INTERNAL_PORT |
623 : : RTE_EVENT_ETH_RX_ADAPTER_CAP_MULTI_EVENTQ |
624 : : RTE_EVENT_ETH_RX_ADAPTER_CAP_OVERRIDE_FLOW_ID |
625 : : RTE_EVENT_ETH_RX_ADAPTER_CAP_EVENT_VECTOR;
626 : :
627 : 0 : return 0;
628 : : }
629 : :
630 : : static void
631 : 0 : cn10k_sso_set_priv_mem(const struct rte_eventdev *event_dev, void *lookup_mem)
632 : : {
633 : : struct cnxk_sso_evdev *dev = cnxk_sso_pmd_priv(event_dev);
634 : : int i;
635 : :
636 [ # # # # : 0 : for (i = 0; i < dev->nb_event_ports; i++) {
# # # # #
# ]
637 : 0 : struct cn10k_sso_hws *ws = event_dev->data->ports[i];
638 : 0 : ws->xaq_lmt = dev->xaq_lmt;
639 : 0 : ws->fc_mem = (int64_t __rte_atomic *)dev->fc_iova;
640 : 0 : ws->tstamp = dev->tstamp;
641 [ # # # # : 0 : if (lookup_mem)
# # ]
642 : 0 : ws->lookup_mem = lookup_mem;
643 : : }
644 : 0 : }
645 : :
646 : : static void
647 : : eventdev_fops_update(struct rte_eventdev *event_dev)
648 : : {
649 : 0 : struct rte_event_fp_ops *fp_op =
650 : 0 : rte_event_fp_ops + event_dev->data->dev_id;
651 : :
652 : 0 : fp_op->dequeue_burst = event_dev->dequeue_burst;
653 : : }
654 : :
655 : : static void
656 : 0 : cn10k_sso_tstamp_hdl_update(uint16_t port_id, uint16_t flags, bool ptp_en)
657 : : {
658 : 0 : struct rte_eth_dev *dev = &rte_eth_devices[port_id];
659 : 0 : struct cnxk_eth_dev *cnxk_eth_dev = dev->data->dev_private;
660 [ # # ]: 0 : struct rte_eventdev *event_dev = cnxk_eth_dev->evdev_priv;
661 : : struct cnxk_sso_evdev *evdev = cnxk_sso_pmd_priv(event_dev);
662 : :
663 : 0 : evdev->rx_offloads |= flags;
664 [ # # ]: 0 : if (ptp_en)
665 : 0 : evdev->tstamp[port_id] = &cnxk_eth_dev->tstamp;
666 : : else
667 : 0 : evdev->tstamp[port_id] = NULL;
668 : : cn10k_sso_fp_fns_set((struct rte_eventdev *)(uintptr_t)event_dev);
669 : : eventdev_fops_update(event_dev);
670 : 0 : }
671 : :
672 : : static void
673 : 0 : cn10k_sso_rx_offload_cb(uint16_t port_id, uint64_t flags)
674 : : {
675 : 0 : struct rte_eth_dev *dev = &rte_eth_devices[port_id];
676 : 0 : struct cnxk_eth_dev *cnxk_eth_dev = dev->data->dev_private;
677 : 0 : struct rte_eventdev *event_dev = cnxk_eth_dev->evdev_priv;
678 : : struct cnxk_sso_evdev *evdev = cnxk_sso_pmd_priv(event_dev);
679 : :
680 : 0 : evdev->rx_offloads |= flags;
681 : : cn10k_sso_fp_fns_set((struct rte_eventdev *)(uintptr_t)event_dev);
682 : : eventdev_fops_update(event_dev);
683 : 0 : }
684 : :
685 : : static int
686 : 0 : cn10k_sso_configure_queue_stash_default(struct cnxk_sso_evdev *dev, uint16_t hwgrp)
687 : : {
688 : : struct roc_sso_hwgrp_stash stash;
689 : : int rc;
690 : :
691 : 0 : stash.hwgrp = hwgrp;
692 : 0 : stash.stash_offset = CN10K_SSO_DEFAULT_STASH_OFFSET;
693 : 0 : stash.stash_count = CN10K_SSO_DEFAULT_STASH_LENGTH;
694 : 0 : rc = roc_sso_hwgrp_stash_config(&dev->sso, &stash, 1);
695 [ # # ]: 0 : if (rc)
696 : 0 : plt_warn("failed to configure HWGRP WQE stashing rc = %d", rc);
697 : :
698 : 0 : return rc;
699 : : }
700 : :
701 : : static int
702 : 0 : cn10k_sso_rx_adapter_queue_add(
703 : : const struct rte_eventdev *event_dev, const struct rte_eth_dev *eth_dev,
704 : : int32_t rx_queue_id,
705 : : const struct rte_event_eth_rx_adapter_queue_conf *queue_conf)
706 : : {
707 [ # # ]: 0 : struct cnxk_eth_dev *cnxk_eth_dev = eth_dev->data->dev_private;
708 : : struct cnxk_sso_evdev *dev = cnxk_sso_pmd_priv(event_dev);
709 : : struct cn10k_eth_rxq *rxq;
710 : : uint16_t nb_rx_queues;
711 : : void *lookup_mem;
712 : : int rc;
713 : :
714 : 0 : rc = strncmp(eth_dev->device->driver->name, "net_cn10k", 8);
715 [ # # ]: 0 : if (rc)
716 : : return -EINVAL;
717 : :
718 : 0 : nb_rx_queues = rx_queue_id == -1 ? 0 : 1;
719 : 0 : rc = cnxk_sso_rx_adapter_queues_add(event_dev, eth_dev, &rx_queue_id, queue_conf,
720 : : nb_rx_queues);
721 [ # # ]: 0 : if (rc)
722 : : return -EINVAL;
723 : :
724 : 0 : cnxk_eth_dev->cnxk_sso_ptp_tstamp_cb = cn10k_sso_tstamp_hdl_update;
725 : 0 : cnxk_eth_dev->evdev_priv = (struct rte_eventdev *)(uintptr_t)event_dev;
726 : :
727 : 0 : rxq = eth_dev->data->rx_queues[0];
728 : 0 : lookup_mem = rxq->lookup_mem;
729 : : cn10k_sso_set_priv_mem(event_dev, lookup_mem);
730 : : cn10k_sso_fp_fns_set((struct rte_eventdev *)(uintptr_t)event_dev);
731 [ # # # # ]: 0 : if (roc_feature_sso_has_stash() && dev->nb_event_ports > 1)
732 : 0 : rc = cn10k_sso_configure_queue_stash_default(dev, queue_conf->ev.queue_id);
733 : :
734 : : return rc;
735 : : }
736 : : static int
737 : 0 : cn10k_sso_rx_adapter_queues_add(const struct rte_eventdev *event_dev,
738 : : const struct rte_eth_dev *eth_dev, int32_t rx_queue_id[],
739 : : const struct rte_event_eth_rx_adapter_queue_conf queue_conf[],
740 : : uint16_t nb_rx_queues)
741 : : {
742 [ # # ]: 0 : struct cnxk_eth_dev *cnxk_eth_dev = eth_dev->data->dev_private;
743 : : struct cnxk_sso_evdev *dev = cnxk_sso_pmd_priv(event_dev);
744 : : struct cn10k_eth_rxq *rxq;
745 : : void *lookup_mem;
746 : : int rc, i;
747 : :
748 : 0 : rc = strncmp(eth_dev->device->driver->name, "net_cn10k", 8);
749 [ # # ]: 0 : if (rc)
750 : : return -EINVAL;
751 : :
752 : 0 : rc = cnxk_sso_rx_adapter_queues_add(event_dev, eth_dev, rx_queue_id, queue_conf,
753 : : nb_rx_queues);
754 [ # # ]: 0 : if (rc)
755 : : return -EINVAL;
756 : :
757 : 0 : cnxk_eth_dev->cnxk_sso_ptp_tstamp_cb = cn10k_sso_tstamp_hdl_update;
758 : 0 : cnxk_eth_dev->evdev_priv = (struct rte_eventdev *)(uintptr_t)event_dev;
759 : :
760 : 0 : rxq = eth_dev->data->rx_queues[0];
761 : 0 : lookup_mem = rxq->lookup_mem;
762 : : cn10k_sso_set_priv_mem(event_dev, lookup_mem);
763 : : cn10k_sso_fp_fns_set((struct rte_eventdev *)(uintptr_t)event_dev);
764 [ # # # # ]: 0 : if (roc_feature_sso_has_stash() && dev->nb_event_ports > 1) {
765 : 0 : uint16_t hwgrp = dev->sso.max_hwgrp;
766 : :
767 [ # # ]: 0 : if (nb_rx_queues == 0)
768 : 0 : rc = cn10k_sso_configure_queue_stash_default(dev,
769 : 0 : queue_conf[0].ev.queue_id);
770 : :
771 [ # # ]: 0 : for (i = 0; i < nb_rx_queues; i++) {
772 [ # # ]: 0 : if (hwgrp == queue_conf[i].ev.queue_id)
773 : 0 : continue;
774 : :
775 : : hwgrp = queue_conf[i].ev.queue_id;
776 : 0 : rc = cn10k_sso_configure_queue_stash_default(dev, hwgrp);
777 [ # # ]: 0 : if (rc < 0)
778 : : break;
779 : : }
780 : : }
781 : :
782 : : return rc;
783 : : }
784 : :
785 : : static int
786 : 0 : cn10k_sso_rx_adapter_queue_del(const struct rte_eventdev *event_dev,
787 : : const struct rte_eth_dev *eth_dev,
788 : : int32_t rx_queue_id)
789 : : {
790 : : int rc;
791 : :
792 : 0 : rc = strncmp(eth_dev->device->driver->name, "net_cn10k", 8);
793 [ # # ]: 0 : if (rc)
794 : : return -EINVAL;
795 : :
796 : 0 : return cnxk_sso_rx_adapter_queue_del(event_dev, eth_dev, rx_queue_id);
797 : : }
798 : :
799 : : static int
800 : 0 : cn10k_sso_rx_adapter_vector_limits(
801 : : const struct rte_eventdev *dev, const struct rte_eth_dev *eth_dev,
802 : : struct rte_event_eth_rx_adapter_vector_limits *limits)
803 : : {
804 : : struct cnxk_eth_dev *cnxk_eth_dev;
805 : : int ret;
806 : :
807 : : RTE_SET_USED(dev);
808 : 0 : ret = strncmp(eth_dev->device->driver->name, "net_cn10k", 8);
809 [ # # ]: 0 : if (ret)
810 : : return -ENOTSUP;
811 : :
812 : : cnxk_eth_dev = cnxk_eth_pmd_priv(eth_dev);
813 : 0 : limits->log2_sz = true;
814 : 0 : limits->min_sz = 1 << ROC_NIX_VWQE_MIN_SIZE_LOG2;
815 : 0 : limits->max_sz = 1 << ROC_NIX_VWQE_MAX_SIZE_LOG2;
816 : 0 : limits->min_timeout_ns =
817 : 0 : (roc_nix_get_vwqe_interval(&cnxk_eth_dev->nix) + 1) * 100;
818 : 0 : limits->max_timeout_ns = BITMASK_ULL(8, 0) * limits->min_timeout_ns;
819 : :
820 : 0 : return 0;
821 : : }
822 : :
823 : : static int
824 : 0 : cn10k_sso_tx_adapter_caps_get(const struct rte_eventdev *dev,
825 : : const struct rte_eth_dev *eth_dev, uint32_t *caps)
826 : : {
827 : : int ret;
828 : :
829 : : RTE_SET_USED(dev);
830 : 0 : ret = strncmp(eth_dev->device->driver->name, "net_cn10k", 8);
831 [ # # ]: 0 : if (ret)
832 : 0 : *caps = 0;
833 : : else
834 : 0 : *caps = RTE_EVENT_ETH_TX_ADAPTER_CAP_INTERNAL_PORT |
835 : : RTE_EVENT_ETH_TX_ADAPTER_CAP_EVENT_VECTOR;
836 : :
837 : 0 : return 0;
838 : : }
839 : :
840 : : static void
841 : 0 : cn10k_sso_txq_fc_update(const struct rte_eth_dev *eth_dev, int32_t tx_queue_id)
842 : : {
843 : 0 : struct cnxk_eth_dev *cnxk_eth_dev = eth_dev->data->dev_private;
844 : : struct cn10k_eth_txq *txq;
845 : : struct roc_nix_sq *sq;
846 : : int i;
847 : :
848 [ # # ]: 0 : if (tx_queue_id < 0) {
849 [ # # ]: 0 : for (i = 0; i < eth_dev->data->nb_tx_queues; i++)
850 : 0 : cn10k_sso_txq_fc_update(eth_dev, i);
851 : : } else {
852 : : uint16_t sqes_per_sqb;
853 : :
854 : 0 : sq = &cnxk_eth_dev->sqs[tx_queue_id];
855 : 0 : txq = eth_dev->data->tx_queues[tx_queue_id];
856 : 0 : sqes_per_sqb = 1U << txq->sqes_per_sqb_log2;
857 [ # # ]: 0 : if (cnxk_eth_dev->tx_offloads & RTE_ETH_TX_OFFLOAD_SECURITY)
858 : 0 : sq->nb_sqb_bufs_adj -= (cnxk_eth_dev->outb.nb_desc / sqes_per_sqb);
859 : 0 : txq->nb_sqb_bufs_adj = sq->nb_sqb_bufs_adj;
860 : : }
861 : 0 : }
862 : :
863 : : static int
864 : 0 : cn10k_sso_tx_adapter_queue_add(uint8_t id, const struct rte_eventdev *event_dev,
865 : : const struct rte_eth_dev *eth_dev,
866 : : int32_t tx_queue_id)
867 : : {
868 : 0 : struct cnxk_eth_dev *cnxk_eth_dev = eth_dev->data->dev_private;
869 : : struct cnxk_sso_evdev *dev = cnxk_sso_pmd_priv(event_dev);
870 : : uint64_t tx_offloads;
871 : : int rc;
872 : :
873 : : RTE_SET_USED(id);
874 : 0 : rc = cnxk_sso_tx_adapter_queue_add(event_dev, eth_dev, tx_queue_id);
875 [ # # ]: 0 : if (rc < 0)
876 : : return rc;
877 : :
878 : : /* Can't enable tstamp if all the ports don't have it enabled. */
879 : 0 : tx_offloads = cnxk_eth_dev->tx_offload_flags;
880 [ # # ]: 0 : if (dev->tx_adptr_configured) {
881 : 0 : uint8_t tstmp_req = !!(tx_offloads & NIX_TX_OFFLOAD_TSTAMP_F);
882 : : uint8_t tstmp_ena =
883 : 0 : !!(dev->tx_offloads & NIX_TX_OFFLOAD_TSTAMP_F);
884 : :
885 [ # # ]: 0 : if (tstmp_ena && !tstmp_req)
886 : 0 : dev->tx_offloads &= ~(NIX_TX_OFFLOAD_TSTAMP_F);
887 [ # # ]: 0 : else if (!tstmp_ena && tstmp_req)
888 : 0 : tx_offloads &= ~(NIX_TX_OFFLOAD_TSTAMP_F);
889 : : }
890 : :
891 : 0 : dev->tx_offloads |= tx_offloads;
892 : 0 : cn10k_sso_txq_fc_update(eth_dev, tx_queue_id);
893 : 0 : rc = cn10k_sso_updt_tx_adptr_data(event_dev);
894 [ # # ]: 0 : if (rc < 0)
895 : : return rc;
896 : : cn10k_sso_fp_fns_set((struct rte_eventdev *)(uintptr_t)event_dev);
897 : 0 : dev->tx_adptr_configured = 1;
898 : :
899 : 0 : return 0;
900 : : }
901 : :
902 : : static int
903 : 0 : cn10k_sso_tx_adapter_queue_del(uint8_t id, const struct rte_eventdev *event_dev,
904 : : const struct rte_eth_dev *eth_dev,
905 : : int32_t tx_queue_id)
906 : : {
907 : : int rc;
908 : :
909 : : RTE_SET_USED(id);
910 : 0 : rc = cnxk_sso_tx_adapter_queue_del(event_dev, eth_dev, tx_queue_id);
911 [ # # ]: 0 : if (rc < 0)
912 : : return rc;
913 : 0 : return cn10k_sso_updt_tx_adptr_data(event_dev);
914 : : }
915 : :
916 : : static int
917 : 0 : cn10k_crypto_adapter_caps_get(const struct rte_eventdev *event_dev,
918 : : const struct rte_cryptodev *cdev, uint32_t *caps)
919 : : {
920 [ # # ]: 0 : CNXK_VALID_DEV_OR_ERR_RET(event_dev->dev, "event_cn10k", ENOTSUP);
921 [ # # ]: 0 : CNXK_VALID_DEV_OR_ERR_RET(cdev->device, "crypto_cn10k", ENOTSUP);
922 : :
923 : 0 : *caps = RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_FWD |
924 : : RTE_EVENT_CRYPTO_ADAPTER_CAP_SESSION_PRIVATE_DATA |
925 : : RTE_EVENT_CRYPTO_ADAPTER_CAP_EVENT_VECTOR;
926 : :
927 : 0 : return 0;
928 : : }
929 : :
930 : : static int
931 : 0 : cn10k_crypto_adapter_qp_add(const struct rte_eventdev *event_dev,
932 : : const struct rte_cryptodev *cdev,
933 : : int32_t queue_pair_id,
934 : : const struct rte_event_crypto_adapter_queue_conf *conf)
935 : : {
936 : : int ret;
937 : :
938 [ # # ]: 0 : CNXK_VALID_DEV_OR_ERR_RET(event_dev->dev, "event_cn10k", EINVAL);
939 [ # # ]: 0 : CNXK_VALID_DEV_OR_ERR_RET(cdev->device, "crypto_cn10k", EINVAL);
940 : :
941 : : cn10k_sso_fp_fns_set((struct rte_eventdev *)(uintptr_t)event_dev);
942 : :
943 : 0 : ret = cnxk_crypto_adapter_qp_add(event_dev, cdev, queue_pair_id, conf);
944 : : cn10k_sso_set_priv_mem(event_dev, NULL);
945 : :
946 : : return ret;
947 : : }
948 : :
949 : : static int
950 : 0 : cn10k_crypto_adapter_qp_del(const struct rte_eventdev *event_dev, const struct rte_cryptodev *cdev,
951 : : int32_t queue_pair_id)
952 : : {
953 [ # # ]: 0 : CNXK_VALID_DEV_OR_ERR_RET(event_dev->dev, "event_cn10k", EINVAL);
954 [ # # ]: 0 : CNXK_VALID_DEV_OR_ERR_RET(cdev->device, "crypto_cn10k", EINVAL);
955 : :
956 : 0 : return cnxk_crypto_adapter_qp_del(cdev, queue_pair_id);
957 : : }
958 : :
959 : : static int
960 : 0 : cn10k_tim_caps_get(const struct rte_eventdev *evdev, uint64_t flags,
961 : : uint32_t *caps, const struct event_timer_adapter_ops **ops)
962 : : {
963 : 0 : return cnxk_tim_caps_get(evdev, flags, caps, ops,
964 : : cn10k_sso_set_priv_mem);
965 : : }
966 : :
967 : : static int
968 : 0 : cn10k_crypto_adapter_vec_limits(const struct rte_eventdev *event_dev,
969 : : const struct rte_cryptodev *cdev,
970 : : struct rte_event_crypto_adapter_vector_limits *limits)
971 : : {
972 [ # # ]: 0 : CNXK_VALID_DEV_OR_ERR_RET(event_dev->dev, "event_cn10k", EINVAL);
973 [ # # ]: 0 : CNXK_VALID_DEV_OR_ERR_RET(cdev->device, "crypto_cn10k", EINVAL);
974 : :
975 : 0 : limits->log2_sz = false;
976 : 0 : limits->min_sz = 0;
977 : 0 : limits->max_sz = UINT16_MAX;
978 : : /* Unused timeout, in software implementation we aggregate all crypto
979 : : * operations passed to the enqueue function
980 : : */
981 : 0 : limits->min_timeout_ns = 0;
982 : 0 : limits->max_timeout_ns = 0;
983 : :
984 : 0 : return 0;
985 : : }
986 : :
987 : : static int
988 : 0 : cn10k_dma_adapter_caps_get(const struct rte_eventdev *event_dev,
989 : : const int16_t dma_dev_id, uint32_t *caps)
990 : : {
991 : : struct rte_dma_dev *dma_dev;
992 : :
993 : : RTE_SET_USED(event_dev);
994 : :
995 : 0 : dma_dev = rte_dma_pmd_get_dev_by_id(dma_dev_id);
996 [ # # ]: 0 : if (dma_dev == NULL)
997 : : return -EINVAL;
998 : :
999 [ # # ]: 0 : CNXK_VALID_DEV_OR_ERR_RET(dma_dev->device, "cnxk_dmadev_pci_driver", EINVAL);
1000 : :
1001 : 0 : *caps = RTE_EVENT_DMA_ADAPTER_CAP_INTERNAL_PORT_OP_FWD;
1002 : :
1003 : 0 : return 0;
1004 : : }
1005 : :
1006 : : static int
1007 : 0 : cn10k_dma_adapter_vchan_add(const struct rte_eventdev *event_dev,
1008 : : const int16_t dma_dev_id, uint16_t vchan_id,
1009 : : const struct rte_event *event)
1010 : : {
1011 : : struct rte_dma_dev *dma_dev;
1012 : : int ret;
1013 : :
1014 : : RTE_SET_USED(event);
1015 : 0 : dma_dev = rte_dma_pmd_get_dev_by_id(dma_dev_id);
1016 [ # # ]: 0 : if (dma_dev == NULL)
1017 : : return -EINVAL;
1018 : :
1019 [ # # ]: 0 : CNXK_VALID_DEV_OR_ERR_RET(dma_dev->device, "cnxk_dmadev_pci_driver", EINVAL);
1020 : :
1021 : : cn10k_sso_fp_fns_set((struct rte_eventdev *)(uintptr_t)event_dev);
1022 : :
1023 : 0 : ret = cnxk_dma_adapter_vchan_add(event_dev, dma_dev_id, vchan_id);
1024 : : cn10k_sso_set_priv_mem(event_dev, NULL);
1025 : :
1026 : : return ret;
1027 : : }
1028 : :
1029 : : static int
1030 : 0 : cn10k_dma_adapter_vchan_del(const struct rte_eventdev *event_dev,
1031 : : const int16_t dma_dev_id, uint16_t vchan_id)
1032 : : {
1033 : : struct rte_dma_dev *dma_dev;
1034 : :
1035 : : RTE_SET_USED(event_dev);
1036 : :
1037 : 0 : dma_dev = rte_dma_pmd_get_dev_by_id(dma_dev_id);
1038 [ # # ]: 0 : if (dma_dev == NULL)
1039 : : return -EINVAL;
1040 : :
1041 [ # # ]: 0 : CNXK_VALID_DEV_OR_ERR_RET(dma_dev->device, "cnxk_dmadev_pci_driver", EINVAL);
1042 : :
1043 : 0 : return cnxk_dma_adapter_vchan_del(dma_dev_id, vchan_id);
1044 : : }
1045 : :
1046 : : static struct eventdev_ops cn10k_sso_dev_ops = {
1047 : : .dev_infos_get = cn10k_sso_info_get,
1048 : : .dev_configure = cn10k_sso_dev_configure,
1049 : :
1050 : : .queue_def_conf = cnxk_sso_queue_def_conf,
1051 : : .queue_setup = cnxk_sso_queue_setup,
1052 : : .queue_release = cnxk_sso_queue_release,
1053 : : .queue_attr_set = cnxk_sso_queue_attribute_set,
1054 : :
1055 : : .port_def_conf = cnxk_sso_port_def_conf,
1056 : : .port_setup = cn10k_sso_port_setup,
1057 : : .port_release = cn10k_sso_port_release,
1058 : : .port_quiesce = cn10k_sso_port_quiesce,
1059 : : .port_link = cn10k_sso_port_link,
1060 : : .port_unlink = cn10k_sso_port_unlink,
1061 : : .port_link_profile = cn10k_sso_port_link_profile,
1062 : : .port_unlink_profile = cn10k_sso_port_unlink_profile,
1063 : : .timeout_ticks = cnxk_sso_timeout_ticks,
1064 : :
1065 : : .eth_rx_adapter_caps_get = cn10k_sso_rx_adapter_caps_get,
1066 : : .eth_rx_adapter_queue_add = cn10k_sso_rx_adapter_queue_add,
1067 : : .eth_rx_adapter_queues_add = cn10k_sso_rx_adapter_queues_add,
1068 : : .eth_rx_adapter_queue_del = cn10k_sso_rx_adapter_queue_del,
1069 : : .eth_rx_adapter_start = cnxk_sso_rx_adapter_start,
1070 : : .eth_rx_adapter_stop = cnxk_sso_rx_adapter_stop,
1071 : :
1072 : : .eth_rx_adapter_vector_limits_get = cn10k_sso_rx_adapter_vector_limits,
1073 : :
1074 : : .eth_tx_adapter_caps_get = cn10k_sso_tx_adapter_caps_get,
1075 : : .eth_tx_adapter_queue_add = cn10k_sso_tx_adapter_queue_add,
1076 : : .eth_tx_adapter_queue_del = cn10k_sso_tx_adapter_queue_del,
1077 : : .eth_tx_adapter_start = cnxk_sso_tx_adapter_start,
1078 : : .eth_tx_adapter_stop = cnxk_sso_tx_adapter_stop,
1079 : : .eth_tx_adapter_free = cnxk_sso_tx_adapter_free,
1080 : :
1081 : : .timer_adapter_caps_get = cn10k_tim_caps_get,
1082 : :
1083 : : .crypto_adapter_caps_get = cn10k_crypto_adapter_caps_get,
1084 : : .crypto_adapter_queue_pair_add = cn10k_crypto_adapter_qp_add,
1085 : : .crypto_adapter_queue_pair_del = cn10k_crypto_adapter_qp_del,
1086 : : .crypto_adapter_vector_limits_get = cn10k_crypto_adapter_vec_limits,
1087 : :
1088 : : .dma_adapter_caps_get = cn10k_dma_adapter_caps_get,
1089 : : .dma_adapter_vchan_add = cn10k_dma_adapter_vchan_add,
1090 : : .dma_adapter_vchan_del = cn10k_dma_adapter_vchan_del,
1091 : :
1092 : : .xstats_get = cnxk_sso_xstats_get,
1093 : : .xstats_reset = cnxk_sso_xstats_reset,
1094 : : .xstats_get_names = cnxk_sso_xstats_get_names,
1095 : :
1096 : : .dump = cnxk_sso_dump,
1097 : : .dev_start = cn10k_sso_start,
1098 : : .dev_stop = cn10k_sso_stop,
1099 : : .dev_close = cn10k_sso_close,
1100 : : .dev_selftest = cn10k_sso_selftest,
1101 : : };
1102 : :
1103 : : static int
1104 : 0 : cn10k_sso_init(struct rte_eventdev *event_dev)
1105 : : {
1106 : : struct cnxk_sso_evdev *dev = cnxk_sso_pmd_priv(event_dev);
1107 : : int rc;
1108 : :
1109 : 0 : rc = roc_plt_init();
1110 [ # # ]: 0 : if (rc < 0) {
1111 : 0 : plt_err("Failed to initialize platform model");
1112 : 0 : return rc;
1113 : : }
1114 : :
1115 : 0 : cnxk_ethdev_rx_offload_cb_register(cn10k_sso_rx_offload_cb);
1116 : 0 : event_dev->dev_ops = &cn10k_sso_dev_ops;
1117 : : /* For secondary processes, the primary has done all the work */
1118 [ # # ]: 0 : if (rte_eal_process_type() != RTE_PROC_PRIMARY) {
1119 : : cn10k_sso_fp_fns_set(event_dev);
1120 : : return 0;
1121 : : }
1122 : :
1123 : 0 : rc = cnxk_sso_init(event_dev);
1124 [ # # ]: 0 : if (rc < 0)
1125 : : return rc;
1126 : :
1127 : : cn10k_sso_set_rsrc(cnxk_sso_pmd_priv(event_dev));
1128 [ # # # # ]: 0 : if (!dev->max_event_ports || !dev->max_event_queues) {
1129 : 0 : plt_err("Not enough eventdev resource queues=%d ports=%d",
1130 : : dev->max_event_queues, dev->max_event_ports);
1131 : 0 : cnxk_sso_fini(event_dev);
1132 : 0 : return -ENODEV;
1133 : : }
1134 : :
1135 : 0 : plt_sso_dbg("Initializing %s max_queues=%d max_ports=%d",
1136 : : event_dev->data->name, dev->max_event_queues,
1137 : : dev->max_event_ports);
1138 : :
1139 : 0 : return 0;
1140 : : }
1141 : :
1142 : : static int
1143 : 0 : cn10k_sso_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev)
1144 : : {
1145 : 0 : return rte_event_pmd_pci_probe(pci_drv, pci_dev,
1146 : : sizeof(struct cnxk_sso_evdev),
1147 : : cn10k_sso_init);
1148 : : }
1149 : :
1150 : : static const struct rte_pci_id cn10k_pci_sso_map[] = {
1151 : : CNXK_PCI_ID(PCI_SUBSYSTEM_DEVID_CN10KA, PCI_DEVID_CNXK_RVU_SSO_TIM_PF),
1152 : : CNXK_PCI_ID(PCI_SUBSYSTEM_DEVID_CN10KAS, PCI_DEVID_CNXK_RVU_SSO_TIM_PF),
1153 : : CNXK_PCI_ID(PCI_SUBSYSTEM_DEVID_CNF10KA, PCI_DEVID_CNXK_RVU_SSO_TIM_PF),
1154 : : CNXK_PCI_ID(PCI_SUBSYSTEM_DEVID_CN10KB, PCI_DEVID_CNXK_RVU_SSO_TIM_PF),
1155 : : CNXK_PCI_ID(PCI_SUBSYSTEM_DEVID_CNF10KB, PCI_DEVID_CNXK_RVU_SSO_TIM_PF),
1156 : : CNXK_PCI_ID(PCI_SUBSYSTEM_DEVID_CN10KA, PCI_DEVID_CNXK_RVU_SSO_TIM_VF),
1157 : : CNXK_PCI_ID(PCI_SUBSYSTEM_DEVID_CN10KAS, PCI_DEVID_CNXK_RVU_SSO_TIM_VF),
1158 : : CNXK_PCI_ID(PCI_SUBSYSTEM_DEVID_CNF10KA, PCI_DEVID_CNXK_RVU_SSO_TIM_VF),
1159 : : CNXK_PCI_ID(PCI_SUBSYSTEM_DEVID_CN10KB, PCI_DEVID_CNXK_RVU_SSO_TIM_VF),
1160 : : CNXK_PCI_ID(PCI_SUBSYSTEM_DEVID_CNF10KB, PCI_DEVID_CNXK_RVU_SSO_TIM_VF),
1161 : : {
1162 : : .vendor_id = 0,
1163 : : },
1164 : : };
1165 : :
1166 : : static struct rte_pci_driver cn10k_pci_sso = {
1167 : : .id_table = cn10k_pci_sso_map,
1168 : : .drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_NEED_IOVA_AS_VA,
1169 : : .probe = cn10k_sso_probe,
1170 : : .remove = cnxk_sso_remove,
1171 : : };
1172 : :
1173 : 254 : RTE_PMD_REGISTER_PCI(event_cn10k, cn10k_pci_sso);
1174 : : RTE_PMD_REGISTER_PCI_TABLE(event_cn10k, cn10k_pci_sso_map);
1175 : : RTE_PMD_REGISTER_KMOD_DEP(event_cn10k, "vfio-pci");
1176 : : RTE_PMD_REGISTER_PARAM_STRING(event_cn10k, CNXK_SSO_XAE_CNT "=<int>"
1177 : : CNXK_SSO_GGRP_QOS "=<string>"
1178 : : CNXK_SSO_FORCE_BP "=1"
1179 : : CNXK_SSO_STASH "=<string>"
1180 : : CNXK_TIM_DISABLE_NPA "=1"
1181 : : CNXK_TIM_CHNK_SLOTS "=<int>"
1182 : : CNXK_TIM_RINGS_LMT "=<int>"
1183 : : CNXK_TIM_STATS_ENA "=1"
1184 : : CNXK_TIM_EXT_CLK "=<string>");
|