From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 7B5404327F; Fri, 3 Nov 2023 22:10:05 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 487E7402AA; Fri, 3 Nov 2023 22:10:05 +0100 (CET) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id B97E54029E for ; Fri, 3 Nov 2023 22:10:03 +0100 (CET) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3A3GtLGd005018; Fri, 3 Nov 2023 14:10:02 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding : content-type; s=pfpt0220; bh=PZkxnDkvaDzjMP3fD8P+cGy7chvq3Kd2+jYrS/TprSA=; b=A+PkN0kahKIymeNgsbGUP67L5yAS1yaJB1w2lv47ngqLVY/k3M6tLs6FosDWKyxoeSfi v53wzRkPhlaRkyavHCcc0jfVJ6p+yv0e8YFOeWddgCibXyMc746EXOAD2GlZVlbNn8Xa r9t9I3HQtrMW0+Ljrayn4ZjdZG4O74pfVaUlptd6qxQyeH/hqKKhcNbxbmY1lFQheKWt hQJs1ClA6AVKPh7dViZk5SVg++k2+h+XBcJe6sevGfHBTGO9WEL5wioIiTzP2//d5K9W wgcWQa2iLJ9++m9+itLfAN4qZnazrKfBWU8e5drCZEq4SvAK1wkGWsDTo/uHXO/TPTSY oA== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3u4upkjh5s-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Fri, 03 Nov 2023 14:10:02 -0700 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.48; Fri, 3 Nov 2023 14:10:01 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server id 15.0.1497.48 via Frontend Transport; Fri, 3 Nov 2023 14:10:01 -0700 Received: from cavium-DT10.. (unknown [10.28.34.39]) by maili.marvell.com (Postfix) with ESMTP id 41DD43F7057; Fri, 3 Nov 2023 14:09:59 -0700 (PDT) From: Tomasz Duszynski To: , Jakub Palider , Tomasz Duszynski CC: , Subject: [PATCH] raw/cnxk_gpio: switch to dynamic logging Date: Fri, 3 Nov 2023 22:09:52 +0100 Message-ID: <20231103210952.2447882-1-tduszynski@marvell.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-ORIG-GUID: e3wo2OZ_ZnC4k_g2XqWPnmzAAqagqIoY X-Proofpoint-GUID: e3wo2OZ_ZnC4k_g2XqWPnmzAAqagqIoY X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-03_20,2023-11-02_03,2023-05-22_02 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Dynamically allocated log type is a standard approach among all drivers. Switch to it. Signed-off-by: Tomasz Duszynski --- drivers/raw/cnxk_gpio/cnxk_gpio.c | 22 ++++++++++++---------- drivers/raw/cnxk_gpio/cnxk_gpio.h | 7 +++++++ drivers/raw/cnxk_gpio/cnxk_gpio_selftest.c | 19 ++++++++----------- 3 files changed, 27 insertions(+), 21 deletions(-) diff --git a/drivers/raw/cnxk_gpio/cnxk_gpio.c b/drivers/raw/cnxk_gpio/cnxk_gpio.c index 29c2506726..ebc914afcf 100644 --- a/drivers/raw/cnxk_gpio/cnxk_gpio.c +++ b/drivers/raw/cnxk_gpio/cnxk_gpio.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include @@ -213,13 +214,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; @@ -229,7 +230,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) @@ -396,7 +397,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; @@ -645,7 +646,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; @@ -739,7 +740,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; } @@ -768,7 +769,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; } @@ -776,20 +777,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; } @@ -849,3 +850,4 @@ RTE_PMD_REGISTER_VDEV(cnxk_gpio, cnxk_gpio_drv); RTE_PMD_REGISTER_PARAM_STRING(cnxk_gpio, "gpiochip= " "allowlist="); +RTE_LOG_REGISTER_DEFAULT(cnxk_gpio_rawdev_logtype, WARNING); diff --git a/drivers/raw/cnxk_gpio/cnxk_gpio.h b/drivers/raw/cnxk_gpio/cnxk_gpio.h index e62f78a760..a2a6b9469b 100644 --- a/drivers/raw/cnxk_gpio/cnxk_gpio.h +++ b/drivers/raw/cnxk_gpio/cnxk_gpio.h @@ -5,6 +5,13 @@ #ifndef _CNXK_GPIO_H_ #define _CNXK_GPIO_H_ +#include + +extern int cnxk_gpio_rawdev_logtype; + +#define CNXK_GPIO_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, cnxk_gpio_rawdev_logtype, "%s(): " fmt "\n", __func__, ##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 10742b5dc4..a462871c4a 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,28 @@ 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", - ret); + 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\n"); 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 +369,12 @@ 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", - ret); + 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.34.1