Skip to content

Commit 6758365

Browse files
shemmingerdavid-marchand
authored andcommitted
net/nfb: use a dynamic logtype
All drivers should be using dynamic logtype. Signed-off-by: Stephen Hemminger <[email protected]> Acked-by: Martin Spinler <[email protected]>
1 parent 626bc4b commit 6758365

File tree

6 files changed

+26
-23
lines changed

6 files changed

+26
-23
lines changed

drivers/net/nfb/nfb.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@
1212
#include <netcope/rxmac.h>
1313
#include <netcope/txmac.h>
1414

15+
extern int nfb_logtype;
16+
#define NFB_LOG(level, fmt, args...) \
17+
rte_log(RTE_LOG_ ## level, nfb_logtype, "%s(): " fmt "\n", \
18+
__func__, ## args)
19+
1520
#include "nfb_rx.h"
1621
#include "nfb_tx.h"
1722

drivers/net/nfb/nfb_ethdev.c

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,7 @@ nfb_eth_dev_configure(struct rte_eth_dev *dev __rte_unused)
192192
(&nfb_timestamp_dynfield_offset,
193193
&nfb_timestamp_rx_dynflag);
194194
if (ret != 0) {
195-
RTE_LOG(ERR, PMD, "Cannot register Rx timestamp"
196-
" field/flag %d\n", ret);
195+
NFB_LOG(ERR, "Cannot register Rx timestamp field/flag %d", ret);
197196
nfb_close(internals->nfb);
198197
return -rte_errno;
199198
}
@@ -520,7 +519,7 @@ nfb_eth_dev_init(struct rte_eth_dev *dev)
520519
struct rte_ether_addr eth_addr_init;
521520
struct rte_kvargs *kvlist;
522521

523-
RTE_LOG(INFO, PMD, "Initializing NFB device (" PCI_PRI_FMT ")\n",
522+
NFB_LOG(INFO, "Initializing NFB device (" PCI_PRI_FMT ")",
524523
pci_addr->domain, pci_addr->bus, pci_addr->devid,
525524
pci_addr->function);
526525

@@ -536,7 +535,7 @@ nfb_eth_dev_init(struct rte_eth_dev *dev)
536535
kvlist = rte_kvargs_parse(dev->device->devargs->args,
537536
VALID_KEYS);
538537
if (kvlist == NULL) {
539-
RTE_LOG(ERR, PMD, "Failed to parse device arguments %s",
538+
NFB_LOG(ERR, "Failed to parse device arguments %s",
540539
dev->device->devargs->args);
541540
rte_kvargs_free(kvlist);
542541
return -EINVAL;
@@ -551,14 +550,14 @@ nfb_eth_dev_init(struct rte_eth_dev *dev)
551550
*/
552551
internals->nfb = nfb_open(internals->nfb_dev);
553552
if (internals->nfb == NULL) {
554-
RTE_LOG(ERR, PMD, "nfb_open(): failed to open %s",
553+
NFB_LOG(ERR, "nfb_open(): failed to open %s",
555554
internals->nfb_dev);
556555
return -EINVAL;
557556
}
558557
data->nb_rx_queues = ndp_get_rx_queue_available_count(internals->nfb);
559558
data->nb_tx_queues = ndp_get_tx_queue_available_count(internals->nfb);
560559

561-
RTE_LOG(INFO, PMD, "Available NDP queues RX: %u TX: %u\n",
560+
NFB_LOG(INFO, "Available NDP queues RX: %u TX: %u",
562561
data->nb_rx_queues, data->nb_tx_queues);
563562

564563
nfb_nc_rxmac_init(internals->nfb,
@@ -583,7 +582,7 @@ nfb_eth_dev_init(struct rte_eth_dev *dev)
583582
data->mac_addrs = rte_zmalloc(data->name,
584583
sizeof(struct rte_ether_addr) * mac_count, RTE_CACHE_LINE_SIZE);
585584
if (data->mac_addrs == NULL) {
586-
RTE_LOG(ERR, PMD, "Could not alloc space for MAC address!\n");
585+
NFB_LOG(ERR, "Could not alloc space for MAC address");
587586
nfb_close(internals->nfb);
588587
return -EINVAL;
589588
}
@@ -601,8 +600,7 @@ nfb_eth_dev_init(struct rte_eth_dev *dev)
601600

602601
dev->data->dev_flags |= RTE_ETH_DEV_AUTOFILL_QUEUE_XSTATS;
603602

604-
RTE_LOG(INFO, PMD, "NFB device ("
605-
PCI_PRI_FMT ") successfully initialized\n",
603+
NFB_LOG(INFO, "NFB device (" PCI_PRI_FMT ") successfully initialized",
606604
pci_addr->domain, pci_addr->bus, pci_addr->devid,
607605
pci_addr->function);
608606

@@ -626,8 +624,7 @@ nfb_eth_dev_uninit(struct rte_eth_dev *dev)
626624

627625
nfb_eth_dev_close(dev);
628626

629-
RTE_LOG(INFO, PMD, "NFB device ("
630-
PCI_PRI_FMT ") successfully uninitialized\n",
627+
NFB_LOG(INFO, "NFB device (" PCI_PRI_FMT ") successfully uninitialized",
631628
pci_addr->domain, pci_addr->bus, pci_addr->devid,
632629
pci_addr->function);
633630

@@ -690,3 +687,4 @@ static struct rte_pci_driver nfb_eth_driver = {
690687
RTE_PMD_REGISTER_PCI(RTE_NFB_DRIVER_NAME, nfb_eth_driver);
691688
RTE_PMD_REGISTER_PCI_TABLE(RTE_NFB_DRIVER_NAME, nfb_pci_id_table);
692689
RTE_PMD_REGISTER_KMOD_DEP(RTE_NFB_DRIVER_NAME, "* nfb");
690+
RTE_LOG_REGISTER_DEFAULT(nfb_logtype, NOTICE);

drivers/net/nfb/nfb_rx.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66

77
#include <rte_kvargs.h>
88

9-
#include "nfb_rx.h"
109
#include "nfb.h"
10+
#include "nfb_rx.h"
1111

1212
uint64_t nfb_timestamp_rx_dynflag;
1313
int nfb_timestamp_dynfield_offset = -1;
@@ -19,7 +19,7 @@ nfb_eth_rx_queue_start(struct rte_eth_dev *dev, uint16_t rxq_id)
1919
int ret;
2020

2121
if (rxq->queue == NULL) {
22-
RTE_LOG(ERR, PMD, "RX NDP queue is NULL!\n");
22+
NFB_LOG(ERR, "RX NDP queue is NULL");
2323
return -EINVAL;
2424
}
2525

@@ -40,7 +40,7 @@ nfb_eth_rx_queue_stop(struct rte_eth_dev *dev, uint16_t rxq_id)
4040
int ret;
4141

4242
if (rxq->queue == NULL) {
43-
RTE_LOG(ERR, PMD, "RX NDP queue is NULL!\n");
43+
NFB_LOG(ERR, "RX NDP queue is NULL");
4444
return -EINVAL;
4545
}
4646

@@ -70,8 +70,8 @@ nfb_eth_rx_queue_setup(struct rte_eth_dev *dev,
7070
RTE_CACHE_LINE_SIZE, socket_id);
7171

7272
if (rxq == NULL) {
73-
RTE_LOG(ERR, PMD, "rte_zmalloc_socket() failed for rx queue id "
74-
"%" PRIu16 "!\n", rx_queue_id);
73+
NFB_LOG(ERR, "rte_zmalloc_socket() failed for rx queue id %" PRIu16,
74+
rx_queue_id);
7575
return -ENOMEM;
7676
}
7777

drivers/net/nfb/nfb_rx.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ nfb_eth_ndp_rx(void *queue,
156156
struct rte_mbuf *mbufs[nb_pkts];
157157

158158
if (unlikely(ndp->queue == NULL || nb_pkts == 0)) {
159-
RTE_LOG(ERR, PMD, "RX invalid arguments!\n");
159+
NFB_LOG(ERR, "RX invalid arguments");
160160
return 0;
161161
}
162162

drivers/net/nfb/nfb_tx.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
* All rights reserved.
55
*/
66

7-
#include "nfb_tx.h"
87
#include "nfb.h"
8+
#include "nfb_tx.h"
99

1010
int
1111
nfb_eth_tx_queue_start(struct rte_eth_dev *dev, uint16_t txq_id)
@@ -14,7 +14,7 @@ nfb_eth_tx_queue_start(struct rte_eth_dev *dev, uint16_t txq_id)
1414
int ret;
1515

1616
if (txq->queue == NULL) {
17-
RTE_LOG(ERR, PMD, "RX NDP queue is NULL!\n");
17+
NFB_LOG(ERR, "RX NDP queue is NULL");
1818
return -EINVAL;
1919
}
2020

@@ -35,7 +35,7 @@ nfb_eth_tx_queue_stop(struct rte_eth_dev *dev, uint16_t txq_id)
3535
int ret;
3636

3737
if (txq->queue == NULL) {
38-
RTE_LOG(ERR, PMD, "TX NDP queue is NULL!\n");
38+
NFB_LOG(ERR, "TX NDP queue is NULL");
3939
return -EINVAL;
4040
}
4141

@@ -62,8 +62,8 @@ nfb_eth_tx_queue_setup(struct rte_eth_dev *dev,
6262
RTE_CACHE_LINE_SIZE, socket_id);
6363

6464
if (txq == NULL) {
65-
RTE_LOG(ERR, PMD, "rte_zmalloc_socket() failed for tx queue id "
66-
"%" PRIu16 "!\n", tx_queue_id);
65+
NFB_LOG(ERR, "rte_zmalloc_socket() failed for tx queue id %" PRIu16,
66+
tx_queue_id);
6767
return -ENOMEM;
6868
}
6969

drivers/net/nfb/nfb_tx.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ nfb_eth_ndp_tx(void *queue,
140140
return 0;
141141

142142
if (unlikely(ndp->queue == NULL)) {
143-
RTE_LOG(ERR, PMD, "TX invalid arguments!\n");
143+
NFB_LOG(ERR, "TX invalid arguments");
144144
return 0;
145145
}
146146

0 commit comments

Comments
 (0)