Thanks for patch! There are some issues.
On Wed, 2023-12-06 at 09:51 -0800, Stephen Hemminger wrote:
>
> 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_
use the _NFB_LOG_H_ guards
> +
> +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_ */
use the _NFB_LOG_H_ guard
> 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
>
> @@ -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");
typo, should be NFB_LOG instead of NFP_LOG
> return -EINVAL;
> }
>
>
Also, the nfb_rx.h and nfb_tx.h files use the macro NFB_LOG inside,
please add '#include "nfb_log.h"' into them (then the include in
nfb_rx.c will be duplicate). Otherwise, all .c sources, which include
main nfb.h, don't compile.
With these changes, the driver works.
Thank you!
Martin
@@ -12,6 +12,7 @@
#include <ethdev_pci.h>
#include <rte_kvargs.h>
+#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);
new file mode 100644
@@ -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_ */
@@ -6,6 +6,7 @@
#include <rte_kvargs.h>
+#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;
}
@@ -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;
}
@@ -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;
}
@@ -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;
}