From: Mingxia Liu <mingxia.liu@intel.com>
To: dev@dpdk.org
Cc: jingjing.wu@intel.com, beilei.xing@intel.com,
Mingxia Liu <mingxia.liu@intel.com>,
Wenjun Wu <wenjun1.wu@intel.com>
Subject: [PATCH v3 3/6] common/idpf: support single q scatter RX datapath
Date: Wed, 18 Jan 2023 07:14:37 +0000 [thread overview]
Message-ID: <20230118071440.902155-4-mingxia.liu@intel.com> (raw)
In-Reply-To: <20230118071440.902155-1-mingxia.liu@intel.com>
This patch add single q recv scatter rx function.
Signed-off-by: Mingxia Liu <mingxia.liu@intel.com>
Signed-off-by: Wenjun Wu <wenjun1.wu@intel.com>
---
drivers/common/idpf/idpf_common_rxtx.c | 134 +++++++++++++++++++++++++
drivers/common/idpf/idpf_common_rxtx.h | 3 +
drivers/common/idpf/version.map | 1 +
drivers/net/idpf/idpf_ethdev.c | 3 +-
drivers/net/idpf/idpf_rxtx.c | 26 ++++-
drivers/net/idpf/idpf_rxtx.h | 2 +
6 files changed, 166 insertions(+), 3 deletions(-)
diff --git a/drivers/common/idpf/idpf_common_rxtx.c b/drivers/common/idpf/idpf_common_rxtx.c
index 7a5dc3f04c..9dbf0f4764 100644
--- a/drivers/common/idpf/idpf_common_rxtx.c
+++ b/drivers/common/idpf/idpf_common_rxtx.c
@@ -1146,6 +1146,140 @@ idpf_singleq_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
return nb_rx;
}
+uint16_t
+idpf_singleq_recv_scatter_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
+ uint16_t nb_pkts)
+{
+ struct idpf_rx_queue *rxq = rx_queue;
+ volatile union virtchnl2_rx_desc *rx_ring = rxq->rx_ring;
+ volatile union virtchnl2_rx_desc *rxdp;
+ union virtchnl2_rx_desc rxd;
+ struct idpf_adapter *ad;
+ struct rte_mbuf *first_seg = rxq->pkt_first_seg;
+ struct rte_mbuf *last_seg = rxq->pkt_last_seg;
+ struct rte_mbuf *rxm;
+ struct rte_mbuf *nmb;
+ struct rte_eth_dev *dev;
+ const uint32_t *ptype_tbl = rxq->adapter->ptype_tbl;
+ uint16_t nb_hold = 0, nb_rx = 0;
+ uint16_t rx_id = rxq->rx_tail;
+ uint16_t rx_packet_len;
+ uint16_t rx_status0;
+ uint64_t pkt_flags;
+ uint64_t dma_addr;
+ uint64_t ts_ns;
+
+ ad = rxq->adapter;
+
+ if (unlikely(!rxq) || unlikely(!rxq->q_started))
+ return nb_rx;
+
+ while (nb_rx < nb_pkts) {
+ rxdp = &rx_ring[rx_id];
+ rx_status0 = rte_le_to_cpu_16(rxdp->flex_nic_wb.status_error0);
+
+ /* Check the DD bit first */
+ if (!(rx_status0 & (1 << VIRTCHNL2_RX_FLEX_DESC_STATUS0_DD_S)))
+ break;
+
+ nmb = rte_mbuf_raw_alloc(rxq->mp);
+ if (unlikely(!nmb)) {
+ rte_atomic64_inc(&(rxq->rx_stats.mbuf_alloc_failed));
+ RX_LOG(DEBUG, "RX mbuf alloc failed port_id=%u "
+ "queue_id=%u", rxq->port_id, rxq->queue_id);
+ break;
+ }
+
+ rxd = *rxdp;
+
+ nb_hold++;
+ rxm = rxq->sw_ring[rx_id];
+ rxq->sw_ring[rx_id] = nmb;
+ rx_id++;
+ if (unlikely(rx_id == rxq->nb_rx_desc))
+ rx_id = 0;
+
+ /* Prefetch next mbuf */
+ rte_prefetch0(rxq->sw_ring[rx_id]);
+
+ /* When next RX descriptor is on a cache line boundary,
+ * prefetch the next 4 RX descriptors and next 8 pointers
+ * to mbufs.
+ */
+ if ((rx_id & 0x3) == 0) {
+ rte_prefetch0(&rx_ring[rx_id]);
+ rte_prefetch0(rxq->sw_ring[rx_id]);
+ }
+ dma_addr =
+ rte_cpu_to_le_64(rte_mbuf_data_iova_default(nmb));
+ rxdp->read.hdr_addr = 0;
+ rxdp->read.pkt_addr = dma_addr;
+ rx_packet_len = (rte_cpu_to_le_16(rxd.flex_nic_wb.pkt_len) &
+ VIRTCHNL2_RX_FLEX_DESC_PKT_LEN_M);
+ rxm->data_len = rx_packet_len;
+ rxm->data_off = RTE_PKTMBUF_HEADROOM;
+
+ /**
+ * If this is the first buffer of the received packet, set the
+ * pointer to the first mbuf of the packet and initialize its
+ * context. Otherwise, update the total length and the number
+ * of segments of the current scattered packet, and update the
+ * pointer to the last mbuf of the current packet.
+ */
+ if (!first_seg) {
+ first_seg = rxm;
+ first_seg->nb_segs = 1;
+ first_seg->pkt_len = rx_packet_len;
+ } else {
+ first_seg->pkt_len =
+ (uint16_t)(first_seg->pkt_len +
+ rx_packet_len);
+ first_seg->nb_segs++;
+ last_seg->next = rxm;
+ }
+
+ if (!(rx_status0 & (1 << VIRTCHNL2_RX_FLEX_DESC_STATUS0_EOF_S))) {
+ last_seg = rxm;
+ continue;
+ }
+
+ rxm->next = NULL;
+
+ first_seg->port = rxq->port_id;
+ first_seg->ol_flags = 0;
+ pkt_flags = idpf_rxd_to_pkt_flags(rx_status0);
+ first_seg->packet_type =
+ ptype_tbl[(uint8_t)(rte_cpu_to_le_16(rxd.flex_nic_wb.ptype_flex_flags0) &
+ VIRTCHNL2_RX_FLEX_DESC_PTYPE_M)];
+
+ if (idpf_timestamp_dynflag > 0 &&
+ (rxq->offloads & IDPF_RX_OFFLOAD_TIMESTAMP) != 0) {
+ /* timestamp */
+ ts_ns = idpf_tstamp_convert_32b_64b(ad,
+ rxq->hw_register_set,
+ rte_le_to_cpu_32(rxd.flex_nic_wb.flex_ts.ts_high));
+ rxq->hw_register_set = 0;
+ *RTE_MBUF_DYNFIELD(rxm,
+ idpf_timestamp_dynfield_offset,
+ rte_mbuf_timestamp_t *) = ts_ns;
+ first_seg->ol_flags |= idpf_timestamp_dynflag;
+ }
+
+ first_seg->ol_flags |= pkt_flags;
+ rte_prefetch0(RTE_PTR_ADD(first_seg->buf_addr,
+ first_seg->data_off));
+ rx_pkts[nb_rx++] = first_seg;
+ first_seg = NULL;
+ }
+ rxq->rx_tail = rx_id;
+ rxq->pkt_first_seg = first_seg;
+ rxq->pkt_last_seg = last_seg;
+
+ idpf_update_rx_tail(rxq, nb_hold, rx_id);
+
+ return nb_rx;
+}
+
static inline int
idpf_xmit_cleanup(struct idpf_tx_queue *txq)
{
diff --git a/drivers/common/idpf/idpf_common_rxtx.h b/drivers/common/idpf/idpf_common_rxtx.h
index 98f492a8c1..aac61ea2cb 100644
--- a/drivers/common/idpf/idpf_common_rxtx.h
+++ b/drivers/common/idpf/idpf_common_rxtx.h
@@ -260,6 +260,9 @@ __rte_internal
uint16_t idpf_splitq_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
uint16_t nb_pkts);
__rte_internal
+uint16_t idpf_singleq_recv_scatter_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
+ uint16_t nb_pkts);
+__rte_internal
uint16_t idpf_splitq_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
uint16_t nb_pkts);
__rte_internal
diff --git a/drivers/common/idpf/version.map b/drivers/common/idpf/version.map
index 36a3a90d39..591af6b046 100644
--- a/drivers/common/idpf/version.map
+++ b/drivers/common/idpf/version.map
@@ -32,6 +32,7 @@ INTERNAL {
idpf_reset_split_tx_descq;
idpf_rx_queue_release;
idpf_singleq_recv_pkts;
+ idpf_singleq_recv_scatter_pkts;
idpf_singleq_recv_pkts_avx512;
idpf_singleq_rx_vec_setup;
idpf_splitq_rx_vec_setup;
diff --git a/drivers/net/idpf/idpf_ethdev.c b/drivers/net/idpf/idpf_ethdev.c
index 037cabb04e..2ab31792ba 100644
--- a/drivers/net/idpf/idpf_ethdev.c
+++ b/drivers/net/idpf/idpf_ethdev.c
@@ -119,7 +119,8 @@ idpf_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
RTE_ETH_RX_OFFLOAD_UDP_CKSUM |
RTE_ETH_RX_OFFLOAD_TCP_CKSUM |
RTE_ETH_RX_OFFLOAD_OUTER_IPV4_CKSUM |
- RTE_ETH_RX_OFFLOAD_TIMESTAMP;
+ RTE_ETH_RX_OFFLOAD_TIMESTAMP |
+ RTE_ETH_RX_OFFLOAD_SCATTER;
dev_info->tx_offload_capa =
RTE_ETH_TX_OFFLOAD_IPV4_CKSUM |
diff --git a/drivers/net/idpf/idpf_rxtx.c b/drivers/net/idpf/idpf_rxtx.c
index 6eeaab41cc..a865d14fea 100644
--- a/drivers/net/idpf/idpf_rxtx.c
+++ b/drivers/net/idpf/idpf_rxtx.c
@@ -503,6 +503,8 @@ int
idpf_rx_queue_init(struct rte_eth_dev *dev, uint16_t rx_queue_id)
{
struct idpf_rx_queue *rxq;
+ uint16_t max_pkt_len;
+ uint32_t frame_size;
int err;
if (rx_queue_id >= dev->data->nb_rx_queues)
@@ -516,6 +518,17 @@ idpf_rx_queue_init(struct rte_eth_dev *dev, uint16_t rx_queue_id)
return -EINVAL;
}
+ frame_size = dev->data->mtu + IDPF_ETH_OVERHEAD;
+
+ max_pkt_len =
+ RTE_MIN((uint32_t)IDPF_SUPPORT_CHAIN_NUM * rxq->rx_buf_len,
+ frame_size);
+
+ rxq->max_pkt_len = max_pkt_len;
+ if ((dev->data->dev_conf.rxmode.offloads & RTE_ETH_RX_OFFLOAD_SCATTER) ||
+ frame_size > rxq->rx_buf_len)
+ dev->data->scattered_rx = 1;
+
err = idpf_register_ts_mbuf(rxq);
if (err != 0) {
PMD_DRV_LOG(ERR, "fail to regidter timestamp mbuf %u",
@@ -801,13 +814,22 @@ idpf_set_rx_function(struct rte_eth_dev *dev)
#endif /* CC_AVX512_SUPPORT */
}
+ if (dev->data->scattered_rx) {
+ dev->rx_pkt_burst = idpf_singleq_recv_scatter_pkts;
+ return;
+ }
dev->rx_pkt_burst = idpf_singleq_recv_pkts;
}
#else
- if (vport->rxq_model == VIRTCHNL2_QUEUE_MODEL_SPLIT)
+ if (vport->rxq_model == VIRTCHNL2_QUEUE_MODEL_SPLIT) {
dev->rx_pkt_burst = idpf_splitq_recv_pkts;
- else
+ } else {
+ if (dev->data->scattered_rx) {
+ dev->rx_pkt_burst = idpf_singleq_recv_scatter_pkts;
+ return;
+ }
dev->rx_pkt_burst = idpf_singleq_recv_pkts;
+ }
#endif /* RTE_ARCH_X86 */
}
diff --git a/drivers/net/idpf/idpf_rxtx.h b/drivers/net/idpf/idpf_rxtx.h
index 3a5084dfd6..41a7495083 100644
--- a/drivers/net/idpf/idpf_rxtx.h
+++ b/drivers/net/idpf/idpf_rxtx.h
@@ -23,6 +23,8 @@
#define IDPF_DEFAULT_TX_RS_THRESH 32
#define IDPF_DEFAULT_TX_FREE_THRESH 32
+#define IDPF_SUPPORT_CHAIN_NUM 5
+
int idpf_rx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
uint16_t nb_desc, unsigned int socket_id,
const struct rte_eth_rxconf *rx_conf,
--
2.25.1
next prev parent reply other threads:[~2023-01-18 8:10 UTC|newest]
Thread overview: 63+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-16 9:36 [PATCH 0/7] add idpf pmd enhancement features Mingxia Liu
2022-12-16 9:37 ` [PATCH 1/7] common/idpf: add hw statistics Mingxia Liu
2022-12-16 9:37 ` [PATCH 2/7] common/idpf: add RSS set/get ops Mingxia Liu
2022-12-16 9:37 ` [PATCH 3/7] common/idpf: support single q scatter RX datapath Mingxia Liu
2022-12-16 9:37 ` [PATCH 4/7] common/idpf: add rss_offload hash in singleq rx Mingxia Liu
2022-12-16 9:37 ` [PATCH 5/7] common/idpf: add alarm to support handle vchnl message Mingxia Liu
2022-12-16 9:37 ` [PATCH 6/7] common/idpf: add xstats ops Mingxia Liu
2022-12-16 9:37 ` [PATCH 7/7] common/idpf: update mbuf_alloc_failed multi-thread process Mingxia Liu
2023-01-11 7:15 ` [PATCH 0/6] add idpf pmd enhancement features Mingxia Liu
2023-01-11 7:15 ` [PATCH v2 1/6] common/idpf: add hw statistics Mingxia Liu
2023-01-11 7:15 ` [PATCH v2 2/6] common/idpf: add RSS set/get ops Mingxia Liu
2023-01-11 7:15 ` [PATCH v2 3/6] common/idpf: support single q scatter RX datapath Mingxia Liu
2023-01-11 7:15 ` [PATCH v2 4/6] common/idpf: add rss_offload hash in singleq rx Mingxia Liu
2023-01-11 7:15 ` [PATCH v2 5/6] common/idpf: add alarm to support handle vchnl message Mingxia Liu
2023-01-11 7:15 ` [PATCH v2 6/6] common/idpf: add xstats ops Mingxia Liu
2023-01-18 7:14 ` [PATCH v3 0/6] add idpf pmd enhancement features Mingxia Liu
2023-01-18 7:14 ` [PATCH v3 1/6] common/idpf: add hw statistics Mingxia Liu
2023-02-01 8:48 ` Wu, Jingjing
2023-02-01 12:34 ` Liu, Mingxia
2023-01-18 7:14 ` [PATCH v3 2/6] common/idpf: add RSS set/get ops Mingxia Liu
2023-02-02 3:28 ` Wu, Jingjing
2023-02-07 3:10 ` Liu, Mingxia
2023-01-18 7:14 ` Mingxia Liu [this message]
2023-02-02 3:45 ` [PATCH v3 3/6] common/idpf: support single q scatter RX datapath Wu, Jingjing
2023-02-02 7:19 ` Liu, Mingxia
2023-01-18 7:14 ` [PATCH v3 4/6] common/idpf: add rss_offload hash in singleq rx Mingxia Liu
2023-01-18 7:14 ` [PATCH v3 5/6] common/idpf: add alarm to support handle vchnl message Mingxia Liu
2023-02-02 4:23 ` Wu, Jingjing
2023-02-02 7:39 ` Liu, Mingxia
2023-02-02 8:46 ` Wu, Jingjing
2023-01-18 7:14 ` [PATCH v3 6/6] common/idpf: add xstats ops Mingxia Liu
2023-02-07 9:56 ` [PATCH v4 0/6] add idpf pmd enhancement features Mingxia Liu
2023-02-07 9:56 ` [PATCH v4 1/6] common/idpf: add hw statistics Mingxia Liu
2023-02-07 9:56 ` [PATCH v4 2/6] common/idpf: add RSS set/get ops Mingxia Liu
2023-02-07 9:56 ` [PATCH v4 3/6] common/idpf: support single q scatter RX datapath Mingxia Liu
2023-02-07 9:56 ` [PATCH v4 4/6] common/idpf: add rss_offload hash in singleq rx Mingxia Liu
2023-02-07 9:57 ` [PATCH v4 5/6] common/idpf: add alarm to support handle vchnl message Mingxia Liu
2023-02-07 9:57 ` [PATCH v4 6/6] common/idpf: add xstats ops Mingxia Liu
2023-02-07 10:08 ` [PATCH v4 0/6] add idpf pmd enhancement features Mingxia Liu
2023-02-07 10:08 ` [PATCH v5 1/6] common/idpf: add hw statistics Mingxia Liu
2023-02-07 10:16 ` [PATCH v6 0/6] add idpf pmd enhancement features Mingxia Liu
2023-02-07 10:16 ` [PATCH v6 1/6] common/idpf: add hw statistics Mingxia Liu
2023-02-08 2:00 ` Zhang, Qi Z
2023-02-08 8:28 ` Liu, Mingxia
2023-02-07 10:16 ` [PATCH v6 2/6] common/idpf: add RSS set/get ops Mingxia Liu
2023-02-07 10:16 ` [PATCH v6 3/6] common/idpf: support single q scatter RX datapath Mingxia Liu
2023-02-07 10:16 ` [PATCH v6 4/6] common/idpf: add rss_offload hash in singleq rx Mingxia Liu
2023-02-07 10:16 ` [PATCH v6 5/6] common/idpf: add alarm to support handle vchnl message Mingxia Liu
2023-02-07 10:16 ` [PATCH v6 6/6] common/idpf: add xstats ops Mingxia Liu
2023-02-08 0:28 ` [PATCH v6 0/6] add idpf pmd enhancement features Wu, Jingjing
2023-02-08 7:33 ` [PATCH v7 " Mingxia Liu
2023-02-08 7:33 ` [PATCH v7 1/6] net/idpf: add hw statistics Mingxia Liu
2023-02-08 7:33 ` [PATCH v7 2/6] net/idpf: add RSS set/get ops Mingxia Liu
2023-02-08 7:33 ` [PATCH v7 3/6] net/idpf: support single q scatter RX datapath Mingxia Liu
2023-02-08 7:33 ` [PATCH v7 4/6] net/idpf: add rss_offload hash in singleq rx Mingxia Liu
2023-02-08 7:34 ` [PATCH v7 5/6] net/idpf: add alarm to support handle vchnl message Mingxia Liu
2023-02-08 7:34 ` [PATCH v7 6/6] net/idpf: add xstats ops Mingxia Liu
2023-02-08 9:32 ` [PATCH v7 0/6] add idpf pmd enhancement features Zhang, Qi Z
2023-02-07 10:08 ` [PATCH v5 2/6] common/idpf: add RSS set/get ops Mingxia Liu
2023-02-07 10:08 ` [PATCH v5 3/6] common/idpf: support single q scatter RX datapath Mingxia Liu
2023-02-07 10:08 ` [PATCH v5 4/6] common/idpf: add rss_offload hash in singleq rx Mingxia Liu
2023-02-07 10:08 ` [PATCH v5 5/6] common/idpf: add alarm to support handle vchnl message Mingxia Liu
2023-02-07 10:08 ` [PATCH v5 6/6] common/idpf: add xstats ops Mingxia Liu
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=20230118071440.902155-4-mingxia.liu@intel.com \
--to=mingxia.liu@intel.com \
--cc=beilei.xing@intel.com \
--cc=dev@dpdk.org \
--cc=jingjing.wu@intel.com \
--cc=wenjun1.wu@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).