DPDK patches and discussions
 help / color / mirror / Atom feed
From: Michal Krawczyk <mk@semihalf.com>
To: dev@dpdk.org
Cc: ndagan@amazon.com, shaibran@amazon.com, upstream@semihalf.com,
	Michal Krawczyk <mk@semihalf.com>,
	Igor Chauskin <igorch@amazon.com>
Subject: [dpdk-dev] [PATCH v3 2/6] net/ena: make use of the IO debug build option
Date: Wed, 14 Jul 2021 12:43:16 +0200	[thread overview]
Message-ID: <20210714104320.4096-3-mk@semihalf.com> (raw)
In-Reply-To: <20210714104320.4096-1-mk@semihalf.com>

ENA defined its own logger flags for Tx and Rx, but they weren't
technically used anywhere. Those data path loggers weren't used anywhere
after the definition.

This commit uses the generic RTE_ETHDEV_DEBUG_RX and RTE_ETHDEV_DEBUG_TX
flags to define PMD_TX_LOG and PMD_RX_LOG which are now being used on
the data path. The PMD_TX_FREE_LOG was removed, as it has no usage in
the current version of the driver.

RTE_ETH_DEBUG_[TR]X now wraps extra checks for the driver state in the
IO path - this saves extra conditionals on the hot path.

ena_com logger is no longer optional (previously it had to be explicitly
enabled by defining this flag: RTE_LIBRTE_ENA_COM_DEBUG). Having this
logger optional makes tracing of ena_com errors much harder.
Due to ena_com design, it's impossible to separate IO path logs
from the management path logs, so for now they will be always enabled.

Default levels for the affected loggers were modified. Hot path loggers
are initialized with the default level of DEBUG instead of NOTICE, as
they have to be explicitly enabled. ena_com logging level was reduced
from NOTICE to WARNING - as it's no longer optional, the driver should
report just a warnings in the ena_com layer.

Signed-off-by: Michal Krawczyk <mk@semihalf.com>
Reviewed-by: Igor Chauskin <igorch@amazon.com>
Reviewed-by: Shai Brandes <shaibran@amazon.com>
---
 drivers/net/ena/base/ena_plat_dpdk.h |  7 ----
 drivers/net/ena/ena_ethdev.c         | 52 +++++++++++++++-------------
 drivers/net/ena/ena_logs.h           | 13 ++-----
 3 files changed, 30 insertions(+), 42 deletions(-)

diff --git a/drivers/net/ena/base/ena_plat_dpdk.h b/drivers/net/ena/base/ena_plat_dpdk.h
index f66df95591..4e7f52881a 100644
--- a/drivers/net/ena/base/ena_plat_dpdk.h
+++ b/drivers/net/ena/base/ena_plat_dpdk.h
@@ -108,7 +108,6 @@ extern int ena_logtype_com;
 #define GENMASK_ULL(h, l) (((~0ULL) - (1ULL << (l)) + 1) &		       \
 			  (~0ULL >> (BITS_PER_LONG_LONG - 1 - (h))))
 
