DPDK patches and discussions
 help / color / mirror / Atom feed
From: Hemant Agrawal <hemant.agrawal@nxp.com>
To: ferruh.yigit@intel.com
Cc: dev@dpdk.org, g.singh@nxp.com,
	Alex Marginean <alexandru.marginean@nxp.com>
Subject: [dpdk-dev] [PATCH 08/10] net/enetc: use bulk free in Tx clean
Date: Mon,  2 Mar 2020 20:02:07 +0530	[thread overview]
Message-ID: <20200302143209.11854-9-hemant.agrawal@nxp.com> (raw)
In-Reply-To: <20200302143209.11854-1-hemant.agrawal@nxp.com>

From: Alex Marginean <alexandru.marginean@nxp.com>

Use rte_pktmbuf_free_bulk to release all mbufs at once.  This is flagged
as obsolete/not yet stable in DPDK but seems to be functional.
Don't count the released frames, it's no longer needed in the caller.

Signed-off-by: Alex Marginean <alexandru.marginean@nxp.com>
---
 drivers/net/enetc/Makefile     |  1 +
 drivers/net/enetc/enetc_rxtx.c | 32 ++++++++++++++++++++++++--------
 drivers/net/enetc/meson.build  |  1 +
 3 files changed, 26 insertions(+), 8 deletions(-)

diff --git a/drivers/net/enetc/Makefile b/drivers/net/enetc/Makefile
index 7276026e3..7f7a85f64 100644
--- a/drivers/net/enetc/Makefile
+++ b/drivers/net/enetc/Makefile
@@ -11,6 +11,7 @@ LIB = librte_pmd_enetc.a
 CFLAGS += -O3
 CFLAGS += $(WERROR_FLAGS)
 CFLAGS += -I$(RTE_SDK)/drivers/common/dpaax
+CFLAGS += -DALLOW_EXPERIMENTAL_API
 EXPORT_MAP := rte_pmd_enetc_version.map
 SRCS-$(CONFIG_RTE_LIBRTE_ENETC_PMD) += enetc_ethdev.c
 SRCS-$(CONFIG_RTE_LIBRTE_ENETC_PMD) += enetc_rxtx.c
diff --git a/drivers/net/enetc/enetc_rxtx.c b/drivers/net/enetc/enetc_rxtx.c
index 8b85c5371..1acc43a08 100644
--- a/drivers/net/enetc/enetc_rxtx.c
+++ b/drivers/net/enetc/enetc_rxtx.c
@@ -20,8 +20,9 @@ static int
 enetc_clean_tx_ring(struct enetc_bdr *tx_ring)
 {
 	int tx_frm_cnt = 0;
-	struct enetc_swbd *tx_swbd;
-	int i, hwci;
+	struct enetc_swbd *tx_swbd, *tx_swbd_base;
+	int i, hwci, bd_count;
+	struct rte_mbuf *m[ENETC_RXBD_BUNDLE];
 
 	/* we don't need barriers here, we just want a relatively current value
 	 * from HW.
@@ -29,8 +30,10 @@ enetc_clean_tx_ring(struct enetc_bdr *tx_ring)
 	hwci = (int)(rte_read32_relaxed(tx_ring->tcisr) &
 		     ENETC_TBCISR_IDX_MASK);
 
+	tx_swbd_base = tx_ring->q_swbd;
+	bd_count = tx_ring->bd_count;
 	i = tx_ring->next_to_clean;
-	tx_swbd = &tx_ring->q_swbd[i];
+	tx_swbd = &tx_swbd_base[i];
 
 	/* we're only reading the CI index once here, which means HW may update
 	 * it while we're doing clean-up.  We could read the register in a loop
@@ -42,20 +45,33 @@ enetc_clean_tx_ring(struct enetc_bdr *tx_ring)
 	 * meantime.
 	 */
 	while (i != hwci) {
-		rte_pktmbuf_free(tx_swbd->buffer_addr);
+		/* It seems calling rte_pktmbuf_free is wasting a lot of cycles,
+		 * make a list and call _free when it's done.
+		 */
+		if (tx_frm_cnt == ENETC_RXBD_BUNDLE) {
+			rte_pktmbuf_free_bulk(m, tx_frm_cnt);
+			tx_frm_cnt = 0;
+		}
+
+		m[tx_frm_cnt] = tx_swbd->buffer_addr;
 		tx_swbd->buffer_addr = NULL;
-		tx_swbd++;
+
 		i++;
-		if (unlikely(i == tx_ring->bd_count)) {
+		tx_swbd++;
+		if (unlikely(i == bd_count)) {
 			i = 0;
-			tx_swbd = &tx_ring->q_swbd[0];
+			tx_swbd = tx_swbd_base;
 		}
 
 		tx_frm_cnt++;
 	}
 
+	if (tx_frm_cnt)
+		rte_pktmbuf_free_bulk(m, tx_frm_cnt);
+
 	tx_ring->next_to_clean = i;
-	return tx_frm_cnt++;
+
+	return 0;
 }
 
 uint16_t
diff --git a/drivers/net/enetc/meson.build b/drivers/net/enetc/meson.build
index bea54bea8..af11c0960 100644
--- a/drivers/net/enetc/meson.build
+++ b/drivers/net/enetc/meson.build
@@ -11,3 +11,4 @@ sources = files('enetc_ethdev.c',
 		'enetc_rxtx.c')
 
 includes += include_directories('base')
+allow_experimental_apis = true
-- 
2.17.1


  parent reply	other threads:[~2020-03-02  9:01 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-02 14:31 [dpdk-dev] [PATCH 00/10] net/enetc: optimization and cleanup Hemant Agrawal
2020-03-02 14:32 ` [dpdk-dev] [PATCH 01/10] net/enetc: do not stall in clean Tx ring Hemant Agrawal
2020-03-02 14:32 ` [dpdk-dev] [PATCH 02/10] net/enetc: use relaxed read for Tx CI in clean Tx Hemant Agrawal
2020-03-02 14:32 ` [dpdk-dev] [PATCH 03/10] net/enetc: batch process enetc clean Tx ring calls Hemant Agrawal
2020-03-02 14:32 ` [dpdk-dev] [PATCH 04/10] net/enetc: erratum wa for Rx lock-up issue Hemant Agrawal
2020-03-02 14:32 ` [dpdk-dev] [PATCH 05/10] net/enetc: improve batching Rx ring refill Hemant Agrawal
2020-03-02 14:32 ` [dpdk-dev] [PATCH 06/10] net/enetc: cache align enetc bdr structure Hemant Agrawal
2020-03-02 14:32 ` [dpdk-dev] [PATCH 07/10] net/enetc: use bulk alloc in Rx refill ring Hemant Agrawal
2020-03-02 14:32 ` Hemant Agrawal [this message]
2020-03-02 14:32 ` [dpdk-dev] [PATCH 09/10] net/enetc: improve prefetch in Rx ring clean Hemant Agrawal
2020-03-02 14:32 ` [dpdk-dev] [PATCH 10/10] net/enetc: init SI transactions attribute reg Hemant Agrawal
2020-03-03 12:31 ` [dpdk-dev] [PATCH 00/10] net/enetc: optimization and cleanup Gagandeep Singh
2020-03-03 14:02   ` 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=20200302143209.11854-9-hemant.agrawal@nxp.com \
    --to=hemant.agrawal@nxp.com \
    --cc=alexandru.marginean@nxp.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@intel.com \
    --cc=g.singh@nxp.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).