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 872AD436E3; Wed, 13 Dec 2023 17:42:04 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7D95842FBF; Wed, 13 Dec 2023 17:40:27 +0100 (CET) Received: from mail-pl1-f173.google.com (mail-pl1-f173.google.com [209.85.214.173]) by mails.dpdk.org (Postfix) with ESMTP id DFB9A42F7D for ; Wed, 13 Dec 2023 17:40:18 +0100 (CET) Received: by mail-pl1-f173.google.com with SMTP id d9443c01a7336-1d076ebf79cso41854975ad.1 for ; Wed, 13 Dec 2023 08:40:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1702485618; x=1703090418; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=xWe82NsCmGM0jd1Tll4EYjvas5G07jqX7o50Jj2ljFo=; b=v6PxAEhy6DxqgQn31BRQFAIB/st8Ta9PvJK4IRcc/nf/GasywhlXToQfO8mRmSnmt5 031txFBex35OcT8zuYDkMQTVSQj0t0ZvctXri1OXVmOFUuwJxAvTzVxp1dRavdJ6lM6a eig4l66psbirXhOxz75PJc8oMhwANw5tXipAmIjV55iFtDDXYL8pKdBrD0sFNIguzg3l o72iK6Ru5rxhSBJAbPPTvJye0U0Ix8hTOsnKRbhQ8SSY1VXna3KD2Xx7Y0rvE5w5HcvB D62LINDzSpKmqkZ7sM69OEEi9kuQ2he/Tgql/Ho2S9rGOzwukBWyFiQoKojFmdEUhPsM m4lw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702485618; x=1703090418; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=xWe82NsCmGM0jd1Tll4EYjvas5G07jqX7o50Jj2ljFo=; b=bZU4DQ2Vq6X20TAkjNcLdW5ft50yHqYxuS+lh8u8eio/fljYqdlXNtp5smMflrYB0k +OzE9EwxjzbErPLdycqHX5WwCB54tkC5eZmFCn50sJBhaoQ+JwX9JK1jUgpMIPmKYVVf 2OOOxgKOpzPoQ8qYumtOMaULgSMRoUTa7waiSObSgq+nn+L3yq9JVybv8dNGPumChgAV 1kjmgnoUvl7XTRfFzSt+Pe8shJhjOfN+ohY9qQb7Qhs/h1LoSKsJdWItQ3lpm3nKelXq aHWB5GRR/pz5vWKZ/7FR/X9CLkrdZdL01Gwri3RJqVxnTIdY0JM11jnwnD8HH1uGwn5G VxHw== X-Gm-Message-State: AOJu0YwQnLH4R9ms46hG+h4dVDXmFeF4nG82guHDDOdD1DUjzCCNbWsq lvSEHfZOEmG0bO01Qn8sfmTVDuYk0931CRmqOxU= X-Google-Smtp-Source: AGHT+IHmMm2EvMe3NWOxXcuhYRVcFJlrBT4usZqU/pNLSVWj2WIq1toiTkKEsEMVMaHRfcGq80+Dzw== X-Received: by 2002:a17:903:2290:b0:1d0:3f5e:d4c8 with SMTP id b16-20020a170903229000b001d03f5ed4c8mr5934629plh.30.1702485618179; Wed, 13 Dec 2023 08:40:18 -0800 (PST) Received: from hermes.local (204-195-123-141.wavecable.com. [204.195.123.141]) by smtp.gmail.com with ESMTPSA id 4-20020a170902c24400b001d0a6f31519sm10749593plg.188.2023.12.13.08.40.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Dec 2023 08:40:17 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Jakub Palider , Tomasz Duszynski Subject: [PATCH v3 28/37] raw/cnxk_gpio: replace PMD logtype with dynamic type Date: Wed, 13 Dec 2023 08:36:02 -0800 Message-ID: <20231213163820.894987-29-stephen@networkplumber.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231213163820.894987-1-stephen@networkplumber.org> References: <20231213014408.612051-1-stephen@networkplumber.org> <20231213163820.894987-1-stephen@networkplumber.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 Driver should not be using PMD logtype, they should have their own logtype. Signed-off-by: Stephen Hemminger --- drivers/raw/cnxk_gpio/cnxk_gpio.c | 22 ++++++++------- drivers/raw/cnxk_gpio/cnxk_gpio.h | 4 +++ drivers/raw/cnxk_gpio/cnxk_gpio_selftest.c | 31 +++++++++++----------- 3 files changed, 31 insertions(+), 26 deletions(-) diff --git a/drivers/raw/cnxk_gpio/cnxk_gpio.c b/drivers/raw/cnxk_gpio/cnxk_gpio.c index 3c4d79e4810e..0ec1b869b805 100644 --- a/drivers/raw/cnxk_gpio/cnxk_gpio.c +++ b/drivers/raw/cnxk_gpio/cnxk_gpio.c @@ -8,6 +8,7 @@ #include #include +#include #include #include #include @@ -215,13 +216,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_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_LOG(ERR, "gpio%d out of 0-%d range", val, gpiochip->num_gpios - 1); ret = -EINVAL; goto out; @@ -231,7 +232,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_LOG(WARNING, "gpio%d already allowed", val); break; } if (i == queue) @@ -398,7 +399,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_LOG(WARNING, "using existing gpio%u", gpio->num); } gpiochip->gpios[num] = gpio; @@ -647,7 +648,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_LOG(WARNING, "previous response got overwritten"); rte_free(gpio->rsp); } gpio->rsp = rsp; @@ -741,7 +742,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_LOG(ERR, "failed to allocate %s rawdev", name); return -ENOMEM; } @@ -770,7 +771,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_LOG(ERR, "failed to read %s", buf); goto out; } @@ -778,20 +779,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_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_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_LOG(ERR, "failed to allocate gpios memory"); ret = -ENOMEM; goto out; } @@ -851,3 +852,4 @@ RTE_PMD_REGISTER_VDEV(cnxk_gpio, cnxk_gpio_drv); RTE_PMD_REGISTER_PARAM_STRING(cnxk_gpio, "gpiochip= " "allowlist="); +RTE_LOG_REGISTER_DEFAULT(cnxk_logtype, INFO); diff --git a/drivers/raw/cnxk_gpio/cnxk_gpio.h b/drivers/raw/cnxk_gpio/cnxk_gpio.h index e62f78a7604a..d9058c364068 100644 --- a/drivers/raw/cnxk_gpio/cnxk_gpio.h +++ b/drivers/raw/cnxk_gpio/cnxk_gpio.h @@ -5,6 +5,10 @@ #ifndef _CNXK_GPIO_H_ #define _CNXK_GPIO_H_ +extern int cnxk_logtype; +#define CNXK_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, cnxk_logtype, 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..e3ec85990c92 100644 --- a/drivers/raw/cnxk_gpio/cnxk_gpio_selftest.c +++ b/drivers/raw/cnxk_gpio/cnxk_gpio_selftest.c @@ -54,12 +54,14 @@ cnxk_gpio_read_attr(char *attr, char *val) return 0; } -#define CNXK_GPIO_ERR_STR(err, str, ...) do { \ - if (err) { \ - RTE_LOG(ERR, PMD, "%s:%d: " str " (%d)\n", __func__, __LINE__, \ - ##__VA_ARGS__, err); \ - goto out; \ - } \ + + +#define CNXK_GPIO_ERR_STR(err, str, ...) do { \ + if (err) { \ + CNXK_LOG(ERR, "%s:%d: " str " (%d)",__func__, __LINE__, \ + ##__VA_ARGS__, err); \ + goto out; \ + } \ } while (0) static int @@ -330,30 +332,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_LOG(ERR, "failed to read queue configuration (%d)n", ret); goto out; } - RTE_LOG(INFO, PMD, "testing queue%d (gpio%d)\n", i, conf.gpio); + CNXK_LOG(INFO, "testing queue%u (gpio%u)", i, conf.gpio); if (conf.size != 1) { - RTE_LOG(ERR, PMD, "wrong queue size received\n"); + CNXK_LOG(ERR, "wrong queue size received: %u", conf.size); 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_LOG(ERR, "failed to setup queue%u (%d)", i, 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_LOG(ERR, "%s does not exist", buf); ret = -ENOENT; goto release; } @@ -371,13 +371,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_LOG(ERR, "failed to release queue%u (%d)", i, ret); break; } if (cnxk_gpio_attr_exists(buf)) { - RTE_LOG(ERR, PMD, "%s still exists\n", buf); + CNXK_LOG(ERR, "%s still exists", buf); ret = -EIO; break; } -- 2.43.0