DPDK patches and discussions
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: dev@dpdk.org
Cc: Stephen Hemminger <stephen@networkplumber.org>,
	Martin Spinler <spinler@cesnet.cz>,
	Rastislav Cernay <cernay@netcope.com>
Subject: [PATCH 3/3] net/nfb: use dynamic logtype
Date: Thu,  7 Dec 2023 10:56:31 -0800	[thread overview]
Message-ID: <20231207185720.19913-4-stephen@networkplumber.org> (raw)
In-Reply-To: <20231207185720.19913-1-stephen@networkplumber.org>

All drivers should be using dynamic logtype.

Fixes: 6435f9a0ac22 ("net/nfb: add new netcope driver")
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/net/nfb/nfb.h        |  6 +++++-
 drivers/net/nfb/nfb_ethdev.c | 22 +++++++++-------------
 drivers/net/nfb/nfb_rx.c     |  9 ++++-----
 drivers/net/nfb/nfb_rx.h     |  2 +-
 drivers/net/nfb/nfb_tx.c     |  9 ++++-----
 drivers/net/nfb/nfb_tx.h     |  2 +-
 6 files changed, 24 insertions(+), 26 deletions(-)

diff --git a/drivers/net/nfb/nfb.h b/drivers/net/nfb/nfb.h
index 2707f3db6240..3a27457d6e33 100644
--- a/drivers/net/nfb/nfb.h
+++ b/drivers/net/nfb/nfb.h
@@ -12,6 +12,11 @@
 #include <netcope/rxmac.h>
 #include <netcope/txmac.h>
 
