eal: set name when creating a control thread
[dpdk.git] / drivers / event / dpaa2 / dpaa2_eventdev.c
index ba7e514..f50bb8d 100644 (file)
@@ -26,7 +26,7 @@
 #include <rte_memory.h>
 #include <rte_pci.h>
 #include <rte_bus_vdev.h>
-#include <rte_ethdev.h>
+#include <rte_ethdev_driver.h>
 #include <rte_event_eth_rx_adapter.h>
 
 #include <fslmc_vfio.h>
@@ -35,6 +35,7 @@
 #include <dpaa2_hw_dpio.h>
 #include <dpaa2_ethdev.h>
 #include "dpaa2_eventdev.h"
+#include "dpaa2_eventdev_logs.h"
 #include <portal/dpaa2_hw_pvt.h>
 #include <mc/fsl_dpci.h>
 
@@ -46,6 +47,9 @@
  * Soft Event Flow is DPCI Instance
  */
 
+/* Dynamic logging identified for mempool */
+int dpaa2_logtype_event;
+
 static uint16_t
 dpaa2_eventdev_enqueue_burst(void *port, const struct rte_event ev[],
                             uint16_t nb_events)
@@ -68,7 +72,7 @@ dpaa2_eventdev_enqueue_burst(void *port, const struct rte_event ev[],
        if (unlikely(!DPAA2_PER_LCORE_DPIO)) {
                ret = dpaa2_affine_qbman_swp();
                if (ret) {
-                       PMD_DRV_LOG(ERR, "Failure in affining portal\n");
+                       DPAA2_EVENTDEV_ERR("Failure in affining portal");
                        return 0;
                }
        }
@@ -95,13 +99,13 @@ dpaa2_eventdev_enqueue_burst(void *port, const struct rte_event ev[],
                        qbman_eq_desc_set_no_orp(&eqdesc[loop], 0);
                        qbman_eq_desc_set_response(&eqdesc[loop], 0, 0);
 
-                       if (event->impl_opaque) {
-                               uint8_t dqrr_index = event->impl_opaque - 1;
+                       if (event->mbuf->seqn) {
+                               uint8_t dqrr_index = event->mbuf->seqn - 1;
 
                                qbman_eq_desc_set_dca(&eqdesc[loop], 1,
                                                      dqrr_index, 0);
-                               DPAA2_PER_LCORE_DPIO->dqrr_size--;
-                               DPAA2_PER_LCORE_DPIO->dqrr_held &=
+                               DPAA2_PER_LCORE_DQRR_SIZE--;
+                               DPAA2_PER_LCORE_DQRR_HELD &=
                                        ~(1 << dqrr_index);
                        }
 
@@ -118,11 +122,12 @@ dpaa2_eventdev_enqueue_burst(void *port, const struct rte_event ev[],
                                if (!loop)
                                        return num_tx;
                                frames_to_send = loop;
-                               PMD_DRV_LOG(ERR, "Unable to allocate memory");
+                               DPAA2_EVENTDEV_ERR(
+                                       "Unable to allocate event object");
                                goto send_partial;
                        }
                        rte_memcpy(ev_temp, event, sizeof(struct rte_event));
-                       DPAA2_SET_FD_ADDR((&fd_arr[loop]), ev_temp);
+                       DPAA2_SET_FD_ADDR((&fd_arr[loop]), (size_t)ev_temp);
                        DPAA2_SET_FD_LEN((&fd_arr[loop]),
                                         sizeof(struct rte_event));
                }
@@ -163,9 +168,9 @@ RETRY:
                 * case to avoid the problem.
                 */
                if (errno == EINTR) {
-                       PMD_DRV_LOG(DEBUG, "epoll_wait fails\n");
+                       DPAA2_EVENTDEV_DEBUG("epoll_wait fails");
                        if (i++ > 10)
-                               PMD_DRV_LOG(DEBUG, "Dequeue burst Failed\n");
+                               DPAA2_EVENTDEV_DEBUG("Dequeue burst Failed");
                goto RETRY;
                }
        }
@@ -178,7 +183,7 @@ static void dpaa2_eventdev_process_parallel(struct qbman_swp *swp,
                                            struct rte_event *ev)
 {
        struct rte_event *ev_temp =
-               (struct rte_event *)DPAA2_GET_FD_ADDR(fd);
+               (struct rte_event *)(size_t)DPAA2_GET_FD_ADDR(fd);
 
        RTE_SET_USED(rxq);
 
@@ -195,7 +200,7 @@ static void dpaa2_eventdev_process_atomic(struct qbman_swp *swp,
                                          struct rte_event *ev)
 {
        struct rte_event *ev_temp =
-               (struct rte_event *)DPAA2_GET_FD_ADDR(fd);
+               (struct rte_event *)(size_t)DPAA2_GET_FD_ADDR(fd);
        uint8_t dqrr_index = qbman_get_dqrr_idx(dq);
 
        RTE_SET_USED(swp);
@@ -203,9 +208,9 @@ static void dpaa2_eventdev_process_atomic(struct qbman_swp *swp,
 
        rte_memcpy(ev, ev_temp, sizeof(struct rte_event));
        rte_free(ev_temp);
-       ev->impl_opaque = dqrr_index + 1;
-       DPAA2_PER_LCORE_DPIO->dqrr_size++;
-       DPAA2_PER_LCORE_DPIO->dqrr_held |= 1 << dqrr_index;
+       ev->mbuf->seqn = dqrr_index + 1;
+       DPAA2_PER_LCORE_DQRR_SIZE++;
+       DPAA2_PER_LCORE_DQRR_HELD |= 1 << dqrr_index;
 }
 
 static uint16_t
@@ -223,23 +228,23 @@ dpaa2_eventdev_dequeue_burst(void *port, struct rte_event ev[],
        if (unlikely(!DPAA2_PER_LCORE_DPIO)) {
                ret = dpaa2_affine_qbman_swp();
                if (ret) {
-                       PMD_DRV_LOG(ERR, "Failure in affining portal\n");
+                       DPAA2_EVENTDEV_ERR("Failure in affining portal");
                        return 0;
                }
        }
-
        swp = DPAA2_PER_LCORE_PORTAL;
 
        /* Check if there are atomic contexts to be released */
-       while (DPAA2_PER_LCORE_DPIO->dqrr_size) {
-               if (DPAA2_PER_LCORE_DPIO->dqrr_held & (1 << i)) {
-                       dq = qbman_get_dqrr_from_idx(swp, i);
-                       qbman_swp_dqrr_consume(swp, dq);
-                       DPAA2_PER_LCORE_DPIO->dqrr_size--;
+       while (DPAA2_PER_LCORE_DQRR_SIZE) {
+               if (DPAA2_PER_LCORE_DQRR_HELD & (1 << i)) {
+                       qbman_swp_dqrr_idx_consume(swp, i);
+                       DPAA2_PER_LCORE_DQRR_SIZE--;
+                       DPAA2_PER_LCORE_DQRR_MBUF(i)->seqn =
+                               DPAA2_INVALID_MBUF_SEQN;
                }
                i++;
        }
-       DPAA2_PER_LCORE_DPIO->dqrr_held = 0;
+       DPAA2_PER_LCORE_DQRR_HELD = 0;
 
        do {
                dq = qbman_swp_dqrr_next(swp);
@@ -251,15 +256,15 @@ dpaa2_eventdev_dequeue_burst(void *port, struct rte_event ev[],
                        }
                        return num_pkts;
                }
+               qbman_swp_prefetch_dqrr_next(swp);
 
                fd = qbman_result_DQ_fd(dq);
-
-               rxq = (struct dpaa2_queue *)qbman_result_DQ_fqd_ctx(dq);
+               rxq = (struct dpaa2_queue *)(size_t)qbman_result_DQ_fqd_ctx(dq);
                if (rxq) {
                        rxq->cb(swp, fd, dq, rxq, &ev[num_pkts]);
                } else {
                        qbman_swp_dqrr_consume(swp, dq);
-                       PMD_DRV_LOG(ERR, "Null Return VQ received\n");
+                       DPAA2_EVENTDEV_ERR("Null Return VQ received");
                        return 0;
                }
 
@@ -282,7 +287,7 @@ dpaa2_eventdev_info_get(struct rte_eventdev *dev,
 {
        struct dpaa2_eventdev *priv = dev->data->dev_private;
 
-       PMD_DRV_FUNC_TRACE();
+       EVENTDEV_INIT_FUNC_TRACE();
 
        RTE_SET_USED(dev);
 
@@ -300,14 +305,18 @@ dpaa2_eventdev_info_get(struct rte_eventdev *dev,
                DPAA2_EVENT_MAX_QUEUE_PRIORITY_LEVELS;
        dev_info->max_event_priority_levels =
                DPAA2_EVENT_MAX_EVENT_PRIORITY_LEVELS;
-       dev_info->max_event_ports = RTE_MAX_LCORE;
+       dev_info->max_event_ports = rte_fslmc_get_device_count(DPAA2_IO);
        dev_info->max_event_port_dequeue_depth =
                DPAA2_EVENT_MAX_PORT_DEQUEUE_DEPTH;
        dev_info->max_event_port_enqueue_depth =
                DPAA2_EVENT_MAX_PORT_ENQUEUE_DEPTH;
        dev_info->max_num_events = DPAA2_EVENT_MAX_NUM_EVENTS;
        dev_info->event_dev_cap = RTE_EVENT_DEV_CAP_DISTRIBUTED_SCHED |
-               RTE_EVENT_DEV_CAP_BURST_MODE;
+               RTE_EVENT_DEV_CAP_BURST_MODE|
+               RTE_EVENT_DEV_CAP_RUNTIME_PORT_LINK |
+               RTE_EVENT_DEV_CAP_MULTIPLE_QUEUE_PORT |
+               RTE_EVENT_DEV_CAP_NONSEQ_MODE;
+
 }
 
 static int
@@ -316,7 +325,7 @@ dpaa2_eventdev_configure(const struct rte_eventdev *dev)
        struct dpaa2_eventdev *priv = dev->data->dev_private;
        struct rte_event_dev_config *conf = &dev->data->dev_conf;
 
-       PMD_DRV_FUNC_TRACE();
+       EVENTDEV_INIT_FUNC_TRACE();
 
        priv->dequeue_timeout_ns = conf->dequeue_timeout_ns;
        priv->nb_event_queues = conf->nb_event_queues;
@@ -326,14 +335,15 @@ dpaa2_eventdev_configure(const struct rte_eventdev *dev)
        priv->nb_event_port_enqueue_depth = conf->nb_event_port_enqueue_depth;
        priv->event_dev_cfg = conf->event_dev_cfg;
 
-       PMD_DRV_LOG(DEBUG, "Configured eventdev devid=%d", dev->data->dev_id);
+       DPAA2_EVENTDEV_DEBUG("Configured eventdev devid=%d",
+                            dev->data->dev_id);
        return 0;
 }
 
 static int
 dpaa2_eventdev_start(struct rte_eventdev *dev)
 {
-       PMD_DRV_FUNC_TRACE();
+       EVENTDEV_INIT_FUNC_TRACE();
 
        RTE_SET_USED(dev);
 
@@ -343,7 +353,7 @@ dpaa2_eventdev_start(struct rte_eventdev *dev)
 static void
 dpaa2_eventdev_stop(struct rte_eventdev *dev)
 {
-       PMD_DRV_FUNC_TRACE();
+       EVENTDEV_INIT_FUNC_TRACE();
 
        RTE_SET_USED(dev);
 }
@@ -351,7 +361,7 @@ dpaa2_eventdev_stop(struct rte_eventdev *dev)
 static int
 dpaa2_eventdev_close(struct rte_eventdev *dev)
 {
-       PMD_DRV_FUNC_TRACE();
+       EVENTDEV_INIT_FUNC_TRACE();
 
        RTE_SET_USED(dev);
 
@@ -362,7 +372,7 @@ static void
 dpaa2_eventdev_queue_def_conf(struct rte_eventdev *dev, uint8_t queue_id,
                              struct rte_event_queue_conf *queue_conf)
 {
-       PMD_DRV_FUNC_TRACE();
+       EVENTDEV_INIT_FUNC_TRACE();
 
        RTE_SET_USED(dev);
        RTE_SET_USED(queue_id);
@@ -377,7 +387,7 @@ dpaa2_eventdev_queue_def_conf(struct rte_eventdev *dev, uint8_t queue_id,
 static void
 dpaa2_eventdev_queue_release(struct rte_eventdev *dev, uint8_t queue_id)
 {
-       PMD_DRV_FUNC_TRACE();
+       EVENTDEV_INIT_FUNC_TRACE();
 
        RTE_SET_USED(dev);
        RTE_SET_USED(queue_id);
@@ -391,7 +401,7 @@ dpaa2_eventdev_queue_setup(struct rte_eventdev *dev, uint8_t queue_id,
        struct evq_info_t *evq_info =
                &priv->evq_info[queue_id];
 
-       PMD_DRV_FUNC_TRACE();
+       EVENTDEV_INIT_FUNC_TRACE();
 
        evq_info->event_queue_cfg = queue_conf->event_queue_cfg;
 
@@ -402,7 +412,7 @@ static void
 dpaa2_eventdev_port_def_conf(struct rte_eventdev *dev, uint8_t port_id,
                             struct rte_event_port_conf *port_conf)
 {
-       PMD_DRV_FUNC_TRACE();
+       EVENTDEV_INIT_FUNC_TRACE();
 
        RTE_SET_USED(dev);
        RTE_SET_USED(port_id);
@@ -414,12 +424,13 @@ dpaa2_eventdev_port_def_conf(struct rte_eventdev *dev, uint8_t port_id,
                DPAA2_EVENT_MAX_PORT_DEQUEUE_DEPTH;
        port_conf->enqueue_depth =
                DPAA2_EVENT_MAX_PORT_ENQUEUE_DEPTH;
+       port_conf->disable_implicit_release = 0;
 }
 
 static void
 dpaa2_eventdev_port_release(void *port)
 {
-       PMD_DRV_FUNC_TRACE();
+       EVENTDEV_INIT_FUNC_TRACE();
 
        RTE_SET_USED(port);
 }
@@ -428,7 +439,7 @@ static int
 dpaa2_eventdev_port_setup(struct rte_eventdev *dev, uint8_t port_id,
                          const struct rte_event_port_conf *port_conf)
 {
-       PMD_DRV_FUNC_TRACE();
+       EVENTDEV_INIT_FUNC_TRACE();
 
        RTE_SET_USED(port_conf);
 
@@ -454,7 +465,7 @@ dpaa2_eventdev_port_unlink(struct rte_eventdev *dev, void *port,
        struct evq_info_t *evq_info;
        int i;
 
-       PMD_DRV_FUNC_TRACE();
+       EVENTDEV_INIT_FUNC_TRACE();
 
        for (i = 0; i < nb_unlinks; i++) {
                evq_info = &priv->evq_info[queues[i]];
@@ -480,7 +491,7 @@ dpaa2_eventdev_port_link(struct rte_eventdev *dev, void *port,
        uint8_t channel_index;
        int ret, i, n;
 
-       PMD_DRV_FUNC_TRACE();
+       EVENTDEV_INIT_FUNC_TRACE();
 
        for (i = 0; i < nb_links; i++) {
                evq_info = &priv->evq_info[queues[i]];
@@ -492,8 +503,8 @@ dpaa2_eventdev_port_link(struct rte_eventdev *dev, void *port,
                        CMD_PRI_LOW, dpaa2_portal->dpio_dev->token,
                        evq_info->dpcon->dpcon_id, &channel_index);
                if (ret < 0) {
-                       PMD_DRV_ERR("Static dequeue cfg failed with ret: %d\n",
-                                   ret);
+                       DPAA2_EVENTDEV_ERR(
+                               "Static dequeue config failed: err(%d)", ret);
                        goto err;
                }
 
@@ -525,7 +536,7 @@ dpaa2_eventdev_timeout_ticks(struct rte_eventdev *dev, uint64_t ns,
 {
        uint32_t scale = 1;
 
-       PMD_DRV_FUNC_TRACE();
+       EVENTDEV_INIT_FUNC_TRACE();
 
        RTE_SET_USED(dev);
        *timeout_ticks = ns * scale;
@@ -536,7 +547,7 @@ dpaa2_eventdev_timeout_ticks(struct rte_eventdev *dev, uint64_t ns,
 static void
 dpaa2_eventdev_dump(struct rte_eventdev *dev, FILE *f)
 {
-       PMD_DRV_FUNC_TRACE();
+       EVENTDEV_INIT_FUNC_TRACE();
 
        RTE_SET_USED(dev);
        RTE_SET_USED(f);
@@ -549,7 +560,7 @@ dpaa2_eventdev_eth_caps_get(const struct rte_eventdev *dev,
 {
        const char *ethdev_driver = eth_dev->device->driver->name;
 
-       PMD_DRV_FUNC_TRACE();
+       EVENTDEV_INIT_FUNC_TRACE();
 
        RTE_SET_USED(dev);
 
@@ -571,14 +582,14 @@ dpaa2_eventdev_eth_queue_add_all(const struct rte_eventdev *dev,
        uint16_t dpcon_id = priv->evq_info[ev_qid].dpcon->dpcon_id;
        int i, ret;
 
-       PMD_DRV_FUNC_TRACE();
+       EVENTDEV_INIT_FUNC_TRACE();
 
        for (i = 0; i < eth_dev->data->nb_rx_queues; i++) {
                ret = dpaa2_eth_eventq_attach(eth_dev, i,
                                dpcon_id, queue_conf);
                if (ret) {
-                       PMD_DRV_ERR("dpaa2_eth_eventq_attach failed: ret %d\n",
-                                   ret);
+                       DPAA2_EVENTDEV_ERR(
+                               "Event queue attach failed: err(%d)", ret);
                        goto fail;
                }
        }
@@ -601,7 +612,7 @@ dpaa2_eventdev_eth_queue_add(const struct rte_eventdev *dev,
        uint16_t dpcon_id = priv->evq_info[ev_qid].dpcon->dpcon_id;
        int ret;
 
-       PMD_DRV_FUNC_TRACE();
+       EVENTDEV_INIT_FUNC_TRACE();
 
        if (rx_queue_id == -1)
                return dpaa2_eventdev_eth_queue_add_all(dev,
@@ -610,7 +621,8 @@ dpaa2_eventdev_eth_queue_add(const struct rte_eventdev *dev,
        ret = dpaa2_eth_eventq_attach(eth_dev, rx_queue_id,
                        dpcon_id, queue_conf);
        if (ret) {
-               PMD_DRV_ERR("dpaa2_eth_eventq_attach failed: ret: %d\n", ret);
+               DPAA2_EVENTDEV_ERR(
+                       "Event queue attach failed: err(%d)", ret);
                return ret;
        }
        return 0;
@@ -622,15 +634,15 @@ dpaa2_eventdev_eth_queue_del_all(const struct rte_eventdev *dev,
 {
        int i, ret;
 
-       PMD_DRV_FUNC_TRACE();
+       EVENTDEV_INIT_FUNC_TRACE();
 
        RTE_SET_USED(dev);
 
        for (i = 0; i < eth_dev->data->nb_rx_queues; i++) {
                ret = dpaa2_eth_eventq_detach(eth_dev, i);
                if (ret) {
-                       PMD_DRV_ERR("dpaa2_eth_eventq_detach failed: ret %d\n",
-                                   ret);
+                       DPAA2_EVENTDEV_ERR(
+                               "Event queue detach failed: err(%d)", ret);
                        return ret;
                }
        }
@@ -645,14 +657,15 @@ dpaa2_eventdev_eth_queue_del(const struct rte_eventdev *dev,
 {
        int ret;
 
-       PMD_DRV_FUNC_TRACE();
+       EVENTDEV_INIT_FUNC_TRACE();
 
        if (rx_queue_id == -1)
                return dpaa2_eventdev_eth_queue_del_all(dev, eth_dev);
 
        ret = dpaa2_eth_eventq_detach(eth_dev, rx_queue_id);
        if (ret) {
-               PMD_DRV_ERR("dpaa2_eth_eventq_detach failed: ret: %d\n", ret);
+               DPAA2_EVENTDEV_ERR(
+                       "Event queue detach failed: err(%d)", ret);
                return ret;
        }
 
@@ -663,7 +676,7 @@ static int
 dpaa2_eventdev_eth_start(const struct rte_eventdev *dev,
                         const struct rte_eth_dev *eth_dev)
 {
-       PMD_DRV_FUNC_TRACE();
+       EVENTDEV_INIT_FUNC_TRACE();
 
        RTE_SET_USED(dev);
        RTE_SET_USED(eth_dev);
@@ -675,7 +688,7 @@ static int
 dpaa2_eventdev_eth_stop(const struct rte_eventdev *dev,
                        const struct rte_eth_dev *eth_dev)
 {
-       PMD_DRV_FUNC_TRACE();
+       EVENTDEV_INIT_FUNC_TRACE();
 
        RTE_SET_USED(dev);
        RTE_SET_USED(eth_dev);
@@ -683,7 +696,7 @@ dpaa2_eventdev_eth_stop(const struct rte_eventdev *dev,
        return 0;
 }
 
-static const struct rte_eventdev_ops dpaa2_eventdev_ops = {
+static struct rte_eventdev_ops dpaa2_eventdev_ops = {
        .dev_infos_get    = dpaa2_eventdev_info_get,
        .dev_configure    = dpaa2_eventdev_configure,
        .dev_start        = dpaa2_eventdev_start,
@@ -726,14 +739,15 @@ dpaa2_eventdev_setup_dpci(struct dpaa2_dpci_dev *dpci_dev,
                dpaa2_eventdev_process_atomic;
 
        for (i = 0 ; i < DPAA2_EVENT_DPCI_MAX_QUEUES; i++) {
-               rx_queue_cfg.user_ctx = (uint64_t)(&dpci_dev->queue[i]);
+               rx_queue_cfg.user_ctx = (size_t)(&dpci_dev->queue[i]);
                ret = dpci_set_rx_queue(&dpci_dev->dpci,
                                        CMD_PRI_LOW,
                                        dpci_dev->token, i,
                                        &rx_queue_cfg);
                if (ret) {
-                       PMD_DRV_LOG(ERR,
-                                   "set_rx_q failed with err code: %d", ret);
+                       DPAA2_EVENTDEV_ERR(
+                               "DPCI Rx queue setup failed: err(%d)",
+                               ret);
                        return ret;
                }
        }
@@ -753,7 +767,7 @@ dpaa2_eventdev_create(const char *name)
                                           sizeof(struct dpaa2_eventdev),
                                           rte_socket_id());
        if (eventdev == NULL) {
-               PMD_DRV_ERR("Failed to create eventdev vdev %s", name);
+               DPAA2_EVENTDEV_ERR("Failed to create Event device %s", name);
                goto fail;
        }
 
@@ -787,8 +801,8 @@ dpaa2_eventdev_create(const char *name)
 
                ret = dpaa2_eventdev_setup_dpci(dpci_dev, dpcon_dev);
                if (ret) {
-                       PMD_DRV_LOG(ERR,
-                                   "dpci setup failed with err code: %d", ret);
+                       DPAA2_EVENTDEV_ERR(
+                                   "DPCI setup failed: err(%d)", ret);
                        return ret;
                }
                priv->max_event_queues++;
@@ -805,7 +819,7 @@ dpaa2_eventdev_probe(struct rte_vdev_device *vdev)
        const char *name;
 
        name = rte_vdev_device_name(vdev);
-       PMD_DRV_LOG(INFO, "Initializing %s", name);
+       DPAA2_EVENTDEV_INFO("Initializing %s", name);
        return dpaa2_eventdev_create(name);
 }
 
@@ -815,7 +829,7 @@ dpaa2_eventdev_remove(struct rte_vdev_device *vdev)
        const char *name;
 
        name = rte_vdev_device_name(vdev);
-       PMD_DRV_LOG(INFO, "Closing %s", name);
+       DPAA2_EVENTDEV_INFO("Closing %s", name);
 
        return rte_event_pmd_vdev_uninit(name);
 }
@@ -826,3 +840,12 @@ static struct rte_vdev_driver vdev_eventdev_dpaa2_pmd = {
 };
 
 RTE_PMD_REGISTER_VDEV(EVENTDEV_NAME_DPAA2_PMD, vdev_eventdev_dpaa2_pmd);
+
+RTE_INIT(dpaa2_eventdev_init_log);
+static void
+dpaa2_eventdev_init_log(void)
+{
+       dpaa2_logtype_event = rte_log_register("pmd.event.dpaa2");
+       if (dpaa2_logtype_event >= 0)
+               rte_log_set_level(dpaa2_logtype_event, RTE_LOG_NOTICE);
+}