DPDK patches and discussions
 help / color / mirror / Atom feed
From: Lance Richardson <lance.richardson@broadcom.com>
To: Ajit Khaparde <ajit.khaparde@broadcom.com>,
	Somnath Kotur <somnath.kotur@broadcom.com>
Cc: dev@dpdk.org
Subject: [dpdk-dev] [PATCH v2] net/bnxt: support fast mbuf free
Date: Fri,  2 Oct 2020 09:40:02 -0400	[thread overview]
Message-ID: <20201002134002.83845-1-lance.richardson@broadcom.com> (raw)

Add support for DEV_TX_OFFLOAD_MBUF_FAST_FREE to bnxt
vector mode transmit. This offload may be enabled
only when multi-segment transmit is not needed, all
transmitted mbufs for a given queue will be allocated
from the same pool, and all transmitted mbufs will
have a reference count of 1.

Since this offload is only supported in vector mode at
this time, support in the features list is indicated
as "partial".

Signed-off-by: Lance Richardson <lance.richardson@broadcom.com>
---
- v2:
  Fixed mangling of advertised tx offload capabilities.

 doc/guides/nics/features/bnxt.ini     |  1 +
 drivers/net/bnxt/bnxt_ethdev.c        | 11 +++++++----
 drivers/net/bnxt/bnxt_rxtx_vec_neon.c | 28 ++++++++++++++++++++++++++-
 drivers/net/bnxt/bnxt_rxtx_vec_sse.c  | 28 ++++++++++++++++++++++++++-
 drivers/net/bnxt/bnxt_txq.c           |  2 ++
 drivers/net/bnxt/bnxt_txq.h           |  1 +
 6 files changed, 65 insertions(+), 6 deletions(-)

diff --git a/doc/guides/nics/features/bnxt.ini b/doc/guides/nics/features/bnxt.ini
index f1f300c8b..7cb873dd0 100644
--- a/doc/guides/nics/features/bnxt.ini
+++ b/doc/guides/nics/features/bnxt.ini
@@ -8,6 +8,7 @@ Speed capabilities   = Y
 Link status          = Y
 Link status event    = Y
 Rx interrupt         = Y
+Fast mbuf free       = P
 Queue start/stop     = Y
 Burst mode info      = Y
 MTU update           = Y
diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c
index 624cb2031..c2a9f80e2 100644
--- a/drivers/net/bnxt/bnxt_ethdev.c
+++ b/drivers/net/bnxt/bnxt_ethdev.c
@@ -920,7 +920,9 @@ static int bnxt_dev_info_get_op(struct rte_eth_dev *eth_dev,
 	dev_info->rx_offload_capa = BNXT_DEV_RX_OFFLOAD_SUPPORT;
 	if (bp->flags & BNXT_FLAG_PTP_SUPPORTED)
 		dev_info->rx_offload_capa |= DEV_RX_OFFLOAD_TIMESTAMP;
-	dev_info->tx_offload_capa = BNXT_DEV_TX_OFFLOAD_SUPPORT;
+	dev_info->tx_queue_offload_capa = DEV_TX_OFFLOAD_MBUF_FAST_FREE;
+	dev_info->tx_offload_capa = BNXT_DEV_TX_OFFLOAD_SUPPORT |
+				    dev_info->tx_queue_offload_capa;
 	dev_info->flow_type_rss_offloads = BNXT_ETH_RSS_SUPPORT;
 
 	dev_info->speed_capa = bnxt_get_speed_capabilities(bp);
@@ -1191,6 +1193,7 @@ bnxt_transmit_function(__rte_unused struct rte_eth_dev *eth_dev)
 {
 #if defined(RTE_ARCH_X86) || defined(RTE_ARCH_ARM64)
 #ifndef RTE_LIBRTE_IEEE1588
+	uint64_t offloads = eth_dev->data->dev_conf.txmode.offloads;
 	struct bnxt *bp = eth_dev->data->dev_private;
 
 	/*
@@ -1198,7 +1201,7 @@ bnxt_transmit_function(__rte_unused struct rte_eth_dev *eth_dev)
 	 * or tx offloads.
 	 */
 	if (!eth_dev->data->scattered_rx &&
-	    !eth_dev->data->dev_conf.txmode.offloads &&
+	    !(offloads & ~DEV_TX_OFFLOAD_MBUF_FAST_FREE) &&
 	    !BNXT_TRUFLOW_EN(bp)) {
 		PMD_DRV_LOG(INFO, "Using vector mode transmit for port %d\n",
 			    eth_dev->data->port_id);
@@ -1210,7 +1213,7 @@ bnxt_transmit_function(__rte_unused struct rte_eth_dev *eth_dev)
 		    "Port %d scatter: %d tx offload: %" PRIX64 "\n",
 		    eth_dev->data->port_id,
 		    eth_dev->data->scattered_rx,
-		    eth_dev->data->dev_conf.txmode.offloads);
+		    offloads);
 #endif
 #endif
 	return bnxt_xmit_pkts;
@@ -2685,7 +2688,7 @@ bnxt_txq_info_get_op(struct rte_eth_dev *dev, uint16_t queue_id,
 	qinfo->conf.tx_free_thresh = txq->tx_free_thresh;
 	qinfo->conf.tx_rs_thresh = 0;
 	qinfo->conf.tx_deferred_start = txq->tx_deferred_start;
-	qinfo->conf.offloads = dev->data->dev_conf.txmode.offloads;
+	qinfo->conf.offloads = txq->offloads;
 }
 
 static const struct {
diff --git a/drivers/net/bnxt/bnxt_rxtx_vec_neon.c b/drivers/net/bnxt/bnxt_rxtx_vec_neon.c
index 299b6b86d..a70055fce 100644
--- a/drivers/net/bnxt/bnxt_rxtx_vec_neon.c
+++ b/drivers/net/bnxt/bnxt_rxtx_vec_neon.c
@@ -338,6 +338,29 @@ bnxt_recv_pkts_vec(void *rx_queue, struct rte_mbuf **rx_pkts,
 	return nb_rx_pkts;
 }
 
+static void
+bnxt_tx_cmp_vec_fast(struct bnxt_tx_queue *txq, int nr_pkts)
+{
+	struct bnxt_tx_ring_info *txr = txq->tx_ring;
+	struct rte_mbuf **free = txq->free;
+	uint16_t cons = txr->tx_cons;
+	unsigned int blk = 0;
+	uint32_t ring_mask = txr->tx_ring_struct->ring_mask;
+
+	while (nr_pkts--) {
+		struct bnxt_sw_tx_bd *tx_buf;
+
+		tx_buf = &txr->tx_buf_ring[cons];
+		cons = (cons + 1) & ring_mask;
+		free[blk++] = tx_buf->mbuf;
+		tx_buf->mbuf = NULL;
+	}
+	if (blk)
+		rte_mempool_put_bulk(free[0]->pool, (void **)free, blk);
+
+	txr->tx_cons = cons;
+}
+
 static void
 bnxt_tx_cmp_vec(struct bnxt_tx_queue *txq, int nr_pkts)
 {
@@ -399,7 +422,10 @@ bnxt_handle_tx_cp_vec(struct bnxt_tx_queue *txq)
 
 	cpr->valid = !!(raw_cons & cp_ring_struct->ring_size);
 	if (nb_tx_pkts) {
-		bnxt_tx_cmp_vec(txq, nb_tx_pkts);
+		if (txq->offloads & DEV_TX_OFFLOAD_MBUF_FAST_FREE)
+			bnxt_tx_cmp_vec_fast(txq, nb_tx_pkts);
+		else
+			bnxt_tx_cmp_vec(txq, nb_tx_pkts);
 		cpr->cp_raw_cons = raw_cons;
 		bnxt_db_cq(cpr);
 	}
diff --git a/drivers/net/bnxt/bnxt_rxtx_vec_sse.c b/drivers/net/bnxt/bnxt_rxtx_vec_sse.c
index 271e7908e..6d1f163f7 100644
--- a/drivers/net/bnxt/bnxt_rxtx_vec_sse.c
+++ b/drivers/net/bnxt/bnxt_rxtx_vec_sse.c
@@ -309,6 +309,29 @@ bnxt_recv_pkts_vec(void *rx_queue, struct rte_mbuf **rx_pkts,
 	return nb_rx_pkts;
 }
 
+static void
+bnxt_tx_cmp_vec_fast(struct bnxt_tx_queue *txq, int nr_pkts)
+{
+	struct bnxt_tx_ring_info *txr = txq->tx_ring;
+	struct rte_mbuf **free = txq->free;
+	uint16_t cons = txr->tx_cons;
+	unsigned int blk = 0;
+	uint32_t ring_mask = txr->tx_ring_struct->ring_mask;
+
+	while (nr_pkts--) {
+		struct bnxt_sw_tx_bd *tx_buf;
+
+		tx_buf = &txr->tx_buf_ring[cons];
+		cons = (cons + 1) & ring_mask;
+		free[blk++] = tx_buf->mbuf;
+		tx_buf->mbuf = NULL;
+	}
+	if (blk)
+		rte_mempool_put_bulk(free[0]->pool, (void **)free, blk);
+
+	txr->tx_cons = cons;
+}
+
 static void
 bnxt_tx_cmp_vec(struct bnxt_tx_queue *txq, int nr_pkts)
 {
@@ -371,7 +394,10 @@ bnxt_handle_tx_cp_vec(struct bnxt_tx_queue *txq)
 
 	cpr->valid = !!(raw_cons & cp_ring_struct->ring_size);
 	if (nb_tx_pkts) {
-		bnxt_tx_cmp_vec(txq, nb_tx_pkts);
+		if (txq->offloads & DEV_TX_OFFLOAD_MBUF_FAST_FREE)
+			bnxt_tx_cmp_vec_fast(txq, nb_tx_pkts);
+		else
+			bnxt_tx_cmp_vec(txq, nb_tx_pkts);
 		cpr->cp_raw_cons = raw_cons;
 		bnxt_db_cq(cpr);
 	}
diff --git a/drivers/net/bnxt/bnxt_txq.c b/drivers/net/bnxt/bnxt_txq.c
index bdc7ffaaa..c8d75ac95 100644
--- a/drivers/net/bnxt/bnxt_txq.c
+++ b/drivers/net/bnxt/bnxt_txq.c
@@ -131,6 +131,8 @@ int bnxt_tx_queue_setup_op(struct rte_eth_dev *eth_dev,
 	txq->nb_tx_desc = nb_desc;
 	txq->tx_free_thresh =
 		RTE_MIN(rte_align32pow2(nb_desc) / 4, RTE_BNXT_MAX_TX_BURST);
+	txq->offloads = eth_dev->data->dev_conf.txmode.offloads |
+			tx_conf->offloads;
 
 	txq->tx_deferred_start = tx_conf->tx_deferred_start;
 
diff --git a/drivers/net/bnxt/bnxt_txq.h b/drivers/net/bnxt/bnxt_txq.h
index 9f849fc71..8033e241e 100644
--- a/drivers/net/bnxt/bnxt_txq.h
+++ b/drivers/net/bnxt/bnxt_txq.h
@@ -39,6 +39,7 @@ struct bnxt_tx_queue {
 	struct bnxt_cp_ring_info	*cp_ring;
 	const struct rte_memzone *mz;
 	struct rte_mbuf **free;
+	uint64_t offloads;
 };
 
 void bnxt_free_txq_stats(struct bnxt_tx_queue *txq);
-- 
2.25.1


             reply	other threads:[~2020-10-02 13:40 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-02 13:40 Lance Richardson [this message]
2020-10-06 17:37 ` [dpdk-dev] [PATCH v3] " Lance Richardson
2020-10-06 21:26   ` Ajit Khaparde

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=20201002134002.83845-1-lance.richardson@broadcom.com \
    --to=lance.richardson@broadcom.com \
    --cc=ajit.khaparde@broadcom.com \
    --cc=dev@dpdk.org \
    --cc=somnath.kotur@broadcom.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).