event/dpaa2: support dynamic logging
authorShreyansh Jain <shreyansh.jain@nxp.com>
Mon, 2 Apr 2018 14:05:58 +0000 (19:35 +0530)
committerThomas Monjalon <thomas@monjalon.net>
Mon, 2 Apr 2018 21:42:23 +0000 (23:42 +0200)
Some changes had already been pushed via SHA:72654f090a11 patch. This
patch updates them.

Signed-off-by: Shreyansh Jain <shreyansh.jain@nxp.com>
Acked-by: Nipun Gupta <nipun.gupta@nxp.com>
doc/guides/eventdevs/dpaa2.rst
drivers/event/dpaa2/dpaa2_eventdev.c
drivers/event/dpaa2/dpaa2_eventdev_logs.h
drivers/event/dpaa2/dpaa2_hw_dpcon.c

index 5b8da95..ad94f24 100644 (file)
@@ -129,7 +129,19 @@ Example:
 
 .. code-block:: console
 
-    ./your_eventdev_application --vdev="event_dpaa2"
+   ./your_eventdev_application --vdev="event_dpaa2"
+
+Enabling logs
+-------------
+
+For enabling logs, use the following EAL parameter:
+
+.. code-block:: console
+
+   ./your_eventdev_application <EAL args> --log-level=pmd.event.dpaa2,<level>
+
+Using ``eventdev.dpaa2`` as log matching criteria, all Event PMD logs can be
+enabled which are lower than logging ``level``.
 
 Limitations
 -----------
index 8800b47..9d9c8d3 100644 (file)
@@ -72,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) {
-                       DPAA2_EVENTDEV_ERR("Failure in affining portal\n");
+                       DPAA2_EVENTDEV_ERR("Failure in affining portal");
                        return 0;
                }
        }
@@ -122,7 +122,8 @@ dpaa2_eventdev_enqueue_burst(void *port, const struct rte_event ev[],
                                if (!loop)
                                        return num_tx;
                                frames_to_send = loop;
-                               DPAA2_EVENTDEV_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));
@@ -167,9 +168,9 @@ RETRY:
                 * case to avoid the problem.
                 */
                if (errno == EINTR) {
-                       DPAA2_EVENTDEV_DEBUG("epoll_wait fails\n");
+                       DPAA2_EVENTDEV_DEBUG("epoll_wait fails");
                        if (i++ > 10)
-                               DPAA2_EVENTDEV_DEBUG("Dequeue burst Failed\n");
+                               DPAA2_EVENTDEV_DEBUG("Dequeue burst Failed");
                goto RETRY;
                }
        }
@@ -227,7 +228,7 @@ dpaa2_eventdev_dequeue_burst(void *port, struct rte_event ev[],
        if (unlikely(!DPAA2_PER_LCORE_DPIO)) {
                ret = dpaa2_affine_qbman_swp();
                if (ret) {
-                       DPAA2_EVENTDEV_ERR("Failure in affining portal\n");
+                       DPAA2_EVENTDEV_ERR("Failure in affining portal");
                        return 0;
                }
        }
@@ -263,7 +264,7 @@ dpaa2_eventdev_dequeue_burst(void *port, struct rte_event ev[],
                        rxq->cb(swp, fd, dq, rxq, &ev[num_pkts]);
                } else {
                        qbman_swp_dqrr_consume(swp, dq);
-                       DPAA2_EVENTDEV_ERR("Null Return VQ received\n");
+                       DPAA2_EVENTDEV_ERR("Null Return VQ received");
                        return 0;
                }
 
@@ -335,7 +336,7 @@ dpaa2_eventdev_configure(const struct rte_eventdev *dev)
        priv->event_dev_cfg = conf->event_dev_cfg;
 
        DPAA2_EVENTDEV_DEBUG("Configured eventdev devid=%d",
-               dev->data->dev_id);
+                            dev->data->dev_id);
        return 0;
 }
 
@@ -502,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) {
-                       DPAA2_EVENTDEV_ERR("Static dequeue cfg failed with ret: %d\n",
-                                   ret);
+                       DPAA2_EVENTDEV_ERR(
+                               "Static dequeue config failed: err(%d)", ret);
                        goto err;
                }
 
@@ -587,8 +588,8 @@ dpaa2_eventdev_eth_queue_add_all(const struct rte_eventdev *dev,
                ret = dpaa2_eth_eventq_attach(eth_dev, i,
                                dpcon_id, queue_conf);
                if (ret) {
-                       DPAA2_EVENTDEV_ERR("dpaa2_eth_eventq_attach failed: ret %d\n",
-                                   ret);
+                       DPAA2_EVENTDEV_ERR(
+                               "Event queue attach failed: err(%d)", ret);
                        goto fail;
                }
        }
@@ -620,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) {
-               DPAA2_EVENTDEV_ERR("dpaa2_eth_eventq_attach failed: ret: %d\n", ret);
+               DPAA2_EVENTDEV_ERR(
+                       "Event queue attach failed: err(%d)", ret);
                return ret;
        }
        return 0;