+extern int nfb_logtype;
+#define NFB_LOG(level, fmt, args...) \
+	rte_log(RTE_LOG_ ## level, nfb_logtype, "%s(): " fmt "\n", \
+		__func__, ## args)
+
 #include "nfb_rx.h"
 #include "nfb_tx.h"
 
@@ -36,7 +41,6 @@
 
 #define RTE_NFB_DRIVER_NAME net_nfb
 
-
 struct pmd_internals {
 	uint16_t         max_rxmac;
 	uint16_t         max_txmac;
diff --git a/drivers/net/nfb/nfb_ethdev.c b/drivers/net/nfb/nfb_ethdev.c
index 892abe81f3d6..fc510db7390c 100644
--- a/drivers/net/nfb/nfb_ethdev.c
+++ b/drivers/net/nfb/nfb_ethdev.c
@@ -12,11 +12,9 @@
 #include <ethdev_pci.h>
 #include <rte_kvargs.h>
 
+#include "nfb.h"
 #include "nfb_stats.h"
-#include "nfb_rx.h"
-#include "nfb_tx.h"
 #include "nfb_rxmode.h"
-#include "nfb.h"
 
 /**
  * Default MAC addr
@@ -192,8 +190,7 @@ nfb_eth_dev_configure(struct rte_eth_dev *dev __rte_unused)
 				(&nfb_timestamp_dynfield_offset,
 				&nfb_timestamp_rx_dynflag);
 		if (ret != 0) {
-			RTE_LOG(ERR, PMD, "Cannot register Rx timestamp"
-					" field/flag %d\n", ret);
+			NFB_LOG(ERR, "Cannot register Rx timestamp field/flag %d", ret);
 			nfb_close(internals->nfb);
 			return -rte_errno;
 		}
@@ -520,7 +517,7 @@ nfb_eth_dev_init(struct rte_eth_dev *dev)
 	struct rte_ether_addr eth_addr_init;
 	char nfb_dev[PATH_MAX];
 
-	RTE_LOG(INFO, PMD, "Initializing NFB device (" PCI_PRI_FMT ")\n",
+	NFB_LOG(INFO, "Initializing NFB device (" PCI_PRI_FMT ")",
 		pci_addr->domain, pci_addr->bus, pci_addr->devid,
 		pci_addr->function);
 
@@ -536,13 +533,13 @@ nfb_eth_dev_init(struct rte_eth_dev *dev)
 	 */
 	internals->nfb = nfb_open(nfb_dev);
 	if (internals->nfb == NULL) {
-		RTE_LOG(ERR, PMD, "nfb_open(): failed to open %s", nfb_dev);
+		NFB_LOG(ERR, "nfb_open(): failed to open %s", nfb_dev);
 		return -EINVAL;
 	}
 	data->nb_rx_queues = ndp_get_rx_queue_available_count(internals->nfb);
 	data->nb_tx_queues = ndp_get_tx_queue_available_count(internals->nfb);
 
-	RTE_LOG(INFO, PMD, "Available NDP queues RX: %u TX: %u\n",
+	NFB_LOG(INFO, "Available NDP queues RX: %u TX: %u\n",
 		data->nb_rx_queues, data->nb_tx_queues);
 
 	nfb_nc_rxmac_init(internals->nfb,
@@ -567,7 +564,7 @@ nfb_eth_dev_init(struct rte_eth_dev *dev)
 	data->mac_addrs = rte_zmalloc(data->name,
 		sizeof(struct rte_ether_addr) * mac_count, RTE_CACHE_LINE_SIZE);
 	if (data->mac_addrs == NULL) {
-		RTE_LOG(ERR, PMD, "Could not alloc space for MAC address!\n");
+		NFB_LOG(ERR, "Could not alloc space for MAC address");
 		nfb_close(internals->nfb);
 		return -EINVAL;
 	}
@@ -585,8 +582,7 @@ nfb_eth_dev_init(struct rte_eth_dev *dev)
 
 	dev->data->dev_flags |= RTE_ETH_DEV_AUTOFILL_QUEUE_XSTATS;
 
-	RTE_LOG(INFO, PMD, "NFB device ("
-		PCI_PRI_FMT ") successfully initialized\n",
+	NFB_LOG(INFO, "NFB device (" PCI_PRI_FMT ") successfully initialized",
 		pci_addr->domain, pci_addr->bus, pci_addr->devid,
 		pci_addr->function);
 
@@ -610,8 +606,7 @@ nfb_eth_dev_uninit(struct rte_eth_dev *dev)
 
 	nfb_eth_dev_close(dev);
 
-	RTE_LOG(INFO, PMD, "NFB device ("
-		PCI_PRI_FMT ") successfully uninitialized\n",
+	NFB_LOG(INFO, "NFB device (" PCI_PRI_FMT ") successfully uninitialized",
 		pci_addr->domain, pci_addr->bus, pci_addr->devid,
 		pci_addr->function);
 
@@ -674,3 +669,4 @@ static struct rte_pci_driver nfb_eth_driver = {
 RTE_PMD_REGISTER_PCI(RTE_NFB_DRIVER_NAME, nfb_eth_driver);
 RTE_PMD_REGISTER_PCI_TABLE(RTE_NFB_DRIVER_NAME, nfb_pci_id_table);
 RTE_PMD_REGISTER_KMOD_DEP(RTE_NFB_DRIVER_NAME, "* nfb");
+RTE_LOG_REGISTER_DEFAULT(nfb_logtype, NOTICE);
diff --git a/drivers/net/nfb/nfb_rx.c b/drivers/net/nfb/nfb_rx.c
index 8a9b232305f2..a20f7b9b4b41 100644
--- a/drivers/net/nfb/nfb_rx.c
+++ b/drivers/net/nfb/nfb_rx.c
@@ -6,7 +6,6 @@
 
 #include <rte_kvargs.h>
 
-#include "nfb_rx.h"
 #include "nfb.h"
 
 uint64_t nfb_timestamp_rx_dynflag;
@@ -19,7 +18,7 @@ nfb_eth_rx_queue_start(struct rte_eth_dev *dev, uint16_t rxq_id)
 	int ret;
 
 	if (rxq->queue == NULL) {
-		RTE_LOG(ERR, PMD, "RX NDP queue is NULL!\n");
+		NFB_LOG(ERR, "RX NDP queue is NULL");
 		return -EINVAL;
 	}
 
@@ -40,7 +39,7 @@ nfb_eth_rx_queue_stop(struct rte_eth_dev *dev, uint16_t rxq_id)
 	int ret;
 
 	if (rxq->queue == NULL) {
-		RTE_LOG(ERR, PMD, "RX NDP queue is NULL!\n");
+		NFB_LOG(ERR, "RX NDP queue is NULL");
 		return -EINVAL;
 	}
 
@@ -70,8 +69,8 @@ nfb_eth_rx_queue_setup(struct rte_eth_dev *dev,
 			RTE_CACHE_LINE_SIZE, socket_id);
 
 	if (rxq == NULL) {
-		RTE_LOG(ERR, PMD, "rte_zmalloc_socket() failed for rx queue id "
-				"%" PRIu16 "!\n", rx_queue_id);
+		NFB_LOG(ERR, "rte_zmalloc_socket() failed for rx queue id %" PRIu16,
+			rx_queue_id);
 		return -ENOMEM;
 	}
 
diff --git a/drivers/net/nfb/nfb_rx.h b/drivers/net/nfb/nfb_rx.h
index b618682e1393..2802f17091a0 100644
--- a/drivers/net/nfb/nfb_rx.h
+++ b/drivers/net/nfb/nfb_rx.h
@@ -156,7 +156,7 @@ nfb_eth_ndp_rx(void *queue,
 	struct rte_mbuf *mbufs[nb_pkts];
 
 	if (unlikely(ndp->queue == NULL || nb_pkts == 0)) {
-		RTE_LOG(ERR, PMD, "RX invalid arguments!\n");
+		NFB_LOG(ERR, "RX invalid arguments");
 		return 0;
 	}
 
diff --git a/drivers/net/nfb/nfb_tx.c b/drivers/net/nfb/nfb_tx.c
index d49fc324e76b..0cc2f596301a 100644
--- a/drivers/net/nfb/nfb_tx.c
+++ b/drivers/net/nfb/nfb_tx.c
@@ -4,7 +4,6 @@
  * All rights reserved.
  */
 
-#include "nfb_tx.h"
 #include "nfb.h"
 
 int
@@ -14,7 +13,7 @@ nfb_eth_tx_queue_start(struct rte_eth_dev *dev, uint16_t txq_id)
 	int ret;
 
 	if (txq->queue == NULL) {
-		RTE_LOG(ERR, PMD, "RX NDP queue is NULL!\n");
+		NFB_LOG(ERR, "RX NDP queue is NULL");
 		return -EINVAL;
 	}
 
@@ -35,7 +34,7 @@ nfb_eth_tx_queue_stop(struct rte_eth_dev *dev, uint16_t txq_id)
 	int ret;
 
 	if (txq->queue == NULL) {
-		RTE_LOG(ERR, PMD, "TX NDP queue is NULL!\n");
+		NFB_LOG(ERR, "TX NDP queue is NULL");
 		return -EINVAL;
 	}
 
@@ -62,8 +61,8 @@ nfb_eth_tx_queue_setup(struct rte_eth_dev *dev,
 		RTE_CACHE_LINE_SIZE, socket_id);
 
 	if (txq == NULL) {
-		RTE_LOG(ERR, PMD, "rte_zmalloc_socket() failed for tx queue id "
-			"%" PRIu16 "!\n", tx_queue_id);
+		NFB_LOG(ERR, "rte_zmalloc_socket() failed for tx queue id %" PRIu16,
+			tx_queue_id);
 		return -ENOMEM;
 	}
 
diff --git a/drivers/net/nfb/nfb_tx.h b/drivers/net/nfb/nfb_tx.h
index 910020e9e96f..f107cf914bbd 100644
--- a/drivers/net/nfb/nfb_tx.h
+++ b/drivers/net/nfb/nfb_tx.h
@@ -140,7 +140,7 @@ nfb_eth_ndp_tx(void *queue,
 		return 0;
 
 	if (unlikely(ndp->queue == NULL)) {
-		RTE_LOG(ERR, PMD, "TX invalid arguments!\n");
+		NFB_LOG(ERR, "TX invalid arguments");
 		return 0;
 	}
 
-- 
2.42.0


  parent reply	other threads:[~2023-12-07 18:57 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-06 17:51 [RFT] " Stephen Hemminger
2023-12-07 10:37 ` Martin Spinler
2023-12-07 17:32   ` Stephen Hemminger
2023-12-07 18:56 ` [PATCH 0/3] net/nfb: driver cleanups Stephen Hemminger
2023-12-07 18:56   ` [PATCH 1/3] net/nfb: remove unused device args Stephen Hemminger
2023-12-07 18:56   ` [PATCH 2/3] net/nfb: make device path local to init function Stephen Hemminger
2023-12-07 18:56   ` Stephen Hemminger [this message]
2023-12-12  8:49     ` [PATCH 3/3] net/nfb: use dynamic logtype Martin Spinler
2024-01-12 12:16   ` [PATCH 0/3] net/nfb: driver cleanups Ferruh Yigit
2024-01-12 13:50     ` Martin Spinler
2024-02-08  1:02       ` Ferruh Yigit
2024-02-08 12:01   ` Ferruh Yigit

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=20231207185720.19913-4-stephen@networkplumber.org \
    --to=stephen@networkplumber.org \
    --cc=cernay@netcope.com \
    --cc=dev@dpdk.org \
    --cc=spinler@cesnet.cz \
    /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).