Driver should not be using PMD logtype, they should have their
own logtype.

Signed-off-by: Stephen Hemminger <step...@networkplumber.org>
---
 drivers/common/cnxk/roc_platform.h         | 16 ++++++-----
 drivers/raw/cnxk_bphy/cnxk_bphy.c          |  3 ++-
 drivers/raw/cnxk_bphy/cnxk_bphy_cgx.c      |  2 +-
 drivers/raw/cnxk_bphy/cnxk_bphy_cgx_test.c | 31 +++++++++++-----------
 drivers/raw/cnxk_bphy/rte_pmd_bphy.h       |  6 +++++
 drivers/raw/cnxk_gpio/cnxk_gpio.c          | 21 ++++++++-------
 drivers/raw/cnxk_gpio/cnxk_gpio.h          |  5 ++++
 drivers/raw/cnxk_gpio/cnxk_gpio_selftest.c | 17 ++++++------
 8 files changed, 57 insertions(+), 44 deletions(-)

diff --git a/drivers/common/cnxk/roc_platform.h 
b/drivers/common/cnxk/roc_platform.h
index ba23b2e0d79e..9d2ea8f00965 100644
--- a/drivers/common/cnxk/roc_platform.h
+++ b/drivers/common/cnxk/roc_platform.h
@@ -265,11 +265,13 @@ extern int cnxk_logtype_tm;
 extern int cnxk_logtype_ree;
 extern int cnxk_logtype_dpi;
 
+#define RTE_LOGTYPE_CNXK cnxk_logtype_base
+
 #define plt_err(fmt, args...)                                                  
