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 : 0 : }
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;
679 : :
680 [ # # ]: 0 : if (event_dev == NULL)
681 : : return;
682 : :
683 : : evdev = cnxk_sso_pmd_priv(event_dev);
684 : 0 : evdev->rx_offloads |= flags;
685 : : cn10k_sso_fp_fns_set((struct rte_eventdev *)(uintptr_t)event_dev);
686 : : eventdev_fops_update(event_dev);
687 : : }
688 : :
689 : : static int
690 : 0 : cn10k_sso_configure_queue_stash_default(struct cnxk_sso_evdev *dev, uint16_t hwgrp)
691 : : {
692 : : struct roc_sso_hwgrp_stash stash;
693 : : int rc;
694 : :
695 : 0 : stash.hwgrp = hwgrp;
696 : 0 : stash.stash_offset = CN10K_SSO_DEFAULT_STASH_OFFSET;
697 : 0 : stash.stash_count = CN10K_SSO_DEFAULT_STASH_LENGTH;
698 : 0 : rc = roc_sso_hwgrp_stash_config(&dev->sso, &stash, 1);
699 [ # # ]: 0 : if (rc)
700 : 0 : plt_warn("failed to configure HWGRP WQE stashing rc = %d", rc);
701 : :
702 : 0 : return rc;
703 : : }
704 : :
705 : : static int
706 : 0 : cn10k_sso_rx_adapter_queue_add(
707 : : const struct rte_eventdev *event_dev, const struct rte_eth_dev *eth_dev,
708 : : int32_t rx_queue_id,
709 : : const struct rte_event_eth_rx_adapter_queue_conf *queue_conf)
710 : : {
711 [ # # ]: 0 : struct cnxk_eth_dev *cnxk_eth_dev = eth_dev->data->dev_private;
712 : : struct cnxk_sso_evdev *dev = cnxk_sso_pmd_priv(event_dev);
713 : : struct cn10k_eth_rxq *rxq;
714 : : uint16_t nb_rx_queues;
715 : : void *lookup_mem;
716 : : int rc;
717 : :
718 : 0 : rc = strncmp(eth_dev->device->driver->name, "net_cn10k", 8);
719 [ # # ]: 0 : if (rc)
720 : : return -EINVAL;
721 : :
722 : 0 : nb_rx_queues = rx_queue_id == -1 ? 0 : 1;
723 : 0 : rc = cnxk_sso_rx_adapter_queues_add(event_dev, eth_dev, &rx_queue_id, queue_conf,
724 : : nb_rx_queues);
725 [ # # ]: 0 : if (rc)
726 : : return -EINVAL;
727 : :
728 : 0 : cnxk_eth_dev->cnxk_sso_ptp_tstamp_cb = cn10k_sso_tstamp_hdl_update;
729 : 0 : cnxk_eth_dev->evdev_priv = (struct rte_eventdev *)(uintptr_t)event_dev;
730 : :
731 : 0 : rxq = eth_dev->data->rx_queues[0];
732 : 0 : lookup_mem = rxq->lookup_mem;
733 : : cn10k_sso_set_priv_mem(event_dev, lookup_mem);
734 : : cn10k_sso_fp_fns_set((struct rte_eventdev *)(uintptr_t)event_dev);
735 [ # # # # ]: 0 : if (roc_feature_sso_has_stash() && dev->nb_event_ports > 1)
736 : 0 : rc = cn10k_sso_configure_queue_stash_default(dev, queue_conf->ev.queue_id);
737 : :
738 : : return rc;
739 : : }
740 : : static int
741 : 0 : cn10k_sso_rx_adapter_queues_add(const struct rte_eventdev *event_dev,
742 : : const struct rte_eth_dev *eth_dev, int32_t rx_queue_id[],
743 : : const struct rte_event_eth_rx_adapter_queue_conf queue_conf[],
744 : : uint16_t nb_rx_queues)
745 : : {
746 [ # # ]: 0 : struct cnxk_eth_dev *cnxk_eth_dev = eth_dev->data->dev_private;
747 : : struct cnxk_sso_evdev *dev = cnxk_sso_pmd_priv(event_dev);
748 : : struct cn10k_eth_rxq *rxq;
749 : : void *lookup_mem;
750 : : int rc, i;
751 : :
752 : 0 : rc = strncmp(eth_dev->device->driver->name, "net_cn10k", 8);
753 [ # # ]: 0 : if (rc)
754 : : return -EINVAL;
755 : :
756 : 0 : rc = cnxk_sso_rx_adapter_queues_add(event_dev, eth_dev, rx_queue_id, queue_conf,
757 : : nb_rx_queues);
758 [ # # ]: 0 : if (rc)
759 : : return -EINVAL;
760 : :
761 : 0 : cnxk_eth_dev->cnxk_sso_ptp_tstamp_cb = cn10k_sso_tstamp_hdl_update;
762 : 0 : cnxk_eth_dev->evdev_priv = (struct rte_eventdev *)(uintptr_t)event_dev;
763 : :
764 : 0 : rxq = eth_dev->data->rx_queues[0];
765 : 0 : lookup_mem = rxq->lookup_mem;
766 : : cn10k_sso_set_priv_mem(event_dev, lookup_mem);
767 : : cn10k_sso_fp_fns_set((struct rte_eventdev *)(uintptr_t)event_dev);
768 [ # # # # ]: 0 : if (roc_feature_sso_has_stash() && dev->nb_event_ports > 1) {
769 : 0 : uint16_t hwgrp = dev->sso.max_hwgrp;
770 : :
771 [ # # ]: 0 : if (nb_rx_queues == 0)
772 : 0 : rc = cn10k_sso_configure_queue_stash_default(dev,
773 : 0 : queue_conf[0].ev.queue_id);
774 : :
775 [ # # ]: 0 : for (i = 0; i < nb_rx_queues; i++) {
776 [ # # ]: 0 : if (hwgrp == queue_conf[i].ev.queue_id)
777 : 0 : continue;
778 : :
779 : : hwgrp = queue_conf[i].ev.queue_id;
780 : 0 : rc = cn10k_sso_configure_queue_stash_default(dev, hwgrp);
781 [ # # ]: 0 : if (rc < 0)
782 : : break;
783 : : }
784 : : }
785 : :
786 : : return rc;
787 : : }
788 : :
789 : : static int
790 : 0 : cn10k_sso_rx_adapter_queue_del(const struct rte_eventdev *event_dev,
791 : : const struct rte_eth_dev *eth_dev,
792 : : int32_t rx_queue_id)
793 : : {
794 : : int rc;
795 : :
796 : 0 : rc = strncmp(eth_dev->device->driver->name, "net_cn10k", 8);
797 [ # # ]: 0 : if (rc)
798 : : return -EINVAL;
799 : :
800 : 0 : return cnxk_sso_rx_adapter_queue_del(event_dev, eth_dev, rx_queue_id);
801 : : }
802 : :
803 : : static int
804 : 0 : cn10k_sso_rx_adapter_vector_limits(
805 : : const struct rte_eventdev *dev, const struct rte_eth_dev *eth_dev,
806 : : struct rte_event_eth_rx_adapter_vector_limits *limits)
807 : : {
808 : : struct cnxk_eth_dev *cnxk_eth_dev;
809 : : int ret;
810 : :
811 : : RTE_SET_USED(dev);
812 : 0 : ret = strncmp(eth_dev->device->driver->name, "net_cn10k", 8);
813 [ # # ]: 0 : if (ret)
814 : : return -ENOTSUP;
815 : :
816 : : cnxk_eth_dev = cnxk_eth_pmd_priv(eth_dev);
817 : 0 : limits->log2_sz = true;
818 : 0 : limits->min_sz = 1 << ROC_NIX_VWQE_MIN_SIZE_LOG2;
819 : 0 : limits->max_sz = 1 << ROC_NIX_VWQE_MAX_SIZE_LOG2;
820 : 0 : limits->min_timeout_ns =
821 : 0 : (roc_nix_get_vwqe_interval(&cnxk_eth_dev->nix) + 1) * 100;
822 : 0 : limits->max_timeout_ns = BITMASK_ULL(8, 0) * limits->min_timeout_ns;
823 : :
824 : 0 : return 0;
825 : : }
826 : :
827 : : static int
828 : 0 : cn10k_sso_tx_adapter_caps_get(const struct rte_eventdev *dev,
829 : : const struct rte_eth_dev *eth_dev, uint32_t *caps)
830 : : {
831 : : int ret;
832 : :
833 : : RTE_SET_USED(dev);
834 : 0 : ret = strncmp(eth_dev->device->driver->name, "net_cn10k", 8);
835 [ # # ]: 0 : if (ret)
836 : 0 : *caps = 0;
837 : : else
838 : 0 : *caps = RTE_EVENT_ETH_TX_ADAPTER_CAP_INTERNAL_PORT |
839 : : RTE_EVENT_ETH_TX_ADAPTER_CAP_EVENT_VECTOR;
840 : :
841 : 0 : return 0;
842 : : }
843 : :
844 : : static void
845 : 0 : cn10k_sso_txq_fc_update(const struct rte_eth_dev *eth_dev, int32_t tx_queue_id)
846 : : {
847 : 0 : struct cnxk_eth_dev *cnxk_eth_dev = eth_dev->data->dev_private;
848 : : struct cn10k_eth_txq *txq;
849 : : struct roc_nix_sq *sq;
850 : : int i;
851 : :
852 [ # # ]: 0 : if (tx_queue_id < 0) {
853 [ # # ]: 0 : for (i = 0; i < eth_dev->data->nb_tx_queues; i++)
854 : 0 : cn10k_sso_txq_fc_update(eth_dev, i);
855 : : } else {
856 : : uint16_t sqes_per_sqb;
857 : :
858 : 0 : sq = &cnxk_eth_dev->sqs[tx_queue_id];
859 : 0 : txq = eth_dev->data->tx_queues[tx_queue_id];
860 : 0 : sqes_per_sqb = 1U << txq->sqes_per_sqb_log2;
861 [ # # ]: 0 : if (cnxk_eth_dev->tx_offloads & RTE_ETH_TX_OFFLOAD_SECURITY)
862 : 0 : sq->nb_sqb_bufs_adj -= (cnxk_eth_dev->outb.nb_desc / sqes_per_sqb);
863 : 0 : txq->nb_sqb_bufs_adj = sq->nb_sqb_bufs_adj;
864 : : }
865 : 0 : }
866 : :
867 : : static int
868 : 0 : cn10k_sso_tx_adapter_queue_add(uint8_t id, const struct rte_eventdev *event_dev,
869 : : const struct rte_eth_dev *eth_dev,
870 : : int32_t tx_queue_id)
871 : : {
872 : 0 : struct cnxk_eth_dev *cnxk_eth_dev = eth_dev->data->dev_private;
873 : : struct cnxk_sso_evdev *dev = cnxk_sso_pmd_priv(event_dev);
874 : : uint64_t tx_offloads;
875 : : int rc;
876 : :
877 : : RTE_SET_USED(id);
878 : 0 : rc = cnxk_sso_tx_adapter_queue_add(event_dev, eth_dev, tx_queue_id);
879 [ # # ]: 0 : if (rc < 0)
880 : : return rc;
881 : :
882 : : /* Can't enable tstamp if all the ports don't have it enabled. */
883 : 0 : tx_offloads = cnxk_eth_dev->tx_offload_flags;
884 [ # # ]: 0 : if (dev->tx_adptr_configured) {
885 : 0 : uint8_t tstmp_req = !!(tx_offloads & NIX_TX_OFFLOAD_TSTAMP_F);
886 : : uint8_t tstmp_ena =
887 : 0 : !!(dev->tx_offloads & NIX_TX_OFFLOAD_TSTAMP_F);
888 : :
889 [ # # ]: 0 : if (tstmp_ena && !tstmp_req)
890 : 0 : dev->tx_offloads &= ~(NIX_TX_OFFLOAD_TSTAMP_F);
891 [ # # ]: 0 : else if (!tstmp_ena && tstmp_req)
892 : 0 : tx_offloads &= ~(NIX_TX_OFFLOAD_TSTAMP_F);
893 : : }
894 : :
895 : 0 : dev->tx_offloads |= tx_offloads;
896 : 0 : cn10k_sso_txq_fc_update(eth_dev, tx_queue_id);
897 : 0 : rc = cn10k_sso_updt_tx_adptr_data(event_dev);
898 [ # # ]: 0 : if (rc < 0)
899 : : return rc;
900 : : cn10k_sso_fp_fns_set((struct rte_eventdev *)(uintptr_t)event_dev);
901 : 0 : dev->tx_adptr_configured = 1;
902 : :
903 : 0 : return 0;
904 : : }
905 : :
906 : : static int
907 : 0 : cn10k_sso_tx_adapter_queue_del(uint8_t id, const struct rte_eventdev *event_dev,
908 : : const struct rte_eth_dev *eth_dev,
909 : : int32_t tx_queue_id)
910 : : {
911 : : int rc;
912 : :
913 : : RTE_SET_USED(id);
914 : 0 : rc = cnxk_sso_tx_adapter_queue_del(event_dev, eth_dev, tx_queue_id);
915 [ # # ]: 0 : if (rc < 0)
916 : : return rc;
917 : 0 : return cn10k_sso_updt_tx_adptr_data(event_dev);
918 : : }
919 : :
920 : : static int
921 : 0 : cn10k_crypto_adapter_caps_get(const struct rte_eventdev *event_dev,
922 : : const struct rte_cryptodev *cdev, uint32_t *caps)
923 : : {
924 [ # # ]: 0 : CNXK_VALID_DEV_OR_ERR_RET(event_dev->dev, "event_cn10k", ENOTSUP);
925 [ # # ]: 0 : CNXK_VALID_DEV_OR_ERR_RET(cdev->device, "crypto_cn10k", ENOTSUP);
926 : :
927 : 0 : *caps = RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_FWD |
928 : : RTE_EVENT_CRYPTO_ADAPTER_CAP_SESSION_PRIVATE_DATA |
929 : : RTE_EVENT_CRYPTO_ADAPTER_CAP_EVENT_VECTOR;
930 : :
931 : 0 : return 0;
932 : : }
933 : :
934 : : static int
935 : 0 : cn10k_crypto_adapter_qp_add(const struct rte_eventdev *event_dev,
936 : : const struct rte_cryptodev *cdev,
937 : : int32_t queue_pair_id,
938 : : const struct rte_event_crypto_adapter_queue_conf *conf)
939 : : {
940 : : int ret;
941 : :
942 [ # # ]: 0 : CNXK_VALID_DEV_OR_ERR_RET(event_dev->dev, "event_cn10k", EINVAL);
943 [ # # ]: 0 : CNXK_VALID_DEV_OR_ERR_RET(cdev->device, "crypto_cn10k", EINVAL);
944 : :
945 : : cn10k_sso_fp_fns_set((struct rte_eventdev *)(uintptr_t)event_dev);
946 : :
947 : 0 : ret = cnxk_crypto_adapter_qp_add(event_dev, cdev, queue_pair_id, conf);
948 : : cn10k_sso_set_priv_mem(event_dev, NULL);
949 : :
950 : : return ret;
951 : : }
952 : :
953 : : static int
954 : 0 : cn10k_crypto_adapter_qp_del(const struct rte_eventdev *event_dev, const struct rte_cryptodev *cdev,
955 : : int32_t queue_pair_id)
956 : : {
957 [ # # ]: 0 : CNXK_VALID_DEV_OR_ERR_RET(event_dev->dev, "event_cn10k", EINVAL);
958 [ # # ]: 0 : CNXK_VALID_DEV_OR_ERR_RET(cdev->device, "crypto_cn10k", EINVAL);
959 : :
960 : 0 : return cnxk_crypto_adapter_qp_del(cdev, queue_pair_id);
961 : : }
962 : :
963 : : static int
964 : 0 : cn10k_tim_caps_get(const struct rte_eventdev *evdev, uint64_t flags,
965 : : uint32_t *caps, const struct event_timer_adapter_ops **ops)
966 : : {
967 : 0 : return cnxk_tim_caps_get(evdev, flags, caps, ops,
968 : : cn10k_sso_set_priv_mem);
969 : : }
970 : :
971 : : static int
972 : 0 : cn10k_crypto_adapter_vec_limits(const struct rte_eventdev *event_dev,
973 : : const struct rte_cryptodev *cdev,
974 : : struct rte_event_crypto_adapter_vector_limits *limits)
975 : : {
976 [ # # ]: 0 : CNXK_VALID_DEV_OR_ERR_RET(event_dev->dev, "event_cn10k", EINVAL);
977 [ # # ]: 0 : CNXK_VALID_DEV_OR_ERR_RET(cdev->device, "crypto_cn10k", EINVAL);
978 : :
979 : 0 : limits->log2_sz = false;
980 : 0 : limits->min_sz = 0;
981 : 0 : limits->max_sz = UINT16_MAX;
982 : : /* Unused timeout, in software implementation we aggregate all crypto
983 : : * operations passed to the enqueue function
984 : : */
985 : 0 : limits->min_timeout_ns = 0;
986 : 0 : limits->max_timeout_ns = 0;
987 : :
988 : 0 : return 0;
989 : : }
990 : :
991 : : static int
992 : 0 : cn10k_dma_adapter_caps_get(const struct rte_eventdev *event_dev,
993 : : const int16_t dma_dev_id, uint32_t *caps)
994 : : {
995 : : struct rte_dma_dev *dma_dev;
996 : :
997 : : RTE_SET_USED(event_dev);
998 : :
999 : 0 : dma_dev = rte_dma_pmd_get_dev_by_id(dma_dev_id);
1000 [ # # ]: 0 : if (dma_dev == NULL)
1001 : : return -EINVAL;
1002 : :
1003 [ # # ]: 0 : CNXK_VALID_DEV_OR_ERR_RET(dma_dev->device, "cnxk_dmadev_pci_driver", EINVAL);
1004 : :
1005 : 0 : *caps = RTE_EVENT_DMA_ADAPTER_CAP_INTERNAL_PORT_OP_FWD;
1006 : :
1007 : 0 : return 0;
1008 : : }
1009 : :
1010 : : static int
1011 : 0 : cn10k_dma_adapter_vchan_add(const struct rte_eventdev *event_dev,
1012 : : const int16_t dma_dev_id, uint16_t vchan_id,
1013 : : const struct rte_event *event)
1014 : : {
1015 : : struct rte_dma_dev *dma_dev;
1016 : : int ret;
1017 : :
1018 : : RTE_SET_USED(event);
1019 : 0 : dma_dev = rte_dma_pmd_get_dev_by_id(dma_dev_id);
1020 [ # # ]: 0 : if (dma_dev == NULL)
1021 : : return -EINVAL;
1022 : :
1023 [ # # ]: 0 : CNXK_VALID_DEV_OR_ERR_RET(dma_dev->device, "cnxk_dmadev_pci_driver", EINVAL);
1024 : :
1025 : : cn10k_sso_fp_fns_set((struct rte_eventdev *)(uintptr_t)event_dev);
1026 : :
1027 : 0 : ret = cnxk_dma_adapter_vchan_add(event_dev, dma_dev_id, vchan_id);
1028 : : cn10k_sso_set_priv_mem(event_dev, NULL);
1029 : :
1030 : : return ret;
1031 : : }
1032 : :
1033 : : static int
1034 : 0 : cn10k_dma_adapter_vchan_del(const struct rte_eventdev *event_dev,
1035 : : const int16_t dma_dev_id, uint16_t vchan_id)
1036 : : {
1037 : : struct rte_dma_dev *dma_dev;
1038 : :
1039 : : RTE_SET_USED(event_dev);
1040 : :
1041 : 0 : dma_dev = rte_dma_pmd_get_dev_by_id(dma_dev_id);
1042 [ # # ]: 0 : if (dma_dev == NULL)
1043 : : return -EINVAL;
1044 : :
1045 [ # # ]: 0 : CNXK_VALID_DEV_OR_ERR_RET(dma_dev->device, "cnxk_dmadev_pci_driver", EINVAL);
1046 : :
1047 : 0 : return cnxk_dma_adapter_vchan_del(dma_dev_id, vchan_id);
1048 : : }
1049 : :
1050 : : static struct eventdev_ops cn10k_sso_dev_ops = {
1051 : : .dev_infos_get = cn10k_sso_info_get,
1052 : : .dev_configure = cn10k_sso_dev_configure,
1053 : :
1054 : : .queue_def_conf = cnxk_sso_queue_def_conf,
1055 : : .queue_setup = cnxk_sso_queue_setup,
1056 : : .queue_release = cnxk_sso_queue_release,
1057 : : .queue_attr_set = cnxk_sso_queue_attribute_set,
1058 : :
1059 : : .port_def_conf = cnxk_sso_port_def_conf,
1060 : : .port_setup = cn10k_sso_port_setup,
1061 : : .port_release = cn10k_sso_port_release,
1062 : : .port_quiesce = cn10k_sso_port_quiesce,
1063 : : .port_link = cn10k_sso_port_link,
1064 : : .port_unlink = cn10k_sso_port_unlink,
1065 : : .port_link_profile = cn10k_sso_port_link_profile,
1066 : : .port_unlink_profile = cn10k_sso_port_unlink_profile,
1067 : : .timeout_ticks = cnxk_sso_timeout_ticks,
1068 : :
1069 : : .eth_rx_adapter_caps_get = cn10k_sso_rx_adapter_caps_get,
1070 : : .eth_rx_adapter_queue_add = cn10k_sso_rx_adapter_queue_add,
1071 : : .eth_rx_adapter_queues_add = cn10k_sso_rx_adapter_queues_add,
1072 : : .eth_rx_adapter_queue_del = cn10k_sso_rx_adapter_queue_del,
1073 : : .eth_rx_adapter_start = cnxk_sso_rx_adapter_start,
1074 : : .eth_rx_adapter_stop = cnxk_sso_rx_adapter_stop,
1075 : :
1076 : : .eth_rx_adapter_vector_limits_get = cn10k_sso_rx_adapter_vector_limits,
1077 : :
1078 : : .eth_tx_adapter_caps_get = cn10k_sso_tx_adapter_caps_get,
1079 : : .eth_tx_adapter_queue_add = cn10k_sso_tx_adapter_queue_add,
1080 : : .eth_tx_adapter_queue_del = cn10k_sso_tx_adapter_queue_del,
1081 : : .eth_tx_adapter_start = cnxk_sso_tx_adapter_start,
1082 : : .eth_tx_adapter_stop = cnxk_sso_tx_adapter_stop,
1083 : : .eth_tx_adapter_free = cnxk_sso_tx_adapter_free,
1084 : :
1085 : : .timer_adapter_caps_get = cn10k_tim_caps_get,
1086 : :
1087 : : .crypto_adapter_caps_get = cn10k_crypto_adapter_caps_get,
1088 : : .crypto_adapter_queue_pair_add = cn10k_crypto_adapter_qp_add,
1089 : : .crypto_adapter_queue_pair_del = cn10k_crypto_adapter_qp_del,
1090 : : .crypto_adapter_vector_limits_get = cn10k_crypto_adapter_vec_limits,
1091 : :
1092 : : .dma_adapter_caps_get = cn10k_dma_adapter_caps_get,
1093 : : .dma_adapter_vchan_add = cn10k_dma_adapter_vchan_add,
1094 : : .dma_adapter_vchan_del = cn10k_dma_adapter_vchan_del,
1095 : :
1096 : : .xstats_get = cnxk_sso_xstats_get,
1097 : : .xstats_reset = cnxk_sso_xstats_reset,
1098 : : .xstats_get_names = cnxk_sso_xstats_get_names,
1099 : :
1100 : : .dump = cnxk_sso_dump,
1101 : : .dev_start = cn10k_sso_start,
1102 : : .dev_stop = cn10k_sso_stop,
1103 : : .dev_close = cn10k_sso_close,
1104 : : .dev_selftest = cn10k_sso_selftest,
1105 : : };
1106 : :
1107 : : static int
1108 : 0 : cn10k_sso_init(struct rte_eventdev *event_dev)
1109 : : {
1110 : : struct cnxk_sso_evdev *dev = cnxk_sso_pmd_priv(event_dev);
1111 : : int rc;
1112 : :
1113 : 0 : rc = roc_plt_init();
1114 [ # # ]: 0 : if (rc < 0) {
1115 : 0 : plt_err("Failed to initialize platform model");
1116 : 0 : return rc;
1117 : : }
1118 : :
1119 : 0 : cnxk_ethdev_rx_offload_cb_register(cn10k_sso_rx_offload_cb);
1120 : 0 : event_dev->dev_ops = &cn10k_sso_dev_ops;
1121 : : /* For secondary processes, the primary has done all the work */
1122 [ # # ]: 0 : if (rte_eal_process_type() != RTE_PROC_PRIMARY) {
1123 : : cn10k_sso_fp_fns_set(event_dev);
1124 : : return 0;
1125 : : }
1126 : :
1127 : 0 : rc = cnxk_sso_init(event_dev);
1128 [ # # ]: 0 : if (rc < 0)
1129 : : return rc;
1130 : :
1131 : : cn10k_sso_set_rsrc(cnxk_sso_pmd_priv(event_dev));
1132 [ # # # # ]: 0 : if (!dev->max_event_ports || !dev->max_event_queues) {
1133 : 0 : plt_err("Not enough eventdev resource queues=%d ports=%d",
1134 : : dev->max_event_queues, dev->max_event_ports);
1135 : 0 : cnxk_sso_fini(event_dev);
1136 : 0 : return -ENODEV;
1137 : : }
1138 : :
1139 : 0 : plt_sso_dbg("Initializing %s max_queues=%d max_ports=%d",
1140 : : event_dev->data->name, dev->max_event_queues,
1141 : : dev->max_event_ports);
1142 : :
1143 : 0 : return 0;
1144 : : }
1145 : :
1146 : : static int
1147 : 0 : cn10k_sso_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev)
1148 : : {
1149 : 0 : return rte_event_pmd_pci_probe(pci_drv, pci_dev,
1150 : : sizeof(struct cnxk_sso_evdev),
1151 : : cn10k_sso_init);
1152 : : }
1153 : :
1154 : : static const struct rte_pci_id cn10k_pci_sso_map[] = {
1155 : : CNXK_PCI_ID(PCI_SUBSYSTEM_DEVID_CN10KA, PCI_DEVID_CNXK_RVU_SSO_TIM_PF),
1156 : : CNXK_PCI_ID(PCI_SUBSYSTEM_DEVID_CN10KAS, PCI_DEVID_CNXK_RVU_SSO_TIM_PF),
1157 : : CNXK_PCI_ID(PCI_SUBSYSTEM_DEVID_CNF10KA, PCI_DEVID_CNXK_RVU_SSO_TIM_PF),
1158 : : CNXK_PCI_ID(PCI_SUBSYSTEM_DEVID_CN10KB, PCI_DEVID_CNXK_RVU_SSO_TIM_PF),
1159 : : CNXK_PCI_ID(PCI_SUBSYSTEM_DEVID_CNF10KB, PCI_DEVID_CNXK_RVU_SSO_TIM_PF),
1160 : : CNXK_PCI_ID(PCI_SUBSYSTEM_DEVID_CN10KA, PCI_DEVID_CNXK_RVU_SSO_TIM_VF),
1161 : : CNXK_PCI_ID(PCI_SUBSYSTEM_DEVID_CN10KAS, PCI_DEVID_CNXK_RVU_SSO_TIM_VF),
1162 : : CNXK_PCI_ID(PCI_SUBSYSTEM_DEVID_CNF10KA, PCI_DEVID_CNXK_RVU_SSO_TIM_VF),
1163 : : CNXK_PCI_ID(PCI_SUBSYSTEM_DEVID_CN10KB, PCI_DEVID_CNXK_RVU_SSO_TIM_VF),
1164 : : CNXK_PCI_ID(PCI_SUBSYSTEM_DEVID_CNF10KB, PCI_DEVID_CNXK_RVU_SSO_TIM_VF),
1165 : : {
1166 : : .vendor_id = 0,
1167 : : },
1168 : : };
1169 : :
1170 : : static struct rte_pci_driver cn10k_pci_sso = {
1171 : : .id_table = cn10k_pci_sso_map,
1172 : : .drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_NEED_IOVA_AS_VA,
1173 : : .probe = cn10k_sso_probe,
1174 : : .remove = cnxk_sso_remove,
1175 : : };
1176 : :
1177 : 276 : RTE_PMD_REGISTER_PCI(event_cn10k, cn10k_pci_sso);
1178 : : RTE_PMD_REGISTER_PCI_TABLE(event_cn10k, cn10k_pci_sso_map);
1179 : : RTE_PMD_REGISTER_KMOD_DEP(event_cn10k, "vfio-pci");
1180 : : RTE_PMD_REGISTER_PARAM_STRING(event_cn10k, CNXK_SSO_XAE_CNT "=<int>"
1181 : : CNXK_SSO_GGRP_QOS "=<string>"
1182 : : CNXK_SSO_FORCE_BP "=1"
1183 : : CNXK_SSO_STASH "=<string>"
1184 : : CNXK_TIM_DISABLE_NPA "=1"
1185 : : CNXK_TIM_CHNK_SLOTS "=<int>"
1186 : : CNXK_TIM_RINGS_LMT "=<int>"
1187 : : CNXK_TIM_STATS_ENA "=1"
1188 : : CNXK_TIM_EXT_CLK "=<string>");
|