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