DPDK patches and discussions
 help / color / mirror / Atom feed
From: Ajit Khaparde <ajit.khaparde@broadcom.com>
To: dev@dpdk.org
Cc: ferruh.yigit@intel.com
Subject: [dpdk-dev] [PATCH v2 02/23] net/bnxt: add Tx batching support
Date: Thu, 28 Jun 2018 13:15:28 -0700	[thread overview]
Message-ID: <20180628201549.3507-3-ajit.khaparde@broadcom.com> (raw)
In-Reply-To: <20180628201549.3507-1-ajit.khaparde@broadcom.com>

Batch more than one Tx requests such that only one completion
is generarted by the HW. We request a Tx completion for first
and last Tx request in the batch.

Signed-off-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
---
 drivers/net/bnxt/bnxt_cpr.h | 12 ++++++
 drivers/net/bnxt/bnxt_txq.h |  1 +
 drivers/net/bnxt/bnxt_txr.c | 97 +++++++++++++++++++++++++++++----------------
 3 files changed, 75 insertions(+), 35 deletions(-)

diff --git a/drivers/net/bnxt/bnxt_cpr.h b/drivers/net/bnxt/bnxt_cpr.h
index 6c1e6d2b0..c7af56983 100644
--- a/drivers/net/bnxt/bnxt_cpr.h
+++ b/drivers/net/bnxt/bnxt_cpr.h
@@ -22,12 +22,20 @@
 #define ADV_RAW_CMP(idx, n)	((idx) + (n))
 #define NEXT_RAW_CMP(idx)	ADV_RAW_CMP(idx, 1)
 #define RING_CMP(ring, idx)	((idx) & (ring)->ring_mask)
+#define RING_CMPL(ring_mask, idx)	((idx) & (ring_mask))
 #define NEXT_CMP(idx)		RING_CMP(ADV_RAW_CMP(idx, 1))
 #define FLIP_VALID(cons, mask, val)	((cons) >= (mask) ? !(val) : (val))
 
 #define DB_CP_REARM_FLAGS	(DB_KEY_CP | DB_IDX_VALID)
 #define DB_CP_FLAGS		(DB_KEY_CP | DB_IDX_VALID | DB_IRQ_DIS)
 
