[dpdk-dev] [PATCH 1/6 v3] event/dpaa2: replace static with dynamic logging

Nipun Gupta nipun.gupta at nxp.com
Wed Jan 17 12:39:09 CET 2018


Signed-off-by: Nipun Gupta <nipun.gupta at nxp.com>
Acked-by: Hemant Agrawal <hemant.agrawal at nxp.com>
---
 drivers/event/dpaa2/dpaa2_eventdev.c      | 83 ++++++++++++++++---------------
 drivers/event/dpaa2/dpaa2_eventdev.h      | 12 -----
 drivers/event/dpaa2/dpaa2_eventdev_logs.h | 37 ++++++++++++++
 drivers/event/dpaa2/dpaa2_hw_dpcon.c      |  1 +
 4 files changed, 82 insertions(+), 51 deletions(-)
 create mode 100644 drivers/event/dpaa2/dpaa2_eventdev_logs.h

diff --git a/drivers/event/dpaa2/dpaa2_eventdev.c b/drivers/event/dpaa2/dpaa2_eventdev.c
index 498d049..542bccc 100644
--- a/drivers/event/dpaa2/dpaa2_eventdev.c
+++ b/drivers/event/dpaa2/dpaa2_eventdev.c
@@ -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 @@
 	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\n");
 			return 0;
 		}
 	}
@@ -118,7 +122,7 @@
 				if (!loop)
 					return num_tx;
 				frames_to_send = loop;
-				PMD_DRV_LOG(ERR, "Unable to allocate memory");
+				DPAA2_EVENTDEV_ERR("Unable to allocate memory");
 				goto send_partial;
 			}
 			rte_memcpy(ev_temp, event, sizeof(struct rte_event));
@@ -163,9 +167,9 @@ static void dpaa2_eventdev_dequeue_wait(uint64_t timeout_ticks)
 		 * case to avoid the problem.
 		 */
 		if (errno == EINTR) {
-			PMD_DRV_LOG(DEBUG, "epoll_wait fails\n");
+			DPAA2_EVENTDEV_DEBUG("epoll_wait fails\n");
 			if (i++ > 10)
-				PMD_DRV_LOG(DEBUG, "Dequeue burst Failed\n");
+				DPAA2_EVENTDEV_DEBUG("Dequeue burst Failed\n");
 		goto RETRY;
 		}
 	}
@@ -223,7 +227,7 @@ static void dpaa2_eventdev_process_atomic(struct qbman_swp *swp,
 	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\n");
 			return 0;
 		}
 	}
@@ -259,7 +263,7 @@ static void dpaa2_eventdev_process_atomic(struct qbman_swp *swp,
 			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\n");
 			return 0;
 		}
 
