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