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 71A384368D; Wed, 6 Dec 2023 18:53:40 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 39BA94029C; Wed, 6 Dec 2023 18:53:40 +0100 (CET) Received: from mail-pl1-f179.google.com (mail-pl1-f179.google.com [209.85.214.179]) by mails.dpdk.org (Postfix) with ESMTP id 202954021E for ; Wed, 6 Dec 2023 18:53:38 +0100 (CET) Received: by mail-pl1-f179.google.com with SMTP id d9443c01a7336-1d0c94397c0so120555ad.2 for ; Wed, 06 Dec 2023 09:53:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1701885217; x=1702490017; darn=dpdk.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=PT+OKHBCJvSJugiRqINhELwQC0QMGnydbXlN42NSOP8=; b=zEmActY+/GNI1AieccA1nGhy5d/ipvXX8xd7/I4sFnvnU6sd6HbRJg1xMPg55BOgCH WKP9d73jdC5etVLCB9wqc9HC85Y3rx95VC2iENNataqQ9028qrR9NeuHhVLLZywUUf2q KI7JZeeBgy5uX18Nq9azyjIJP2O59BbvIhgrCedsARH96WtmfP46iihE5ChWrWDi/HaP DatxC5I8KugLlqHMTrWPngraxNrj3oAdXxKeKT/xv6wzZPIuGIElyg+F+ke+a1SBR2w3 gaa2p7efsQ8jWmS0aVpaFXYTvPUvn2fkRuyYX910wEHk283YPNxDbNX5eUqlistrn4Fd XL7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701885217; x=1702490017; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=PT+OKHBCJvSJugiRqINhELwQC0QMGnydbXlN42NSOP8=; b=kfizD381SjFy0M5xQ9oQUSAVk3em/rBWoS1ykZEgf3RWi7yJT4UAGtyO2bcgth7Ggz ftqojDjH1OpipKSb2VnADOb7V+6yR4VVCb8Azi35HyjszPIpSgTiwoqvYu7jhdo702J2 Q7uMN7Qz1mkG6yTQepPt8/zfIB6XFRe/9A7wP67B1HCSi8M6hkM/fy3dsqnQGQNTArWP lKn5GC3TiSPP6P/bn9n+4RX1kAj+PXTVboJT2mcGSr/Dkg+m9/8r1IssfcUtzsYe59ER alTRU64P9wQBv8k/TmwMYWgOKO3zDnSTFGV0x+4ShArtuQM0E9WZmrPoawQJak9on/Zi Upuw== X-Gm-Message-State: AOJu0YxqzDLQGkiDRP9lDRLddSJOSi+GGxqvUsG0V2b+731uFHHDa3jf WJ9SOXqL/FuYxMZuRBKTak+KAQtQpV/nvX/gfc0= X-Google-Smtp-Source: AGHT+IHCTgaOl01g7Mv+3uDhKnzZt+Tm1pdY3XE46F56lOahm9wRaBysPl6UPKtLpLDu9O9gJAfYGQ== X-Received: by 2002:a17:903:32ca:b0:1d0:6ffd:ae05 with SMTP id i10-20020a17090332ca00b001d06ffdae05mr1073121plr.108.1701885217283; Wed, 06 Dec 2023 09:53:37 -0800 (PST) Received: from hermes.local (204-195-123-141.wavecable.com. [204.195.123.141]) by smtp.gmail.com with ESMTPSA id p2-20020a170902eac200b001d0c41b1d03sm114350pld.32.2023.12.06.09.53.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Dec 2023 09:53:36 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Martin Spinler , Rastislav Cernay Subject: [RFT] net/nfb: use dynamic logtype Date: Wed, 6 Dec 2023 09:51:57 -0800 Message-ID: <20231206175326.116375-1-stephen@networkplumber.org> X-Mailer: git-send-email 2.42.0 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 All drivers should be using dynamic logtype. This should have been caught during initial driver review. Since this driver requires non-standard external library this patch can not be tested by me. Fixes: 6435f9a0ac22 ("net/nfb: add new netcope driver") Signed-off-by: Stephen Hemminger --- drivers/net/nfb/nfb_ethdev.c | 22 ++++++++++------------ drivers/net/nfb/nfb_log.h | 13 +++++++++++++ drivers/net/nfb/nfb_rx.c | 9 +++++---- drivers/net/nfb/nfb_rx.h | 2 +- drivers/net/nfb/nfb_tx.c | 8 ++++---- drivers/net/nfb/nfb_tx.h | 2 +- 6 files changed, 34 insertions(+), 22 deletions(-) create mode 100644 drivers/net/nfb/nfb_log.h diff --git a/drivers/net/nfb/nfb_ethdev.c b/drivers/net/nfb/nfb_ethdev.c index defd118bd0ee..6c72ac101241 100644 --- a/drivers/net/nfb/nfb_ethdev.c +++ b/drivers/net/nfb/nfb_ethdev.c @@ -12,6 +12,7 @@ #include #include +#include "nfb_log.h" #include "nfb_stats.h" #include "nfb_rx.h" #include "nfb_tx.h" @@ -192,8 +193,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 +520,7 @@ nfb_eth_dev_init(struct rte_eth_dev *dev) struct rte_ether_addr eth_addr_init; struct rte_kvargs *kvlist; - 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,7 +536,7 @@ nfb_eth_dev_init(struct rte_eth_dev *dev) kvlist = rte_kvargs_parse(dev->device->devargs->args, VALID_KEYS); if (kvlist == NULL) { - RTE_LOG(ERR, PMD, "Failed to parse device arguments %s", + NFB_LOG(ERR, "Failed to parse device arguments %s", dev->device->devargs->args); rte_kvargs_free(kvlist); return -EINVAL; @@ -551,14 +551,13 @@ nfb_eth_dev_init(struct rte_eth_dev *dev) */ internals->nfb = nfb_open(internals->nfb_dev); if (internals->nfb == NULL) { - RTE_LOG(ERR, PMD, "nfb_open(): failed to open %s", - internals->nfb_dev); + NFB_LOG(ERR, "nfb_open(): failed to open %s", internals->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", data->nb_rx_queues, data->nb_tx_queues); nfb_nc_rxmac_init(internals->nfb, @@ -583,7 +582,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; } @@ -601,8 +600,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); @@ -626,8 +624,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); @@ -690,3 +687,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_log.h b/drivers/net/nfb/nfb_log.h new file mode 100644 index 000000000000..fac66a38d4b3 --- /dev/null +++ b/drivers/net/nfb/nfb_log.h @@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: BSD-3-Clause + */ + +#ifndef _NFB_STATS_H_ +#define _NFB_STATS_H_ + +extern int nfb_logtype; + +#define NFB_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, nfb_logtype, "%s(): " fmt "\n", \ + __func__, ## args) + +#endif /* _NFB_STATS_H_ */ diff --git a/drivers/net/nfb/nfb_rx.c b/drivers/net/nfb/nfb_rx.c index 8a9b232305f2..e39592d04737 100644 --- a/drivers/net/nfb/nfb_rx.c +++ b/drivers/net/nfb/nfb_rx.c @@ -6,6 +6,7 @@ #include +#include "nfb_log.h" #include "nfb_rx.h" #include "nfb.h" @@ -19,7 +20,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"); + NFP_LOG(ERR, "RX NDP queue is NULL"); return -EINVAL; } @@ -40,7 +41,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 +71,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..3fdfb66a969e 100644 --- a/drivers/net/nfb/nfb_tx.c +++ b/drivers/net/nfb/nfb_tx.c @@ -14,7 +14,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 +35,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 +62,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