-#ifdef RTE_LIBRTE_ENA_COM_DEBUG
 #define ena_trc_log(dev, level, fmt, arg...)				       \
 	(								       \
 		ENA_TOUCH(dev),						       \
@@ -121,12 +120,6 @@ extern int ena_logtype_com;
 #define ena_trc_warn(dev, format, arg...)				       \
 	ena_trc_log(dev, WARNING, format, ##arg)
 #define ena_trc_err(dev, format, arg...) ena_trc_log(dev, ERR, format, ##arg)
-#else
-#define ena_trc_dbg(dev, format, arg...) ENA_TOUCH(dev)
-#define ena_trc_info(dev, format, arg...) ENA_TOUCH(dev)
-#define ena_trc_warn(dev, format, arg...) ENA_TOUCH(dev)
-#define ena_trc_err(dev, format, arg...) ENA_TOUCH(dev)
-#endif /* RTE_LIBRTE_ENA_COM_DEBUG */
 
 #define ENA_WARN(cond, dev, format, arg...)				       \
 	do {								       \
diff --git a/drivers/net/ena/ena_ethdev.c b/drivers/net/ena/ena_ethdev.c
index f5e812d507..2335436b6c 100644
--- a/drivers/net/ena/ena_ethdev.c
+++ b/drivers/net/ena/ena_ethdev.c
@@ -399,9 +399,9 @@ static int validate_tx_req_id(struct ena_ring *tx_ring, u16 req_id)
 	}
 
 	if (tx_info)
-		PMD_DRV_LOG(ERR, "tx_info doesn't have valid mbuf\n");
+		PMD_TX_LOG(ERR, "tx_info doesn't have valid mbuf\n");
 	else
-		PMD_DRV_LOG(ERR, "Invalid req_id: %hu\n", req_id);
+		PMD_TX_LOG(ERR, "Invalid req_id: %hu\n", req_id);
 
 	/* Trigger device reset */
 	++tx_ring->tx_stats.bad_req_id;
@@ -1461,7 +1461,7 @@ static int ena_add_single_rx_desc(struct ena_com_io_sq *io_sq,
 	/* pass resource to device */
 	rc = ena_com_add_single_rx_desc(io_sq, &ebuf, id);
 	if (unlikely(rc != 0))
-		PMD_DRV_LOG(WARNING, "Failed adding Rx desc\n");
+		PMD_RX_LOG(WARNING, "Failed adding Rx desc\n");
 
 	return rc;
 }
@@ -1471,16 +1471,21 @@ static int ena_populate_rx_queue(struct ena_ring *rxq, unsigned int count)
 	unsigned int i;
 	int rc;
 	uint16_t next_to_use = rxq->next_to_use;
-	uint16_t in_use, req_id;
+	uint16_t req_id;
+#ifdef RTE_ETHDEV_DEBUG_RX
+	uint16_t in_use;
+#endif
 	struct rte_mbuf **mbufs = rxq->rx_refill_buffer;
 
 	if (unlikely(!count))
 		return 0;
 
+#ifdef RTE_ETHDEV_DEBUG_RX
 	in_use = rxq->ring_size - 1 -
 		ena_com_free_q_entries(rxq->ena_com_io_sq);
-	ena_assert_msg(((in_use + count) < rxq->ring_size),
-		"bad ring state\n");
+	if (unlikely((in_use + count) >= rxq->ring_size))
+		PMD_RX_LOG(ERR, "Bad Rx ring state\n");
+#endif
 
 	/* get resources for incoming packets */
 	rc = rte_pktmbuf_alloc_bulk(rxq->mb_pool, mbufs, count);
@@ -1510,7 +1515,7 @@ static int ena_populate_rx_queue(struct ena_ring *rxq, unsigned int count)
 	}
 
 	if (unlikely(i < count)) {
-		PMD_DRV_LOG(WARNING,
+		PMD_RX_LOG(WARNING,
 			"Refilled Rx queue[%d] with only %d/%d buffers\n",
 			rxq->id, i, count);
 		rte_pktmbuf_free_bulk(&mbufs[i], count - i);
@@ -2218,12 +2223,14 @@ static uint16_t eth_ena_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
 	struct ena_com_rx_ctx ena_rx_ctx;
 	int i, rc = 0;
 
+#ifdef RTE_ETHDEV_DEBUG_RX
 	/* Check adapter state */
 	if (unlikely(rx_ring->adapter->state != ENA_ADAPTER_STATE_RUNNING)) {
-		PMD_DRV_LOG(ALERT,
+		PMD_RX_LOG(ALERT,
 			"Trying to receive pkts while device is NOT running\n");
 		return 0;
 	}
+#endif
 
 	descs_in_use = rx_ring->ring_size -
 		ena_com_free_q_entries(rx_ring->ena_com_io_sq) - 1;
@@ -2239,7 +2246,7 @@ static uint16_t eth_ena_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
 				    rx_ring->ena_com_io_sq,
 				    &ena_rx_ctx);
 		if (unlikely(rc)) {
-			PMD_DRV_LOG(ERR,
+			PMD_RX_LOG(ERR,
 				"Failed to get the packet from the device, rc: %d\n",
 				rc);
 			if (rc == ENA_COM_NO_SPACE) {
@@ -2416,13 +2423,13 @@ static int ena_check_space_and_linearize_mbuf(struct ena_ring *tx_ring,
 	 * be needed so we reduce the segments number from num_segments to 1
 	 */
 	if (!ena_com_sq_have_enough_space(tx_ring->ena_com_io_sq, 3)) {
-		PMD_DRV_LOG(DEBUG, "Not enough space in the Tx queue\n");
+		PMD_TX_LOG(DEBUG, "Not enough space in the Tx queue\n");
 		return ENA_COM_NO_MEM;
 	}
 	++tx_ring->tx_stats.linearize;
 	rc = rte_pktmbuf_linearize(mbuf);
 	if (unlikely(rc)) {
-		PMD_DRV_LOG(WARNING, "Mbuf linearize failed\n");
+		PMD_TX_LOG(WARNING, "Mbuf linearize failed\n");
 		rte_atomic64_inc(&tx_ring->adapter->drv_stats->ierrors);
 		++tx_ring->tx_stats.linearize_failed;
 		return rc;
@@ -2436,7 +2443,7 @@ static int ena_check_space_and_linearize_mbuf(struct ena_ring *tx_ring,
 	 */
 	if (!ena_com_sq_have_enough_space(tx_ring->ena_com_io_sq,
 					  num_segments + 2)) {
-		PMD_DRV_LOG(DEBUG, "Not enough space in the Tx queue\n");
+		PMD_TX_LOG(DEBUG, "Not enough space in the Tx queue\n");
 		return ENA_COM_NO_MEM;
 	}
 
@@ -2551,7 +2558,7 @@ static int ena_xmit_mbuf(struct ena_ring *tx_ring, struct rte_mbuf *mbuf)
 
 	if (unlikely(ena_com_is_doorbell_needed(tx_ring->ena_com_io_sq,
 			&ena_tx_ctx))) {
-		PMD_DRV_LOG(DEBUG,
+		PMD_TX_LOG(DEBUG,
 			"LLQ Tx max burst size of queue %d achieved, writing doorbell to send burst\n",
 			tx_ring->id);
 		ena_com_write_sq_doorbell(tx_ring->ena_com_io_sq);
@@ -2628,12 +2635,14 @@ static uint16_t eth_ena_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
 	struct ena_ring *tx_ring = (struct ena_ring *)(tx_queue);
 	uint16_t sent_idx = 0;
 
+#ifdef RTE_ETHDEV_DEBUG_TX
 	/* Check adapter state */
 	if (unlikely(tx_ring->adapter->state != ENA_ADAPTER_STATE_RUNNING)) {
-		PMD_DRV_LOG(ALERT,
+		PMD_TX_LOG(ALERT,
 			"Trying to xmit pkts while device is NOT running\n");
 		return 0;
 	}
+#endif
 
 	for (sent_idx = 0; sent_idx < nb_pkts; sent_idx++) {
 		if (ena_xmit_mbuf(tx_ring, tx_pkts[sent_idx]))
@@ -2960,18 +2969,13 @@ RTE_PMD_REGISTER_KMOD_DEP(net_ena, "* igb_uio | uio_pci_generic | vfio-pci");
 RTE_PMD_REGISTER_PARAM_STRING(net_ena, ENA_DEVARG_LARGE_LLQ_HDR "=<0|1>");
 RTE_LOG_REGISTER_SUFFIX(ena_logtype_init, init, NOTICE);
 RTE_LOG_REGISTER_SUFFIX(ena_logtype_driver, driver, NOTICE);
-#ifdef RTE_LIBRTE_ENA_DEBUG_RX
-RTE_LOG_REGISTER_SUFFIX(ena_logtype_rx, rx, NOTICE);
-#endif
-#ifdef RTE_LIBRTE_ENA_DEBUG_TX
-RTE_LOG_REGISTER_SUFFIX(ena_logtype_tx, tx, NOTICE);
-#endif
-#ifdef RTE_LIBRTE_ENA_DEBUG_TX_FREE
-RTE_LOG_REGISTER_SUFFIX(ena_logtype_tx_free, tx_free, NOTICE);
+#ifdef RTE_ETHDEV_DEBUG_RX
+RTE_LOG_REGISTER_SUFFIX(ena_logtype_rx, rx, DEBUG);
 #endif
-#ifdef RTE_LIBRTE_ENA_COM_DEBUG
-RTE_LOG_REGISTER_SUFFIX(ena_logtype_com, com, NOTICE);
+#ifdef RTE_ETHDEV_DEBUG_TX
+RTE_LOG_REGISTER_SUFFIX(ena_logtype_tx, tx, DEBUG);
 #endif
+RTE_LOG_REGISTER_SUFFIX(ena_logtype_com, com, WARNING);
 
 /******************************************************************************
  ******************************** AENQ Handlers *******************************
diff --git a/drivers/net/ena/ena_logs.h b/drivers/net/ena/ena_logs.h
index 040bebfb98..43f16458ea 100644
--- a/drivers/net/ena/ena_logs.h
+++ b/drivers/net/ena/ena_logs.h
@@ -11,7 +11,7 @@ extern int ena_logtype_init;
 	rte_log(RTE_LOG_ ## level, ena_logtype_init, \
 		"%s(): " fmt, __func__, ## args)
 
-#ifdef RTE_LIBRTE_ENA_DEBUG_RX
+#ifdef RTE_ETHDEV_DEBUG_RX
 extern int ena_logtype_rx;
 #define PMD_RX_LOG(level, fmt, args...)			\
 	rte_log(RTE_LOG_ ## level, ena_logtype_rx,	\
@@ -20,7 +20,7 @@ extern int ena_logtype_rx;
 #define PMD_RX_LOG(level, fmt, args...) do { } while (0)
 #endif
 
-#ifdef RTE_LIBRTE_ENA_DEBUG_TX
+#ifdef RTE_ETHDEV_DEBUG_TX
 extern int ena_logtype_tx;
 #define PMD_TX_LOG(level, fmt, args...)			\
 	rte_log(RTE_LOG_ ## level, ena_logtype_tx,	\
@@ -29,15 +29,6 @@ extern int ena_logtype_tx;
 #define PMD_TX_LOG(level, fmt, args...) do { } while (0)
 #endif
 
-#ifdef RTE_LIBRTE_ENA_DEBUG_TX_FREE
-extern int ena_logtype_tx_free;
-#define PMD_TX_FREE_LOG(level, fmt, args...)			\
-	rte_log(RTE_LOG_ ## level, ena_logtype_tx_free,	\
-		"%s(): " fmt, __func__, ## args)
-#else
-#define PMD_TX_FREE_LOG(level, fmt, args...) do { } while (0)
-#endif
-
 extern int ena_logtype_driver;
 #define PMD_DRV_LOG(level, fmt, args...) \
 	rte_log(RTE_LOG_ ## level, ena_logtype_driver, \
-- 
2.25.1


  parent reply	other threads:[~2021-07-14 10:43 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-13 15:41 [dpdk-dev] [PATCH 0/6] net/ena: v2.4.0 driver update Michal Krawczyk
2021-07-13 15:41 ` [dpdk-dev] [PATCH 1/6] net/ena: adjust driver logs Michal Krawczyk
2021-07-13 15:41 ` [dpdk-dev] [PATCH 2/6] net/ena: make use of the IO debug build option Michal Krawczyk
2021-07-13 15:41 ` [dpdk-dev] [PATCH 3/6] net/ena: trigger reset when Tx prepare fails Michal Krawczyk
2021-07-13 15:41 ` [dpdk-dev] [PATCH 4/6] net/ena: add support for Rx interrupts Michal Krawczyk
2021-07-13 15:41 ` [dpdk-dev] [PATCH 5/6] net/ena: rework RSS configuration Michal Krawczyk
2021-07-14  8:04   ` Vladimir Medvedkin
2021-07-14  8:20     ` Michał Krawczyk
2021-07-14 11:43       ` Vladimir Medvedkin
2021-07-14 12:07         ` Michał Krawczyk
2021-07-13 15:41 ` [dpdk-dev] [PATCH 6/6] net/ena: update version to v2.4.0 Michal Krawczyk
2021-07-14 10:34 ` [dpdk-dev] [PATCH v2 0/6] net/ena: v2.4.0 driver update Michal Krawczyk
2021-07-14 10:34   ` [dpdk-dev] [PATCH v2 1/6] net/ena: adjust driver logs Michal Krawczyk
2021-07-14 10:34   ` [dpdk-dev] [PATCH v2 2/6] net/ena: make use of the IO debug build option Michal Krawczyk
2021-07-14 10:34   ` [dpdk-dev] [PATCH v2 3/6] net/ena: trigger reset when Tx prepare fails Michal Krawczyk
2021-07-14 10:34   ` [dpdk-dev] [PATCH v2 4/6] net/ena: add support for Rx interrupts Michal Krawczyk
2021-07-14 10:34   ` [dpdk-dev] [PATCH v2 5/6] net/ena: rework RSS configuration Michal Krawczyk
2021-07-14 10:34   ` [dpdk-dev] [PATCH v2 6/6] net/ena: update version to v2.4.0 Michal Krawczyk
2021-07-14 10:43   ` [dpdk-dev] [PATCH v3 0/6] net/ena: v2.4.0 driver update Michal Krawczyk
2021-07-14 10:43     ` [dpdk-dev] [PATCH v3 1/6] net/ena: adjust driver logs Michal Krawczyk
2021-07-14 10:43     ` Michal Krawczyk [this message]
2021-07-14 10:43     ` [dpdk-dev] [PATCH v3 3/6] net/ena: trigger reset when Tx prepare fails Michal Krawczyk
2021-07-14 10:43     ` [dpdk-dev] [PATCH v3 4/6] net/ena: add support for Rx interrupts Michal Krawczyk
2021-07-14 10:43     ` [dpdk-dev] [PATCH v3 5/6] net/ena: rework RSS configuration Michal Krawczyk
2021-07-23  9:23       ` Thomas Monjalon
2021-07-23  9:39         ` Michał Krawczyk
2021-07-23  9:44           ` Thomas Monjalon
2021-07-23  9:49             ` Michał Krawczyk
2021-07-23 11:52               ` Thomas Monjalon
2021-07-23 13:19                 ` Thomas Monjalon
2021-07-14 10:43     ` [dpdk-dev] [PATCH v3 6/6] net/ena: update version to v2.4.0 Michal Krawczyk
2021-07-23 10:24     ` [dpdk-dev] [PATCH v4 0/6] net/ena: v2.4.0 driver update Michal Krawczyk
2021-07-23 10:24       ` [dpdk-dev] [PATCH v4 1/6] net/ena: adjust driver logs Michal Krawczyk
2021-07-23 10:24       ` [dpdk-dev] [PATCH v4 2/6] net/ena: make use of the IO debug build option Michal Krawczyk
2021-07-23 10:24       ` [dpdk-dev] [PATCH v4 3/6] net/ena: trigger reset when Tx prepare fails Michal Krawczyk
2021-07-23 10:24       ` [dpdk-dev] [PATCH v4 4/6] net/ena: add support for Rx interrupts Michal Krawczyk
2021-07-23 10:24       ` [dpdk-dev] [PATCH v4 5/6] net/ena: rework RSS configuration Michal Krawczyk
2021-07-23 10:24       ` [dpdk-dev] [PATCH v4 6/6] net/ena: update version to v2.4.0 Michal Krawczyk
2021-07-23 15:46       ` [dpdk-dev] [PATCH v4 0/6] net/ena: v2.4.0 driver update Thomas Monjalon

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=20210714104320.4096-3-mk@semihalf.com \
    --to=mk@semihalf.com \
    --cc=dev@dpdk.org \
    --cc=igorch@amazon.com \
    --cc=ndagan@amazon.com \
    --cc=shaibran@amazon.com \
    --cc=upstream@semihalf.com \
    /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).