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