From: <wanry@3snic.com>
To: <dev@dpdk.org>
Cc: <ferruh.yigit@amd.com>, Renyong Wan <wanry@3snic.com>,
Steven Song <steven.song@3snic.com>
Subject: [PATCH v5 23/32] net/sssnic: support Rx packet burst
Date: Mon, 4 Sep 2023 12:56:49 +0800 [thread overview]
Message-ID: <20230904045658.238185-24-wanry@3snic.com> (raw)
In-Reply-To: <20230904045658.238185-1-wanry@3snic.com>
From: Renyong Wan <wanry@3snic.com>
Signed-off-by: Steven Song <steven.song@3snic.com>
Signed-off-by: Renyong Wan <wanry@3snic.com>
---
v2:
* Fixed wrong format of printing uint64_t.
---
doc/guides/nics/features/sssnic.ini | 2 +
drivers/net/sssnic/sssnic_ethdev.c | 2 +
drivers/net/sssnic/sssnic_ethdev_rx.c | 167 ++++++++++++++++++++++++++
drivers/net/sssnic/sssnic_ethdev_rx.h | 2 +
4 files changed, 173 insertions(+)
diff --git a/doc/guides/nics/features/sssnic.ini b/doc/guides/nics/features/sssnic.ini
index aba0b78c95..320ac4533d 100644
--- a/doc/guides/nics/features/sssnic.ini
+++ b/doc/guides/nics/features/sssnic.ini
@@ -8,6 +8,8 @@ Link status = Y
Link status event = Y
Queue start/stop = Y
Rx interrupt = Y
+Scattered Rx = Y
+LRO = Y
Promiscuous mode = Y
Allmulticast mode = Y
Unicast MAC filter = Y
diff --git a/drivers/net/sssnic/sssnic_ethdev.c b/drivers/net/sssnic/sssnic_ethdev.c
index 99e6d6152a..021fabcbe5 100644
--- a/drivers/net/sssnic/sssnic_ethdev.c
+++ b/drivers/net/sssnic/sssnic_ethdev.c
@@ -769,6 +769,8 @@ sssnic_ethdev_init(struct rte_eth_dev *ethdev)
if (rte_eal_process_type() != RTE_PROC_PRIMARY)
return 0;
+ ethdev->rx_pkt_burst = sssnic_ethdev_rx_pkt_burst;
+
netdev = SSSNIC_ETHDEV_PRIVATE(ethdev);
pci_dev = RTE_ETH_DEV_TO_PCI(ethdev);
hw = rte_zmalloc("sssnic_hw", sizeof(struct sssnic_hw), 0);
diff --git a/drivers/net/sssnic/sssnic_ethdev_rx.c b/drivers/net/sssnic/sssnic_ethdev_rx.c
index 66045f7a98..82e65f2482 100644
--- a/drivers/net/sssnic/sssnic_ethdev_rx.c
+++ b/drivers/net/sssnic/sssnic_ethdev_rx.c
@@ -1183,3 +1183,170 @@ sssnic_ethdev_rx_queue_stats_clear(struct rte_eth_dev *ethdev, uint16_t qid)
memset(&rxq->stats, 0, sizeof(rxq->stats));
}
};
+
+static inline void
+sssnic_ethdev_rx_csum_offload(struct sssnic_ethdev_rxq *rxq,
+ struct rte_mbuf *rxm, volatile struct sssnic_ethdev_rx_desc *rxd)
+{
+ /* no errors */
+ if (likely(rxd->status_err == 0)) {
+ rxm->ol_flags |= RTE_MBUF_F_RX_IP_CKSUM_GOOD |
+ RTE_MBUF_F_RX_L4_CKSUM_GOOD;
+ return;
+ }
+
+ /* bypass hw crc error*/
+ if (unlikely(rxd->hw_crc_err)) {
+ rxm->ol_flags |= RTE_MBUF_F_RX_IP_CKSUM_UNKNOWN;
+ return;
+ }
+
+ if (rxd->ip_csum_err) {
+ rxm->ol_flags |= RTE_MBUF_F_RX_IP_CKSUM_BAD;
+ rxq->stats.csum_errors++;
+ }
+
+ if (rxd->tcp_csum_err || rxd->udp_csum_err || rxd->sctp_crc_err) {
+ rxm->ol_flags |= RTE_MBUF_F_RX_L4_CKSUM_BAD;
+ rxq->stats.csum_errors++;
+ }
+
+ if (unlikely(rxd->other_err))
+ rxq->stats.other_errors++;
+}
+
+static inline void
+sssnic_ethdev_rx_vlan_offload(struct rte_mbuf *rxm,
+ volatile struct sssnic_ethdev_rx_desc *rxd)
+{
+ if (rxd->vlan_en == 0 || rxd->vlan == 0) {
+ rxm->vlan_tci = 0;
+ return;
+ }
+
+ rxm->vlan_tci = rxd->vlan;
+ rxm->ol_flags |= RTE_MBUF_F_RX_VLAN | RTE_MBUF_F_RX_VLAN_STRIPPED;
+}
+
+static inline void
+sssnic_ethdev_rx_segments(struct sssnic_ethdev_rxq *rxq, struct rte_mbuf *head,
+ uint32_t remain_size)
+{
+ struct sssnic_ethdev_rx_entry *rxe;
+ struct rte_mbuf *curr, *prev = head;
+ uint16_t rx_buf_size = rxq->rx_buf_size;
+ uint16_t ci;
+ uint32_t rx_size;
+
+ while (remain_size > 0) {
+ ci = sssnic_ethdev_rxq_ci_get(rxq);
+ rxe = &rxq->rxe[ci];
+ curr = rxe->pktmbuf;
+
+ sssnic_ethdev_rxq_consume(rxq, 1);
+
+ rx_size = RTE_MIN(remain_size, rx_buf_size);
+ remain_size -= rx_size;
+
+ curr->data_len = rx_size;
+ curr->next = NULL;
+ prev->next = curr;
+ prev = curr;
+ head->nb_segs++;
+ }
+}
+
+uint16_t
+sssnic_ethdev_rx_pkt_burst(void *rx_queue, struct rte_mbuf **rx_pkts,
+ uint16_t nb_pkts)
+{
+ struct sssnic_ethdev_rxq *rxq = (struct sssnic_ethdev_rxq *)rx_queue;
+ struct sssnic_ethdev_rx_entry *rxe;
+ struct rte_mbuf *rxm;
+ struct sssnic_ethdev_rx_desc *rxd, rx_desc;
+ uint16_t ci, idle_entries;
+ uint16_t rx_buf_size;
+ uint32_t rx_size;
+ uint64_t nb_rx = 0;
+ uint64_t rx_bytes = 0;
+
+ ci = sssnic_ethdev_rxq_ci_get(rxq);
+ rx_buf_size = rxq->rx_buf_size;
+ rxd = &rx_desc;
+
+ while (nb_rx < nb_pkts) {
+ rxd->dword0 = __atomic_load_n(&rxq->desc[ci].dword0,
+ __ATOMIC_ACQUIRE);
+ /* check rx done */
+ if (!rxd->done)
+ break;
+
+ rxd->dword1 = rxq->desc[ci].dword1;
+ rxd->dword2 = rxq->desc[ci].dword2;
+ rxd->dword3 = rxq->desc[ci].dword3;
+
+ /* reset rx desc status */
+ rxq->desc[ci].dword0 = 0;
+
+ /* get current pktmbuf */
+ rxe = &rxq->rxe[ci];
+ rxm = rxe->pktmbuf;
+
+ /* prefetch next packet */
+ sssnic_ethdev_rxq_consume(rxq, 1);
+ ci = sssnic_ethdev_rxq_ci_get(rxq);
+ rte_prefetch0(rxq->rxe[ci].pktmbuf);
+
+ /* set pktmbuf len */
+ rx_size = rxd->len;
+ rxm->pkt_len = rx_size;
+ if (likely(rx_size <= rx_buf_size)) {
+ rxm->data_len = rx_size;
+ } else {
+ rxm->data_len = rx_buf_size;
+ sssnic_ethdev_rx_segments(rxq, rxm,
+ rx_size - rx_buf_size);
+ }
+ rxm->data_off = RTE_PKTMBUF_HEADROOM;
+ rxm->port = rxq->port;
+
+ /* process checksum offload*/
+ sssnic_ethdev_rx_csum_offload(rxq, rxm, rxd);
+
+ /* process vlan offload */
+ sssnic_ethdev_rx_vlan_offload(rxm, rxd);
+
+ /* process lro */
+ if (unlikely(rxd->lro_num != 0)) {
+ rxm->ol_flags |= RTE_MBUF_F_RX_LRO;
+ rxm->tso_segsz = rx_size / rxd->lro_num;
+ }
+
+ /* process RSS offload */
+ if (likely(rxd->rss_type != 0)) {
+ rxm->hash.rss = rxd->rss_hash;
+ rxm->ol_flags |= RTE_MBUF_F_RX_RSS_HASH;
+ }
+
+ rx_pkts[nb_rx++] = rxm;
+ rx_bytes += rx_size;
+
+ SSSNIC_RX_LOG(DEBUG,
+ "Received one packet on port %u, len=%u, nb_seg=%u, tso_segsz=%u, ol_flags=%"
+ PRIx64, rxq->port, rxm->pkt_len, rxm->nb_segs, rxm->tso_segsz,
+ rxm->ol_flags);
+ }
+
+ if (nb_rx > 0) {
+ rxq->stats.packets += nb_rx;
+ rxq->stats.bytes += rx_bytes;
+ rxq->stats.burst = nb_rx;
+
+ /* refill packet mbuf */
+ idle_entries = sssnic_ethdev_rxq_num_idle_entries(rxq) - 1;
+ if (idle_entries >= rxq->rx_free_thresh)
+ sssnic_ethdev_rxq_pktmbufs_fill(rxq);
+ }
+
+ return nb_rx;
+}
diff --git a/drivers/net/sssnic/sssnic_ethdev_rx.h b/drivers/net/sssnic/sssnic_ethdev_rx.h
index 5532aced4e..b0b35dee73 100644
--- a/drivers/net/sssnic/sssnic_ethdev_rx.h
+++ b/drivers/net/sssnic/sssnic_ethdev_rx.h
@@ -42,5 +42,7 @@ int sssnic_ethdev_rx_queue_stats_get(struct rte_eth_dev *ethdev, uint16_t qid,
struct sssnic_ethdev_rxq_stats *stats);
void sssnic_ethdev_rx_queue_stats_clear(struct rte_eth_dev *ethdev,
uint16_t qid);
+uint16_t sssnic_ethdev_rx_pkt_burst(void *rx_queue, struct rte_mbuf **rx_pkts,
+ uint16_t nb_pkts);
#endif
--
2.27.0
next prev parent reply other threads:[~2023-09-04 5:00 UTC|newest]
Thread overview: 66+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-04 4:56 [PATCH v5 00/32] Introduce sssnic PMD for 3SNIC's 9x0 serials Ethernet adapters wanry
2023-09-04 4:56 ` [PATCH v5 01/32] net/sssnic: add build and doc infrastructure wanry
2023-09-26 13:06 ` Ferruh Yigit
2023-09-04 4:56 ` [PATCH v5 02/32] net/sssnic: add log type and log macros wanry
2023-09-04 4:56 ` [PATCH v5 03/32] net/sssnic: support probe and remove wanry
2023-09-18 16:08 ` Stephen Hemminger
2023-09-19 2:00 ` Renyong Wan
2023-09-04 4:56 ` [PATCH v5 04/32] net/sssnic: initialize hardware base wanry
2023-09-18 2:28 ` Stephen Hemminger
2023-09-18 4:47 ` Renyong Wan
2023-09-04 4:56 ` [PATCH v5 05/32] net/sssnic: add event queue wanry
2023-09-04 4:56 ` [PATCH v5 06/32] net/sssnic/base: add message definition and utility wanry
2023-09-18 2:31 ` Stephen Hemminger
2023-09-18 5:08 ` Renyong Wan
2023-09-04 4:56 ` [PATCH v5 07/32] net/sssnic/base: add mailbox support wanry
2023-09-18 2:32 ` Stephen Hemminger
2023-09-18 5:10 ` Renyong Wan
2023-09-26 13:13 ` Ferruh Yigit
2023-09-04 4:56 ` [PATCH v5 08/32] net/sssnic/base: add work queue wanry
2023-09-18 2:33 ` Stephen Hemminger
2023-09-18 5:11 ` Renyong Wan
2023-09-04 4:56 ` [PATCH v5 09/32] net/sssnic/base: add control queue wanry
2023-09-18 2:36 ` Stephen Hemminger
2023-09-18 5:22 ` Renyong Wan
2023-09-04 4:56 ` [PATCH v5 10/32] net/sssnic: add dev configure and infos get wanry
2023-09-04 4:56 ` [PATCH v5 11/32] net/sssnic: add dev MAC ops wanry
2023-09-26 13:07 ` Ferruh Yigit
2023-09-04 4:56 ` [PATCH v5 12/32] net/sssnic: support dev link status wanry
2023-09-04 4:56 ` [PATCH v5 13/32] net/sssnic: support link status event wanry
2023-09-26 13:08 ` Ferruh Yigit
2023-09-04 4:56 ` [PATCH v5 14/32] net/sssnic: support Rx queue setup and release wanry
2023-09-04 4:56 ` [PATCH v5 15/32] net/sssnic: support Tx " wanry
2023-09-04 4:56 ` [PATCH v5 16/32] net/sssnic: support Rx queue start and stop wanry
2023-09-04 4:56 ` [PATCH v5 17/32] net/sssnic: support Tx " wanry
2023-09-04 4:56 ` [PATCH v5 18/32] net/sssnic: add Rx interrupt support wanry
2023-09-04 4:56 ` [PATCH v5 19/32] net/sssnic: support dev start and stop wanry
2023-09-26 13:09 ` Ferruh Yigit
2023-09-04 4:56 ` [PATCH v5 20/32] net/sssnic: support dev close and reset wanry
2023-09-26 13:09 ` Ferruh Yigit
2023-09-04 4:56 ` [PATCH v5 21/32] net/sssnic: add allmulticast and promiscuous ops wanry
2023-09-04 4:56 ` [PATCH v5 22/32] net/sssnic: add basic and extended stats ops wanry
2023-09-04 4:56 ` wanry [this message]
2023-09-04 4:56 ` [PATCH v5 24/32] net/sssnic: support Tx packet burst wanry
2023-09-26 13:10 ` Ferruh Yigit
2023-09-04 4:56 ` [PATCH v5 25/32] net/sssnic: add RSS support wanry
2023-09-04 4:56 ` [PATCH v5 26/32] net/sssnic: support dev MTU set wanry
2023-09-04 4:56 ` [PATCH v5 27/32] net/sssnic: support dev queue info get wanry
2023-09-04 4:56 ` [PATCH v5 28/32] net/sssnic: support dev firmware version get wanry
2023-09-04 4:56 ` [PATCH v5 29/32] net/sssnic: add dev flow control ops wanry
2023-09-26 13:12 ` Ferruh Yigit
2023-09-04 4:56 ` [PATCH v5 30/32] net/sssnic: support VLAN offload and filter wanry
2023-09-04 4:56 ` [PATCH v5 31/32] net/sssnic: add generic flow ops wanry
2023-09-04 4:56 ` [PATCH v5 32/32] net/sssnic: add VF dev support wanry
2023-09-26 13:11 ` Ferruh Yigit
2023-09-18 2:37 ` [PATCH v5 00/32] Introduce sssnic PMD for 3SNIC's 9x0 serials Ethernet adapters Stephen Hemminger
2023-09-18 3:23 ` Renyong Wan
2023-09-19 3:19 ` Stephen Hemminger
2023-09-19 5:18 ` Renyong Wan
2023-09-19 3:21 ` Stephen Hemminger
2023-09-19 5:18 ` Renyong Wan
2023-09-19 3:23 ` Stephen Hemminger
2023-09-19 5:19 ` Renyong Wan
2023-09-19 15:24 ` Stephen Hemminger
2023-09-26 13:13 ` Ferruh Yigit
2024-03-29 11:32 ` Ferruh Yigit
2024-07-31 17:32 ` Thomas Monjalon
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=20230904045658.238185-24-wanry@3snic.com \
--to=wanry@3snic.com \
--cc=dev@dpdk.org \
--cc=ferruh.yigit@amd.com \
--cc=steven.song@3snic.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).