DPDK patches and discussions
 help / color / mirror / Atom feed
From: "Renyong Wan" <wanry@yunsilicon.com>
To: <dev@dpdk.org>
Cc: <thomas@monjalon.net>, <stephen@networkplumber.org>,
	 <qianr@yunsilicon.com>, <nana@yunsilicon.com>,
	<zhangxx@yunsilicon.com>,  <xudw@yunsilicon.com>,
	<jacky@yunsilicon.com>, <weihg@yunsilicon.com>,
	 <zhenghy@yunsilicon.com>
Subject: [PATCH 10/14] net/xsc: optimize Rx path
Date: Fri, 29 Aug 2025 16:24:28 +0800	[thread overview]
Message-ID: <20250829082427.24369-11-wanry@yunsilicon.com> (raw)
In-Reply-To: <20250829082406.24369-1-wanry@yunsilicon.com>

CQEs are not cache line aligned, which can cause cache conflicts when
polling Rx CQs under high-PPS load.

This patch checks CQ producer/consumer indices before processing packets,
reducing cache conflicts. The added MMIO read overhead is minor
compared to the latency caused by cache conflicts, improving observed
small-packet performance.

Signed-off-by: Rong Qian <qianr@yunsilicon.com>
Signed-off-by: Renyong Wan <wanry@yunsilicon.com>
---
 drivers/net/xsc/xsc_defs.h |  2 ++
 drivers/net/xsc/xsc_rx.c   | 18 ++++++++++++++++--
 drivers/net/xsc/xsc_rx.h   |  1 +
 drivers/net/xsc/xsc_vfio.c |  2 +-
 4 files changed, 20 insertions(+), 3 deletions(-)

diff --git a/drivers/net/xsc/xsc_defs.h b/drivers/net/xsc/xsc_defs.h
index 4b95a0521d..73941901e7 100644
--- a/drivers/net/xsc/xsc_defs.h
+++ b/drivers/net/xsc/xsc_defs.h
@@ -46,10 +46,12 @@
 #define XSC_PF_TX_DB_ADDR		0x4802000
 #define XSC_PF_RX_DB_ADDR		0x4804000
 #define XSC_PF_CQ_DB_ADDR		0x2120000
+#define XSC_PF_CQ_PID_START_ADDR	0x2080000
 
 #define XSC_VF_RX_DB_ADDR		0x8d4
 #define XSC_VF_TX_DB_ADDR		0x8d0
 #define XSC_VF_CQ_DB_ADDR		0x8c4
+#define XSC_VF_CQ_PID_START_ADDR	0x60000
 
 #define XSC_HIF_CMDQM_VECTOR_ID_MEM_ADDR	0x1034000
 
diff --git a/drivers/net/xsc/xsc_rx.c b/drivers/net/xsc/xsc_rx.c
index 332ceb9606..5f8003a1f6 100644
--- a/drivers/net/xsc/xsc_rx.c
+++ b/drivers/net/xsc/xsc_rx.c
@@ -83,6 +83,16 @@ xsc_rx_burst(void *dpdk_rxq, struct rte_mbuf **pkts, uint16_t pkts_n)
 	int cqe_msg_len = 0;
 	volatile struct xsc_cqe_u64 *cqe_u64 = NULL;
 	struct rte_mbuf *rep;
+	uint16_t cq_pi;
+	uint16_t cqe_pkts_n = 0;
+
+	if (rxq->cq_pi != NULL) {
+		cq_pi = (*(volatile uint32_t *)(rxq->cq_pi)) & 0xFFFF;
+		if (cq_pi == rxq->cq_ci)
+			return 0;
+		cqe_pkts_n = (uint16_t)((cq_pi - rxq->cq_ci) & 0xFFFF);
+		pkts_n = pkts_n < cqe_pkts_n ? pkts_n : cqe_pkts_n;
+	}
 
 	while (pkts_n) {
 		uint32_t idx = rq_ci & wqe_m;
@@ -463,12 +473,16 @@ xsc_rss_qp_create(struct xsc_ethdev_priv *priv, int port_id)
 		}
 
 		rxq_data->wqes = rxq_data->rq_pas->addr;
