1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright 2017,2019 NXP
11 #include <sys/epoll.h>
13 #include <rte_atomic.h>
14 #include <rte_byteorder.h>
15 #include <rte_common.h>
16 #include <rte_debug.h>
19 #include <rte_fslmc.h>
20 #include <rte_lcore.h>
22 #include <rte_malloc.h>
23 #include <rte_memcpy.h>
24 #include <rte_memory.h>
26 #include <rte_bus_vdev.h>
27 #include <rte_ethdev_driver.h>
28 #include <rte_cryptodev.h>
29 #include <rte_event_eth_rx_adapter.h>
30 #include <rte_event_eth_tx_adapter.h>
32 #include <fslmc_vfio.h>
33 #include <dpaa2_hw_pvt.h>
34 #include <dpaa2_hw_mempool.h>
35 #include <dpaa2_hw_dpio.h>
36 #include <dpaa2_ethdev.h>
37 #include <dpaa2_sec_event.h>
38 #include "dpaa2_eventdev.h"
39 #include "dpaa2_eventdev_logs.h"
40 #include <portal/dpaa2_hw_pvt.h>
41 #include <mc/fsl_dpci.h>
44 * Evendev = SoC Instance
45 * Eventport = DPIO Instance
46 * Eventqueue = DPCON Instance
47 * 1 Eventdev can have N Eventqueue
48 * Soft Event Flow is DPCI Instance
51 #define DPAA2_EV_TX_RETRY_COUNT 10000
54 dpaa2_eventdev_enqueue_burst(void *port, const struct rte_event ev[],
58 struct dpaa2_port *dpaa2_portal = port;
59 struct dpaa2_dpio_dev *dpio_dev;
60 uint32_t queue_id = ev[0].queue_id;
61 struct dpaa2_eventq *evq_info;
62 uint32_t fqid, retry_count;
63 struct qbman_swp *swp;
64 struct qbman_fd fd_arr[MAX_TX_RING_SLOTS];
65 uint32_t loop, frames_to_send;
66 struct qbman_eq_desc eqdesc[MAX_TX_RING_SLOTS];
69 uint8_t channel_index;
71 if (unlikely(!DPAA2_PER_LCORE_DPIO)) {
72 /* Affine current thread context to a qman portal */
73 ret = dpaa2_affine_qbman_swp();
76 "Failed to allocate IO portal, tid: %d\n",
81 /* todo - dpaa2_portal shall have dpio_dev - no per thread variable */
82 dpio_dev = DPAA2_PER_LCORE_DPIO;
83 swp = DPAA2_PER_LCORE_PORTAL;
85 if (likely(dpaa2_portal->is_port_linked))
88 /* Create mapping between portal and channel to receive packets */
89 for (i = 0; i < DPAA2_EVENT_MAX_QUEUES; i++) {
90 evq_info = &dpaa2_portal->evq_info[i];
91 if (!evq_info->event_port)
94 ret = dpio_add_static_dequeue_channel(dpio_dev->dpio,
97 evq_info->dpcon->dpcon_id,
101 "Static dequeue config failed: err(%d)", ret);
105 qbman_swp_push_set(swp, channel_index, 1);
106 evq_info->dpcon->channel_index = channel_index;
108 dpaa2_portal->is_port_linked = true;
111 evq_info = &dpaa2_portal->evq_info[queue_id];
114 frames_to_send = (nb_events > dpaa2_eqcr_size) ?
115 dpaa2_eqcr_size : nb_events;
117 for (loop = 0; loop < frames_to_send; loop++) {
118 const struct rte_event *event = &ev[num_tx + loop];
120 if (event->sched_type != RTE_SCHED_TYPE_ATOMIC)
121 fqid = evq_info->dpci->rx_queue[
122 DPAA2_EVENT_DPCI_PARALLEL_QUEUE].fqid;
124 fqid = evq_info->dpci->rx_queue[
125 DPAA2_EVENT_DPCI_ATOMIC_QUEUE].fqid;
127 /* Prepare enqueue descriptor */
128 qbman_eq_desc_clear(&eqdesc[loop]);
129 qbman_eq_desc_set_fq(&eqdesc[loop], fqid);
130 qbman_eq_desc_set_no_orp(&eqdesc[loop], 0);
131 qbman_eq_desc_set_response(&eqdesc[loop], 0, 0);
133 if (event->sched_type == RTE_SCHED_TYPE_ATOMIC
134 && *dpaa2_seqn(event->mbuf)) {
136 *dpaa2_seqn(event->mbuf) - 1;
138 qbman_eq_desc_set_dca(&eqdesc[loop], 1,
140 DPAA2_PER_LCORE_DQRR_SIZE--;
141 DPAA2_PER_LCORE_DQRR_HELD &= ~(1 << dqrr_index);
144 memset(&fd_arr[loop], 0, sizeof(struct qbman_fd));
147 * todo - need to align with hw context data
150 struct rte_event *ev_temp = rte_malloc(NULL,
151 sizeof(struct rte_event), 0);
156 frames_to_send = loop;
158 "Unable to allocate event object");
161 rte_memcpy(ev_temp, event, sizeof(struct rte_event));
162 DPAA2_SET_FD_ADDR((&fd_arr[loop]), (size_t)ev_temp);
163 DPAA2_SET_FD_LEN((&fd_arr[loop]),
164 sizeof(struct rte_event));
169 while (loop < frames_to_send) {
170 ret = qbman_swp_enqueue_multiple_desc(swp,
171 &eqdesc[loop], &fd_arr[loop],
172 frames_to_send - loop);
173 if (unlikely(ret < 0)) {
175 if (retry_count > DPAA2_EV_TX_RETRY_COUNT) {
178 return num_tx + loop;
191 for (n = 0; n < i; n++) {
192 evq_info = &dpaa2_portal->evq_info[n];
193 if (!evq_info->event_port)
195 qbman_swp_push_set(swp, evq_info->dpcon->channel_index, 0);
196 dpio_remove_static_dequeue_channel(dpio_dev->dpio, 0,
198 evq_info->dpcon->dpcon_id);
205 dpaa2_eventdev_enqueue(void *port, const struct rte_event *ev)
207 return dpaa2_eventdev_enqueue_burst(port, ev, 1);
210 static void dpaa2_eventdev_dequeue_wait(uint64_t timeout_ticks)
212 struct epoll_event epoll_ev;
214 qbman_swp_interrupt_clear_status(DPAA2_PER_LCORE_PORTAL,
215 QBMAN_SWP_INTERRUPT_DQRI);
217 epoll_wait(DPAA2_PER_LCORE_DPIO->epoll_fd,
218 &epoll_ev, 1, timeout_ticks);
221 static void dpaa2_eventdev_process_parallel(struct qbman_swp *swp,
222 const struct qbman_fd *fd,
223 const struct qbman_result *dq,
224 struct dpaa2_queue *rxq,
225 struct rte_event *ev)
227 struct rte_event *ev_temp =
228 (struct rte_event *)(size_t)DPAA2_GET_FD_ADDR(fd);
232 rte_memcpy(ev, ev_temp, sizeof(struct rte_event));
235 qbman_swp_dqrr_consume(swp, dq);
238 static void dpaa2_eventdev_process_atomic(struct qbman_swp *swp,
239 const struct qbman_fd *fd,
240 const struct qbman_result *dq,
241 struct dpaa2_queue *rxq,
242 struct rte_event *ev)
244 struct rte_event *ev_temp =
245 (struct rte_event *)(size_t)DPAA2_GET_FD_ADDR(fd);
246 uint8_t dqrr_index = qbman_get_dqrr_idx(dq);
251 rte_memcpy(ev, ev_temp, sizeof(struct rte_event));
253 *dpaa2_seqn(ev->mbuf) = dqrr_index + 1;
254 DPAA2_PER_LCORE_DQRR_SIZE++;
255 DPAA2_PER_LCORE_DQRR_HELD |= 1 << dqrr_index;
256 DPAA2_PER_LCORE_DQRR_MBUF(dqrr_index) = ev->mbuf;
260 dpaa2_eventdev_dequeue_burst(void *port, struct rte_event ev[],
261 uint16_t nb_events, uint64_t timeout_ticks)
263 const struct qbman_result *dq;
264 struct dpaa2_dpio_dev *dpio_dev = NULL;
265 struct dpaa2_port *dpaa2_portal = port;
266 struct dpaa2_eventq *evq_info;
267 struct qbman_swp *swp;
268 const struct qbman_fd *fd;
269 struct dpaa2_queue *rxq;
270 int num_pkts = 0, ret, i = 0, n;
271 uint8_t channel_index;
273 if (unlikely(!DPAA2_PER_LCORE_DPIO)) {
274 /* Affine current thread context to a qman portal */
275 ret = dpaa2_affine_qbman_swp();
278 "Failed to allocate IO portal, tid: %d\n",
284 dpio_dev = DPAA2_PER_LCORE_DPIO;
285 swp = DPAA2_PER_LCORE_PORTAL;
287 if (likely(dpaa2_portal->is_port_linked))
290 /* Create mapping between portal and channel to receive packets */
291 for (i = 0; i < DPAA2_EVENT_MAX_QUEUES; i++) {
292 evq_info = &dpaa2_portal->evq_info[i];
293 if (!evq_info->event_port)
296 ret = dpio_add_static_dequeue_channel(dpio_dev->dpio,
299 evq_info->dpcon->dpcon_id,
303 "Static dequeue config failed: err(%d)", ret);
307 qbman_swp_push_set(swp, channel_index, 1);
308 evq_info->dpcon->channel_index = channel_index;
310 dpaa2_portal->is_port_linked = true;
313 /* Check if there are atomic contexts to be released */
314 while (DPAA2_PER_LCORE_DQRR_SIZE) {
315 if (DPAA2_PER_LCORE_DQRR_HELD & (1 << i)) {
316 qbman_swp_dqrr_idx_consume(swp, i);
317 DPAA2_PER_LCORE_DQRR_SIZE--;
318 *dpaa2_seqn(DPAA2_PER_LCORE_DQRR_MBUF(i)) =
319 DPAA2_INVALID_MBUF_SEQN;
323 DPAA2_PER_LCORE_DQRR_HELD = 0;
326 dq = qbman_swp_dqrr_next(swp);
328 if (!num_pkts && timeout_ticks) {
329 dpaa2_eventdev_dequeue_wait(timeout_ticks);
335 qbman_swp_prefetch_dqrr_next(swp);
337 fd = qbman_result_DQ_fd(dq);
338 rxq = (struct dpaa2_queue *)(size_t)qbman_result_DQ_fqd_ctx(dq);
340 rxq->cb(swp, fd, dq, rxq, &ev[num_pkts]);
342 qbman_swp_dqrr_consume(swp, dq);
343 DPAA2_EVENTDEV_ERR("Null Return VQ received");
348 } while (num_pkts < nb_events);
352 for (n = 0; n < i; n++) {
353 evq_info = &dpaa2_portal->evq_info[n];
354 if (!evq_info->event_port)
357 qbman_swp_push_set(swp, evq_info->dpcon->channel_index, 0);
358 dpio_remove_static_dequeue_channel(dpio_dev->dpio, 0,
360 evq_info->dpcon->dpcon_id);
366 dpaa2_eventdev_dequeue(void *port, struct rte_event *ev,
367 uint64_t timeout_ticks)
369 return dpaa2_eventdev_dequeue_burst(port, ev, 1, timeout_ticks);
373 dpaa2_eventdev_info_get(struct rte_eventdev *dev,
374 struct rte_event_dev_info *dev_info)
376 struct dpaa2_eventdev *priv = dev->data->dev_private;
378 EVENTDEV_INIT_FUNC_TRACE();
382 memset(dev_info, 0, sizeof(struct rte_event_dev_info));
383 dev_info->min_dequeue_timeout_ns =
384 DPAA2_EVENT_MIN_DEQUEUE_TIMEOUT;
385 dev_info->max_dequeue_timeout_ns =
386 DPAA2_EVENT_MAX_DEQUEUE_TIMEOUT;
387 dev_info->dequeue_timeout_ns =
388 DPAA2_EVENT_PORT_DEQUEUE_TIMEOUT_NS;
389 dev_info->max_event_queues = priv->max_event_queues;
390 dev_info->max_event_queue_flows =
391 DPAA2_EVENT_MAX_QUEUE_FLOWS;
392 dev_info->max_event_queue_priority_levels =
393 DPAA2_EVENT_MAX_QUEUE_PRIORITY_LEVELS;
394 dev_info->max_event_priority_levels =
395 DPAA2_EVENT_MAX_EVENT_PRIORITY_LEVELS;
396 dev_info->max_event_ports = rte_fslmc_get_device_count(DPAA2_IO);
397 /* we only support dpio up to number of cores */
398 if (dev_info->max_event_ports > rte_lcore_count())
399 dev_info->max_event_ports = rte_lcore_count();
400 dev_info->max_event_port_dequeue_depth =
401 DPAA2_EVENT_MAX_PORT_DEQUEUE_DEPTH;
402 dev_info->max_event_port_enqueue_depth =
403 DPAA2_EVENT_MAX_PORT_ENQUEUE_DEPTH;
404 dev_info->max_num_events = DPAA2_EVENT_MAX_NUM_EVENTS;
405 dev_info->event_dev_cap = RTE_EVENT_DEV_CAP_DISTRIBUTED_SCHED |
406 RTE_EVENT_DEV_CAP_BURST_MODE|
407 RTE_EVENT_DEV_CAP_RUNTIME_PORT_LINK |
408 RTE_EVENT_DEV_CAP_MULTIPLE_QUEUE_PORT |
409 RTE_EVENT_DEV_CAP_NONSEQ_MODE |
410 RTE_EVENT_DEV_CAP_QUEUE_ALL_TYPES |
411 RTE_EVENT_DEV_CAP_CARRY_FLOW_ID;
416 dpaa2_eventdev_configure(const struct rte_eventdev *dev)
418 struct dpaa2_eventdev *priv = dev->data->dev_private;
419 struct rte_event_dev_config *conf = &dev->data->dev_conf;
421 EVENTDEV_INIT_FUNC_TRACE();
423 priv->nb_event_queues = conf->nb_event_queues;
424 priv->nb_event_ports = conf->nb_event_ports;
425 priv->nb_event_queue_flows = conf->nb_event_queue_flows;
426 priv->nb_event_port_dequeue_depth = conf->nb_event_port_dequeue_depth;
427 priv->nb_event_port_enqueue_depth = conf->nb_event_port_enqueue_depth;
428 priv->event_dev_cfg = conf->event_dev_cfg;
430 /* Check dequeue timeout method is per dequeue or global */
431 if (priv->event_dev_cfg & RTE_EVENT_DEV_CFG_PER_DEQUEUE_TIMEOUT) {
433 * Use timeout value as given in dequeue operation.
434 * So invalidating this timeout value.
436 priv->dequeue_timeout_ns = 0;
438 } else if (conf->dequeue_timeout_ns == 0) {
439 priv->dequeue_timeout_ns = DPAA2_EVENT_PORT_DEQUEUE_TIMEOUT_NS;
441 priv->dequeue_timeout_ns = conf->dequeue_timeout_ns;
444 DPAA2_EVENTDEV_DEBUG("Configured eventdev devid=%d",
450 dpaa2_eventdev_start(struct rte_eventdev *dev)
452 EVENTDEV_INIT_FUNC_TRACE();
460 dpaa2_eventdev_stop(struct rte_eventdev *dev)
462 EVENTDEV_INIT_FUNC_TRACE();
468 dpaa2_eventdev_close(struct rte_eventdev *dev)
470 EVENTDEV_INIT_FUNC_TRACE();
478 dpaa2_eventdev_queue_def_conf(struct rte_eventdev *dev, uint8_t queue_id,
479 struct rte_event_queue_conf *queue_conf)
481 EVENTDEV_INIT_FUNC_TRACE();
484 RTE_SET_USED(queue_id);
486 queue_conf->nb_atomic_flows = DPAA2_EVENT_QUEUE_ATOMIC_FLOWS;
487 queue_conf->nb_atomic_order_sequences =
488 DPAA2_EVENT_QUEUE_ORDER_SEQUENCES;
489 queue_conf->schedule_type = RTE_SCHED_TYPE_PARALLEL;
490 queue_conf->priority = RTE_EVENT_DEV_PRIORITY_NORMAL;
494 dpaa2_eventdev_queue_setup(struct rte_eventdev *dev, uint8_t queue_id,
495 const struct rte_event_queue_conf *queue_conf)
497 struct dpaa2_eventdev *priv = dev->data->dev_private;
498 struct dpaa2_eventq *evq_info = &priv->evq_info[queue_id];
500 EVENTDEV_INIT_FUNC_TRACE();
502 switch (queue_conf->schedule_type) {
503 case RTE_SCHED_TYPE_PARALLEL:
504 case RTE_SCHED_TYPE_ATOMIC:
505 case RTE_SCHED_TYPE_ORDERED:
508 DPAA2_EVENTDEV_ERR("Schedule type is not supported.");
511 evq_info->event_queue_cfg = queue_conf->event_queue_cfg;
512 evq_info->event_queue_id = queue_id;
518 dpaa2_eventdev_queue_release(struct rte_eventdev *dev, uint8_t queue_id)
520 EVENTDEV_INIT_FUNC_TRACE();
523 RTE_SET_USED(queue_id);
527 dpaa2_eventdev_port_def_conf(struct rte_eventdev *dev, uint8_t port_id,
528 struct rte_event_port_conf *port_conf)
530 EVENTDEV_INIT_FUNC_TRACE();
533 RTE_SET_USED(port_id);
535 port_conf->new_event_threshold =
536 DPAA2_EVENT_MAX_NUM_EVENTS;
537 port_conf->dequeue_depth =
538 DPAA2_EVENT_MAX_PORT_DEQUEUE_DEPTH;
539 port_conf->enqueue_depth =
540 DPAA2_EVENT_MAX_PORT_ENQUEUE_DEPTH;
541 port_conf->event_port_cfg = 0;
545 dpaa2_eventdev_port_setup(struct rte_eventdev *dev, uint8_t port_id,
546 const struct rte_event_port_conf *port_conf)
548 char event_port_name[32];
549 struct dpaa2_port *portal;
551 EVENTDEV_INIT_FUNC_TRACE();
553 RTE_SET_USED(port_conf);
555 sprintf(event_port_name, "event-port-%d", port_id);
556 portal = rte_malloc(event_port_name, sizeof(struct dpaa2_port), 0);
558 DPAA2_EVENTDEV_ERR("Memory allocation failure");
562 memset(portal, 0, sizeof(struct dpaa2_port));
563 dev->data->ports[port_id] = portal;
568 dpaa2_eventdev_port_release(void *port)
570 struct dpaa2_port *portal = port;
572 EVENTDEV_INIT_FUNC_TRACE();
577 /* TODO: Cleanup is required when ports are in linked state. */
578 if (portal->is_port_linked)
579 DPAA2_EVENTDEV_WARN("Event port must be unlinked before release");
585 dpaa2_eventdev_port_link(struct rte_eventdev *dev, void *port,
586 const uint8_t queues[], const uint8_t priorities[],
589 struct dpaa2_eventdev *priv = dev->data->dev_private;
590 struct dpaa2_port *dpaa2_portal = port;
591 struct dpaa2_eventq *evq_info;
594 EVENTDEV_INIT_FUNC_TRACE();
596 RTE_SET_USED(priorities);
598 for (i = 0; i < nb_links; i++) {
599 evq_info = &priv->evq_info[queues[i]];
600 memcpy(&dpaa2_portal->evq_info[queues[i]], evq_info,
601 sizeof(struct dpaa2_eventq));
602 dpaa2_portal->evq_info[queues[i]].event_port = port;
603 dpaa2_portal->num_linked_evq++;
606 return (int)nb_links;
610 dpaa2_eventdev_port_unlink(struct rte_eventdev *dev, void *port,
611 uint8_t queues[], uint16_t nb_unlinks)
613 struct dpaa2_port *dpaa2_portal = port;
615 struct dpaa2_dpio_dev *dpio_dev = NULL;
616 struct dpaa2_eventq *evq_info;
617 struct qbman_swp *swp;
619 EVENTDEV_INIT_FUNC_TRACE();
622 RTE_SET_USED(queues);
624 for (i = 0; i < nb_unlinks; i++) {
625 evq_info = &dpaa2_portal->evq_info[queues[i]];
627 if (DPAA2_PER_LCORE_DPIO && evq_info->dpcon) {
628 /* todo dpaa2_portal shall have dpio_dev-no per lcore*/
629 dpio_dev = DPAA2_PER_LCORE_DPIO;
630 swp = DPAA2_PER_LCORE_PORTAL;
632 qbman_swp_push_set(swp,
633 evq_info->dpcon->channel_index, 0);
634 dpio_remove_static_dequeue_channel(dpio_dev->dpio, 0,
636 evq_info->dpcon->dpcon_id);
638 memset(evq_info, 0, sizeof(struct dpaa2_eventq));
639 if (dpaa2_portal->num_linked_evq)
640 dpaa2_portal->num_linked_evq--;
643 if (!dpaa2_portal->num_linked_evq)
644 dpaa2_portal->is_port_linked = false;
646 return (int)nb_unlinks;
651 dpaa2_eventdev_timeout_ticks(struct rte_eventdev *dev, uint64_t ns,
652 uint64_t *timeout_ticks)
654 uint32_t scale = 1000*1000;
656 EVENTDEV_INIT_FUNC_TRACE();
659 *timeout_ticks = ns / scale;
665 dpaa2_eventdev_dump(struct rte_eventdev *dev, FILE *f)
667 EVENTDEV_INIT_FUNC_TRACE();
674 dpaa2_eventdev_eth_caps_get(const struct rte_eventdev *dev,
675 const struct rte_eth_dev *eth_dev,
678 const char *ethdev_driver = eth_dev->device->driver->name;
680 EVENTDEV_INIT_FUNC_TRACE();
684 if (!strcmp(ethdev_driver, "net_dpaa2"))
685 *caps = RTE_EVENT_ETH_RX_ADAPTER_DPAA2_CAP;
687 *caps = RTE_EVENT_ETH_RX_ADAPTER_SW_CAP;
693 dpaa2_eventdev_eth_queue_add_all(const struct rte_eventdev *dev,
694 const struct rte_eth_dev *eth_dev,
695 const struct rte_event_eth_rx_adapter_queue_conf *queue_conf)
697 struct dpaa2_eventdev *priv = dev->data->dev_private;
698 uint8_t ev_qid = queue_conf->ev.queue_id;
699 struct dpaa2_dpcon_dev *dpcon = priv->evq_info[ev_qid].dpcon;
702 EVENTDEV_INIT_FUNC_TRACE();
704 for (i = 0; i < eth_dev->data->nb_rx_queues; i++) {
705 ret = dpaa2_eth_eventq_attach(eth_dev, i,
709 "Event queue attach failed: err(%d)", ret);
715 for (i = (i - 1); i >= 0 ; i--)
716 dpaa2_eth_eventq_detach(eth_dev, i);
722 dpaa2_eventdev_eth_queue_add(const struct rte_eventdev *dev,
723 const struct rte_eth_dev *eth_dev,
725 const struct rte_event_eth_rx_adapter_queue_conf *queue_conf)
727 struct dpaa2_eventdev *priv = dev->data->dev_private;
728 uint8_t ev_qid = queue_conf->ev.queue_id;
729 struct dpaa2_dpcon_dev *dpcon = priv->evq_info[ev_qid].dpcon;
732 EVENTDEV_INIT_FUNC_TRACE();
734 if (rx_queue_id == -1)
735 return dpaa2_eventdev_eth_queue_add_all(dev,
736 eth_dev, queue_conf);
738 ret = dpaa2_eth_eventq_attach(eth_dev, rx_queue_id,
742 "Event queue attach failed: err(%d)", ret);
749 dpaa2_eventdev_eth_queue_del_all(const struct rte_eventdev *dev,
750 const struct rte_eth_dev *eth_dev)
754 EVENTDEV_INIT_FUNC_TRACE();
758 for (i = 0; i < eth_dev->data->nb_rx_queues; i++) {
759 ret = dpaa2_eth_eventq_detach(eth_dev, i);
762 "Event queue detach failed: err(%d)", ret);
771 dpaa2_eventdev_eth_queue_del(const struct rte_eventdev *dev,
772 const struct rte_eth_dev *eth_dev,
777 EVENTDEV_INIT_FUNC_TRACE();
779 if (rx_queue_id == -1)
780 return dpaa2_eventdev_eth_queue_del_all(dev, eth_dev);
782 ret = dpaa2_eth_eventq_detach(eth_dev, rx_queue_id);
785 "Event queue detach failed: err(%d)", ret);
793 dpaa2_eventdev_eth_start(const struct rte_eventdev *dev,
794 const struct rte_eth_dev *eth_dev)
796 EVENTDEV_INIT_FUNC_TRACE();
799 RTE_SET_USED(eth_dev);
805 dpaa2_eventdev_eth_stop(const struct rte_eventdev *dev,
806 const struct rte_eth_dev *eth_dev)
808 EVENTDEV_INIT_FUNC_TRACE();
811 RTE_SET_USED(eth_dev);
817 dpaa2_eventdev_crypto_caps_get(const struct rte_eventdev *dev,
818 const struct rte_cryptodev *cdev,
821 const char *name = cdev->data->name;
823 EVENTDEV_INIT_FUNC_TRACE();
827 if (!strncmp(name, "dpsec-", 6))
828 *caps = RTE_EVENT_CRYPTO_ADAPTER_DPAA2_CAP;
836 dpaa2_eventdev_crypto_queue_add_all(const struct rte_eventdev *dev,
837 const struct rte_cryptodev *cryptodev,
838 const struct rte_event *ev)
840 struct dpaa2_eventdev *priv = dev->data->dev_private;
841 uint8_t ev_qid = ev->queue_id;
842 struct dpaa2_dpcon_dev *dpcon = priv->evq_info[ev_qid].dpcon;
845 EVENTDEV_INIT_FUNC_TRACE();
847 for (i = 0; i < cryptodev->data->nb_queue_pairs; i++) {
848 ret = dpaa2_sec_eventq_attach(cryptodev, i, dpcon, ev);
850 DPAA2_EVENTDEV_ERR("dpaa2_sec_eventq_attach failed: ret %d\n",
857 for (i = (i - 1); i >= 0 ; i--)
858 dpaa2_sec_eventq_detach(cryptodev, i);
864 dpaa2_eventdev_crypto_queue_add(const struct rte_eventdev *dev,
865 const struct rte_cryptodev *cryptodev,
867 const struct rte_event *ev)
869 struct dpaa2_eventdev *priv = dev->data->dev_private;
870 uint8_t ev_qid = ev->queue_id;
871 struct dpaa2_dpcon_dev *dpcon = priv->evq_info[ev_qid].dpcon;
874 EVENTDEV_INIT_FUNC_TRACE();
876 if (rx_queue_id == -1)
877 return dpaa2_eventdev_crypto_queue_add_all(dev,
880 ret = dpaa2_sec_eventq_attach(cryptodev, rx_queue_id,
884 "dpaa2_sec_eventq_attach failed: ret: %d\n", ret);
891 dpaa2_eventdev_crypto_queue_del_all(const struct rte_eventdev *dev,
892 const struct rte_cryptodev *cdev)
896 EVENTDEV_INIT_FUNC_TRACE();
900 for (i = 0; i < cdev->data->nb_queue_pairs; i++) {
901 ret = dpaa2_sec_eventq_detach(cdev, i);
904 "dpaa2_sec_eventq_detach failed:ret %d\n", ret);
913 dpaa2_eventdev_crypto_queue_del(const struct rte_eventdev *dev,
914 const struct rte_cryptodev *cryptodev,
919 EVENTDEV_INIT_FUNC_TRACE();
921 if (rx_queue_id == -1)
922 return dpaa2_eventdev_crypto_queue_del_all(dev, cryptodev);
924 ret = dpaa2_sec_eventq_detach(cryptodev, rx_queue_id);
927 "dpaa2_sec_eventq_detach failed: ret: %d\n", ret);
935 dpaa2_eventdev_crypto_start(const struct rte_eventdev *dev,
936 const struct rte_cryptodev *cryptodev)
938 EVENTDEV_INIT_FUNC_TRACE();
941 RTE_SET_USED(cryptodev);
947 dpaa2_eventdev_crypto_stop(const struct rte_eventdev *dev,
948 const struct rte_cryptodev *cryptodev)
950 EVENTDEV_INIT_FUNC_TRACE();
953 RTE_SET_USED(cryptodev);
959 dpaa2_eventdev_tx_adapter_create(uint8_t id,
960 const struct rte_eventdev *dev)
965 /* Nothing to do. Simply return. */
970 dpaa2_eventdev_tx_adapter_caps(const struct rte_eventdev *dev,
971 const struct rte_eth_dev *eth_dev,
975 RTE_SET_USED(eth_dev);
977 *caps = RTE_EVENT_ETH_TX_ADAPTER_CAP_INTERNAL_PORT;
982 dpaa2_eventdev_txa_enqueue_same_dest(void *port,
983 struct rte_event ev[],
986 struct rte_mbuf *m[DPAA2_EVENT_MAX_PORT_ENQUEUE_DEPTH], *m0;
991 m0 = (struct rte_mbuf *)ev[0].mbuf;
992 qid = rte_event_eth_tx_adapter_txq_get(m0);
994 for (i = 0; i < nb_events; i++)
995 m[i] = (struct rte_mbuf *)ev[i].mbuf;
997 return rte_eth_tx_burst(m0->port, qid, m, nb_events);
1001 dpaa2_eventdev_txa_enqueue(void *port,
1002 struct rte_event ev[],
1005 struct rte_mbuf *m = (struct rte_mbuf *)ev[0].mbuf;
1010 for (i = 0; i < nb_events; i++) {
1011 qid = rte_event_eth_tx_adapter_txq_get(m);
1012 rte_eth_tx_burst(m->port, qid, &m, 1);
1018 static struct rte_eventdev_ops dpaa2_eventdev_ops = {
1019 .dev_infos_get = dpaa2_eventdev_info_get,
1020 .dev_configure = dpaa2_eventdev_configure,
1021 .dev_start = dpaa2_eventdev_start,
1022 .dev_stop = dpaa2_eventdev_stop,
1023 .dev_close = dpaa2_eventdev_close,
1024 .queue_def_conf = dpaa2_eventdev_queue_def_conf,
1025 .queue_setup = dpaa2_eventdev_queue_setup,
1026 .queue_release = dpaa2_eventdev_queue_release,
1027 .port_def_conf = dpaa2_eventdev_port_def_conf,
1028 .port_setup = dpaa2_eventdev_port_setup,
1029 .port_release = dpaa2_eventdev_port_release,
1030 .port_link = dpaa2_eventdev_port_link,
1031 .port_unlink = dpaa2_eventdev_port_unlink,
1032 .timeout_ticks = dpaa2_eventdev_timeout_ticks,
1033 .dump = dpaa2_eventdev_dump,
1034 .dev_selftest = test_eventdev_dpaa2,
1035 .eth_rx_adapter_caps_get = dpaa2_eventdev_eth_caps_get,
1036 .eth_rx_adapter_queue_add = dpaa2_eventdev_eth_queue_add,
1037 .eth_rx_adapter_queue_del = dpaa2_eventdev_eth_queue_del,
1038 .eth_rx_adapter_start = dpaa2_eventdev_eth_start,
1039 .eth_rx_adapter_stop = dpaa2_eventdev_eth_stop,
1040 .eth_tx_adapter_caps_get = dpaa2_eventdev_tx_adapter_caps,
1041 .eth_tx_adapter_create = dpaa2_eventdev_tx_adapter_create,
1042 .crypto_adapter_caps_get = dpaa2_eventdev_crypto_caps_get,
1043 .crypto_adapter_queue_pair_add = dpaa2_eventdev_crypto_queue_add,
1044 .crypto_adapter_queue_pair_del = dpaa2_eventdev_crypto_queue_del,
1045 .crypto_adapter_start = dpaa2_eventdev_crypto_start,
1046 .crypto_adapter_stop = dpaa2_eventdev_crypto_stop,
1050 dpaa2_eventdev_setup_dpci(struct dpaa2_dpci_dev *dpci_dev,
1051 struct dpaa2_dpcon_dev *dpcon_dev)
1053 struct dpci_rx_queue_cfg rx_queue_cfg;
1056 /*Do settings to get the frame on a DPCON object*/
1057 rx_queue_cfg.options = DPCI_QUEUE_OPT_DEST |
1058 DPCI_QUEUE_OPT_USER_CTX;
1059 rx_queue_cfg.dest_cfg.dest_type = DPCI_DEST_DPCON;
1060 rx_queue_cfg.dest_cfg.dest_id = dpcon_dev->dpcon_id;
1061 rx_queue_cfg.dest_cfg.priority = DPAA2_EVENT_DEFAULT_DPCI_PRIO;
1063 dpci_dev->rx_queue[DPAA2_EVENT_DPCI_PARALLEL_QUEUE].cb =
1064 dpaa2_eventdev_process_parallel;
1065 dpci_dev->rx_queue[DPAA2_EVENT_DPCI_ATOMIC_QUEUE].cb =
1066 dpaa2_eventdev_process_atomic;
1068 for (i = 0 ; i < DPAA2_EVENT_DPCI_MAX_QUEUES; i++) {
1069 rx_queue_cfg.user_ctx = (size_t)(&dpci_dev->rx_queue[i]);
1070 ret = dpci_set_rx_queue(&dpci_dev->dpci,
1076 "DPCI Rx queue setup failed: err(%d)",
1085 dpaa2_eventdev_create(const char *name)
1087 struct rte_eventdev *eventdev;
1088 struct dpaa2_eventdev *priv;
1089 struct dpaa2_dpcon_dev *dpcon_dev = NULL;
1090 struct dpaa2_dpci_dev *dpci_dev = NULL;
1093 eventdev = rte_event_pmd_vdev_init(name,
1094 sizeof(struct dpaa2_eventdev),
1096 if (eventdev == NULL) {
1097 DPAA2_EVENTDEV_ERR("Failed to create Event device %s", name);
1101 eventdev->dev_ops = &dpaa2_eventdev_ops;
1102 eventdev->enqueue = dpaa2_eventdev_enqueue;
1103 eventdev->enqueue_burst = dpaa2_eventdev_enqueue_burst;
1104 eventdev->enqueue_new_burst = dpaa2_eventdev_enqueue_burst;
1105 eventdev->enqueue_forward_burst = dpaa2_eventdev_enqueue_burst;
1106 eventdev->dequeue = dpaa2_eventdev_dequeue;
1107 eventdev->dequeue_burst = dpaa2_eventdev_dequeue_burst;
1108 eventdev->txa_enqueue = dpaa2_eventdev_txa_enqueue;
1109 eventdev->txa_enqueue_same_dest = dpaa2_eventdev_txa_enqueue_same_dest;
1111 /* For secondary processes, the primary has done all the work */
1112 if (rte_eal_process_type() != RTE_PROC_PRIMARY)
1115 priv = eventdev->data->dev_private;
1116 priv->max_event_queues = 0;
1119 dpcon_dev = rte_dpaa2_alloc_dpcon_dev();
1122 priv->evq_info[priv->max_event_queues].dpcon = dpcon_dev;
1124 dpci_dev = rte_dpaa2_alloc_dpci_dev();
1126 rte_dpaa2_free_dpcon_dev(dpcon_dev);
1129 priv->evq_info[priv->max_event_queues].dpci = dpci_dev;
1131 ret = dpaa2_eventdev_setup_dpci(dpci_dev, dpcon_dev);
1134 "DPCI setup failed: err(%d)", ret);
1137 priv->max_event_queues++;
1138 } while (dpcon_dev && dpci_dev);
1140 RTE_LOG(INFO, PMD, "%s eventdev created\n", name);
1148 dpaa2_eventdev_destroy(const char *name)
1150 struct rte_eventdev *eventdev;
1151 struct dpaa2_eventdev *priv;
1154 eventdev = rte_event_pmd_get_named_dev(name);
1155 if (eventdev == NULL) {
1156 RTE_EDEV_LOG_ERR("eventdev with name %s not allocated", name);
1160 /* For secondary processes, the primary has done all the work */
1161 if (rte_eal_process_type() != RTE_PROC_PRIMARY)
1164 priv = eventdev->data->dev_private;
1165 for (i = 0; i < priv->max_event_queues; i++) {
1166 if (priv->evq_info[i].dpcon)
1167 rte_dpaa2_free_dpcon_dev(priv->evq_info[i].dpcon);
1169 if (priv->evq_info[i].dpci)
1170 rte_dpaa2_free_dpci_dev(priv->evq_info[i].dpci);
1173 priv->max_event_queues = 0;
1175 RTE_LOG(INFO, PMD, "%s eventdev cleaned\n", name);
1181 dpaa2_eventdev_probe(struct rte_vdev_device *vdev)
1185 name = rte_vdev_device_name(vdev);
1186 DPAA2_EVENTDEV_INFO("Initializing %s", name);
1187 return dpaa2_eventdev_create(name);
1191 dpaa2_eventdev_remove(struct rte_vdev_device *vdev)
1195 name = rte_vdev_device_name(vdev);
1196 DPAA2_EVENTDEV_INFO("Closing %s", name);
1198 dpaa2_eventdev_destroy(name);
1200 return rte_event_pmd_vdev_uninit(name);
1203 static struct rte_vdev_driver vdev_eventdev_dpaa2_pmd = {
1204 .probe = dpaa2_eventdev_probe,
1205 .remove = dpaa2_eventdev_remove
1208 RTE_PMD_REGISTER_VDEV(EVENTDEV_NAME_DPAA2_PMD, vdev_eventdev_dpaa2_pmd);
1209 RTE_LOG_REGISTER(dpaa2_logtype_event, pmd.event.dpaa2, NOTICE);