This patch supports DPAA DMA driver logs.

Signed-off-by: Gagandeep Singh <g.si...@nxp.com>
---
 drivers/dma/dpaa/dpaa_qdma.c      | 10 +++++++
 drivers/dma/dpaa/dpaa_qdma_logs.h | 46 +++++++++++++++++++++++++++++++
 2 files changed, 56 insertions(+)
 create mode 100644 drivers/dma/dpaa/dpaa_qdma_logs.h

diff --git a/drivers/dma/dpaa/dpaa_qdma.c b/drivers/dma/dpaa/dpaa_qdma.c
index aea09edc9e..8b0454abce 100644
--- a/drivers/dma/dpaa/dpaa_qdma.c
+++ b/drivers/dma/dpaa/dpaa_qdma.c
@@ -6,6 +6,7 @@
 #include <rte_dmadev_pmd.h>
 
 #include "dpaa_qdma.h"
+#include "dpaa_qdma_logs.h"
 
 static inline int ilog2(int x)
 {
@@ -107,6 +108,7 @@ static struct fsl_qdma_queue
                for (i = 0; i < queue_num; i++) {
                        if (queue_size[i] > FSL_QDMA_CIRCULAR_DESC_SIZE_MAX ||
                            queue_size[i] < FSL_QDMA_CIRCULAR_DESC_SIZE_MIN) {
+                               DPAA_QDMA_ERR("Get wrong queue-sizes.\n");
                                return NULL;
                        }
                        queue_temp = queue_head + i + (j * queue_num);
@@ -143,6 +145,7 @@ static struct fsl_qdma_queue 
*fsl_qdma_prep_status_queue(void)
        status_size = QDMA_STATUS_SIZE;
        if (status_size > FSL_QDMA_CIRCULAR_DESC_SIZE_MAX ||
            status_size < FSL_QDMA_CIRCULAR_DESC_SIZE_MIN) {
+               DPAA_QDMA_ERR("Get wrong status_size.\n");
                return NULL;
        }
 
@@ -227,6 +230,7 @@ static int fsl_qdma_reg_init(struct fsl_qdma_engine 
*fsl_qdma)
        /* Try to halt the qDMA engine first. */
        ret = fsl_qdma_halt(fsl_qdma);
        if (ret) {
+               DPAA_QDMA_ERR("DMA halt failed!");
                return ret;
        }
 
@@ -353,6 +357,7 @@ dpaa_qdma_init(struct rte_dmadev *dmadev)
 
        ccsr_qdma_fd = open("/dev/mem", O_RDWR);
        if (unlikely(ccsr_qdma_fd < 0)) {
+               DPAA_QDMA_ERR("Can not open /dev/mem for qdma CCSR map");
                goto err;
        }
 
@@ -364,6 +369,8 @@ dpaa_qdma_init(struct rte_dmadev *dmadev)
 
        close(ccsr_qdma_fd);
        if (fsl_qdma->ctrl_base == MAP_FAILED) {
+               DPAA_QDMA_ERR("Can not map CCSR base qdma: Phys: %08" PRIx64
+                      "size %d\n", phys_addr, regs_size);
                goto err;
        }
 
@@ -387,6 +394,7 @@ dpaa_qdma_init(struct rte_dmadev *dmadev)
 
        ret = fsl_qdma_reg_init(fsl_qdma);
        if (ret) {
+               DPAA_QDMA_ERR("Can't Initialize the qDMA engine.\n");
                munmap(fsl_qdma->ctrl_base, regs_size);
                goto err;
        }
@@ -409,6 +417,7 @@ dpaa_qdma_probe(__rte_unused struct rte_dpaa_driver 
*dpaa_drv,
 
        dmadev = rte_dmadev_pmd_allocate(dpaa_dev->device.name);
        if (!dmadev) {
+               DPAA_QDMA_ERR("Unable to allocate dmadevice");
                return -EINVAL;
        }
 
@@ -462,3 +471,4 @@ static struct rte_dpaa_driver rte_dpaa_qdma_pmd = {
 };
 
 RTE_PMD_REGISTER_DPAA(dpaa_qdma, rte_dpaa_qdma_pmd);
+RTE_LOG_REGISTER_DEFAULT(dpaa_qdma_logtype, INFO);
diff --git a/drivers/dma/dpaa/dpaa_qdma_logs.h 
b/drivers/dma/dpaa/dpaa_qdma_logs.h
new file mode 100644
index 0000000000..01d4a508fc
--- /dev/null
+++ b/drivers/dma/dpaa/dpaa_qdma_logs.h
@@ -0,0 +1,46 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright 2021 NXP
+ */
+
+#ifndef __DPAA_QDMA_LOGS_H__
+#define __DPAA_QDMA_LOGS_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern int dpaa_qdma_logtype;
+
+#define DPAA_QDMA_LOG(level, fmt, args...) \
+       rte_log(RTE_LOG_ ## level, dpaa_qdma_logtype, "dpaa_qdma: " \
+               fmt "\n", ## args)
+
+#define DPAA_QDMA_DEBUG(fmt, args...) \
+       rte_log(RTE_LOG_DEBUG, dpaa_qdma_logtype, "dpaa_qdma: %s(): " \
+               fmt "\n", __func__, ## args)
+
+#define DPAA_QDMA_FUNC_TRACE() DPAA_QDMA_DEBUG(">>")
+
+#define DPAA_QDMA_INFO(fmt, args...) \
+       DPAA_QDMA_LOG(INFO, fmt, ## args)
+#define DPAA_QDMA_ERR(fmt, args...) \
+       DPAA_QDMA_LOG(ERR, fmt, ## args)
+#define DPAA_QDMA_WARN(fmt, args...) \
+       DPAA_QDMA_LOG(WARNING, fmt, ## args)
+
+/* DP Logs, toggled out at compile time if level lower than current level */
+#define DPAA_QDMA_DP_LOG(level, fmt, args...) \
+       RTE_LOG_DP(level, PMD, "dpaa_qdma: " fmt "\n", ## args)
+
+#define DPAA_QDMA_DP_DEBUG(fmt, args...) \
+       DPAA_QDMA_DP_LOG(DEBUG, fmt, ## args)
+#define DPAA_QDMA_DP_INFO(fmt, args...) \
+       DPAA_QDMA_DP_LOG(INFO, fmt, ## args)
+#define DPAA_QDMA_DP_WARN(fmt, args...) \
+       DPAA_QDMA_DP_LOG(WARNING, fmt, ## args)
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __DPAA_QDMA_LOGS_H__ */
-- 
2.25.1

Reply via email to