DPDK patches and discussions
 help / color / mirror / Atom feed
From: Rasesh Mody <rasesh.mody@qlogic.com>
To: <bruce.richardson@intel.com>
Cc: <dev@dpdk.org>, <Dept-EngDPDKDev@qlogic.com>,
	Rasesh Mody <rasesh.mody@qlogic.com>,
	Harish Patil <harish.patil@qlogic.com>
Subject: [dpdk-dev] [PATCH v5 3/5] bnx2x: restructure Tx routine
Date: Wed, 11 May 2016 17:06:23 -0700	[thread overview]
Message-ID: <1463011585-15429-3-git-send-email-rasesh.mody@qlogic.com> (raw)
In-Reply-To: <1463011585-15429-1-git-send-email-rasesh.mody@qlogic.com>

 - Process Tx completions based on configured Tx free threshold and
   determine how much TX BDs are required before invoking bnx2x_tx_encap()
 - Change bnx2x_tx_encap() to void function

Signed-off-by: Rasesh Mody <rasesh.mody@qlogic.com>
Signed-off-by: Harish Patil <harish.patil@qlogic.com>
---
 drivers/net/bnx2x/bnx2x.c      |   14 ++++----------
 drivers/net/bnx2x/bnx2x.h      |    5 ++++-
 drivers/net/bnx2x/bnx2x_rxtx.c |   39 ++++++++++++++++++---------------------
 3 files changed, 26 insertions(+), 32 deletions(-)

