DPDK patches and discussions
 help / color / mirror / Atom feed
From: Michal Krawczyk <mk@semihalf.com>
To: dev@dpdk.org
Cc: shaibran@amazon.com, upstream@semihalf.com,
	Dawid Gorecki <dgr@semihalf.com>,
	Michal Krawczyk <mk@semihalf.com>
Subject: [PATCH v2 13/21] net/ena: expose Tx cleanup function
Date: Tue, 22 Feb 2022 19:11:38 +0100	[thread overview]
Message-ID: <20220222181146.28882-14-mk@semihalf.com> (raw)
In-Reply-To: <20220222181146.28882-1-mk@semihalf.com>

From: Dawid Gorecki <dgr@semihalf.com>

ENA driver did not allow applications to call tx_cleanup. Freeing Tx
mbufs was always done by the driver and it was not possible to manually
request the driver to free mbufs.

Modify ena_tx_cleanup function to accept maximum number of packets to
free and return number of packets that was freed.

Signed-off-by: Dawid Gorecki <dgr@semihalf.com>
Reviewed-by: Michal Krawczyk <mk@semihalf.com>
Reviewed-by: Shai Brandes <shaibran@amazon.com>
---
 doc/guides/nics/features/ena.ini       |  1 +
 doc/guides/rel_notes/release_22_03.rst |  1 +
 drivers/net/ena/ena_ethdev.c           | 27 ++++++++++++++++++--------
 3 files changed, 21 insertions(+), 8 deletions(-)

diff --git a/doc/guides/nics/features/ena.ini b/doc/guides/nics/features/ena.ini
index 55690aaf5a..59c1ae85fa 100644
--- a/doc/guides/nics/features/ena.ini
+++ b/doc/guides/nics/features/ena.ini
@@ -7,6 +7,7 @@
 Link status          = Y
 Link status event    = Y
 Rx interrupt         = Y
+Free Tx mbuf on demand = Y
 MTU update           = Y
 Scattered Rx         = Y
 TSO                  = Y
diff --git a/doc/guides/rel_notes/release_22_03.rst b/doc/guides/rel_notes/release_22_03.rst
index 92f36fa8ab..91324dae18 100644
--- a/doc/guides/rel_notes/release_22_03.rst
+++ b/doc/guides/rel_notes/release_22_03.rst
@@ -114,6 +114,7 @@ New Features
   * Added support for the link status configuration.
   * Added optimized memcpy support for the ARM platforms.
   * Added ENA admin queue support for the MP applications.
+  * Added free Tx mbuf on demand feature support.
 
 * **Updated Cisco enic driver.**
 
diff --git a/drivers/net/ena/ena_ethdev.c b/drivers/net/ena/ena_ethdev.c
index 8f30718f2c..eecdd447dd 100644
--- a/drivers/net/ena/ena_ethdev.c
+++ b/drivers/net/ena/ena_ethdev.c
@@ -170,7 +170,7 @@ static void ena_tx_map_mbuf(struct ena_ring *tx_ring,
 	void **push_header,
 	uint16_t *header_len);
 static int ena_xmit_mbuf(struct ena_ring *tx_ring, struct rte_mbuf *mbuf);
-static void ena_tx_cleanup(struct ena_ring *tx_ring);
+static int ena_tx_cleanup(void *txp, uint32_t free_pkt_cnt);
 static uint16_t eth_ena_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
 				  uint16_t nb_pkts);
 static uint16_t eth_ena_prep_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