-		if (!xsc_dev_is_vf(xdev))
+		if (!xsc_dev_is_vf(xdev)) {
 			rxq_data->rq_db = (uint32_t *)((uint8_t *)xdev->bar_addr +
 					  XSC_PF_RX_DB_ADDR);
-		else
+			rxq_data->cq_pi = (uint32_t *)((uint8_t *)xdev->bar_addr +
+					  XSC_PF_CQ_PID_START_ADDR + rxq_data->cqn * 4);
+		} else {
 			rxq_data->rq_db = (uint32_t *)((uint8_t *)xdev->bar_addr +
 					  XSC_VF_RX_DB_ADDR);
+			rxq_data->cq_pi = NULL;
+		}
 
 		rxq_data->qpn = rqn_base + i;
 		xsc_dev_modify_qp_status(xdev, rxq_data->qpn, 1, XSC_CMD_OP_RTR2RTS_QP);
diff --git a/drivers/net/xsc/xsc_rx.h b/drivers/net/xsc/xsc_rx.h
index 90fbb89197..59cbbb5141 100644
--- a/drivers/net/xsc/xsc_rx.h
+++ b/drivers/net/xsc/xsc_rx.h
@@ -31,6 +31,7 @@ struct __rte_cache_aligned xsc_rxq_data {
 	uint16_t rsv0:4;
 	volatile uint32_t *rq_db;
 	volatile uint32_t *cq_db;
+	volatile uint32_t *cq_pi;
 	uint32_t rq_ci;
 	uint32_t rq_pi;
 	uint16_t cq_ci;
diff --git a/drivers/net/xsc/xsc_vfio.c b/drivers/net/xsc/xsc_vfio.c
index 1650a3ab2b..c233728c5f 100644
--- a/drivers/net/xsc/xsc_vfio.c
+++ b/drivers/net/xsc/xsc_vfio.c
@@ -562,7 +562,7 @@ xsc_vfio_rx_cq_create(struct xsc_dev *xdev, struct xsc_rx_cq_params *cq_params,
 		PMD_DRV_LOG(WARNING, "Port %u rxq %u: cq numa_node=%u, device numa_node=%u",
 			    port_id, idx, cq_params->socket_id, numa_node);
 
-	cqe_n = cq_params->wqe_s;
+	cqe_n = cq_params->wqe_s * 2;
 	log_cq_sz = rte_log2_u32(cqe_n);
 	cqe_total_sz = cqe_n * sizeof(struct xsc_cqe);
 	pa_num = (cqe_total_sz + XSC_PAGE_SIZE - 1) / XSC_PAGE_SIZE;
-- 
2.25.1

  parent reply	other threads:[~2025-08-29  8:25 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-29  8:24 [PATCH 00/14] net/xsc: PMD updates Renyong Wan
2025-08-29  8:24 ` [PATCH 01/14] net/xsc: add FW version get support Renyong Wan
2025-08-29  8:24 ` [PATCH 02/14] net/xsc: add TSO support Renyong Wan
2025-08-29  8:24 ` [PATCH 03/14] net/xsc: support module EEPROM dump Renyong Wan
2025-08-29  8:24 ` [PATCH 04/14] net/xsc: support promiscuous mode Renyong Wan
2025-08-29  8:24 ` [PATCH 05/14] net/xsc: add link status support Renyong Wan
2025-08-29  8:24 ` [PATCH 06/14] net/xsc: add link status event support Renyong Wan
2025-08-29  8:24 ` [PATCH 07/14] net/xsc: add FEC get and set support Renyong Wan
2025-08-29  8:24 ` [PATCH 08/14] net/xsc: optimize RSS queue creation Renyong Wan
2025-08-29  8:24 ` [PATCH 09/14] net/xsc: optimize QP and CQ memory allocation Renyong Wan
2025-08-29  8:24 ` Renyong Wan [this message]
2025-08-29  8:24 ` [PATCH 11/14] net/xsc: optimize stop and close Renyong Wan
2025-08-29  8:24 ` [PATCH 12/14] net/xsc: support per port for multi-process Renyong Wan
2025-08-29  8:24 ` [PATCH 13/14] net/xsc: fix uninitialized value Renyong Wan
2025-08-29  8:24 ` [PATCH 14/14] net/xsc: update release notes for xsc PMD Renyong Wan

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=20250829082427.24369-11-wanry@yunsilicon.com \
    --to=wanry@yunsilicon.com \
    --cc=dev@dpdk.org \
    --cc=jacky@yunsilicon.com \
    --cc=nana@yunsilicon.com \
    --cc=qianr@yunsilicon.com \
    --cc=stephen@networkplumber.org \
    --cc=thomas@monjalon.net \
    --cc=weihg@yunsilicon.com \
    --cc=xudw@yunsilicon.com \
    --cc=zhangxx@yunsilicon.com \
    --cc=zhenghy@yunsilicon.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).