diff --git a/drivers/net/bnx2x/bnx2x.c b/drivers/net/bnx2x/bnx2x.c
index 6edb2f9..5d182c3 100644
--- a/drivers/net/bnx2x/bnx2x.c
+++ b/drivers/net/bnx2x/bnx2x.c
@@ -2113,10 +2113,12 @@ bnx2x_nic_unload(struct bnx2x_softc *sc, uint32_t unload_mode, uint8_t keep_link
  * the mbuf and return to the caller.
  *
  * Returns:
- *   0 = Success, !0 = Failure
+ *   void.
+ *
  *   Note the side effect that an mbuf may be freed if it causes a problem.
  */
-int bnx2x_tx_encap(struct bnx2x_tx_queue *txq, struct rte_mbuf **m_head, int m_pkts)
+void bnx2x_tx_encap(struct bnx2x_tx_queue *txq, struct rte_mbuf **m_head,
+		    int m_pkts)
 {
 	struct rte_mbuf *m0;
 	struct eth_tx_start_bd *tx_start_bd;
@@ -2136,12 +2138,6 @@ int bnx2x_tx_encap(struct bnx2x_tx_queue *txq, struct rte_mbuf **m_head, int m_p
 
 		m0 = *m_head++;
 
-		if (unlikely(txq->nb_tx_avail < 3)) {
-			PMD_TX_LOG(ERR, "no enough bds %d/%d",
-				   bd_prod, txq->nb_tx_avail);
-			return -ENOMEM;
-		}
-
 		txq->sw_ring[TX_BD(pkt_prod, txq)] = m0;
 
 		tx_start_bd = &txq->tx_ring[TX_BD(bd_prod, txq)].start_bd;
@@ -2252,8 +2248,6 @@ int bnx2x_tx_encap(struct bnx2x_tx_queue *txq, struct rte_mbuf **m_head, int m_p
 	fp->tx_db.data.prod += (m_pkts << 1) + nbds;
 	DOORBELL(sc, txq->queue_id, fp->tx_db.raw);
 	mb();
-
-	return 0;
 }
 
 static uint16_t bnx2x_cid_ilt_lines(struct bnx2x_softc *sc)
diff --git a/drivers/net/bnx2x/bnx2x.h b/drivers/net/bnx2x/bnx2x.h
index 135a6eb..42700e7 100644
--- a/drivers/net/bnx2x/bnx2x.h
+++ b/drivers/net/bnx2x/bnx2x.h
@@ -167,6 +167,8 @@ struct bnx2x_device_type {
 #define TX_PAGE(x)              (((x) & ~USABLE_TX_BD_PER_PAGE) >> 8)
 #define TX_IDX(x)               ((x) & USABLE_TX_BD_PER_PAGE)
 
+#define BDS_PER_TX_PKT		(3)
+
 /*
  * Trigger pending transmits when the number of available BDs is greater
  * than 1/8 of the total number of usable BDs.
@@ -1864,7 +1866,8 @@ int bnx2x_alloc_hsi_mem(struct bnx2x_softc *sc);
 int bnx2x_alloc_ilt_mem(struct bnx2x_softc *sc);
 void bnx2x_free_ilt_mem(struct bnx2x_softc *sc);
 void bnx2x_dump_tx_chain(struct bnx2x_fastpath * fp, int bd_prod, int count);
-int bnx2x_tx_encap(struct bnx2x_tx_queue *txq, struct rte_mbuf **m_head, int m_pkts);
+void bnx2x_tx_encap(struct bnx2x_tx_queue *txq, struct rte_mbuf **m_head,
+	int m_pkts);
 uint8_t bnx2x_txeof(struct bnx2x_softc *sc, struct bnx2x_fastpath *fp);
 void bnx2x_print_adapter_info(struct bnx2x_softc *sc);
 int bnx2x_intr_legacy(struct bnx2x_softc *sc, int scan_fp);
diff --git a/drivers/net/bnx2x/bnx2x_rxtx.c b/drivers/net/bnx2x/bnx2x_rxtx.c
index e825bce..3e1f83b 100644
--- a/drivers/net/bnx2x/bnx2x_rxtx.c
+++ b/drivers/net/bnx2x/bnx2x_rxtx.c
@@ -222,40 +222,37 @@ bnx2x_xmit_pkts(void *p_txq, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
 	struct bnx2x_tx_queue *txq;
 	struct bnx2x_softc *sc;
 	struct bnx2x_fastpath *fp;
-	uint32_t burst, nb_tx;
+	uint32_t burst;
 	struct rte_mbuf **m = tx_pkts;
-	int ret;
+	uint16_t nb_tx_pkts;
+	uint16_t nb_pkt_sent = 0;
 
 	txq = p_txq;
 	sc = txq->sc;
 	fp = &sc->fp[txq->queue_id];
 
-	nb_tx = nb_pkts;
+	if ((unlikely((txq->nb_tx_desc - txq->nb_tx_avail) >
+				txq->tx_free_thresh)))
+		bnx2x_txeof(sc, fp);
 
-	do {
-		burst = RTE_MIN(nb_pkts, RTE_PMD_BNX2X_TX_MAX_BURST);
+	nb_tx_pkts = RTE_MIN(nb_pkts, txq->nb_tx_avail / BDS_PER_TX_PKT);
+	if (unlikely(nb_tx_pkts == 0))
+		return 0;
 
-		ret = bnx2x_tx_encap(txq, m, burst);
-		if (unlikely(ret)) {
-			PMD_TX_LOG(ERR, "tx_encap failed!");
-		}
+	burst = RTE_MIN(nb_tx_pkts, RTE_PMD_BNX2X_TX_MAX_BURST);
 
+	while (nb_tx_pkts--) {
+		assert(m != NULL);
+		bnx2x_tx_encap(txq, m, burst);
 		bnx2x_update_fp_sb_idx(fp);
-
-		if ((txq->nb_tx_desc - txq->nb_tx_avail) > txq->tx_free_thresh) {
+		if ((txq->nb_tx_desc - txq->nb_tx_avail) >
+					txq->tx_free_thresh)
 			bnx2x_txeof(sc, fp);
-		}
-
-		if (unlikely(ret == -ENOMEM)) {
-			break;
-		}
-
 		m += burst;
-		nb_pkts -= burst;
-
-	} while (nb_pkts);
+		nb_pkt_sent++;
+	}
 
-	return nb_tx - nb_pkts;
+	return nb_pkt_sent;
 }
 
 int
-- 
1.7.10.3

  parent reply	other threads:[~2016-05-12  0:06 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-12  0:06 [dpdk-dev] [PATCH v5 1/5] bnx2x: fixed stats get Rasesh Mody
2016-05-12  0:06 ` [dpdk-dev] [PATCH v5 2/5] bnx2x: add xstats support Rasesh Mody
2016-06-28 14:34   ` Thomas Monjalon
2016-06-29  0:09     ` Rasesh Mody
2016-05-12  0:06 ` Rasesh Mody [this message]
2016-05-12  0:06 ` [dpdk-dev] [PATCH v5 4/5] bnx2x: use single doorbell for TX Rasesh Mody
2016-05-12  0:06 ` [dpdk-dev] [PATCH v5 5/5] bnx2x: update driver version to 1.0.1.1 Rasesh Mody
2016-06-08 16:15 ` [dpdk-dev] [PATCH v5 1/5] bnx2x: fixed stats get Bruce Richardson
2016-06-10 10:08   ` Ferruh Yigit
2016-06-13 10:32     ` Ferruh Yigit
2016-06-13 10:47     ` [dpdk-dev] [PATCH] bnx2x: fix ICC compilation error Ferruh Yigit
2016-06-27 16:02       ` [dpdk-dev] [PATCH v2] bnx2x: fix icc " Ferruh Yigit
2016-06-27 23:21         ` Rasesh Mody
2016-06-29  9:53           ` Bruce Richardson

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=1463011585-15429-3-git-send-email-rasesh.mody@qlogic.com \
    --to=rasesh.mody@qlogic.com \
    --cc=Dept-EngDPDKDev@qlogic.com \
    --cc=bruce.richardson@intel.com \
    --cc=dev@dpdk.org \
    --cc=harish.patil@qlogic.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).