From: Jerin Jacob Kollanukkaran <jerinj@marvell.com>
To: Tomasz Duszynski <tduszynski@marvell.com>,
"dev@dpdk.org" <dev@dpdk.org>,
Jakub Palider <jpalider@marvell.com>,
Tomasz Duszynski <tduszynski@marvell.com>
Cc: "stephen@networkplumber.org" <stephen@networkplumber.org>
Subject: RE: [PATCH] raw/cnxk_gpio: switch to dynamic logging
Date: Tue, 5 Dec 2023 09:37:03 +0000 [thread overview]
Message-ID: <BY3PR18MB4785477FDFEFDD3644939BB5C885A@BY3PR18MB4785.namprd18.prod.outlook.com> (raw)
In-Reply-To: <20231103210952.2447882-1-tduszynski@marvell.com>
> -----Original Message-----
> From: Tomasz Duszynski <tduszynski@marvell.com>
> Sent: Saturday, November 4, 2023 2:40 AM
> To: dev@dpdk.org; Jakub Palider <jpalider@marvell.com>; Tomasz Duszynski
> <tduszynski@marvell.com>
> Cc: Jerin Jacob Kollanukkaran <jerinj@marvell.com>;
> stephen@networkplumber.org
> Subject: [PATCH] raw/cnxk_gpio: switch to dynamic logging
>
> Dynamically allocated log type is a standard approach among all drivers.
> Switch to it.
>
> Signed-off-by: Tomasz Duszynski <tduszynski@marvell.com>
Applied to dpdk-next-net-mrvl/for-main. Thanks
> ---
> 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 <rte_eal.h>
> #include <rte_kvargs.h>
> #include <rte_lcore.h>
> +#include <rte_log.h>
> #include <rte_rawdev_pmd.h>
>
> #include <roc_api.h>
> @@ -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=<int> "
> "allowlist=<list>");
> +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 <rte_log.h>
> +
> +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
next prev parent reply other threads:[~2023-12-05 9:37 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-03 21:09 Tomasz Duszynski
2023-12-05 9:37 ` Jerin Jacob Kollanukkaran [this message]
2024-02-21 1:54 ` Thomas Monjalon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=BY3PR18MB4785477FDFEFDD3644939BB5C885A@BY3PR18MB4785.namprd18.prod.outlook.com \
--to=jerinj@marvell.com \
--cc=dev@dpdk.org \
--cc=jpalider@marvell.com \
--cc=stephen@networkplumber.org \
--cc=tduszynski@marvell.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).