DPDK patches and discussions
 help / color / mirror / Atom feed
From: "Kumar, Ravi1" <Ravi1.Kumar@amd.com>
To: "Sebastian, Selwin" <Selwin.Sebastian@amd.com>,
	"dev@dpdk.org" <dev@dpdk.org>
Subject: Re: [dpdk-dev] [PATCH v1] net/axgbe: add support for Scattered Rx
Date: Wed, 26 Feb 2020 05:47:17 +0000	[thread overview]
Message-ID: <MW2PR12MB257068D500492D844432D5A9AEEA0@MW2PR12MB2570.namprd12.prod.outlook.com> (raw)
In-Reply-To: <20200225124004.26946-1-ssebasti@amd.com>

[AMD Official Use Only - Internal Distribution Only]

Acked-by: Ravi Kumar <ravi1.kumar@amd.com>

>
>
>-----Original Message-----
>From: Sebastian, Selwin <Selwin.Sebastian@amd.com> 
>Sent: Tuesday, February 25, 2020 6:10 PM
>To: dev@dpdk.org
>Cc: Kumar, Ravi1 <Ravi1.Kumar@amd.com>
>Subject: [PATCH v1] net/axgbe: add support for Scattered Rx
>
>From: Selwin Sebastian <selwin.sebastian@amd.com>
>
>Enable scattered rx support and add jumbo packet transmit capability
>
>Signed-off-by: Selwin Sebastian <selwin.sebastian@amd.com>
>---
> doc/guides/nics/features/axgbe.ini |   1 +
> drivers/net/axgbe/axgbe_common.h   |   2 +
> drivers/net/axgbe/axgbe_ethdev.c   |  18 +++-
> drivers/net/axgbe/axgbe_rxtx.c     | 146 +++++++++++++++++++++++++++++
> drivers/net/axgbe/axgbe_rxtx.h     |   2 +
> 5 files changed, 168 insertions(+), 1 deletion(-)
>
>diff --git a/doc/guides/nics/features/axgbe.ini b/doc/guides/nics/features/axgbe.ini
>index ab4da559f..0becaa097 100644
>--- a/doc/guides/nics/features/axgbe.ini
>+++ b/doc/guides/nics/features/axgbe.ini
>@@ -7,6 +7,7 @@
> Speed capabilities   = Y
> Link status          = Y
> Jumbo frame          = Y
>+Scattered Rx         = Y
> Promiscuous mode     = Y
> Allmulticast mode    = Y
> RSS hash             = Y
>diff --git a/drivers/net/axgbe/axgbe_common.h b/drivers/net/axgbe/axgbe_common.h
>index fdb037dd5..fbd46150c 100644
>--- a/drivers/net/axgbe/axgbe_common.h
>+++ b/drivers/net/axgbe/axgbe_common.h
>@@ -1135,6 +1135,8 @@
> #define RX_NORMAL_DESC3_PL_WIDTH		14
> #define RX_NORMAL_DESC3_RSV_INDEX		26
> #define RX_NORMAL_DESC3_RSV_WIDTH		1
>+#define RX_NORMAL_DESC3_LD_INDEX		28
>+#define RX_NORMAL_DESC3_LD_WIDTH		1
> 
> #define RX_DESC3_L34T_IPV4_TCP			1
> #define RX_DESC3_L34T_IPV4_UDP			2
>diff --git a/drivers/net/axgbe/axgbe_ethdev.c b/drivers/net/axgbe/axgbe_ethdev.c
>index d0b6f091f..eb2f51f89 100644
>--- a/drivers/net/axgbe/axgbe_ethdev.c
>+++ b/drivers/net/axgbe/axgbe_ethdev.c
>@@ -789,11 +789,17 @@ axgbe_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
> 		DEV_RX_OFFLOAD_IPV4_CKSUM |
> 		DEV_RX_OFFLOAD_UDP_CKSUM  |
> 		DEV_RX_OFFLOAD_TCP_CKSUM  |
>+		DEV_RX_OFFLOAD_JUMBO_FRAME	|
>+		DEV_RX_OFFLOAD_SCATTER	  |
> 		DEV_RX_OFFLOAD_KEEP_CRC;
> 
> 	dev_info->tx_offload_capa =
> 		DEV_TX_OFFLOAD_IPV4_CKSUM  |
> 		DEV_TX_OFFLOAD_UDP_CKSUM   |
>+		DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM |
>+		DEV_TX_OFFLOAD_UDP_TSO		|
>+		DEV_TX_OFFLOAD_SCTP_CKSUM	|
>+		DEV_TX_OFFLOAD_MULTI_SEGS	|
> 		DEV_TX_OFFLOAD_TCP_CKSUM;
> 
> 	if (pdata->hw_feat.rss) {
>@@ -1018,9 +1024,19 @@ eth_axgbe_dev_init(struct rte_eth_dev *eth_dev)
> 	struct rte_pci_device *pci_dev;
> 	uint32_t reg, mac_lo, mac_hi;
> 	int ret;
>+	struct rte_eth_dev_info dev_info = { 0 };
> 
> 	eth_dev->dev_ops = &axgbe_eth_dev_ops;
>-	eth_dev->rx_pkt_burst = &axgbe_recv_pkts;
>+	eth_dev->dev_ops->dev_infos_get(eth_dev, &dev_info);
>+
>+	if (dev_info.rx_offload_capa & DEV_RX_OFFLOAD_SCATTER)
>+		eth_dev->data->scattered_rx = 1;
>+
>+	/*  Scatter Rx handling */
>+	if (eth_dev->data->scattered_rx)
>+		eth_dev->rx_pkt_burst = &eth_axgbe_recv_scattered_pkts;
>+	else
>+		eth_dev->rx_pkt_burst = &axgbe_recv_pkts;
> 
> 	/*
> 	 * For secondary processes, we don't initialise any further as primary diff --git a/drivers/net/axgbe/axgbe_rxtx.c b/drivers/net/axgbe/axgbe_rxtx.c index 96055c25b..57e2bbb34 100644
>--- a/drivers/net/axgbe/axgbe_rxtx.c
>+++ b/drivers/net/axgbe/axgbe_rxtx.c
>@@ -307,6 +307,152 @@ axgbe_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
> 	return nb_rx;
> }
> 
>+
>+uint16_t eth_axgbe_recv_scattered_pkts(void *rx_queue,
>+		struct rte_mbuf **rx_pkts, uint16_t nb_pkts) {
>+	PMD_INIT_FUNC_TRACE();
>+	uint16_t nb_rx = 0;
>+	struct axgbe_rx_queue *rxq = rx_queue;
>+	volatile union axgbe_rx_desc *desc;
>+
>+	uint64_t old_dirty = rxq->dirty;
>+	struct rte_mbuf *first_seg = NULL;
>+	struct rte_mbuf *mbuf, *tmbuf;
>+	unsigned int err;
>+	uint32_t error_status;
>+	uint16_t idx, pidx, data_len = 0, pkt_len = 0;
>+
>+	idx = AXGBE_GET_DESC_IDX(rxq, rxq->cur);
>+	while (nb_rx < nb_pkts) {
>+		bool eop = 0;
>+next_desc:
>+		if (unlikely(idx == rxq->nb_desc))
>+			idx = 0;
>+
>+		desc = &rxq->desc[idx];
>+
>+		if (AXGMAC_GET_BITS_LE(desc->write.desc3, RX_NORMAL_DESC3, OWN))
>+			break;
>+
>+		tmbuf = rte_mbuf_raw_alloc(rxq->mb_pool);
>+		if (unlikely(!tmbuf)) {
>+			PMD_DRV_LOG(ERR, "RX mbuf alloc failed port_id = %u"
>+				    " queue_id = %u\n",
>+				    (unsigned int)rxq->port_id,
>+				    (unsigned int)rxq->queue_id);
>+			rte_eth_devices[rxq->port_id].data->rx_mbuf_alloc_failed++;
>+			break;
>+		}
>+
>+		pidx = idx + 1;
>+		if (unlikely(pidx == rxq->nb_desc))
>+			pidx = 0;
>+
>+		rte_prefetch0(rxq->sw_ring[pidx]);
>+		if ((pidx & 0x3) == 0) {
>+			rte_prefetch0(&rxq->desc[pidx]);
>+			rte_prefetch0(&rxq->sw_ring[pidx]);
>+		}
>+
>+		mbuf = rxq->sw_ring[idx];
>+		/* Check for any errors and free mbuf*/
>+		err = AXGMAC_GET_BITS_LE(desc->write.desc3,
>+					 RX_NORMAL_DESC3, ES);
>+		error_status = 0;
>+		if (unlikely(err)) {
>+			error_status = desc->write.desc3 & AXGBE_ERR_STATUS;
>+			if ((error_status != AXGBE_L3_CSUM_ERR)
>+					&& (error_status != AXGBE_L4_CSUM_ERR)) {
>+				rxq->errors++;
>+				rte_pktmbuf_free(mbuf);
>+				goto err_set;
>+			}
>+		}
>+		rte_prefetch1(rte_pktmbuf_mtod(mbuf, void *));
>+
>+		if (!AXGMAC_GET_BITS_LE(desc->write.desc3,
>+					RX_NORMAL_DESC3, LD)) {
>+			eop = 0;
>+			pkt_len = rxq->buf_size;
>+			data_len = pkt_len;
>+		} else {
>+			eop = 1;
>+			pkt_len = AXGMAC_GET_BITS_LE(desc->write.desc3,
>+					RX_NORMAL_DESC3, PL);
>+			data_len = pkt_len - rxq->crc_len;
>+		}
>+
>+		if (first_seg != NULL) {
>+			if (rte_pktmbuf_chain(first_seg, mbuf) != 0)
>+				rte_mempool_put(rxq->mb_pool,
>+						first_seg);
>+		} else {
>+			first_seg = mbuf;
>+		}
>+
>+		/* Get the RSS hash */
>+		if (AXGMAC_GET_BITS_LE(desc->write.desc3, RX_NORMAL_DESC3, RSV))
>+			mbuf->hash.rss = rte_le_to_cpu_32(desc->write.desc1);
>+
>+		/* Mbuf populate */
>+		mbuf->data_off = RTE_PKTMBUF_HEADROOM;
>+		mbuf->data_len = data_len;
>+
>+err_set:
>+		rxq->cur++;
>+		rxq->sw_ring[idx++] = tmbuf;
>+		desc->read.baddr =
>+			rte_cpu_to_le_64(rte_mbuf_data_iova_default(tmbuf));
>+		memset((void *)(&desc->read.desc2), 0, 8);
>+		AXGMAC_SET_BITS_LE(desc->read.desc3, RX_NORMAL_DESC3, OWN, 1);
>+		rxq->dirty++;
>+
>+		if (!eop) {
>+			rte_pktmbuf_free(mbuf);
>+			goto next_desc;
>+		}
>+
>+		first_seg->pkt_len = pkt_len;
>+		rxq->bytes += pkt_len;
>+		mbuf->next = NULL;
>+
>+		first_seg->port = rxq->port_id;
>+		if (rxq->pdata->rx_csum_enable) {
>+			mbuf->ol_flags = 0;
>+			mbuf->ol_flags |= PKT_RX_IP_CKSUM_GOOD;
>+			mbuf->ol_flags |= PKT_RX_L4_CKSUM_GOOD;
>+			if (unlikely(error_status == AXGBE_L3_CSUM_ERR)) {
>+				mbuf->ol_flags &= ~PKT_RX_IP_CKSUM_GOOD;
>+				mbuf->ol_flags |= PKT_RX_IP_CKSUM_BAD;
>+				mbuf->ol_flags &= ~PKT_RX_L4_CKSUM_GOOD;
>+				mbuf->ol_flags |= PKT_RX_L4_CKSUM_UNKNOWN;
>+			} else if (unlikely(error_status
>+						== AXGBE_L4_CSUM_ERR)) {
>+				mbuf->ol_flags &= ~PKT_RX_L4_CKSUM_GOOD;
>+				mbuf->ol_flags |= PKT_RX_L4_CKSUM_BAD;
>+			}
>+		}
>+
>+		rx_pkts[nb_rx++] = first_seg;
>+
>+		 /* Setup receipt context for a new packet.*/
>+		first_seg = NULL;
>+	}
>+
>+	/* Save receive context.*/
>+	rxq->pkts += nb_rx;
>+
>+	if (rxq->dirty != old_dirty) {
>+		rte_wmb();
>+		idx = AXGBE_GET_DESC_IDX(rxq, rxq->dirty - 1);
>+		AXGMAC_DMA_IOWRITE(rxq, DMA_CH_RDTR_LO,
>+				   low32_value(rxq->ring_phys_addr +
>+				   (idx * sizeof(union axgbe_rx_desc))));
>+	}
>+	return nb_rx;
>+}
>+
> /* Tx Apis */
> static void axgbe_tx_queue_release(struct axgbe_tx_queue *tx_queue)  { diff --git a/drivers/net/axgbe/axgbe_rxtx.h b/drivers/net/axgbe/axgbe_rxtx.h index a21537df9..f6796b09b 100644
>--- a/drivers/net/axgbe/axgbe_rxtx.h
>+++ b/drivers/net/axgbe/axgbe_rxtx.h
>@@ -179,6 +179,8 @@ int axgbe_dev_rx_queue_start(struct rte_eth_dev *dev, uint16_t rx_queue_id);  int axgbe_dev_rx_queue_stop(struct rte_eth_dev *dev, uint16_t rx_queue_id);  uint16_t axgbe_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
> 			 uint16_t nb_pkts);
>+uint16_t eth_axgbe_recv_scattered_pkts(void *rx_queue,
>+		struct rte_mbuf **rx_pkts, uint16_t nb_pkts);
> uint16_t axgbe_recv_pkts_threshold_refresh(void *rx_queue,
> 					   struct rte_mbuf **rx_pkts,
> 					   uint16_t nb_pkts);
>--
>2.17.1
>

  reply	other threads:[~2020-02-26  5:47 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-25 12:40 ssebasti
2020-02-26  5:47 ` Kumar, Ravi1 [this message]
2020-03-05 10:20   ` Kumar, Ravi1
2020-03-05 10:27     ` Kumar, Ravi1
2020-02-27  6:33 ssebasti
2020-02-27 14:28 ` Ferruh Yigit
2020-02-27 14:35   ` Sebastian, Selwin
2020-02-27 14:38     ` Ferruh Yigit
2020-02-28  9:00       ` Sebastian, Selwin
2020-02-28 13:08         ` Ferruh Yigit
2020-02-28 13:09 ` 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=MW2PR12MB257068D500492D844432D5A9AEEA0@MW2PR12MB2570.namprd12.prod.outlook.com \
    --to=ravi1.kumar@amd.com \
    --cc=Selwin.Sebastian@amd.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).