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