Branch data Line data Source code
1 : : /* SPDX-License-Identifier: BSD-3-Clause
2 : : * Copyright 2017,2019-2022 NXP
3 : : */
4 : :
5 : : #include <assert.h>
6 : : #include <stdio.h>
7 : : #include <stdbool.h>
8 : : #include <errno.h>
9 : : #include <stdint.h>
10 : : #include <string.h>
11 : : #include <sys/epoll.h>
12 : :
13 : : #include <rte_atomic.h>
14 : : #include <rte_byteorder.h>
15 : : #include <rte_common.h>
16 : : #include <rte_debug.h>
17 : : #include <dev_driver.h>
18 : : #include <rte_eal.h>
19 : : #include <bus_fslmc_driver.h>
20 : : #include <rte_lcore.h>
21 : : #include <rte_log.h>
22 : : #include <rte_malloc.h>
23 : : #include <rte_memcpy.h>
24 : : #include <rte_memory.h>
25 : : #include <rte_pci.h>
26 : : #include <bus_vdev_driver.h>
27 : : #include <ethdev_driver.h>
28 : : #include <cryptodev_pmd.h>
29 : : #include <rte_event_crypto_adapter.h>
30 : : #include <rte_event_eth_rx_adapter.h>
31 : : #include <rte_event_eth_tx_adapter.h>
32 : :
33 : : #include <fslmc_vfio.h>
34 : : #include <dpaa2_hw_pvt.h>
35 : : #include <dpaa2_hw_mempool.h>
36 : : #include <dpaa2_hw_dpio.h>
37 : : #include <dpaa2_ethdev.h>
38 : : #include <dpaa2_sec_event.h>
39 : : #include "dpaa2_eventdev.h"
40 : : #include "dpaa2_eventdev_logs.h"
41 : : #include <portal/dpaa2_hw_pvt.h>
42 : : #include <mc/fsl_dpci.h>
43 : :
44 : : /* Clarifications
45 : : * Evendev = SoC Instance
46 : : * Eventport = DPIO Instance
47 : : * Eventqueue = DPCON Instance
48 : : * 1 Eventdev can have N Eventqueue
49 : : * Soft Event Flow is DPCI Instance
50 : : */
51 : :
52 : : #define DPAA2_EV_TX_RETRY_COUNT 10000
53 : :
54 : : static uint16_t
55 : 0 : dpaa2_eventdev_enqueue_burst(void *port, const struct rte_event ev[],
56 : : uint16_t nb_events)
57 : : {
58 : :
59 : : struct dpaa2_port *dpaa2_portal = port;
60 : : struct dpaa2_dpio_dev *dpio_dev;
61 : 0 : uint32_t queue_id = ev[0].queue_id;
62 : : struct dpaa2_eventq *evq_info;
63 : : uint32_t fqid, retry_count;
64 : : struct qbman_swp *swp;
65 : : struct qbman_fd fd_arr[MAX_TX_RING_SLOTS];
66 : : uint32_t loop, frames_to_send;
67 : : struct qbman_eq_desc eqdesc[MAX_TX_RING_SLOTS];
68 : : uint16_t num_tx = 0;
69 : : int i, n, ret;
70 : : uint8_t channel_index;
71 : :
72 [ # # ]: 0 : if (unlikely(!DPAA2_PER_LCORE_DPIO)) {
73 : : /* Affine current thread context to a qman portal */
74 : 0 : ret = dpaa2_affine_qbman_swp();
75 [ # # ]: 0 : if (ret < 0) {
76 : 0 : DPAA2_EVENTDEV_ERR(
77 : : "Failed to allocate IO portal, tid: %d\n",
78 : : rte_gettid());
79 : 0 : return 0;
80 : : }
81 : : }
82 : : /* todo - dpaa2_portal shall have dpio_dev - no per thread variable */
83 : 0 : dpio_dev = DPAA2_PER_LCORE_DPIO;
84 : 0 : swp = DPAA2_PER_LCORE_PORTAL;
85 : :
86 [ # # ]: 0 : if (likely(dpaa2_portal->is_port_linked))
87 : 0 : goto skip_linking;
88 : :
89 : : /* Create mapping between portal and channel to receive packets */
90 [ # # ]: 0 : for (i = 0; i < DPAA2_EVENT_MAX_QUEUES; i++) {
91 : : evq_info = &dpaa2_portal->evq_info[i];
92 [ # # ]: 0 : if (!evq_info->event_port)
93 : 0 : continue;
94 : :
95 : 0 : ret = dpio_add_static_dequeue_channel(dpio_dev->dpio,
96 : : CMD_PRI_LOW,
97 : 0 : dpio_dev->token,
98 : 0 : evq_info->dpcon->dpcon_id,
99 : : &channel_index);
100 [ # # ]: 0 : if (ret < 0) {
101 : 0 : DPAA2_EVENTDEV_ERR(
102 : : "Static dequeue config failed: err(%d)", ret);
103 : 0 : goto err;
104 : : }
105 : :
106 : 0 : qbman_swp_push_set(swp, channel_index, 1);
107 : 0 : evq_info->dpcon->channel_index = channel_index;
108 : : }
109 : 0 : dpaa2_portal->is_port_linked = true;
110 : :
111 : : skip_linking:
112 : : evq_info = &dpaa2_portal->evq_info[queue_id];
113 : :
114 [ # # ]: 0 : while (nb_events) {
115 : 0 : frames_to_send = (nb_events > dpaa2_eqcr_size) ?
116 [ # # ]: 0 : dpaa2_eqcr_size : nb_events;
117 : :
118 [ # # ]: 0 : for (loop = 0; loop < frames_to_send; loop++) {
119 : 0 : const struct rte_event *event = &ev[num_tx + loop];
120 : :
121 [ # # ]: 0 : if (event->sched_type != RTE_SCHED_TYPE_ATOMIC)
122 : 0 : fqid = evq_info->dpci->rx_queue[
123 : : DPAA2_EVENT_DPCI_PARALLEL_QUEUE].fqid;
124 : : else
125 : 0 : fqid = evq_info->dpci->rx_queue[
126 : : DPAA2_EVENT_DPCI_ATOMIC_QUEUE].fqid;
127 : :
128 : : /* Prepare enqueue descriptor */
129 : 0 : qbman_eq_desc_clear(&eqdesc[loop]);
130 : 0 : qbman_eq_desc_set_fq(&eqdesc[loop], fqid);
131 : 0 : qbman_eq_desc_set_no_orp(&eqdesc[loop], 0);
132 : 0 : qbman_eq_desc_set_response(&eqdesc[loop], 0, 0);
133 : :
134 [ # # ]: 0 : if (event->sched_type == RTE_SCHED_TYPE_ATOMIC
135 [ # # ]: 0 : && *dpaa2_seqn(event->mbuf)) {
136 : 0 : uint8_t dqrr_index =
137 : 0 : *dpaa2_seqn(event->mbuf) - 1;
138 : :
139 : 0 : qbman_eq_desc_set_dca(&eqdesc[loop], 1,
140 : : dqrr_index, 0);
141 : 0 : DPAA2_PER_LCORE_DQRR_SIZE--;
142 : 0 : DPAA2_PER_LCORE_DQRR_HELD &= ~(1 << dqrr_index);
143 : : }
144 : :
145 : 0 : memset(&fd_arr[loop], 0, sizeof(struct qbman_fd));
146 : :
147 : : /*
148 : : * todo - need to align with hw context data
149 : : * to avoid copy
150 : : */
151 : 0 : struct rte_event *ev_temp = rte_malloc(NULL,
152 : : sizeof(struct rte_event), 0);
153 : :
154 [ # # ]: 0 : if (!ev_temp) {
155 [ # # ]: 0 : if (!loop)
156 : 0 : return num_tx;
157 : : frames_to_send = loop;
158 : 0 : DPAA2_EVENTDEV_ERR(
159 : : "Unable to allocate event object");
160 : 0 : goto send_partial;
161 : : }
162 : : rte_memcpy(ev_temp, event, sizeof(struct rte_event));
163 : 0 : DPAA2_SET_FD_ADDR((&fd_arr[loop]), (size_t)ev_temp);
164 : 0 : DPAA2_SET_FD_LEN((&fd_arr[loop]),
165 : : sizeof(struct rte_event));
166 : : }
167 : 0 : send_partial:
168 : : loop = 0;
169 : : retry_count = 0;
170 [ # # ]: 0 : while (loop < frames_to_send) {
171 : 0 : ret = qbman_swp_enqueue_multiple_desc(swp,
172 : 0 : &eqdesc[loop], &fd_arr[loop],
173 : 0 : frames_to_send - loop);
174 [ # # ]: 0 : if (unlikely(ret < 0)) {
175 : 0 : retry_count++;
176 [ # # ]: 0 : if (retry_count > DPAA2_EV_TX_RETRY_COUNT) {
177 : 0 : num_tx += loop;
178 : : nb_events -= loop;
179 : 0 : return num_tx;
180 : : }
181 : : } else {
182 : 0 : loop += ret;
183 : : retry_count = 0;
184 : : }
185 : : }
186 : 0 : num_tx += loop;
187 : 0 : nb_events -= loop;
188 : : }
189 : :
190 : : return num_tx;
191 : : err:
192 [ # # ]: 0 : for (n = 0; n < i; n++) {
193 : : evq_info = &dpaa2_portal->evq_info[n];
194 [ # # ]: 0 : if (!evq_info->event_port)
195 : 0 : continue;
196 : 0 : qbman_swp_push_set(swp, evq_info->dpcon->channel_index, 0);
197 : 0 : dpio_remove_static_dequeue_channel(dpio_dev->dpio, 0,
198 : 0 : dpio_dev->token,
199 : 0 : evq_info->dpcon->dpcon_id);
200 : : }
201 : : return 0;
202 : :
203 : : }
204 : :
205 : : static uint16_t
206 : 0 : dpaa2_eventdev_enqueue(void *port, const struct rte_event *ev)
207 : : {
208 : 0 : return dpaa2_eventdev_enqueue_burst(port, ev, 1);
209 : : }
210 : :
211 : 0 : static void dpaa2_eventdev_dequeue_wait(uint64_t timeout_ticks)
212 : : {
213 : : struct epoll_event epoll_ev;
214 : :
215 : 0 : qbman_swp_interrupt_clear_status(DPAA2_PER_LCORE_PORTAL,
216 : : QBMAN_SWP_INTERRUPT_DQRI);
217 : :
218 : 0 : epoll_wait(DPAA2_PER_LCORE_DPIO->epoll_fd,
219 : : &epoll_ev, 1, timeout_ticks);
220 : 0 : }
221 : :
222 : 0 : static void dpaa2_eventdev_process_parallel(struct qbman_swp *swp,
223 : : const struct qbman_fd *fd,
224 : : const struct qbman_result *dq,
225 : : struct dpaa2_queue *rxq,
226 : : struct rte_event *ev)
227 : : {
228 : 0 : struct rte_event *ev_temp =
229 [ # # ]: 0 : (struct rte_event *)(size_t)DPAA2_GET_FD_ADDR(fd);
230 : :
231 : : RTE_SET_USED(rxq);
232 : :
233 : : rte_memcpy(ev, ev_temp, sizeof(struct rte_event));
234 : 0 : rte_free(ev_temp);
235 : :
236 : 0 : qbman_swp_dqrr_consume(swp, dq);
237 : 0 : }
238 : :
239 : 0 : static void dpaa2_eventdev_process_atomic(struct qbman_swp *swp,
240 : : const struct qbman_fd *fd,
241 : : const struct qbman_result *dq,
242 : : struct dpaa2_queue *rxq,
243 : : struct rte_event *ev)
244 : : {
245 : 0 : struct rte_event *ev_temp =
246 : 0 : (struct rte_event *)(size_t)DPAA2_GET_FD_ADDR(fd);
247 : 0 : uint8_t dqrr_index = qbman_get_dqrr_idx(dq);
248 : :
249 : : RTE_SET_USED(swp);
250 : : RTE_SET_USED(rxq);
251 : :
252 : : rte_memcpy(ev, ev_temp, sizeof(struct rte_event));
253 : 0 : rte_free(ev_temp);
254 : 0 : *dpaa2_seqn(ev->mbuf) = dqrr_index + 1;
255 : 0 : DPAA2_PER_LCORE_DQRR_SIZE++;
256 : 0 : DPAA2_PER_LCORE_DQRR_HELD |= 1 << dqrr_index;
257 : 0 : DPAA2_PER_LCORE_DQRR_MBUF(dqrr_index) = ev->mbuf;
258 : 0 : }
259 : :
260 : : static uint16_t
261 : 0 : dpaa2_eventdev_dequeue_burst(void *port, struct rte_event ev[],
262 : : uint16_t nb_events, uint64_t timeout_ticks)
263 : : {
264 : : const struct qbman_result *dq;
265 : : struct dpaa2_dpio_dev *dpio_dev = NULL;
266 : : struct dpaa2_port *dpaa2_portal = port;
267 : : struct dpaa2_eventq *evq_info;
268 : : struct qbman_swp *swp;
269 : : const struct qbman_fd *fd;
270 : : struct dpaa2_queue *rxq;
271 : : int num_pkts = 0, ret, i = 0, n;
272 : : uint8_t channel_index;
273 : :
274 [ # # ]: 0 : if (unlikely(!DPAA2_PER_LCORE_DPIO)) {
275 : : /* Affine current thread context to a qman portal */
276 : 0 : ret = dpaa2_affine_qbman_swp();
277 [ # # ]: 0 : if (ret < 0) {
278 : 0 : DPAA2_EVENTDEV_ERR(
279 : : "Failed to allocate IO portal, tid: %d\n",
280 : : rte_gettid());
281 : 0 : return 0;
282 : : }
283 : : }
284 : :
285 : 0 : dpio_dev = DPAA2_PER_LCORE_DPIO;
286 : 0 : swp = DPAA2_PER_LCORE_PORTAL;
287 : :
288 [ # # ]: 0 : if (likely(dpaa2_portal->is_port_linked))
289 : 0 : goto skip_linking;
290 : :
291 : : /* Create mapping between portal and channel to receive packets */
292 [ # # ]: 0 : for (i = 0; i < DPAA2_EVENT_MAX_QUEUES; i++) {
293 : : evq_info = &dpaa2_portal->evq_info[i];
294 [ # # ]: 0 : if (!evq_info->event_port)
295 : 0 : continue;
296 : :
297 : 0 : ret = dpio_add_static_dequeue_channel(dpio_dev->dpio,
298 : : CMD_PRI_LOW,
299 : 0 : dpio_dev->token,
300 : 0 : evq_info->dpcon->dpcon_id,
301 : : &channel_index);
302 [ # # ]: 0 : if (ret < 0) {
303 : 0 : DPAA2_EVENTDEV_ERR(
304 : : "Static dequeue config failed: err(%d)", ret);
305 : 0 : goto err;
306 : : }
307 : :
308 : 0 : qbman_swp_push_set(swp, channel_index, 1);
309 : 0 : evq_info->dpcon->channel_index = channel_index;
310 : : }
311 : 0 : dpaa2_portal->is_port_linked = true;
312 : :
313 : : skip_linking:
314 : : /* Check if there are atomic contexts to be released */
315 [ # # ]: 0 : while (DPAA2_PER_LCORE_DQRR_SIZE) {
316 [ # # ]: 0 : if (DPAA2_PER_LCORE_DQRR_HELD & (1 << i)) {
317 : 0 : qbman_swp_dqrr_idx_consume(swp, i);
318 : 0 : DPAA2_PER_LCORE_DQRR_SIZE--;
319 : 0 : *dpaa2_seqn(DPAA2_PER_LCORE_DQRR_MBUF(i)) =
320 : : DPAA2_INVALID_MBUF_SEQN;
321 : : }
322 : 0 : i++;
323 : : }
324 : 0 : DPAA2_PER_LCORE_DQRR_HELD = 0;
325 : :
326 : : do {
327 : 0 : dq = qbman_swp_dqrr_next(swp);
328 [ # # ]: 0 : if (!dq) {
329 [ # # ]: 0 : if (!num_pkts && timeout_ticks) {
330 : 0 : dpaa2_eventdev_dequeue_wait(timeout_ticks);
331 : : timeout_ticks = 0;
332 : 0 : continue;
333 : : }
334 : 0 : return num_pkts;
335 : : }
336 : 0 : qbman_swp_prefetch_dqrr_next(swp);
337 : :
338 : 0 : fd = qbman_result_DQ_fd(dq);
339 : 0 : rxq = (struct dpaa2_queue *)(size_t)qbman_result_DQ_fqd_ctx(dq);
340 [ # # ]: 0 : if (rxq) {
341 : 0 : rxq->cb(swp, fd, dq, rxq, &ev[num_pkts]);
342 : : } else {
343 : 0 : qbman_swp_dqrr_consume(swp, dq);
344 : 0 : DPAA2_EVENTDEV_ERR("Null Return VQ received");
345 : 0 : return 0;
346 : : }
347 : :
348 : 0 : num_pkts++;
349 [ # # ]: 0 : } while (num_pkts < nb_events);
350 : :
351 : 0 : return num_pkts;
352 : : err:
353 [ # # ]: 0 : for (n = 0; n < i; n++) {
354 : : evq_info = &dpaa2_portal->evq_info[n];
355 [ # # ]: 0 : if (!evq_info->event_port)
356 : 0 : continue;
357 : :
358 : 0 : qbman_swp_push_set(swp, evq_info->dpcon->channel_index, 0);
359 : 0 : dpio_remove_static_dequeue_channel(dpio_dev->dpio, 0,
360 : 0 : dpio_dev->token,
361 : 0 : evq_info->dpcon->dpcon_id);
362 : : }
363 : : return 0;
364 : : }
365 : :
366 : : static uint16_t
367 : 0 : dpaa2_eventdev_dequeue(void *port, struct rte_event *ev,
368 : : uint64_t timeout_ticks)
369 : : {
370 : 0 : return dpaa2_eventdev_dequeue_burst(port, ev, 1, timeout_ticks);
371 : : }
372 : :
373 : : static void
374 : 0 : dpaa2_eventdev_info_get(struct rte_eventdev *dev,
375 : : struct rte_event_dev_info *dev_info)
376 : : {
377 : 0 : struct dpaa2_eventdev *priv = dev->data->dev_private;
378 : :
379 : 0 : EVENTDEV_INIT_FUNC_TRACE();
380 : :
381 : : RTE_SET_USED(dev);
382 : :
383 : : memset(dev_info, 0, sizeof(struct rte_event_dev_info));
384 : 0 : dev_info->min_dequeue_timeout_ns =
385 : : DPAA2_EVENT_MIN_DEQUEUE_TIMEOUT;
386 : 0 : dev_info->max_dequeue_timeout_ns =
387 : : DPAA2_EVENT_MAX_DEQUEUE_TIMEOUT;
388 : 0 : dev_info->dequeue_timeout_ns =
389 : : DPAA2_EVENT_PORT_DEQUEUE_TIMEOUT_NS;
390 : 0 : dev_info->max_event_queues = priv->max_event_queues;
391 : 0 : dev_info->max_event_queue_flows =
392 : : DPAA2_EVENT_MAX_QUEUE_FLOWS;
393 : 0 : dev_info->max_event_queue_priority_levels =
394 : : DPAA2_EVENT_MAX_QUEUE_PRIORITY_LEVELS;
395 : : dev_info->max_event_priority_levels =
396 : : DPAA2_EVENT_MAX_EVENT_PRIORITY_LEVELS;
397 : 0 : dev_info->max_event_ports = rte_fslmc_get_device_count(DPAA2_IO);
398 : : /* we only support dpio up to number of cores */
399 [ # # ]: 0 : if (dev_info->max_event_ports > rte_lcore_count())
400 : 0 : dev_info->max_event_ports = rte_lcore_count();
401 : 0 : dev_info->max_event_port_dequeue_depth =
402 : : DPAA2_EVENT_MAX_PORT_DEQUEUE_DEPTH;
403 : 0 : dev_info->max_event_port_enqueue_depth =
404 : : DPAA2_EVENT_MAX_PORT_ENQUEUE_DEPTH;
405 : 0 : dev_info->max_num_events = DPAA2_EVENT_MAX_NUM_EVENTS;
406 : 0 : dev_info->event_dev_cap = RTE_EVENT_DEV_CAP_DISTRIBUTED_SCHED |
407 : : RTE_EVENT_DEV_CAP_ATOMIC |
408 : : RTE_EVENT_DEV_CAP_PARALLEL |
409 : : RTE_EVENT_DEV_CAP_BURST_MODE|
410 : : RTE_EVENT_DEV_CAP_RUNTIME_PORT_LINK |
411 : : RTE_EVENT_DEV_CAP_MULTIPLE_QUEUE_PORT |
412 : : RTE_EVENT_DEV_CAP_NONSEQ_MODE |
413 : : RTE_EVENT_DEV_CAP_QUEUE_ALL_TYPES |
414 : : RTE_EVENT_DEV_CAP_CARRY_FLOW_ID |
415 : : RTE_EVENT_DEV_CAP_MAINTENANCE_FREE;
416 : 0 : dev_info->max_profiles_per_port = 1;
417 : 0 : }
418 : :
419 : : static int
420 : 0 : dpaa2_eventdev_configure(const struct rte_eventdev *dev)
421 : : {
422 : 0 : struct dpaa2_eventdev *priv = dev->data->dev_private;
423 : : struct rte_event_dev_config *conf = &dev->data->dev_conf;
424 : :
425 : 0 : EVENTDEV_INIT_FUNC_TRACE();
426 : :
427 : 0 : priv->nb_event_queues = conf->nb_event_queues;
428 : 0 : priv->nb_event_ports = conf->nb_event_ports;
429 : 0 : priv->nb_event_queue_flows = conf->nb_event_queue_flows;
430 : 0 : priv->nb_event_port_dequeue_depth = conf->nb_event_port_dequeue_depth;
431 : 0 : priv->nb_event_port_enqueue_depth = conf->nb_event_port_enqueue_depth;
432 : 0 : priv->event_dev_cfg = conf->event_dev_cfg;
433 : :
434 : : /* Check dequeue timeout method is per dequeue or global */
435 [ # # ]: 0 : if (priv->event_dev_cfg & RTE_EVENT_DEV_CFG_PER_DEQUEUE_TIMEOUT) {
436 : : /*
437 : : * Use timeout value as given in dequeue operation.
438 : : * So invalidating this timeout value.
439 : : */
440 : 0 : priv->dequeue_timeout_ns = 0;
441 : :
442 [ # # ]: 0 : } else if (conf->dequeue_timeout_ns == 0) {
443 : 0 : priv->dequeue_timeout_ns = DPAA2_EVENT_PORT_DEQUEUE_TIMEOUT_NS;
444 : : } else {
445 : 0 : priv->dequeue_timeout_ns = conf->dequeue_timeout_ns;
446 : : }
447 : :
448 : 0 : DPAA2_EVENTDEV_DEBUG("Configured eventdev devid=%d",
449 : : dev->data->dev_id);
450 : 0 : return 0;
451 : : }
452 : :
453 : : static int
454 : 0 : dpaa2_eventdev_start(struct rte_eventdev *dev)
455 : : {
456 : 0 : EVENTDEV_INIT_FUNC_TRACE();
457 : :
458 : : RTE_SET_USED(dev);
459 : :
460 : 0 : return 0;
461 : : }
462 : :
463 : : static void
464 : 0 : dpaa2_eventdev_stop(struct rte_eventdev *dev)
465 : : {
466 : 0 : EVENTDEV_INIT_FUNC_TRACE();
467 : :
468 : : RTE_SET_USED(dev);
469 : 0 : }
470 : :
471 : : static int
472 : 0 : dpaa2_eventdev_close(struct rte_eventdev *dev)
473 : : {
474 : 0 : EVENTDEV_INIT_FUNC_TRACE();
475 : :
476 : : RTE_SET_USED(dev);
477 : :
478 : 0 : return 0;
479 : : }
480 : :
481 : : static void
482 : 0 : dpaa2_eventdev_queue_def_conf(struct rte_eventdev *dev, uint8_t queue_id,
483 : : struct rte_event_queue_conf *queue_conf)
484 : : {
485 : 0 : EVENTDEV_INIT_FUNC_TRACE();
486 : :
487 : : RTE_SET_USED(dev);
488 : : RTE_SET_USED(queue_id);
489 : :
490 : 0 : queue_conf->nb_atomic_flows = DPAA2_EVENT_QUEUE_ATOMIC_FLOWS;
491 : 0 : queue_conf->nb_atomic_order_sequences =
492 : : DPAA2_EVENT_QUEUE_ORDER_SEQUENCES;
493 : 0 : queue_conf->schedule_type = RTE_SCHED_TYPE_PARALLEL;
494 : 0 : queue_conf->priority = RTE_EVENT_DEV_PRIORITY_NORMAL;
495 : 0 : }
496 : :
497 : : static int
498 : 0 : dpaa2_eventdev_queue_setup(struct rte_eventdev *dev, uint8_t queue_id,
499 : : const struct rte_event_queue_conf *queue_conf)
500 : : {
501 : 0 : struct dpaa2_eventdev *priv = dev->data->dev_private;
502 : 0 : struct dpaa2_eventq *evq_info = &priv->evq_info[queue_id];
503 : :
504 : 0 : EVENTDEV_INIT_FUNC_TRACE();
505 : :
506 [ # # ]: 0 : switch (queue_conf->schedule_type) {
507 : : case RTE_SCHED_TYPE_PARALLEL:
508 : : case RTE_SCHED_TYPE_ATOMIC:
509 : : case RTE_SCHED_TYPE_ORDERED:
510 : : break;
511 : 0 : default:
512 : 0 : DPAA2_EVENTDEV_ERR("Schedule type is not supported.");
513 : 0 : return -1;
514 : : }
515 : 0 : evq_info->event_queue_cfg = queue_conf->event_queue_cfg;
516 : 0 : evq_info->event_queue_id = queue_id;
517 : :
518 : 0 : return 0;
519 : : }
520 : :
521 : : static void
522 : 0 : dpaa2_eventdev_queue_release(struct rte_eventdev *dev, uint8_t queue_id)
523 : : {
524 : 0 : EVENTDEV_INIT_FUNC_TRACE();
525 : :
526 : : RTE_SET_USED(dev);
527 : : RTE_SET_USED(queue_id);
528 : 0 : }
529 : :
530 : : static void
531 : 0 : dpaa2_eventdev_port_def_conf(struct rte_eventdev *dev, uint8_t port_id,
532 : : struct rte_event_port_conf *port_conf)
533 : : {
534 : 0 : EVENTDEV_INIT_FUNC_TRACE();
535 : :
536 : : RTE_SET_USED(dev);
537 : : RTE_SET_USED(port_id);
538 : :
539 : 0 : port_conf->new_event_threshold =
540 : : DPAA2_EVENT_MAX_NUM_EVENTS;
541 : 0 : port_conf->dequeue_depth =
542 : : DPAA2_EVENT_MAX_PORT_DEQUEUE_DEPTH;
543 : 0 : port_conf->enqueue_depth =
544 : : DPAA2_EVENT_MAX_PORT_ENQUEUE_DEPTH;
545 : 0 : port_conf->event_port_cfg = 0;
546 : 0 : }
547 : :
548 : : static int
549 : 0 : dpaa2_eventdev_port_setup(struct rte_eventdev *dev, uint8_t port_id,
550 : : const struct rte_event_port_conf *port_conf)
551 : : {
552 : : char event_port_name[32];
553 : : struct dpaa2_port *portal;
554 : :
555 : 0 : EVENTDEV_INIT_FUNC_TRACE();
556 : :
557 : : RTE_SET_USED(port_conf);
558 : :
559 : 0 : sprintf(event_port_name, "event-port-%d", port_id);
560 : 0 : portal = rte_malloc(event_port_name, sizeof(struct dpaa2_port), 0);
561 [ # # ]: 0 : if (!portal) {
562 : 0 : DPAA2_EVENTDEV_ERR("Memory allocation failure");
563 : 0 : return -ENOMEM;
564 : : }
565 : :
566 : : memset(portal, 0, sizeof(struct dpaa2_port));
567 : 0 : dev->data->ports[port_id] = portal;
568 : 0 : return 0;
569 : : }
570 : :
571 : : static void
572 : 0 : dpaa2_eventdev_port_release(void *port)
573 : : {
574 : : struct dpaa2_port *portal = port;
575 : :
576 : 0 : EVENTDEV_INIT_FUNC_TRACE();
577 : :
578 [ # # ]: 0 : if (portal == NULL)
579 : : return;
580 : :
581 : : /* TODO: Cleanup is required when ports are in linked state. */
582 [ # # ]: 0 : if (portal->is_port_linked)
583 : 0 : DPAA2_EVENTDEV_WARN("Event port must be unlinked before release");
584 : :
585 : 0 : rte_free(portal);
586 : : }
587 : :
588 : : static int
589 : 0 : dpaa2_eventdev_port_link(struct rte_eventdev *dev, void *port,
590 : : const uint8_t queues[], const uint8_t priorities[],
591 : : uint16_t nb_links)
592 : : {
593 : 0 : struct dpaa2_eventdev *priv = dev->data->dev_private;
594 : : struct dpaa2_port *dpaa2_portal = port;
595 : : struct dpaa2_eventq *evq_info;
596 : : uint16_t i;
597 : :
598 : 0 : EVENTDEV_INIT_FUNC_TRACE();
599 : :
600 : : RTE_SET_USED(priorities);
601 : :
602 [ # # ]: 0 : for (i = 0; i < nb_links; i++) {
603 : 0 : evq_info = &priv->evq_info[queues[i]];
604 : 0 : memcpy(&dpaa2_portal->evq_info[queues[i]], evq_info,
605 : : sizeof(struct dpaa2_eventq));
606 : 0 : dpaa2_portal->evq_info[queues[i]].event_port = port;
607 : 0 : dpaa2_portal->num_linked_evq++;
608 : : }
609 : :
610 : 0 : return (int)nb_links;
611 : : }
612 : :
613 : : static int
614 : 0 : dpaa2_eventdev_port_unlink(struct rte_eventdev *dev, void *port,
615 : : uint8_t queues[], uint16_t nb_unlinks)
616 : : {
617 : : struct dpaa2_port *dpaa2_portal = port;
618 : : int i;
619 : : struct dpaa2_dpio_dev *dpio_dev = NULL;
620 : : struct dpaa2_eventq *evq_info;
621 : : struct qbman_swp *swp;
622 : :
623 : 0 : EVENTDEV_INIT_FUNC_TRACE();
624 : :
625 : : RTE_SET_USED(dev);
626 : : RTE_SET_USED(queues);
627 : :
628 [ # # ]: 0 : for (i = 0; i < nb_unlinks; i++) {
629 : 0 : evq_info = &dpaa2_portal->evq_info[queues[i]];
630 : :
631 [ # # # # ]: 0 : if (DPAA2_PER_LCORE_DPIO && evq_info->dpcon) {
632 : : /* todo dpaa2_portal shall have dpio_dev-no per lcore*/
633 : : dpio_dev = DPAA2_PER_LCORE_DPIO;
634 : 0 : swp = DPAA2_PER_LCORE_PORTAL;
635 : :
636 : 0 : qbman_swp_push_set(swp,
637 : 0 : evq_info->dpcon->channel_index, 0);
638 : 0 : dpio_remove_static_dequeue_channel(dpio_dev->dpio, 0,
639 : 0 : dpio_dev->token,
640 : 0 : evq_info->dpcon->dpcon_id);
641 : : }
642 : : memset(evq_info, 0, sizeof(struct dpaa2_eventq));
643 [ # # ]: 0 : if (dpaa2_portal->num_linked_evq)
644 : 0 : dpaa2_portal->num_linked_evq--;
645 : : }
646 : :
647 [ # # ]: 0 : if (!dpaa2_portal->num_linked_evq)
648 : 0 : dpaa2_portal->is_port_linked = false;
649 : :
650 : 0 : return (int)nb_unlinks;
651 : : }
652 : :
653 : :
654 : : static int
655 : 0 : dpaa2_eventdev_timeout_ticks(struct rte_eventdev *dev, uint64_t ns,
656 : : uint64_t *timeout_ticks)
657 : : {
658 : : uint32_t scale = 1000*1000;
659 : :
660 : 0 : EVENTDEV_INIT_FUNC_TRACE();
661 : :
662 : : RTE_SET_USED(dev);
663 : 0 : *timeout_ticks = ns / scale;
664 : :
665 : 0 : return 0;
666 : : }
667 : :
668 : : static void
669 : 0 : dpaa2_eventdev_dump(struct rte_eventdev *dev, FILE *f)
670 : : {
671 : 0 : EVENTDEV_INIT_FUNC_TRACE();
672 : :
673 : : RTE_SET_USED(dev);
674 : : RTE_SET_USED(f);
675 : 0 : }
676 : :
677 : : static int
678 : 0 : dpaa2_eventdev_eth_caps_get(const struct rte_eventdev *dev,
679 : : const struct rte_eth_dev *eth_dev,
680 : : uint32_t *caps)
681 : : {
682 : 0 : const char *ethdev_driver = eth_dev->device->driver->name;
683 : :
684 : 0 : EVENTDEV_INIT_FUNC_TRACE();
685 : :
686 : : RTE_SET_USED(dev);
687 : :
688 [ # # ]: 0 : if (!strcmp(ethdev_driver, "net_dpaa2"))
689 : 0 : *caps = RTE_EVENT_ETH_RX_ADAPTER_DPAA2_CAP;
690 : : else
691 : 0 : *caps = RTE_EVENT_ETH_RX_ADAPTER_SW_CAP;
692 : :
693 : 0 : return 0;
694 : : }
695 : :
696 : : static int
697 : 0 : dpaa2_eventdev_eth_queue_add_all(const struct rte_eventdev *dev,
698 : : const struct rte_eth_dev *eth_dev,
699 : : const struct rte_event_eth_rx_adapter_queue_conf *queue_conf)
700 : : {
701 : 0 : struct dpaa2_eventdev *priv = dev->data->dev_private;
702 : 0 : uint8_t ev_qid = queue_conf->ev.queue_id;
703 : 0 : struct dpaa2_dpcon_dev *dpcon = priv->evq_info[ev_qid].dpcon;
704 : : int i, ret;
705 : :
706 : 0 : EVENTDEV_INIT_FUNC_TRACE();
707 : :
708 [ # # ]: 0 : for (i = 0; i < eth_dev->data->nb_rx_queues; i++) {
709 : 0 : ret = dpaa2_eth_eventq_attach(eth_dev, i,
710 : : dpcon, queue_conf);
711 [ # # ]: 0 : if (ret) {
712 : 0 : DPAA2_EVENTDEV_ERR(
713 : : "Event queue attach failed: err(%d)", ret);
714 : 0 : goto fail;
715 : : }
716 : : }
717 : : return 0;
718 : : fail:
719 [ # # ]: 0 : for (i = (i - 1); i >= 0 ; i--)
720 : 0 : dpaa2_eth_eventq_detach(eth_dev, i);
721 : :
722 : : return ret;
723 : : }
724 : :
725 : : static int
726 : 0 : dpaa2_eventdev_eth_queue_add(const struct rte_eventdev *dev,
727 : : const struct rte_eth_dev *eth_dev,
728 : : int32_t rx_queue_id,
729 : : const struct rte_event_eth_rx_adapter_queue_conf *queue_conf)
730 : : {
731 : 0 : struct dpaa2_eventdev *priv = dev->data->dev_private;
732 : 0 : uint8_t ev_qid = queue_conf->ev.queue_id;
733 : 0 : struct dpaa2_dpcon_dev *dpcon = priv->evq_info[ev_qid].dpcon;
734 : : int ret;
735 : :
736 : 0 : EVENTDEV_INIT_FUNC_TRACE();
737 : :
738 [ # # ]: 0 : if (rx_queue_id == -1)
739 : 0 : return dpaa2_eventdev_eth_queue_add_all(dev,
740 : : eth_dev, queue_conf);
741 : :
742 : 0 : ret = dpaa2_eth_eventq_attach(eth_dev, rx_queue_id,
743 : : dpcon, queue_conf);
744 [ # # ]: 0 : if (ret) {
745 : 0 : DPAA2_EVENTDEV_ERR(
746 : : "Event queue attach failed: err(%d)", ret);
747 : 0 : return ret;
748 : : }
749 : : return 0;
750 : : }
751 : :
752 : : static int
753 : 0 : dpaa2_eventdev_eth_queue_del_all(const struct rte_eventdev *dev,
754 : : const struct rte_eth_dev *eth_dev)
755 : : {
756 : : int i, ret;
757 : :
758 : 0 : EVENTDEV_INIT_FUNC_TRACE();
759 : :
760 : : RTE_SET_USED(dev);
761 : :
762 [ # # ]: 0 : for (i = 0; i < eth_dev->data->nb_rx_queues; i++) {
763 : 0 : ret = dpaa2_eth_eventq_detach(eth_dev, i);
764 [ # # ]: 0 : if (ret) {
765 : 0 : DPAA2_EVENTDEV_ERR(
766 : : "Event queue detach failed: err(%d)", ret);
767 : 0 : return ret;
768 : : }
769 : : }
770 : :
771 : : return 0;
772 : : }
773 : :
774 : : static int
775 : 0 : dpaa2_eventdev_eth_queue_del(const struct rte_eventdev *dev,
776 : : const struct rte_eth_dev *eth_dev,
777 : : int32_t rx_queue_id)
778 : : {
779 : : int ret;
780 : :
781 : 0 : EVENTDEV_INIT_FUNC_TRACE();
782 : :
783 [ # # ]: 0 : if (rx_queue_id == -1)
784 : 0 : return dpaa2_eventdev_eth_queue_del_all(dev, eth_dev);
785 : :
786 : 0 : ret = dpaa2_eth_eventq_detach(eth_dev, rx_queue_id);
787 [ # # ]: 0 : if (ret) {
788 : 0 : DPAA2_EVENTDEV_ERR(
789 : : "Event queue detach failed: err(%d)", ret);
790 : 0 : return ret;
791 : : }
792 : :
793 : : return 0;
794 : : }
795 : :
796 : : static int
797 : 0 : dpaa2_eventdev_eth_start(const struct rte_eventdev *dev,
798 : : const struct rte_eth_dev *eth_dev)
799 : : {
800 : 0 : EVENTDEV_INIT_FUNC_TRACE();
801 : :
802 : : RTE_SET_USED(dev);
803 : : RTE_SET_USED(eth_dev);
804 : :
805 : 0 : return 0;
806 : : }
807 : :
808 : : static int
809 : 0 : dpaa2_eventdev_eth_stop(const struct rte_eventdev *dev,
810 : : const struct rte_eth_dev *eth_dev)
811 : : {
812 : 0 : EVENTDEV_INIT_FUNC_TRACE();
813 : :
814 : : RTE_SET_USED(dev);
815 : : RTE_SET_USED(eth_dev);
816 : :
817 : 0 : return 0;
818 : : }
819 : :
820 : : static int
821 : 0 : dpaa2_eventdev_crypto_caps_get(const struct rte_eventdev *dev,
822 : : const struct rte_cryptodev *cdev,
823 : : uint32_t *caps)
824 : : {
825 : 0 : const char *name = cdev->data->name;
826 : :
827 : 0 : EVENTDEV_INIT_FUNC_TRACE();
828 : :
829 : : RTE_SET_USED(dev);
830 : :
831 [ # # ]: 0 : if (!strncmp(name, "dpsec-", 6))
832 : 0 : *caps = RTE_EVENT_CRYPTO_ADAPTER_DPAA2_CAP;
833 : : else
834 : : return -1;
835 : :
836 : 0 : return 0;
837 : : }
838 : :
839 : : static int
840 : 0 : dpaa2_eventdev_crypto_queue_add_all(const struct rte_eventdev *dev,
841 : : const struct rte_cryptodev *cryptodev,
842 : : const struct rte_event *ev)
843 : : {
844 : 0 : struct dpaa2_eventdev *priv = dev->data->dev_private;
845 : 0 : uint8_t ev_qid = ev->queue_id;
846 : 0 : struct dpaa2_dpcon_dev *dpcon = priv->evq_info[ev_qid].dpcon;
847 : : int i, ret;
848 : :
849 : 0 : EVENTDEV_INIT_FUNC_TRACE();
850 : :
851 [ # # ]: 0 : for (i = 0; i < cryptodev->data->nb_queue_pairs; i++) {
852 : 0 : ret = dpaa2_sec_eventq_attach(cryptodev, i, dpcon, ev);
853 [ # # ]: 0 : if (ret) {
854 : 0 : DPAA2_EVENTDEV_ERR("dpaa2_sec_eventq_attach failed: ret %d\n",
855 : : ret);
856 : 0 : goto fail;
857 : : }
858 : : }
859 : : return 0;
860 : : fail:
861 [ # # ]: 0 : for (i = (i - 1); i >= 0 ; i--)
862 : 0 : dpaa2_sec_eventq_detach(cryptodev, i);
863 : :
864 : : return ret;
865 : : }
866 : :
867 : : static int
868 : 0 : dpaa2_eventdev_crypto_queue_add(const struct rte_eventdev *dev,
869 : : const struct rte_cryptodev *cryptodev,
870 : : int32_t rx_queue_id,
871 : : const struct rte_event_crypto_adapter_queue_conf *conf)
872 : : {
873 : 0 : struct dpaa2_eventdev *priv = dev->data->dev_private;
874 : 0 : uint8_t ev_qid = conf->ev.queue_id;
875 : 0 : struct dpaa2_dpcon_dev *dpcon = priv->evq_info[ev_qid].dpcon;
876 : : int ret;
877 : :
878 : 0 : EVENTDEV_INIT_FUNC_TRACE();
879 : :
880 [ # # ]: 0 : if (rx_queue_id == -1)
881 : 0 : return dpaa2_eventdev_crypto_queue_add_all(dev,
882 : : cryptodev, &conf->ev);
883 : :
884 : 0 : ret = dpaa2_sec_eventq_attach(cryptodev, rx_queue_id,
885 : : dpcon, &conf->ev);
886 [ # # ]: 0 : if (ret) {
887 : 0 : DPAA2_EVENTDEV_ERR(
888 : : "dpaa2_sec_eventq_attach failed: ret: %d\n", ret);
889 : 0 : return ret;
890 : : }
891 : : return 0;
892 : : }
893 : :
894 : : static int
895 : 0 : dpaa2_eventdev_crypto_queue_del_all(const struct rte_eventdev *dev,
896 : : const struct rte_cryptodev *cdev)
897 : : {
898 : : int i, ret;
899 : :
900 : 0 : EVENTDEV_INIT_FUNC_TRACE();
901 : :
902 : : RTE_SET_USED(dev);
903 : :
904 [ # # ]: 0 : for (i = 0; i < cdev->data->nb_queue_pairs; i++) {
905 : 0 : ret = dpaa2_sec_eventq_detach(cdev, i);
906 [ # # ]: 0 : if (ret) {
907 : 0 : DPAA2_EVENTDEV_ERR(
908 : : "dpaa2_sec_eventq_detach failed:ret %d\n", ret);
909 : 0 : return ret;
910 : : }
911 : : }
912 : :
913 : : return 0;
914 : : }
915 : :
916 : : static int
917 : 0 : dpaa2_eventdev_crypto_queue_del(const struct rte_eventdev *dev,
918 : : const struct rte_cryptodev *cryptodev,
919 : : int32_t rx_queue_id)
920 : : {
921 : : int ret;
922 : :
923 : 0 : EVENTDEV_INIT_FUNC_TRACE();
924 : :
925 [ # # ]: 0 : if (rx_queue_id == -1)
926 : 0 : return dpaa2_eventdev_crypto_queue_del_all(dev, cryptodev);
927 : :
928 : 0 : ret = dpaa2_sec_eventq_detach(cryptodev, rx_queue_id);
929 [ # # ]: 0 : if (ret) {
930 : 0 : DPAA2_EVENTDEV_ERR(
931 : : "dpaa2_sec_eventq_detach failed: ret: %d\n", ret);
932 : 0 : return ret;
933 : : }
934 : :
935 : : return 0;
936 : : }
937 : :
938 : : static int
939 : 0 : dpaa2_eventdev_crypto_start(const struct rte_eventdev *dev,
940 : : const struct rte_cryptodev *cryptodev)
941 : : {
942 : 0 : EVENTDEV_INIT_FUNC_TRACE();
943 : :
944 : : RTE_SET_USED(dev);
945 : : RTE_SET_USED(cryptodev);
946 : :
947 : 0 : return 0;
948 : : }
949 : :
950 : : static int
951 : 0 : dpaa2_eventdev_crypto_stop(const struct rte_eventdev *dev,
952 : : const struct rte_cryptodev *cryptodev)
953 : : {
954 : 0 : EVENTDEV_INIT_FUNC_TRACE();
955 : :
956 : : RTE_SET_USED(dev);
957 : : RTE_SET_USED(cryptodev);
958 : :
959 : 0 : return 0;
960 : : }
961 : :
962 : : static int
963 : 0 : dpaa2_eventdev_tx_adapter_create(uint8_t id,
964 : : const struct rte_eventdev *dev)
965 : : {
966 : : RTE_SET_USED(id);
967 : : RTE_SET_USED(dev);
968 : :
969 : : /* Nothing to do. Simply return. */
970 : 0 : return 0;
971 : : }
972 : :
973 : : static int
974 : 0 : dpaa2_eventdev_tx_adapter_caps(const struct rte_eventdev *dev,
975 : : const struct rte_eth_dev *eth_dev,
976 : : uint32_t *caps)
977 : : {
978 : : RTE_SET_USED(dev);
979 : : RTE_SET_USED(eth_dev);
980 : :
981 : 0 : *caps = RTE_EVENT_ETH_TX_ADAPTER_CAP_INTERNAL_PORT;
982 : 0 : return 0;
983 : : }
984 : :
985 : : static uint16_t
986 : 0 : dpaa2_eventdev_txa_enqueue_same_dest(void *port,
987 : : struct rte_event ev[],
988 : : uint16_t nb_events)
989 : : {
990 : : struct rte_mbuf *m[DPAA2_EVENT_MAX_PORT_ENQUEUE_DEPTH], *m0;
991 : : uint8_t qid, i;
992 : :
993 : : RTE_SET_USED(port);
994 : :
995 : 0 : m0 = (struct rte_mbuf *)ev[0].mbuf;
996 : 0 : qid = rte_event_eth_tx_adapter_txq_get(m0);
997 : :
998 [ # # ]: 0 : for (i = 0; i < nb_events; i++)
999 : 0 : m[i] = (struct rte_mbuf *)ev[i].mbuf;
1000 : :
1001 : 0 : return rte_eth_tx_burst(m0->port, qid, m, nb_events);
1002 : : }
1003 : :
1004 : : static uint16_t
1005 : 0 : dpaa2_eventdev_txa_enqueue(void *port,
1006 : : struct rte_event ev[],
1007 : : uint16_t nb_events)
1008 : : {
1009 : : void *txq[DPAA2_EVENT_MAX_PORT_ENQUEUE_DEPTH];
1010 : : struct rte_mbuf *m[DPAA2_EVENT_MAX_PORT_ENQUEUE_DEPTH];
1011 : : uint8_t qid, i;
1012 : :
1013 : : RTE_SET_USED(port);
1014 : :
1015 [ # # ]: 0 : for (i = 0; i < nb_events; i++) {
1016 : 0 : m[i] = (struct rte_mbuf *)ev[i].mbuf;
1017 : 0 : qid = rte_event_eth_tx_adapter_txq_get(m[i]);
1018 : 0 : txq[i] = rte_eth_devices[m[i]->port].data->tx_queues[qid];
1019 : : }
1020 : :
1021 : 0 : return dpaa2_dev_tx_multi_txq_ordered(txq, m, nb_events);
1022 : : }
1023 : :
1024 : : static struct eventdev_ops dpaa2_eventdev_ops = {
1025 : : .dev_infos_get = dpaa2_eventdev_info_get,
1026 : : .dev_configure = dpaa2_eventdev_configure,
1027 : : .dev_start = dpaa2_eventdev_start,
1028 : : .dev_stop = dpaa2_eventdev_stop,
1029 : : .dev_close = dpaa2_eventdev_close,
1030 : : .queue_def_conf = dpaa2_eventdev_queue_def_conf,
1031 : : .queue_setup = dpaa2_eventdev_queue_setup,
1032 : : .queue_release = dpaa2_eventdev_queue_release,
1033 : : .port_def_conf = dpaa2_eventdev_port_def_conf,
1034 : : .port_setup = dpaa2_eventdev_port_setup,
1035 : : .port_release = dpaa2_eventdev_port_release,
1036 : : .port_link = dpaa2_eventdev_port_link,
1037 : : .port_unlink = dpaa2_eventdev_port_unlink,
1038 : : .timeout_ticks = dpaa2_eventdev_timeout_ticks,
1039 : : .dump = dpaa2_eventdev_dump,
1040 : : .dev_selftest = test_eventdev_dpaa2,
1041 : : .eth_rx_adapter_caps_get = dpaa2_eventdev_eth_caps_get,
1042 : : .eth_rx_adapter_queue_add = dpaa2_eventdev_eth_queue_add,
1043 : : .eth_rx_adapter_queue_del = dpaa2_eventdev_eth_queue_del,
1044 : : .eth_rx_adapter_start = dpaa2_eventdev_eth_start,
1045 : : .eth_rx_adapter_stop = dpaa2_eventdev_eth_stop,
1046 : : .eth_tx_adapter_caps_get = dpaa2_eventdev_tx_adapter_caps,
1047 : : .eth_tx_adapter_create = dpaa2_eventdev_tx_adapter_create,
1048 : : .crypto_adapter_caps_get = dpaa2_eventdev_crypto_caps_get,
1049 : : .crypto_adapter_queue_pair_add = dpaa2_eventdev_crypto_queue_add,
1050 : : .crypto_adapter_queue_pair_del = dpaa2_eventdev_crypto_queue_del,
1051 : : .crypto_adapter_start = dpaa2_eventdev_crypto_start,
1052 : : .crypto_adapter_stop = dpaa2_eventdev_crypto_stop,
1053 : : };
1054 : :
1055 : : static int
1056 : 0 : dpaa2_eventdev_setup_dpci(struct dpaa2_dpci_dev *dpci_dev,
1057 : : struct dpaa2_dpcon_dev *dpcon_dev)
1058 : : {
1059 : : struct dpci_rx_queue_cfg rx_queue_cfg;
1060 : : int ret, i;
1061 : :
1062 : : /*Do settings to get the frame on a DPCON object*/
1063 : 0 : rx_queue_cfg.options = DPCI_QUEUE_OPT_DEST |
1064 : : DPCI_QUEUE_OPT_USER_CTX;
1065 : 0 : rx_queue_cfg.dest_cfg.dest_type = DPCI_DEST_DPCON;
1066 : 0 : rx_queue_cfg.dest_cfg.dest_id = dpcon_dev->dpcon_id;
1067 : 0 : rx_queue_cfg.dest_cfg.priority = DPAA2_EVENT_DEFAULT_DPCI_PRIO;
1068 : :
1069 : 0 : dpci_dev->rx_queue[DPAA2_EVENT_DPCI_PARALLEL_QUEUE].cb =
1070 : : dpaa2_eventdev_process_parallel;
1071 : 0 : dpci_dev->rx_queue[DPAA2_EVENT_DPCI_ATOMIC_QUEUE].cb =
1072 : : dpaa2_eventdev_process_atomic;
1073 : :
1074 [ # # ]: 0 : for (i = 0 ; i < DPAA2_EVENT_DPCI_MAX_QUEUES; i++) {
1075 : 0 : rx_queue_cfg.user_ctx = (size_t)(&dpci_dev->rx_queue[i]);
1076 : 0 : ret = dpci_set_rx_queue(&dpci_dev->dpci,
1077 : : CMD_PRI_LOW,
1078 : 0 : dpci_dev->token, i,
1079 : : &rx_queue_cfg);
1080 [ # # ]: 0 : if (ret) {
1081 : 0 : DPAA2_EVENTDEV_ERR(
1082 : : "DPCI Rx queue setup failed: err(%d)",
1083 : : ret);
1084 : 0 : return ret;
1085 : : }
1086 : : }
1087 : : return 0;
1088 : : }
1089 : :
1090 : : static int
1091 : 0 : dpaa2_eventdev_create(const char *name, struct rte_vdev_device *vdev)
1092 : : {
1093 : : struct rte_eventdev *eventdev;
1094 : : struct dpaa2_eventdev *priv;
1095 : : struct dpaa2_dpcon_dev *dpcon_dev = NULL;
1096 : : struct dpaa2_dpci_dev *dpci_dev = NULL;
1097 : : int ret;
1098 : :
1099 : 0 : eventdev = rte_event_pmd_vdev_init(name,
1100 : : sizeof(struct dpaa2_eventdev),
1101 : 0 : rte_socket_id(), vdev);
1102 [ # # ]: 0 : if (eventdev == NULL) {
1103 : 0 : DPAA2_EVENTDEV_ERR("Failed to create Event device %s", name);
1104 : 0 : goto fail;
1105 : : }
1106 : :
1107 : 0 : eventdev->dev_ops = &dpaa2_eventdev_ops;
1108 : 0 : eventdev->enqueue = dpaa2_eventdev_enqueue;
1109 : 0 : eventdev->enqueue_burst = dpaa2_eventdev_enqueue_burst;
1110 : 0 : eventdev->enqueue_new_burst = dpaa2_eventdev_enqueue_burst;
1111 : 0 : eventdev->enqueue_forward_burst = dpaa2_eventdev_enqueue_burst;
1112 : 0 : eventdev->dequeue = dpaa2_eventdev_dequeue;
1113 : 0 : eventdev->dequeue_burst = dpaa2_eventdev_dequeue_burst;
1114 : 0 : eventdev->txa_enqueue = dpaa2_eventdev_txa_enqueue;
1115 : 0 : eventdev->txa_enqueue_same_dest = dpaa2_eventdev_txa_enqueue_same_dest;
1116 : :
1117 : : /* For secondary processes, the primary has done all the work */
1118 [ # # ]: 0 : if (rte_eal_process_type() != RTE_PROC_PRIMARY)
1119 : 0 : goto done;
1120 : :
1121 : 0 : priv = eventdev->data->dev_private;
1122 : 0 : priv->max_event_queues = 0;
1123 : :
1124 : : do {
1125 : 0 : dpcon_dev = rte_dpaa2_alloc_dpcon_dev();
1126 [ # # ]: 0 : if (!dpcon_dev)
1127 : : break;
1128 : 0 : priv->evq_info[priv->max_event_queues].dpcon = dpcon_dev;
1129 : :
1130 : 0 : dpci_dev = rte_dpaa2_alloc_dpci_dev();
1131 [ # # ]: 0 : if (!dpci_dev) {
1132 : 0 : rte_dpaa2_free_dpcon_dev(dpcon_dev);
1133 : 0 : break;
1134 : : }
1135 : 0 : priv->evq_info[priv->max_event_queues].dpci = dpci_dev;
1136 : :
1137 : 0 : ret = dpaa2_eventdev_setup_dpci(dpci_dev, dpcon_dev);
1138 [ # # ]: 0 : if (ret) {
1139 : 0 : DPAA2_EVENTDEV_ERR(
1140 : : "DPCI setup failed: err(%d)", ret);
1141 : 0 : return ret;
1142 : : }
1143 : 0 : priv->max_event_queues++;
1144 : : } while (dpcon_dev && dpci_dev);
1145 : :
1146 : 0 : DPAA2_EVENTDEV_INFO("%s eventdev created", name);
1147 : :
1148 : 0 : done:
1149 : 0 : event_dev_probing_finish(eventdev);
1150 : 0 : return 0;
1151 : : fail:
1152 : 0 : return -EFAULT;
1153 : : }
1154 : :
1155 : : static int
1156 : 0 : dpaa2_eventdev_destroy(const char *name)
1157 : : {
1158 : : struct rte_eventdev *eventdev;
1159 : : struct dpaa2_eventdev *priv;
1160 : : int i;
1161 : :
1162 : 0 : eventdev = rte_event_pmd_get_named_dev(name);
1163 [ # # ]: 0 : if (eventdev == NULL) {
1164 : 0 : RTE_EDEV_LOG_ERR("eventdev with name %s not allocated", name);
1165 : 0 : return -1;
1166 : : }
1167 : :
1168 : : /* For secondary processes, the primary has done all the work */
1169 [ # # ]: 0 : if (rte_eal_process_type() != RTE_PROC_PRIMARY)
1170 : : return 0;
1171 : :
1172 : 0 : priv = eventdev->data->dev_private;
1173 [ # # ]: 0 : for (i = 0; i < priv->max_event_queues; i++) {
1174 [ # # ]: 0 : if (priv->evq_info[i].dpcon)
1175 : 0 : rte_dpaa2_free_dpcon_dev(priv->evq_info[i].dpcon);
1176 : :
1177 [ # # ]: 0 : if (priv->evq_info[i].dpci)
1178 : 0 : rte_dpaa2_free_dpci_dev(priv->evq_info[i].dpci);
1179 : :
1180 : : }
1181 : 0 : priv->max_event_queues = 0;
1182 : :
1183 : 0 : DPAA2_EVENTDEV_INFO("%s eventdev cleaned", name);
1184 : 0 : return 0;
1185 : : }
1186 : :
1187 : :
1188 : : static int
1189 [ # # ]: 0 : dpaa2_eventdev_probe(struct rte_vdev_device *vdev)
1190 : : {
1191 : : const char *name;
1192 : :
1193 : : name = rte_vdev_device_name(vdev);
1194 : 0 : DPAA2_EVENTDEV_INFO("Initializing %s", name);
1195 : 0 : return dpaa2_eventdev_create(name, vdev);
1196 : : }
1197 : :
1198 : : static int
1199 [ # # ]: 0 : dpaa2_eventdev_remove(struct rte_vdev_device *vdev)
1200 : : {
1201 : : const char *name;
1202 : :
1203 : : name = rte_vdev_device_name(vdev);
1204 : 0 : DPAA2_EVENTDEV_INFO("Closing %s", name);
1205 : :
1206 : 0 : dpaa2_eventdev_destroy(name);
1207 : :
1208 : 0 : return rte_event_pmd_vdev_uninit(name);
1209 : : }
1210 : :
1211 : : static struct rte_vdev_driver vdev_eventdev_dpaa2_pmd = {
1212 : : .probe = dpaa2_eventdev_probe,
1213 : : .remove = dpaa2_eventdev_remove
1214 : : };
1215 : :
1216 : 238 : RTE_PMD_REGISTER_VDEV(EVENTDEV_NAME_DPAA2_PMD, vdev_eventdev_dpaa2_pmd);
1217 [ - + ]: 238 : RTE_LOG_REGISTER_DEFAULT(dpaa2_logtype_event, NOTICE);
|