DPDK patches and discussions
 help / color / mirror / Atom feed
From: "Polehn, Mike A" <mike.a.polehn@intel.com>
To: "dev@dpdk.org" <dev@dpdk.org>
Subject: [dpdk-dev] [Patch 2/2] i40e simple tx: Larger list size (33 to 128) throughput optimization
Date: Tue, 27 Oct 2015 20:56:49 +0000	[thread overview]
Message-ID: <745DB4B8861F8E4B9849C970520ABBF14974C218@ORSMSX102.amr.corp.intel.com> (raw)

Added packet memory prefetch for faster access to variables inside packet buffer needed 
for the free operation.

Signed-off-by: Mike A. Polehn <mike.a.polehn@intel.com>

diff --git a/drivers/net/i40e/i40e_rxtx.c b/drivers/net/i40e/i40e_rxtx.c
index 177fb2e..d9bc30a 100644
--- a/drivers/net/i40e/i40e_rxtx.c
+++ b/drivers/net/i40e/i40e_rxtx.c
@@ -1748,7 +1748,8 @@ static inline int __attribute__((always_inline))
 i40e_tx_free_bufs(struct i40e_tx_queue *txq)
 {
 	struct i40e_tx_entry *txep;
-	uint16_t i;
+	unsigned i, l, tx_rs_thresh;
+	struct rte_mbuf *pk, *pk_next;
 
 	if ((txq->tx_ring[txq->tx_next_dd].cmd_type_offset_bsz &
 			rte_cpu_to_le_64(I40E_TXD_QW1_DTYPE_MASK)) !=
@@ -1757,18 +1758,46 @@ i40e_tx_free_bufs(struct i40e_tx_queue *txq)
 
 	txep = &(txq->sw_ring[txq->tx_next_dd - (txq->tx_rs_thresh - 1)]);
 
-	for (i = 0; i < txq->tx_rs_thresh; i++)
-		rte_prefetch0((txep + i)->mbuf);
+	/* Prefetch first 2 packets */
+	pk = txep->mbuf;
+	rte_prefetch0(pk);
+	txep->mbuf = NULL;
+	txep++;
+	tx_rs_thresh = txq->tx_rs_thresh;
+	if (likely(txq->tx_rs_thresh > 1)) {
+		pk_next = txep->mbuf;
+		rte_prefetch0(pk_next);
+		txep->mbuf = NULL;
+		txep++;
+		l = tx_rs_thresh - 2;
+	} else {
+		pk_next = pk;
+		l = tx_rs_thresh - 1;
+	}
 
 	if (!(txq->txq_flags & (uint32_t)ETH_TXQ_FLAGS_NOREFCOUNT)) {
-		for (i = 0; i < txq->tx_rs_thresh; ++i, ++txep) {
-			rte_mempool_put(txep->mbuf->pool, txep->mbuf);
-			txep->mbuf = NULL;
+		for (i = 0; i < tx_rs_thresh; ++i) {
+			struct rte_mbuf *mbuf = pk;
+			pk = pk_next;
+			if (likely(i < l)) {
+				pk_next = txep->mbuf;
+				rte_prefetch0(pk_next);
+				txep->mbuf = NULL;
+				txep++;
+			}
+			rte_mempool_put(mbuf->pool, mbuf);
 		}
 	} else {
-		for (i = 0; i < txq->tx_rs_thresh; ++i, ++txep) {
-			rte_pktmbuf_free_seg(txep->mbuf);
-			txep->mbuf = NULL;
+		for (i = 0; i < tx_rs_thresh; ++i) {
+			struct rte_mbuf *mbuf = pk;
+			pk = pk_next;
+			if (likely(i < l)) {
+				pk_next = txep->mbuf;
+				rte_prefetch0(pk_next);
+				txep->mbuf = NULL;
+				txep++;
+			}
+			rte_pktmbuf_free_seg(mbuf);
 		}
 	}

                 reply	other threads:[~2015-10-27 20:57 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=745DB4B8861F8E4B9849C970520ABBF14974C218@ORSMSX102.amr.corp.intel.com \
    --to=mike.a.polehn@intel.com \
    --cc=dev@dpdk.org \
    /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).