@@ -276,6 +276,7 @@ static const struct eth_dev_ops ena_dev_ops = {
 	.rx_queue_intr_disable = ena_rx_queue_intr_disable,
 	.rss_hash_update      = ena_rss_hash_update,
 	.rss_hash_conf_get    = ena_rss_hash_conf_get,
+	.tx_done_cleanup      = ena_tx_cleanup,
 };
 
 /*********************************************************************
@@ -2990,16 +2991,22 @@ static int ena_xmit_mbuf(struct ena_ring *tx_ring, struct rte_mbuf *mbuf)
 	return 0;
 }
 
-static void ena_tx_cleanup(struct ena_ring *tx_ring)
+static int ena_tx_cleanup(void *txp, uint32_t free_pkt_cnt)
 {
+	struct ena_ring *tx_ring = (struct ena_ring *)txp;
 	unsigned int total_tx_descs = 0;
+	unsigned int total_tx_pkts = 0;
 	uint16_t cleanup_budget;
 	uint16_t next_to_clean = tx_ring->next_to_clean;
 
-	/* Attempt to release all Tx descriptors (ring_size - 1 -> size_mask) */
-	cleanup_budget = tx_ring->size_mask;
+	/*
+	 * If free_pkt_cnt is equal to 0, it means that the user requested
+	 * full cleanup, so attempt to release all Tx descriptors
+	 * (ring_size - 1 -> size_mask)
+	 */
+	cleanup_budget = (free_pkt_cnt == 0) ? tx_ring->size_mask : free_pkt_cnt;
 