+#define NEXT_CMPL(cpr, idx, v, inc)	do { \
+	(idx) += (inc); \
+	if (unlikely((idx) == (cpr)->cp_ring_struct->ring_size)) { \
+		(v) = !(v); \
+		(idx) = 0; \
+	} \
+} while (0)
 #define B_CP_DB_REARM(cpr, raw_cons)					\
 	rte_write32((DB_CP_REARM_FLAGS |				\
 		    RING_CMP(((cpr)->cp_ring_struct), raw_cons)),	\
@@ -50,6 +58,10 @@
 	rte_write32((DB_CP_FLAGS |					\
 		    RING_CMP(((cpr)->cp_ring_struct), raw_cons)),	\
 		    ((cpr)->cp_doorbell))
+#define B_CP_DB(cpr, raw_cons, ring_mask)				\
+	rte_write32((DB_CP_FLAGS |					\
+		    RING_CMPL((ring_mask), raw_cons)),	\
+		    ((cpr)->cp_doorbell))
 
 struct bnxt_ring;
 struct bnxt_cp_ring_info {
diff --git a/drivers/net/bnxt/bnxt_txq.h b/drivers/net/bnxt/bnxt_txq.h
index 720ca90cf..f2c712a75 100644
--- a/drivers/net/bnxt/bnxt_txq.h
+++ b/drivers/net/bnxt/bnxt_txq.h
@@ -24,6 +24,7 @@ struct bnxt_tx_queue {
 	uint8_t			wthresh; /* Write-back threshold reg */
 	uint32_t		ctx_curr; /* Hardware context states */
 	uint8_t			tx_deferred_start; /* not in global dev start */
+	uint8_t			cmpl_next; /* Next BD to trigger a compl */
 
 	struct bnxt		*bp;
 	int			index;
diff --git a/drivers/net/bnxt/bnxt_txr.c b/drivers/net/bnxt/bnxt_txr.c
index 470fddd56..0fdf0fd08 100644
--- a/drivers/net/bnxt/bnxt_txr.c
+++ b/drivers/net/bnxt/bnxt_txr.c
@@ -114,7 +114,9 @@ static inline uint32_t bnxt_tx_avail(struct bnxt_tx_ring_info *txr)
 }
 
 static uint16_t bnxt_start_xmit(struct rte_mbuf *tx_pkt,
-				struct bnxt_tx_queue *txq)
+				struct bnxt_tx_queue *txq,
+				uint16_t *coal_pkts,
+				uint16_t *cmpl_next)
 {
 	struct bnxt_tx_ring_info *txr = txq->tx_ring;
 	struct tx_bd_long *txbd;
@@ -146,8 +148,15 @@ static uint16_t bnxt_start_xmit(struct rte_mbuf *tx_pkt,
 		return -ENOMEM;
 
 	txbd = &txr->tx_desc_ring[txr->tx_prod];
-	txbd->opaque = txr->tx_prod;
+	txbd->opaque = *coal_pkts;
 	txbd->flags_type = tx_buf->nr_bds << TX_BD_LONG_FLAGS_BD_CNT_SFT;
+	txbd->flags_type |= TX_BD_SHORT_FLAGS_COAL_NOW;
+	if (!*cmpl_next) {
+		txbd->flags_type |= TX_BD_LONG_FLAGS_NO_CMPL;
+	} else {
+		*coal_pkts = 0;
+		*cmpl_next = false;
+	}
 	txbd->len = tx_pkt->data_len;
 	if (txbd->len >= 2014)
 		txbd->flags_type |= TX_BD_LONG_FLAGS_LHINT_GTE2K;
@@ -235,7 +244,7 @@ static uint16_t bnxt_start_xmit(struct rte_mbuf *tx_pkt,
 
 		txbd = &txr->tx_desc_ring[txr->tx_prod];
 		txbd->address = rte_cpu_to_le_32(rte_mbuf_data_iova(m_seg));
-		txbd->flags_type = TX_BD_SHORT_TYPE_TX_BD_SHORT;
+		txbd->flags_type |= TX_BD_SHORT_TYPE_TX_BD_SHORT;
 		txbd->len = m_seg->data_len;
 
 		m_seg = m_seg->next;
@@ -278,35 +287,44 @@ static int bnxt_handle_tx_cp(struct bnxt_tx_queue *txq)
 	struct bnxt_cp_ring_info *cpr = txq->cp_ring;
 	uint32_t raw_cons = cpr->cp_raw_cons;
 	uint32_t cons;
-	int nb_tx_pkts = 0;
+	uint32_t nb_tx_pkts = 0;
 	struct tx_cmpl *txcmp;
+	struct cmpl_base *cp_desc_ring = cpr->cp_desc_ring;
+	struct bnxt_ring *cp_ring_struct = cpr->cp_ring_struct;
+	uint32_t ring_mask = cp_ring_struct->ring_mask;
+	uint32_t opaque = 0;
 
-	if ((txq->tx_ring->tx_ring_struct->ring_size -
-			(bnxt_tx_avail(txq->tx_ring))) >
-			txq->tx_free_thresh) {
-		while (1) {
-			cons = RING_CMP(cpr->cp_ring_struct, raw_cons);
-			txcmp = (struct tx_cmpl *)&cpr->cp_desc_ring[cons];
-
-			if (!CMP_VALID(txcmp, raw_cons, cpr->cp_ring_struct))
-				break;
-			cpr->valid = FLIP_VALID(cons,
-						cpr->cp_ring_struct->ring_mask,
-						cpr->valid);
-
-			if (CMP_TYPE(txcmp) == TX_CMPL_TYPE_TX_L2)
-				nb_tx_pkts++;
-			else
-				RTE_LOG_DP(DEBUG, PMD,
-						"Unhandled CMP type %02x\n",
-						CMP_TYPE(txcmp));
-			raw_cons = NEXT_RAW_CMP(raw_cons);
-		}
-		if (nb_tx_pkts)
-			bnxt_tx_cmp(txq, nb_tx_pkts);
+	if (((txq->tx_ring->tx_prod - txq->tx_ring->tx_cons) &
+		txq->tx_ring->tx_ring_struct->ring_mask) < txq->tx_free_thresh)
+		return 0;
+
+	do {
+		cons = RING_CMPL(ring_mask, raw_cons);
+		txcmp = (struct tx_cmpl *)&cpr->cp_desc_ring[cons];
+		rte_prefetch_non_temporal(&cp_desc_ring[(cons + 2) &
+							ring_mask]);
+
+		if (!CMPL_VALID(txcmp, cpr->valid))
+			break;
+		opaque = rte_cpu_to_le_32(txcmp->opaque);
+		NEXT_CMPL(cpr, cons, cpr->valid, 1);
+		rte_prefetch0(&cp_desc_ring[cons]);
+
+		if (CMP_TYPE(txcmp) == TX_CMPL_TYPE_TX_L2)
+			nb_tx_pkts += opaque;
+		else
+			RTE_LOG_DP(ERR, PMD,
+					"Unhandled CMP type %02x\n",
+					CMP_TYPE(txcmp));
+		raw_cons = cons;
+	} while (nb_tx_pkts < ring_mask);
+
+	if (nb_tx_pkts) {
+		bnxt_tx_cmp(txq, nb_tx_pkts);
 		cpr->cp_raw_cons = raw_cons;
-		B_CP_DIS_DB(cpr, cpr->cp_raw_cons);
+		B_CP_DB(cpr, cpr->cp_raw_cons, ring_mask);
 	}
+
 	return nb_tx_pkts;
 }
 
@@ -315,8 +333,8 @@ uint16_t bnxt_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
 {
 	struct bnxt_tx_queue *txq = tx_queue;
 	uint16_t nb_tx_pkts = 0;
-	uint16_t db_mask = txq->tx_ring->tx_ring_struct->ring_size >> 2;
-	uint16_t last_db_mask = 0;
+	uint16_t coal_pkts = 0;
+	uint16_t cmpl_next = txq->cmpl_next;
 
 	/* Handle TX completions */
 	bnxt_handle_tx_cp(txq);
@@ -326,16 +344,25 @@ uint16_t bnxt_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
 		PMD_DRV_LOG(DEBUG, "Tx q stopped;return\n");
 		return 0;
 	}
+
+	txq->cmpl_next = 0;
 	/* Handle TX burst request */
 	for (nb_tx_pkts = 0; nb_tx_pkts < nb_pkts; nb_tx_pkts++) {
-		if (bnxt_start_xmit(tx_pkts[nb_tx_pkts], txq)) {
+		int rc;
+
+		/* Request a completion on first and last packet */
+		cmpl_next |= (nb_pkts == nb_tx_pkts + 1);
+		coal_pkts++;
+		rc = bnxt_start_xmit(tx_pkts[nb_tx_pkts], txq,
+				&coal_pkts, &cmpl_next);
+
+		if (unlikely(rc)) {
+			/* Request a completion in next cycle */
+			txq->cmpl_next = 1;
 			break;
-		} else if ((nb_tx_pkts & db_mask) != last_db_mask) {
-			B_TX_DB(txq->tx_ring->tx_doorbell,
-					txq->tx_ring->tx_prod);
-			last_db_mask = nb_tx_pkts & db_mask;
 		}
 	}
+
 	if (nb_tx_pkts)
 		B_TX_DB(txq->tx_ring->tx_doorbell, txq->tx_ring->tx_prod);
 
-- 
2.15.2 (Apple Git-101.1)

  parent reply	other threads:[~2018-06-28 20:15 UTC|newest]

Thread overview: 73+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-19 21:30 [dpdk-dev] [PATCH 00/31] bnxt patchset Ajit Khaparde
2018-06-19 21:30 ` [dpdk-dev] [PATCH 01/31] net/bnxt: fix clear port stats Ajit Khaparde
2018-06-19 21:30 ` [dpdk-dev] [PATCH 02/31] net/bnxt: add Tx batching support Ajit Khaparde
2018-06-19 21:30 ` [dpdk-dev] [PATCH 03/31] net/bnxt: Rx processing optimization Ajit Khaparde
2018-06-19 21:30 ` [dpdk-dev] [PATCH 04/31] net/bnxt: set min and max descriptor count for Tx and Rx rings Ajit Khaparde
2018-06-19 21:30 ` [dpdk-dev] [PATCH 05/31] net/bnxt: fix dev close operation Ajit Khaparde
2018-06-26 15:28   ` Ferruh Yigit
2018-06-28 20:16     ` Ajit Khaparde
2018-06-19 21:30 ` [dpdk-dev] [PATCH 06/31] net/bnxt: set ring coalesce parameters for Stratus NIC Ajit Khaparde
2018-06-19 21:30 ` [dpdk-dev] [PATCH 07/31] net/bnxt: fix HW Tx checksum offload check Ajit Khaparde
2018-06-19 21:30 ` [dpdk-dev] [PATCH 08/31] net/bnxt: add support for VF id 0xd800 Ajit Khaparde
2018-06-26 15:28   ` Ferruh Yigit
2018-06-28 20:14     ` Ajit Khaparde
2018-06-19 21:30 ` [dpdk-dev] [PATCH 09/31] net/bnxt: fix rx/tx queue start/stop operations Ajit Khaparde
2018-06-19 21:30 ` [dpdk-dev] [PATCH 10/31] net/bnxt: code cleanup style of bnxt cpr Ajit Khaparde
2018-06-19 21:30 ` [dpdk-dev] [PATCH 11/31] net/bnxt: code cleanup style of bnxt rxr Ajit Khaparde
2018-06-26 15:29   ` Ferruh Yigit
2018-06-19 21:30 ` [dpdk-dev] [PATCH 12/31] net/bnxt: code cleanup style of rte pmd bnxt file Ajit Khaparde
2018-06-19 21:30 ` [dpdk-dev] [PATCH 13/31] net/bnxt: code cleanup style of bnxt stats Ajit Khaparde
2018-06-19 21:30 ` [dpdk-dev] [PATCH 14/31] net/bnxt: code cleanup style of bnxt vnic Ajit Khaparde
2018-06-19 21:30 ` [dpdk-dev] [PATCH 15/31] net/bnxt: code cleanup style of bnxt txq Ajit Khaparde
2018-06-19 21:30 ` [dpdk-dev] [PATCH 16/31] net/bnxt: code cleanup style of bnxt rxq Ajit Khaparde
2018-06-19 21:30 ` [dpdk-dev] [PATCH 17/31] net/bnxt: code cleanup style of bnxt vnic Ajit Khaparde
2018-06-19 21:30 ` [dpdk-dev] [PATCH 18/31] net/bnxt: code cleanup style of bnxt txr Ajit Khaparde
2018-06-19 21:30 ` [dpdk-dev] [PATCH 19/31] net/bnxt: code cleanup style of bnxt ring Ajit Khaparde
2018-06-19 21:30 ` [dpdk-dev] [PATCH 20/31] net/bnxt: code cleanup style of bnxt ethdev Ajit Khaparde
2018-06-19 21:30 ` [dpdk-dev] [PATCH 21/31] net/bnxt: move function check zero bytes to bnxt util.h Ajit Khaparde
2018-06-19 21:30 ` [dpdk-dev] [PATCH 22/31] net/bnxt: filter/flow refactoring Ajit Khaparde
2018-06-26 15:29   ` Ferruh Yigit
2018-06-19 21:30 ` [dpdk-dev] [PATCH 23/31] net/bnxt: check for invalid vnic id Ajit Khaparde
2018-06-26 15:30   ` Ferruh Yigit
2018-06-19 21:30 ` [dpdk-dev] [PATCH 24/31] net/bnxt: update HWRM API to v1.9.2.9 Ajit Khaparde
2018-06-26 15:30   ` Ferruh Yigit
2018-06-28 20:14     ` Ajit Khaparde
2018-06-19 21:30 ` [dpdk-dev] [PATCH 25/31] net/bnxt: fix Tx with multiple mbuf Ajit Khaparde
2018-06-19 21:30 ` [dpdk-dev] [PATCH 26/31] net/bnxt: Revert reset of L2 filter id in clear_ntuple_filter Ajit Khaparde
2018-06-19 21:30 ` [dpdk-dev] [PATCH 27/31] net/bnxt: check filter type before clearing it Ajit Khaparde
2018-06-26 15:30   ` Ferruh Yigit
2018-06-19 21:30 ` [dpdk-dev] [PATCH 28/31] net/bnxt: fix set MTU Ajit Khaparde
2018-06-26 15:30   ` Ferruh Yigit
2018-06-28 20:13     ` Ajit Khaparde
2018-06-19 21:30 ` [dpdk-dev] [PATCH 29/31] net/bnxt: fix incorrect IO address handling in Tx Ajit Khaparde
2018-06-19 21:30 ` [dpdk-dev] [PATCH 30/31] net/bnxt: allocate RSS context only if RSS mode is enabled Ajit Khaparde
2018-06-19 21:30 ` [dpdk-dev] [PATCH 31/31] net/bnxt: fix to move a flow to a different queue Ajit Khaparde
2018-06-26 15:27 ` [dpdk-dev] [PATCH 00/31] bnxt patchset Ferruh Yigit
2018-06-28 20:15   ` Ajit Khaparde
2018-06-28 20:15   ` [dpdk-dev] [PATCH v2 00/23] " Ajit Khaparde
2018-06-28 20:15     ` [dpdk-dev] [PATCH v2 01/23] net/bnxt: fix clear port stats Ajit Khaparde
2018-06-28 20:15     ` Ajit Khaparde [this message]
2018-06-28 20:15     ` [dpdk-dev] [PATCH v2 03/23] net/bnxt: optimize receive processing code Ajit Khaparde
2018-06-28 20:15     ` [dpdk-dev] [PATCH v2 04/23] net/bnxt: set MIN/MAX descriptor count fox Tx and Rx Rings Ajit Khaparde
2018-06-28 20:15     ` [dpdk-dev] [PATCH v2 05/23] net/bnxt: fix dev close operation Ajit Khaparde
2018-06-28 20:15     ` [dpdk-dev] [PATCH v2 06/23] net/bnxt: set ring coalesce parameters for Stratus NIC Ajit Khaparde
2018-06-28 20:15     ` [dpdk-dev] [PATCH v2 07/23] net/bnxt: fix HW Tx checksum offload check Ajit Khaparde
2018-06-28 20:15     ` [dpdk-dev] [PATCH v2 08/23] net/bnxt: add support for VF id 0xd800 Ajit Khaparde
2018-06-28 20:15     ` [dpdk-dev] [PATCH v2 09/23] net/bnxt: fix Rx/Tx queue start/stop operations Ajit Khaparde
2018-06-28 20:15     ` [dpdk-dev] [PATCH v2 10/23] net/bnxt: move function check zero bytes to bnxt util.h Ajit Khaparde
2018-07-02 12:20       ` Ferruh Yigit
2018-07-02 12:55         ` Ferruh Yigit
2018-06-28 20:15     ` [dpdk-dev] [PATCH v2 11/23] net/bnxt: refactor filter/flow Ajit Khaparde
2018-06-28 20:15     ` [dpdk-dev] [PATCH v2 12/23] net/bnxt: check for invalid vnic id Ajit Khaparde
2018-06-28 20:15     ` [dpdk-dev] [PATCH v2 13/23] net/bnxt: update HWRM API to v1.9.2.9 Ajit Khaparde
2018-06-28 20:15     ` [dpdk-dev] [PATCH v2 14/23] net/bnxt: fix Tx with multiple mbuf Ajit Khaparde
2018-06-28 20:15     ` [dpdk-dev] [PATCH v2 15/23] net/bnxt: revert reset of L2 filter id Ajit Khaparde
2018-06-28 20:15     ` [dpdk-dev] [PATCH v2 16/23] net/bnxt: check filter type before clearing it Ajit Khaparde
2018-06-28 20:15     ` [dpdk-dev] [PATCH v2 17/23] net/bnxt: fix set MTU Ajit Khaparde
2018-06-28 20:15     ` [dpdk-dev] [PATCH v2 18/23] net/bnxt: fix incorrect IO address handling in Tx Ajit Khaparde
2018-06-28 20:15     ` [dpdk-dev] [PATCH v2 19/23] net/bnxt: allocate RSS context only if RSS mode is enabled Ajit Khaparde
2018-06-28 20:15     ` [dpdk-dev] [PATCH v2 20/23] net/bnxt: fix to move a flow to a different queue Ajit Khaparde
2018-06-28 20:15     ` [dpdk-dev] [PATCH v2 21/23] net/bnxt: check VF resources if resource manager is enabled Ajit Khaparde
2018-06-28 20:15     ` [dpdk-dev] [PATCH v2 22/23] net/bnxt: fix Rx ring count limitation Ajit Khaparde
2018-06-28 20:15     ` [dpdk-dev] [PATCH v2 23/23] net/bnxt: use correct flags during VLAN configuration Ajit Khaparde
2018-07-02 15:48     ` [dpdk-dev] [PATCH v2 00/23] bnxt patchset 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=20180628201549.3507-3-ajit.khaparde@broadcom.com \
    --to=ajit.khaparde@broadcom.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@intel.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).