@@ -639,8 +641,8 @@ dpaa2_eventdev_eth_queue_del_all(const struct rte_eventdev *dev,
        for (i = 0; i < eth_dev->data->nb_rx_queues; i++) {
                ret = dpaa2_eth_eventq_detach(eth_dev, i);
                if (ret) {
-                       DPAA2_EVENTDEV_ERR("dpaa2_eth_eventq_detach failed: ret %d\n",
-                                   ret);
+                       DPAA2_EVENTDEV_ERR(
+                               "Event queue detach failed: err(%d)", ret);
                        return ret;
                }
        }
@@ -662,7 +664,8 @@ dpaa2_eventdev_eth_queue_del(const struct rte_eventdev *dev,
 
        ret = dpaa2_eth_eventq_detach(eth_dev, rx_queue_id);
        if (ret) {
-               DPAA2_EVENTDEV_ERR("dpaa2_eth_eventq_detach failed: ret: %d\n", ret);
+               DPAA2_EVENTDEV_ERR(
+                       "Event queue detach failed: err(%d)", ret);
                return ret;
        }
 
@@ -743,7 +746,8 @@ dpaa2_eventdev_setup_dpci(struct dpaa2_dpci_dev *dpci_dev,
                                        &rx_queue_cfg);
                if (ret) {
                        DPAA2_EVENTDEV_ERR(
-                                   "set_rx_q failed with err code: %d", ret);
+                               "DPCI Rx queue setup failed: err(%d)",
+                               ret);
                        return ret;
                }
        }
@@ -763,7 +767,7 @@ dpaa2_eventdev_create(const char *name)
                                           sizeof(struct dpaa2_eventdev),
                                           rte_socket_id());
        if (eventdev == NULL) {
-               DPAA2_EVENTDEV_ERR("Failed to create eventdev vdev %s", name);
+               DPAA2_EVENTDEV_ERR("Failed to create Event device %s", name);
                goto fail;
        }
 
@@ -798,7 +802,7 @@ dpaa2_eventdev_create(const char *name)
                ret = dpaa2_eventdev_setup_dpci(dpci_dev, dpcon_dev);
                if (ret) {
                        DPAA2_EVENTDEV_ERR(
-                                   "dpci setup failed with err code: %d", ret);
+                                   "DPCI setup failed: err(%d)", ret);
                        return ret;
                }
                priv->max_event_queues++;
@@ -836,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);
+}
index 7d250c3..48f1abd 100644 (file)
@@ -9,13 +9,15 @@
 extern int dpaa2_logtype_event;
 
 #define DPAA2_EVENTDEV_LOG(level, fmt, args...) \
-       rte_log(RTE_LOG_ ## level, dpaa2_logtype_event, "%s(): " fmt "\n", \
-               __func__, ##args)
+       rte_log(RTE_LOG_ ## level, dpaa2_logtype_event, "dpaa2_event: " \
+               fmt "\n", ##args)
+
+#define DPAA2_EVENTDEV_DEBUG(fmt, args...) \
+       rte_log(RTE_LOG_DEBUG, dpaa2_logtype_event, "dpaa2_event: %s(): " \
+               fmt "\n", __func__, ##args)
 
 #define EVENTDEV_INIT_FUNC_TRACE() DPAA2_EVENTDEV_LOG(DEBUG, " >>")
 
-#define DPAA2_EVENTDEV_DEBUG(fmt, args...) \
-       DPAA2_EVENTDEV_LOG(DEBUG, fmt, ## args)
 #define DPAA2_EVENTDEV_INFO(fmt, args...) \
        DPAA2_EVENTDEV_LOG(INFO, fmt, ## args)
 #define DPAA2_EVENTDEV_ERR(fmt, args...) \
index f2377b9..d64e588 100644 (file)
 #include <rte_dev.h>
 #include <rte_ethdev_driver.h>
 
-#include <fslmc_logs.h>
 #include <rte_fslmc.h>
 #include <mc/fsl_dpcon.h>
 #include <portal/dpaa2_hw_pvt.h>
 #include "dpaa2_eventdev.h"
+#include "dpaa2_eventdev_logs.h"
 
 TAILQ_HEAD(dpcon_dev_list, dpaa2_dpcon_dev);
 static struct dpcon_dev_list dpcon_dev_list
@@ -42,7 +42,8 @@ rte_dpaa2_create_dpcon_device(int dev_fd __rte_unused,
        /* Allocate DPAA2 dpcon handle */
        dpcon_node = rte_malloc(NULL, sizeof(struct dpaa2_dpcon_dev), 0);
        if (!dpcon_node) {
-               PMD_DRV_LOG(ERR, "Memory allocation failed for DPCON Device");
+               DPAA2_EVENTDEV_ERR(
+                               "Memory allocation failed for dpcon device");
                return -1;
        }
 
@@ -51,8 +52,8 @@ rte_dpaa2_create_dpcon_device(int dev_fd __rte_unused,
        ret = dpcon_open(&dpcon_node->dpcon,
                         CMD_PRI_LOW, dpcon_id, &dpcon_node->token);
        if (ret) {
-               PMD_DRV_LOG(ERR, "Resource alloc failure with err code: %d",
-                           ret);
+               DPAA2_EVENTDEV_ERR("Unable to open dpcon device: err(%d)",
+                                  ret);
                rte_free(dpcon_node);
                return -1;
        }
@@ -61,8 +62,8 @@ rte_dpaa2_create_dpcon_device(int dev_fd __rte_unused,
        ret = dpcon_get_attributes(&dpcon_node->dpcon,
                                   CMD_PRI_LOW, dpcon_node->token, &attr);
        if (ret != 0) {
-               PMD_DRV_LOG(ERR, "Reading device failed with err code: %d",
-                           ret);
+               DPAA2_EVENTDEV_ERR("dpcon attribute fetch failed: err(%d)",
+                                  ret);
                rte_free(dpcon_node);
                return -1;
        }
@@ -75,8 +76,6 @@ rte_dpaa2_create_dpcon_device(int dev_fd __rte_unused,
 
        TAILQ_INSERT_TAIL(&dpcon_dev_list, dpcon_node, next);
 
-       RTE_LOG(DEBUG, PMD, "DPAA2: Added [dpcon.%d]\n", dpcon_id);
-
        return 0;
 }