@@ -282,7 +286,7 @@ static void dpaa2_eventdev_process_atomic(struct qbman_swp *swp,
 {
 	struct dpaa2_eventdev *priv = dev->data->dev_private;
 
-	PMD_DRV_FUNC_TRACE();
+	EVENTDEV_INIT_FUNC_TRACE();
 
 	RTE_SET_USED(dev);
 
@@ -320,7 +324,7 @@ static void dpaa2_eventdev_process_atomic(struct qbman_swp *swp,
 	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;
@@ -330,14 +334,15 @@ static void dpaa2_eventdev_process_atomic(struct qbman_swp *swp,
 	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);
 
@@ -347,7 +352,7 @@ static void dpaa2_eventdev_process_atomic(struct qbman_swp *swp,
 static void
 dpaa2_eventdev_stop(struct rte_eventdev *dev)
 {
-	PMD_DRV_FUNC_TRACE();
+	EVENTDEV_INIT_FUNC_TRACE();
 
 	RTE_SET_USED(dev);
 }
@@ -355,7 +360,7 @@ static void dpaa2_eventdev_process_atomic(struct qbman_swp *swp,
 static int
 dpaa2_eventdev_close(struct rte_eventdev *dev)
 {
-	PMD_DRV_FUNC_TRACE();
+	EVENTDEV_INIT_FUNC_TRACE();
 
 	RTE_SET_USED(dev);
 
@@ -366,7 +371,7 @@ static void dpaa2_eventdev_process_atomic(struct qbman_swp *swp,
 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);
@@ -381,7 +386,7 @@ static void dpaa2_eventdev_process_atomic(struct qbman_swp *swp,
 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);
@@ -395,7 +400,7 @@ static void dpaa2_eventdev_process_atomic(struct qbman_swp *swp,
 	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;
 
@@ -406,7 +411,7 @@ static void dpaa2_eventdev_process_atomic(struct qbman_swp *swp,
 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);
@@ -424,7 +429,7 @@ static void dpaa2_eventdev_process_atomic(struct qbman_swp *swp,
 static void
 dpaa2_eventdev_port_release(void *port)
 {
-	PMD_DRV_FUNC_TRACE();
+	EVENTDEV_INIT_FUNC_TRACE();
 
 	RTE_SET_USED(port);
 }
@@ -433,7 +438,7 @@ static void dpaa2_eventdev_process_atomic(struct qbman_swp *swp,
 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);
 
@@ -459,7 +464,7 @@ static void dpaa2_eventdev_process_atomic(struct qbman_swp *swp,
 	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]];
@@ -485,7 +490,7 @@ static void dpaa2_eventdev_process_atomic(struct qbman_swp *swp,
 	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]];
@@ -497,7 +502,7 @@ static void dpaa2_eventdev_process_atomic(struct qbman_swp *swp,
 			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",
+			DPAA2_EVENTDEV_ERR("Static dequeue cfg failed with ret: %d\n",
 				    ret);
 			goto err;
 		}
@@ -530,7 +535,7 @@ static void dpaa2_eventdev_process_atomic(struct qbman_swp *swp,
 {
 	uint32_t scale = 1;
 
-	PMD_DRV_FUNC_TRACE();
+	EVENTDEV_INIT_FUNC_TRACE();
 
 	RTE_SET_USED(dev);
 	*timeout_ticks = ns * scale;
@@ -541,7 +546,7 @@ static void dpaa2_eventdev_process_atomic(struct qbman_swp *swp,
 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);
@@ -554,7 +559,7 @@ static void dpaa2_eventdev_process_atomic(struct qbman_swp *swp,
 {
 	const char *ethdev_driver = eth_dev->device->driver->name;
 
-	PMD_DRV_FUNC_TRACE();
+	EVENTDEV_INIT_FUNC_TRACE();
 
 	RTE_SET_USED(dev);
 
@@ -576,13 +581,13 @@ static void dpaa2_eventdev_process_atomic(struct qbman_swp *swp,
 	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",
+			DPAA2_EVENTDEV_ERR("dpaa2_eth_eventq_attach failed: ret %d\n",
 				    ret);
 			goto fail;
 		}
@@ -606,7 +611,7 @@ static void dpaa2_eventdev_process_atomic(struct qbman_swp *swp,
 	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,
@@ -615,7 +620,7 @@ static void dpaa2_eventdev_process_atomic(struct qbman_swp *swp,
 	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("dpaa2_eth_eventq_attach failed: ret: %d\n", ret);
 		return ret;
 	}
 	return 0;
@@ -627,14 +632,14 @@ static void dpaa2_eventdev_process_atomic(struct qbman_swp *swp,
 {
 	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",
+			DPAA2_EVENTDEV_ERR("dpaa2_eth_eventq_detach failed: ret %d\n",
 				    ret);
 			return ret;
 		}
@@ -650,14 +655,14 @@ static void dpaa2_eventdev_process_atomic(struct qbman_swp *swp,
 {
 	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("dpaa2_eth_eventq_detach failed: ret: %d\n", ret);
 		return ret;
 	}
 
@@ -668,7 +673,7 @@ static void dpaa2_eventdev_process_atomic(struct qbman_swp *swp,
 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);
@@ -680,7 +685,7 @@ static void dpaa2_eventdev_process_atomic(struct qbman_swp *swp,
 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);
@@ -737,7 +742,7 @@ static void dpaa2_eventdev_process_atomic(struct qbman_swp *swp,
 					dpci_dev->token, i,
 					&rx_queue_cfg);
 		if (ret) {
-			PMD_DRV_LOG(ERR,
+			DPAA2_EVENTDEV_ERR(
 				    "set_rx_q failed with err code: %d", ret);
 			return ret;
 		}
@@ -758,7 +763,7 @@ static void dpaa2_eventdev_process_atomic(struct qbman_swp *swp,
 					   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 eventdev vdev %s", name);
 		goto fail;
 	}
 
@@ -792,7 +797,7 @@ static void dpaa2_eventdev_process_atomic(struct qbman_swp *swp,
 
 		ret = dpaa2_eventdev_setup_dpci(dpci_dev, dpcon_dev);
 		if (ret) {
-			PMD_DRV_LOG(ERR,
+			DPAA2_EVENTDEV_ERR(
 				    "dpci setup failed with err code: %d", ret);
 			return ret;
 		}
@@ -810,7 +815,7 @@ static void dpaa2_eventdev_process_atomic(struct qbman_swp *swp,
 	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);
 }
 
@@ -820,7 +825,7 @@ static void dpaa2_eventdev_process_atomic(struct qbman_swp *swp,
 	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);
 }
diff --git a/drivers/event/dpaa2/dpaa2_eventdev.h b/drivers/event/dpaa2/dpaa2_eventdev.h
index 96524fa..91c8f2a 100644
--- a/drivers/event/dpaa2/dpaa2_eventdev.h
+++ b/drivers/event/dpaa2/dpaa2_eventdev.h
@@ -16,18 +16,6 @@
 
 #define EVENTDEV_NAME_DPAA2_PMD		event_dpaa2
 
-#ifdef RTE_LIBRTE_PMD_DPAA2_EVENTDEV_DEBUG
-#define PMD_DRV_LOG(level, fmt, args...) \
-	RTE_LOG(level, PMD, "%s(): " fmt "\n", __func__, ## args)
-#define PMD_DRV_FUNC_TRACE() PMD_DRV_LOG(DEBUG, ">>")
-#else
-#define PMD_DRV_LOG(level, fmt, args...) do { } while (0)
-#define PMD_DRV_FUNC_TRACE() do { } while (0)
-#endif
-
-#define PMD_DRV_ERR(fmt, args...) \
-	RTE_LOG(ERR, PMD, "%s(): " fmt "\n", __func__, ## args)
-
 #define DPAA2_EVENT_DEFAULT_DPCI_PRIO 0
 
 #define DPAA2_EVENT_MAX_QUEUES			16
diff --git a/drivers/event/dpaa2/dpaa2_eventdev_logs.h b/drivers/event/dpaa2/dpaa2_eventdev_logs.h
new file mode 100644
index 0000000..7d250c3
--- /dev/null
+++ b/drivers/event/dpaa2/dpaa2_eventdev_logs.h
@@ -0,0 +1,37 @@
+/*-
+ * SPDX-License-Identifier: BSD-3-Clause
+ * Copyright 2018 NXP
+ */
+
+#ifndef _DPAA2_EVENTDEV_LOGS_H_
+#define _DPAA2_EVENTDEV_LOGS_H_
+
+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)
+
+#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...) \
+	DPAA2_EVENTDEV_LOG(ERR, fmt, ## args)
+#define DPAA2_EVENTDEV_WARN(fmt, args...) \
+	DPAA2_EVENTDEV_LOG(WARNING, fmt, ## args)
+
+/* DP Logs, toggled out at compile time if level lower than current level */
+#define DPAA2_EVENTDEV_DP_LOG(level, fmt, args...) \
+	RTE_LOG_DP(level, PMD, fmt, ## args)
+
+#define DPAA2_EVENTDEV_DP_DEBUG(fmt, args...) \
+	DPAA2_EVENTDEV_DP_LOG(DEBUG, fmt, ## args)
+#define DPAA2_EVENTDEV_DP_INFO(fmt, args...) \
+	DPAA2_EVENTDEV_DP_LOG(INFO, fmt, ## args)
+#define DPAA2_EVENTDEV_DP_WARN(fmt, args...) \
+	DPAA2_EVENTDEV_DP_LOG(WARNING, fmt, ## args)
+
+#endif /* _DPAA2_EVENTDEV_LOGS_H_ */
diff --git a/drivers/event/dpaa2/dpaa2_hw_dpcon.c b/drivers/event/dpaa2/dpaa2_hw_dpcon.c
index cdb3f86..c949b2d 100644
--- a/drivers/event/dpaa2/dpaa2_hw_dpcon.c
+++ b/drivers/event/dpaa2/dpaa2_hw_dpcon.c
@@ -20,6 +20,7 @@
 #include <rte_dev.h>
 #include <rte_ethdev.h>
 
+#include <fslmc_logs.h>
 #include <rte_fslmc.h>
 #include <mc/fsl_dpcon.h>
 #include <portal/dpaa2_hw_pvt.h>
-- 
1.9.1



More information about the dev mailing list