\
-       RTE_LOG(ERR, PMD, "%s():%u " fmt "\n", __func__, __LINE__, ##args)
-#define plt_info(fmt, args...) RTE_LOG(INFO, PMD, fmt "\n", ##args)
-#define plt_warn(fmt, args...) RTE_LOG(WARNING, PMD, fmt "\n", ##args)
-#define plt_print(fmt, args...) RTE_LOG(INFO, PMD, fmt "\n", ##args)
+       RTE_LOG(ERR, CNXK, "%s():%u " fmt "\n", __func__, __LINE__, ##args)
+#define plt_info(fmt, args...) RTE_LOG(INFO, CNXK, fmt "\n", ##args)
+#define plt_warn(fmt, args...) RTE_LOG(WARNING, CNXK, fmt "\n", ##args)
+#define plt_print(fmt, args...) RTE_LOG(INFO, CNXK, fmt "\n", ##args)
 #define plt_dump(fmt, ...)      fprintf(stderr, fmt "\n", ##__VA_ARGS__)
 #define plt_dump_no_nl(fmt, ...) fprintf(stderr, fmt, ##__VA_ARGS__)
 
@@ -296,11 +298,11 @@ extern int cnxk_logtype_dpi;
 
 /* Datapath logs */
 #define plt_dp_err(fmt, args...)                                               
\
-       RTE_LOG_DP(ERR, PMD, "%s():%u " fmt "\n", __func__, __LINE__, ##args)
+       RTE_LOG_DP(ERR, CNXK, "%s():%u " fmt "\n", __func__, __LINE__, ##args)
 #define plt_dp_info(fmt, args...)                                              
\
-       RTE_LOG_DP(INFO, PMD, "%s():%u " fmt "\n", __func__, __LINE__, ##args)
+       RTE_LOG_DP(INFO, CNXK, "%s():%u " fmt "\n", __func__, __LINE__, ##args)
 #define plt_dp_dbg(fmt, args...)                                              \
-       RTE_LOG_DP(DEBUG, PMD, "%s():%u " fmt "\n", __func__, __LINE__, ##args)
+       RTE_LOG_DP(DEBUG, CNXK, "%s():%u " fmt "\n", __func__, __LINE__, ##args)
 
 #ifdef __cplusplus
 #define CNXK_PCI_ID(subsystem_dev, dev)                                        
\
diff --git a/drivers/raw/cnxk_bphy/cnxk_bphy.c 
b/drivers/raw/cnxk_bphy/cnxk_bphy.c
index 15dbc4c1a637..1dbab6fb3e12 100644
--- a/drivers/raw/cnxk_bphy/cnxk_bphy.c
+++ b/drivers/raw/cnxk_bphy/cnxk_bphy.c
@@ -251,7 +251,7 @@ cnxk_bphy_irq_enqueue_bufs(struct rte_rawdev *dev,
 
        /* get rid of last response if any */
        if (qp->rsp) {
-               RTE_LOG(WARNING, PMD, "Previous response got overwritten\n");
+               CNXK_BPHY_LOG(WARNING, "Previous response got overwritten");
                rte_free(qp->rsp);
        }
        qp->rsp = rsp;
@@ -410,3 +410,4 @@ static struct rte_pci_driver cnxk_bphy_rawdev_pmd = {
 RTE_PMD_REGISTER_PCI(bphy_rawdev_pci_driver, cnxk_bphy_rawdev_pmd);
 RTE_PMD_REGISTER_PCI_TABLE(bphy_rawdev_pci_driver, pci_bphy_map);
 RTE_PMD_REGISTER_KMOD_DEP(bphy_rawdev_pci_driver, "vfio-pci");
+RTE_LOG_REGISTER_SUFFIX(cnxk_logtype_bphy, bphy, INFO);
diff --git a/drivers/raw/cnxk_bphy/cnxk_bphy_cgx.c 
b/drivers/raw/cnxk_bphy/cnxk_bphy_cgx.c
index 2d8466ef918b..4358aeecc3e5 100644
--- a/drivers/raw/cnxk_bphy/cnxk_bphy_cgx.c
+++ b/drivers/raw/cnxk_bphy/cnxk_bphy_cgx.c
@@ -189,7 +189,7 @@ cnxk_bphy_cgx_process_buf(struct cnxk_bphy_cgx *cgx, 
unsigned int queue,
 
        /* get rid of last response if any */
        if (qp->rsp) {
-               RTE_LOG(WARNING, PMD, "Previous response got overwritten\n");
+               CNXK_BPHY_LOG(WARNING, "Previous response got overwritten");
                rte_free(qp->rsp);
        }
        qp->rsp = rsp;
diff --git a/drivers/raw/cnxk_bphy/cnxk_bphy_cgx_test.c 
b/drivers/raw/cnxk_bphy/cnxk_bphy_cgx_test.c
index a3021b4bb7db..f01d958661ad 100644
--- a/drivers/raw/cnxk_bphy/cnxk_bphy_cgx_test.c
+++ b/drivers/raw/cnxk_bphy/cnxk_bphy_cgx_test.c
@@ -57,62 +57,61 @@ cnxk_bphy_cgx_dev_selftest(uint16_t dev_id)
                if (ret)
                        break;
                if (descs != 1) {
-                       RTE_LOG(ERR, PMD, "Wrong number of descs reported\n");
+                       CNXK_BPHY_LOG(ERR, "Wrong number of descs reported");
                        ret = -ENODEV;
                        break;
                }
 
-               RTE_LOG(INFO, PMD, "Testing queue %d\n", i);
+               CNXK_BPHY_LOG(INFO, "Testing queue %d", i);
 
                ret = rte_pmd_bphy_cgx_stop_rxtx(dev_id, i);
                if (ret) {
-                       RTE_LOG(ERR, PMD, "Failed to stop rx/tx\n");
+                       CNXK_BPHY_LOG(ERR, "Failed to stop rx/tx");
                        break;
                }
 
                ret = rte_pmd_bphy_cgx_start_rxtx(dev_id, i);
                if (ret) {
-                       RTE_LOG(ERR, PMD, "Failed to start rx/tx\n");
+                       CNXK_BPHY_LOG(ERR, "Failed to start rx/tx");
                        break;
                }
 
                ret = rte_pmd_bphy_cgx_set_link_state(dev_id, i, false);
                if (ret) {
-                       RTE_LOG(ERR, PMD, "Failed to set link down\n");
+                       CNXK_BPHY_LOG(ERR, "Failed to set link down");
                        break;
                }
 
                ret = cnxk_bphy_cgx_link_cond(dev_id, i, 0);
                if (ret != 0)
-                       RTE_LOG(ERR, PMD,
-                               "Timed out waiting for a link down\n");
+                       CNXK_BPHY_LOG(ERR, "Timed out waiting for a link down");
 
                ret = rte_pmd_bphy_cgx_set_link_state(dev_id, i, true);
                if (ret) {
-                       RTE_LOG(ERR, PMD, "Failed to set link up\n");
+                       CNXK_BPHY_LOG(ERR, "Failed to set link up");
                        break;
                }
 
                ret = cnxk_bphy_cgx_link_cond(dev_id, i, 1);
                if (ret != 1)
-                       RTE_LOG(ERR, PMD, "Timed out waiting for a link up\n");
+                       CNXK_BPHY_LOG(ERR, "Timed out waiting for a link up");
 
                ret = rte_pmd_bphy_cgx_intlbk_enable(dev_id, i);
                if (ret) {
-                       RTE_LOG(ERR, PMD, "Failed to enable internal lbk\n");
+                       CNXK_BPHY_LOG(ERR, "Failed to enable internal lbk");
                        break;
                }
 
                ret = rte_pmd_bphy_cgx_intlbk_disable(dev_id, i);
                if (ret) {
-                       RTE_LOG(ERR, PMD, "Failed to disable internal lbk\n");
+                       CNXK_BPHY_LOG(ERR, "Failed to disable internal lbk");
                        break;
                }
 
                ret = rte_pmd_bphy_cgx_ptp_rx_enable(dev_id, i);
                /* ptp not available on RPM */
                if (ret < 0 && ret != -ENOTSUP) {
-                       RTE_LOG(ERR, PMD, "Failed to enable ptp\n");
+                       CNXK_BPHY_LOG(ERR, "Failed to enable ptp");
                        break;
                }
                ret = 0;
@@ -120,27 +119,27 @@ cnxk_bphy_cgx_dev_selftest(uint16_t dev_id)
                ret = rte_pmd_bphy_cgx_ptp_rx_disable(dev_id, i);
                /* ptp not available on RPM */
                if (ret < 0 && ret != -ENOTSUP) {
-                       RTE_LOG(ERR, PMD, "Failed to disable ptp\n");
+                       CNXK_BPHY_LOG(ERR, "Failed to disable ptp");
                        break;
                }
                ret = 0;
 
                ret = rte_pmd_bphy_cgx_get_supported_fec(dev_id, i, &fec);
                if (ret) {
-                       RTE_LOG(ERR, PMD, "Failed to get supported FEC\n");
+                       CNXK_BPHY_LOG(ERR, "Failed to get supported FEC");
                        break;
                }
 
                ret = rte_pmd_bphy_cgx_set_fec(dev_id, i, fec);
                if (ret) {
-                       RTE_LOG(ERR, PMD, "Failed to set FEC to %d\n", fec);
+                       CNXK_BPHY_LOG(ERR, "Failed to set FEC to %d", fec);
                        break;
                }
 
                fec = CNXK_BPHY_CGX_ETH_LINK_FEC_NONE;
                ret = rte_pmd_bphy_cgx_set_fec(dev_id, i, fec);
                if (ret) {
-                       RTE_LOG(ERR, PMD, "Failed to disable FEC\n");
+                       CNXK_BPHY_LOG(ERR, "Failed to disable FEC");
                        break;
                }
        }
diff --git a/drivers/raw/cnxk_bphy/rte_pmd_bphy.h 
b/drivers/raw/cnxk_bphy/rte_pmd_bphy.h
index 9d8d0285581b..7a7d9f6fa66f 100644
--- a/drivers/raw/cnxk_bphy/rte_pmd_bphy.h
+++ b/drivers/raw/cnxk_bphy/rte_pmd_bphy.h
@@ -26,6 +26,12 @@
 extern "C" {
 #endif
 
+extern int cnxk_logtype_bphy;
+
+#define CNXK_BPHY_LOG(level, fmt, args...)     \
+       rte_log(RTE_LOG_ ## level, cnxk_logtype_bphy, \
+               "%s(): " fmt "\n", __func__, ## args)
+
 /** Available message types */
 enum cnxk_bphy_cgx_msg_type {
        /** Type used to obtain link information */
diff --git a/drivers/raw/cnxk_gpio/cnxk_gpio.c 
b/drivers/raw/cnxk_gpio/cnxk_gpio.c
index 3c4d79e4810e..329ac28a2736 100644
--- a/drivers/raw/cnxk_gpio/cnxk_gpio.c
+++ b/drivers/raw/cnxk_gpio/cnxk_gpio.c
@@ -215,13 +215,13 @@ cnxk_gpio_parse_allowlist(struct cnxk_gpiochip *gpiochip, 
char *allowlist)
                errno = 0;
                val = strtol(token, NULL, 10);
                if (errno) {
-                       RTE_LOG(ERR, PMD, "failed to parse %s\n", token);
+                       CNXK_GPIO_LOG(ERR, "failed to parse %s", token);
                        ret = -errno;
                        goto out;
                }
 
                if (val < 0 || val >= gpiochip->num_gpios) {
-                       RTE_LOG(ERR, PMD, "gpio%d out of 0-%d range\n", val,
+                       CNXK_GPIO_LOG(ERR, "gpio%d out of 0-%d range", val,
                                gpiochip->num_gpios - 1);
                        ret = -EINVAL;
                        goto out;
@@ -231,7 +231,7 @@ cnxk_gpio_parse_allowlist(struct cnxk_gpiochip *gpiochip, 
char *allowlist)
                        if (list[i] != val)
                                continue;
 
-                       RTE_LOG(WARNING, PMD, "gpio%d already allowed\n", val);
+                       CNXK_GPIO_LOG(WARNING, "gpio%d already allowed", val);
                        break;
                }
                if (i == queue)
@@ -398,7 +398,7 @@ cnxk_gpio_queue_setup(struct rte_rawdev *dev, uint16_t 
queue_id,
                        return ret;
                }
        } else {
-               RTE_LOG(WARNING, PMD, "using existing gpio%d\n", gpio->num);
+               CNXK_GPIO_LOG(WARNING, "using existing gpio%d", gpio->num);
        }
 
        gpiochip->gpios[num] = gpio;
@@ -647,7 +647,7 @@ cnxk_gpio_process_buf(struct cnxk_gpio *gpio, struct 
rte_rawdev_buf *rbuf)
 
        /* get rid of last response if any */
        if (gpio->rsp) {
-               RTE_LOG(WARNING, PMD, "previous response got overwritten\n");
+               CNXK_GPIO_LOG(WARNING, "previous response got overwritten");
                rte_free(gpio->rsp);
        }
        gpio->rsp = rsp;
@@ -741,7 +741,7 @@ cnxk_gpio_probe(struct rte_vdev_device *dev)
        cnxk_gpio_format_name(name, sizeof(name));
        rawdev = rte_rawdev_pmd_allocate(name, sizeof(*gpiochip), 
rte_socket_id());
        if (!rawdev) {
-               RTE_LOG(ERR, PMD, "failed to allocate %s rawdev\n", name);
+               CNXK_GPIO_LOG(ERR, "failed to allocate %s rawdev", name);
                return -ENOMEM;
        }
 
@@ -770,7 +770,7 @@ cnxk_gpio_probe(struct rte_vdev_device *dev)
        snprintf(buf, sizeof(buf), "%s/gpiochip%d/base", CNXK_GPIO_CLASS_PATH, 
gpiochip->num);
        ret = cnxk_gpio_read_attr_int(buf, &gpiochip->base);
        if (ret) {
-               RTE_LOG(ERR, PMD, "failed to read %s\n", buf);
+               CNXK_GPIO_LOG(ERR, "failed to read %s", buf);
                goto out;
        }
 
@@ -778,20 +778,20 @@ cnxk_gpio_probe(struct rte_vdev_device *dev)
        snprintf(buf, sizeof(buf), "%s/gpiochip%d/ngpio", CNXK_GPIO_CLASS_PATH, 
gpiochip->num);
        ret = cnxk_gpio_read_attr_int(buf, &gpiochip->num_gpios);
        if (ret) {
-               RTE_LOG(ERR, PMD, "failed to read %s\n", buf);
+               CNXK_GPIO_LOG(ERR, "failed to read %s", buf);
                goto out;
        }
        gpiochip->num_queues = gpiochip->num_gpios;
 
        ret = cnxk_gpio_parse_allowlist(gpiochip, params->allowlist);
        if (ret) {
-               RTE_LOG(ERR, PMD, "failed to parse allowed gpios\n");
+               CNXK_GPIO_LOG(ERR, "failed to parse allowed gpios");
                goto out;
        }
 
        gpiochip->gpios = rte_calloc(NULL, gpiochip->num_gpios, sizeof(struct 
cnxk_gpio *), 0);
        if (!gpiochip->gpios) {
-               RTE_LOG(ERR, PMD, "failed to allocate gpios memory\n");
+               CNXK_GPIO_LOG(ERR, "failed to allocate gpios memory");
                ret = -ENOMEM;
                goto out;
        }
@@ -851,3 +851,4 @@ RTE_PMD_REGISTER_VDEV(cnxk_gpio, cnxk_gpio_drv);
 RTE_PMD_REGISTER_PARAM_STRING(cnxk_gpio,
                "gpiochip=<int> "
                "allowlist=<list>");
+RTE_LOG_REGISTER_SUFFIX(cnxk_logtype_gpio, gpio, INFO);
diff --git a/drivers/raw/cnxk_gpio/cnxk_gpio.h 
b/drivers/raw/cnxk_gpio/cnxk_gpio.h
index e62f78a7604a..336d7ac373d7 100644
--- a/drivers/raw/cnxk_gpio/cnxk_gpio.h
+++ b/drivers/raw/cnxk_gpio/cnxk_gpio.h
@@ -5,6 +5,11 @@
 #ifndef _CNXK_GPIO_H_
 #define _CNXK_GPIO_H_
 
+extern int cnxk_logtype_gpio;
+
+#define CNXK_GPIO_LOG(level, fmt, args...) \
+       rte_log(RTE_LOG_ ## level, cnxk_logtype_gpio, fmt "\n", ## args)
+
 struct cnxk_gpiochip;
 
 struct cnxk_gpio {
diff --git a/drivers/raw/cnxk_gpio/cnxk_gpio_selftest.c 
b/drivers/raw/cnxk_gpio/cnxk_gpio_selftest.c
index 10742b5dc48a..2f3973a7b5e6 100644
--- a/drivers/raw/cnxk_gpio/cnxk_gpio_selftest.c
+++ b/drivers/raw/cnxk_gpio/cnxk_gpio_selftest.c
@@ -56,7 +56,7 @@ cnxk_gpio_read_attr(char *attr, char *val)
 
 #define CNXK_GPIO_ERR_STR(err, str, ...) do {                                  
\
        if (err) {                                                             \
-               RTE_LOG(ERR, PMD, "%s:%d: " str " (%d)\n", __func__, __LINE__, \
+               CNXK_GPIO_LOG(ERR, "%s:%d: " str " (%d)", __func__, __LINE__, \
                        ##__VA_ARGS__, err);                                   \
                goto out;                                                      \
        }                                                                      \
@@ -330,30 +330,29 @@ cnxk_gpio_selftest(uint16_t dev_id)
        for (i = 0; i < queues; i++) {
                ret = rte_rawdev_queue_conf_get(dev_id, i, &conf, sizeof(conf));
                if (ret) {
-                       RTE_LOG(ERR, PMD,
-                               "failed to read queue configuration (%d)\n",
+                       CNXK_GPIO_LOG(ERR, "failed to read queue configuration 
(%d)",
                                ret);
                        goto out;
                }
 
-               RTE_LOG(INFO, PMD, "testing queue%d (gpio%d)\n", i, conf.gpio);
+               CNXK_GPIO_LOG(INFO, "testing queue%d (gpio%d)", i, conf.gpio);
 
                if (conf.size != 1) {
-                       RTE_LOG(ERR, PMD, "wrong queue size received\n");
+                       CNXK_GPIO_LOG(ERR, "wrong queue size received");
                        ret = -EIO;
                        goto out;
                }
 
                ret = rte_rawdev_queue_setup(dev_id, i, NULL, 0);
                if (ret) {
-                       RTE_LOG(ERR, PMD, "failed to setup queue (%d)\n", ret);
+                       CNXK_GPIO_LOG(ERR, "failed to setup queue (%d)", ret);
                        goto out;
                }
 
                gpio = gpiochip->gpios[conf.gpio];
                snprintf(buf, sizeof(buf), CNXK_GPIO_PATH_FMT, gpio->num);
                if (!cnxk_gpio_attr_exists(buf)) {
-                       RTE_LOG(ERR, PMD, "%s does not exist\n", buf);
+                       CNXK_GPIO_LOG(ERR, "%s does not exist", buf);
                        ret = -ENOENT;
                        goto release;
                }
@@ -371,13 +370,13 @@ cnxk_gpio_selftest(uint16_t dev_id)
                ret2 = ret;
                ret = rte_rawdev_queue_release(dev_id, i);
                if (ret) {
-                       RTE_LOG(ERR, PMD, "failed to release queue (%d)\n",
+                       CNXK_GPIO_LOG(ERR, "failed to release queue (%d)",
                                ret);
                        break;
                }
 
                if (cnxk_gpio_attr_exists(buf)) {
-                       RTE_LOG(ERR, PMD, "%s still exists\n", buf);
+                       CNXK_GPIO_LOG(ERR, "%s still exists", buf);
                        ret = -EIO;
                        break;
                }
-- 
2.43.0

Reply via email to