-	while (likely(total_tx_descs < cleanup_budget)) {
+	while (likely(total_tx_pkts < cleanup_budget)) {
 		struct rte_mbuf *mbuf;
 		struct ena_tx_buffer *tx_info;
 		uint16_t req_id;
@@ -3021,6 +3028,7 @@ static void ena_tx_cleanup(struct ena_ring *tx_ring)
 		tx_ring->empty_tx_reqs[next_to_clean] = req_id;
 
 		total_tx_descs += tx_info->tx_descs;
+		total_tx_pkts++;
 
 		/* Put back descriptor to the ring for reuse */
 		next_to_clean = ENA_IDX_NEXT_MASKED(next_to_clean,
@@ -3034,8 +3042,11 @@ static void ena_tx_cleanup(struct ena_ring *tx_ring)
 		ena_com_update_dev_comp_head(tx_ring->ena_com_io_cq);
 	}
 
-	/* Notify completion handler that the cleanup was just called */
-	tx_ring->last_cleanup_ticks = rte_get_timer_cycles();
+	/* Notify completion handler that full cleanup was performed */
+	if (free_pkt_cnt == 0 || total_tx_pkts < cleanup_budget)
+		tx_ring->last_cleanup_ticks = rte_get_timer_cycles();
+
+	return total_tx_pkts;
 }
 
 static uint16_t eth_ena_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
@@ -3056,7 +3067,7 @@ static uint16_t eth_ena_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
 
 	available_desc = ena_com_free_q_entries(tx_ring->ena_com_io_sq);
 	if (available_desc < tx_ring->tx_free_thresh)
-		ena_tx_cleanup(tx_ring);
+		ena_tx_cleanup((void *)tx_ring, 0);
 
 	for (sent_idx = 0; sent_idx < nb_pkts; sent_idx++) {
 		if (ena_xmit_mbuf(tx_ring, tx_pkts[sent_idx]))
-- 
2.25.1


  parent reply	other threads:[~2022-02-22 18:13 UTC|newest]

Thread overview: 77+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-22 16:06 [PATCH 00/21] net/ena: v2.6.0 driver update Michal Krawczyk
2022-02-22 16:06 ` [PATCH 01/21] net/ena: remove linearization function Michal Krawczyk
2022-02-22 16:06 ` [PATCH 02/21] net/ena: add assertion on Tx info mbuf Michal Krawczyk
2022-02-22 16:06 ` [PATCH 03/21] net/ena: remove unused enumeration Michal Krawczyk
2022-02-22 16:06 ` [PATCH 04/21] net/ena: remove unused offloads variables Michal Krawczyk
2022-02-22 16:06 ` [PATCH 05/21] net/ena: add extra Rx checksum related xstats Michal Krawczyk
2022-02-22 16:06 ` [PATCH 06/21] net/ena: make LSC configurable Michal Krawczyk
2022-02-22 16:06 ` [PATCH 07/21] net/ena: skip timer if the reset is triggered Michal Krawczyk
2022-02-22 16:06 ` [PATCH 08/21] net/ena: perform Tx cleanup before sending pkts Michal Krawczyk
2022-02-22 16:06 ` [PATCH 09/21] net/ena/base: use optimized memcpy version also on Arm Michal Krawczyk
2022-02-22 16:06 ` [PATCH 10/21] net/ena: proxy AQ calls to primary process Michal Krawczyk
2022-02-22 16:06 ` [PATCH 11/21] net/ena: enable stats get function for MP mode Michal Krawczyk
2022-02-22 16:06 ` [PATCH 12/21] net/ena/base: make IO memzone unique per port Michal Krawczyk
2022-02-22 16:06 ` [PATCH 13/21] net/ena: expose Tx cleanup function Michal Krawczyk
2022-02-22 16:06 ` [PATCH 14/21] net/ena: add API for probing xstat names by ID Michal Krawczyk
2022-02-22 16:06 ` [PATCH 15/21] net/ena: check if reset was already triggered Michal Krawczyk
2022-02-22 16:06 ` [PATCH 16/21] net/ena: make Tx completion timeout configurable Michal Krawczyk
2022-02-22 16:06 ` [PATCH 17/21] net/ena: fix meta-desc DF flag setup Michal Krawczyk
2022-02-22 16:06 ` [PATCH 18/21] net/ena: extend debug prints for invalid req ID resets Michal Krawczyk
2022-02-22 16:06 ` [PATCH 19/21] net/ena: don't initialize LLQ when membar isn't exposed Michal Krawczyk
2022-02-22 16:06 ` [PATCH 20/21] net/ena: don't indicate bad csum for L4 csum error Michal Krawczyk
2022-02-22 16:06 ` [PATCH 21/21] net/ena: update version to 2.6.0 Michal Krawczyk
2022-02-22 18:11 ` [PATCH v2 00/21] net/ena: v2.6.0 driver update Michal Krawczyk
2022-02-22 18:11   ` [PATCH v2 01/21] net/ena: remove linearization function Michal Krawczyk
2022-02-22 18:11   ` [PATCH v2 02/21] net/ena: add assertion on Tx info mbuf Michal Krawczyk
2022-02-22 18:11   ` [PATCH v2 03/21] net/ena: remove unused enumeration Michal Krawczyk
2022-02-22 18:11   ` [PATCH v2 04/21] net/ena: remove unused offloads variables Michal Krawczyk
2022-02-22 18:11   ` [PATCH v2 05/21] net/ena: add extra Rx checksum related xstats Michal Krawczyk
2022-02-22 18:11   ` [PATCH v2 06/21] net/ena: make LSC configurable Michal Krawczyk
2022-02-22 18:11   ` [PATCH v2 07/21] net/ena: skip timer if the reset is triggered Michal Krawczyk
2022-02-22 18:11   ` [PATCH v2 08/21] net/ena: perform Tx cleanup before sending pkts Michal Krawczyk
2022-02-22 18:11   ` [PATCH v2 09/21] net/ena/base: use optimized memcpy version also on Arm Michal Krawczyk
2022-02-22 18:11   ` [PATCH v2 10/21] net/ena: proxy AQ calls to primary process Michal Krawczyk
2022-02-22 22:24     ` Ferruh Yigit
2022-02-23  0:50       ` Ferruh Yigit
2022-02-22 18:11   ` [PATCH v2 11/21] net/ena: enable stats get function for MP mode Michal Krawczyk
2022-02-22 18:11   ` [PATCH v2 12/21] net/ena/base: make IO memzone unique per port Michal Krawczyk
2022-02-22 18:11   ` Michal Krawczyk [this message]
2022-02-22 18:11   ` [PATCH v2 14/21] net/ena: add API for probing xstat names by ID Michal Krawczyk
2022-02-22 18:11   ` [PATCH v2 15/21] net/ena: check if reset was already triggered Michal Krawczyk
2022-02-22 18:11   ` [PATCH v2 16/21] net/ena: make Tx completion timeout configurable Michal Krawczyk
2022-02-22 18:11   ` [PATCH v2 17/21] net/ena: fix meta-desc DF flag setup Michal Krawczyk
2022-02-22 18:11   ` [PATCH v2 18/21] net/ena: extend debug prints for invalid req ID resets Michal Krawczyk
2022-02-22 18:11   ` [PATCH v2 19/21] net/ena: don't initialize LLQ when membar isn't exposed Michal Krawczyk
2022-02-22 18:11   ` [PATCH v2 20/21] net/ena: don't indicate bad csum for L4 csum error Michal Krawczyk
2022-02-22 18:11   ` [PATCH v2 21/21] net/ena: update version to 2.6.0 Michal Krawczyk
2022-02-22 22:21   ` [PATCH v2 00/21] net/ena: v2.6.0 driver update Ferruh Yigit
2022-02-23 10:07     ` Michał Krawczyk
2022-02-23 12:19   ` [PATCH v3 " Michal Krawczyk
2022-02-23 12:19     ` [PATCH v3 01/21] net/ena: remove linearization function Michal Krawczyk
2022-02-23 12:19     ` [PATCH v3 02/21] net/ena: add assertion on Tx info mbuf Michal Krawczyk
2022-02-23 12:19     ` [PATCH v3 03/21] net/ena: remove unused enumeration Michal Krawczyk
2022-02-23 17:25       ` Ferruh Yigit
2022-02-23 12:19     ` [PATCH v3 04/21] net/ena: remove unused offloads variables Michal Krawczyk
2022-02-23 17:25       ` Ferruh Yigit
2022-02-23 17:47         ` Michał Krawczyk
2022-02-23 18:12           ` Ferruh Yigit
2022-02-23 12:19     ` [PATCH v3 05/21] net/ena: add extra Rx checksum related xstats Michal Krawczyk
2022-02-23 12:19     ` [PATCH v3 06/21] net/ena: make LSC configurable Michal Krawczyk
2022-02-23 12:19     ` [PATCH v3 07/21] net/ena: skip timer if the reset is triggered Michal Krawczyk
2022-02-23 12:19     ` [PATCH v3 08/21] net/ena: perform Tx cleanup before sending pkts Michal Krawczyk
2022-02-23 12:19     ` [PATCH v3 09/21] net/ena/base: use optimized memcpy version also on Arm Michal Krawczyk
2022-02-23 17:25       ` Ferruh Yigit
2022-02-23 17:40         ` Michał Krawczyk
2022-02-23 12:19     ` [PATCH v3 10/21] net/ena: proxy AQ calls to primary process Michal Krawczyk
2022-02-23 12:19     ` [PATCH v3 11/21] net/ena: enable stats get function for MP mode Michal Krawczyk
2022-02-23 12:19     ` [PATCH v3 12/21] net/ena/base: make IO memzone unique per port Michal Krawczyk
2022-02-23 12:19     ` [PATCH v3 13/21] net/ena: expose Tx cleanup function Michal Krawczyk
2022-02-23 12:19     ` [PATCH v3 14/21] net/ena: add API for probing xstat names by ID Michal Krawczyk
2022-02-23 12:19     ` [PATCH v3 15/21] net/ena: check if reset was already triggered Michal Krawczyk
2022-02-23 12:19     ` [PATCH v3 16/21] net/ena: make Tx completion timeout configurable Michal Krawczyk
2022-02-23 12:19     ` [PATCH v3 17/21] net/ena: fix meta-desc DF flag setup Michal Krawczyk
2022-02-23 12:19     ` [PATCH v3 18/21] net/ena: extend debug prints for invalid req ID resets Michal Krawczyk
2022-02-23 12:19     ` [PATCH v3 19/21] net/ena: don't initialize LLQ when membar isn't exposed Michal Krawczyk
2022-02-23 12:19     ` [PATCH v3 20/21] net/ena: don't indicate bad csum for L4 csum error Michal Krawczyk
2022-02-23 12:19     ` [PATCH v3 21/21] net/ena: update version to 2.6.0 Michal Krawczyk
2022-02-23 18:12     ` [PATCH v3 00/21] net/ena: v2.6.0 driver update 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=20220222181146.28882-14-mk@semihalf.com \
    --to=mk@semihalf.com \
    --cc=dev@dpdk.org \
    --cc=dgr@semihalf.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).