Skip to contentSkip to conversation

net: hibmcge: Add support for tracepoint and pagepool on hibmcge driver

PATCH Applied Jijie Shao 2 participants 5 messages Nov 22, 2025 – Nov 27, 2025

Subsystems (4)
lore
Share & tools
lore

Jijie Shao

author maintainer
#0 lore raw

v2 cover net: hibmcge: Add support for tracepoint and pagepool on hibmcge driver

In this patch set:
1: add support for tracepoint for rx descriptor 2: double the rx queue depth to reduce packet drop 3: add support for pagepool on rx

---
ChangeLog:
v1 -> v2:
- remove the legacy path after using pagepool, suggested by Jakub.
v1: https://lore.kernel.org/all/[email protected]/
---

Jijie Shao (2):
net: hibmcge: reduce packet drop under stress testing
net: hibmcge: add support for pagepool on rx

Tao Lan (1):
net: hibmcge: add support for tracepoint to dump some fields of
rx_desc

 drivers/net/ethernet/hisilicon/Kconfig        |   1 +
 .../net/ethernet/hisilicon/hibmcge/Makefile   |   1 +
 .../ethernet/hisilicon/hibmcge/hbg_common.h   |   8 +
 .../net/ethernet/hisilicon/hibmcge/hbg_reg.h  |   4 +
 .../ethernet/hisilicon/hibmcge/hbg_trace.h    |  84 +++++++
 .../net/ethernet/hisilicon/hibmcge/hbg_txrx.c | 217 ++++++++++++++----
 6 files changed, 272 insertions(+), 43 deletions(-)
 create mode 100644 drivers/net/ethernet/hisilicon/hibmcge/hbg_trace.h
Signature · 1 line
2.33.0
author maintainer
#1 lore raw

PATCH v2 1/3 net: hibmcge: add support for tracepoint to dump some fields of rx_desc

From: Tao Lan <[email protected]>

add support for tracepoint to dump some fields of rx_desc

---
 .../net/ethernet/hisilicon/hibmcge/Makefile   |  1 +
 .../net/ethernet/hisilicon/hibmcge/hbg_reg.h  |  4 +
 .../ethernet/hisilicon/hibmcge/hbg_trace.h    | 84 +++++++++++++++++++
 .../net/ethernet/hisilicon/hibmcge/hbg_txrx.c |  4 +
 4 files changed, 93 insertions(+)
 create mode 100644 drivers/net/ethernet/hisilicon/hibmcge/hbg_trace.h
drivers/net/ethernet/hisilicon/hibmcge/Makefile +1 -0
index 1a9da564b306..d6610ba16855 100644
@@ -3,6 +3,7 @@
 # Makefile for the HISILICON BMC GE network device drivers.
 #
 
+ccflags-y += -I$(src)
 obj-$(CONFIG_HIBMCGE) += hibmcge.o
 
 hibmcge-objs = hbg_main.o hbg_hw.o hbg_mdio.o hbg_irq.o hbg_txrx.o hbg_ethtool.o \
drivers/net/ethernet/hisilicon/hibmcge/hbg_reg.h +4 -0
index a39d1e796e4a..30b3903c8f2d 100644
@@ -252,6 +252,8 @@ struct hbg_rx_desc {
 
 #define HBG_RX_DESC_W2_PKT_LEN_M	GENMASK(31, 16)
 #define HBG_RX_DESC_W2_PORT_NUM_M	GENMASK(15, 12)
+#define HBG_RX_DESC_W3_IP_OFFSET_M	GENMASK(23, 16)
+#define HBG_RX_DESC_W3_VLAN_M		GENMASK(15, 0)
 #define HBG_RX_DESC_W4_IP_TCP_UDP_M	GENMASK(31, 30)
 #define HBG_RX_DESC_W4_IPSEC_B		BIT(29)
 #define HBG_RX_DESC_W4_IP_VERSION_B	BIT(28)
@@ -269,6 +271,8 @@ struct hbg_rx_desc {
 #define HBG_RX_DESC_W4_L3_ERR_CODE_M	GENMASK(12, 9)
 #define HBG_RX_DESC_W4_L2_ERR_B		BIT(8)
 #define HBG_RX_DESC_W4_IDX_MATCH_B	BIT(7)
+#define HBG_RX_DESC_W4_PARSE_MODE_M	GENMASK(6, 5)
+#define HBG_RX_DESC_W5_VALID_SIZE_M	GENMASK(15, 0)
 
 enum hbg_l3_err_code {
 	HBG_L3_OK = 0,
drivers/net/ethernet/hisilicon/hibmcge/hbg_trace.h new file +84 -0

84 lines not on this page · raw message

drivers/net/ethernet/hisilicon/hibmcge/hbg_txrx.c +4 -0
index 8d814c8f19ea..5f2e48f1dd25 100644
@@ -7,6 +7,9 @@
 #include "hbg_reg.h"
 #include "hbg_txrx.h"
 
+#define CREATE_TRACE_POINTS
+#include "hbg_trace.h"
+
 #define netdev_get_tx_ring(netdev) \
 			(&(((struct hbg_priv *)netdev_priv(netdev))->tx_ring))
 
@@ -429,6 +432,7 @@ static int hbg_napi_rx_poll(struct napi_struct *napi, int budget)
 			break;
 		rx_desc = (struct hbg_rx_desc *)buffer->skb->data;
 		pkt_len = FIELD_GET(HBG_RX_DESC_W2_PKT_LEN_M, rx_desc->word2);
+		trace_hbg_rx_desc(priv, ring->ntc, rx_desc);
 
 		if (unlikely(!hbg_rx_pkt_check(priv, rx_desc, buffer->skb))) {
 			hbg_buffer_free(buffer);
Signature · 1 line
2.33.0
author maintainer
#2 lore raw

PATCH v2 2/3 net: hibmcge: reduce packet drop under stress testing

In reply to Jijie Shao

Under stress test scenarios, hibmcge driver may not receive packets in a timely manner, which can lead to the buffer of the hardware queue being exhausted, resulting in packet drop.

This patch doubles the software queue depth and uses half of the buffer to fill the hardware queue before receiving packets, thus preventing packet loss caused by the hardware queue buffer being exhausted.

---
 .../net/ethernet/hisilicon/hibmcge/hbg_txrx.c | 47 +++++++++++++++----
 1 file changed, 37 insertions(+), 10 deletions(-)
drivers/net/ethernet/hisilicon/hibmcge/hbg_txrx.c +37 -10
index 5f2e48f1dd25..ea691d564161 100644
@@ -377,7 +377,8 @@ static int hbg_rx_fill_one_buffer(struct hbg_priv *priv)
 	struct hbg_buffer *buffer;
 	int ret;
 
-	if (hbg_queue_is_full(ring->ntc, ring->ntu, ring))
+	if (hbg_queue_is_full(ring->ntc, ring->ntu, ring) ||
+	    hbg_fifo_is_full(priv, ring->dir))
 		return 0;
 
 	buffer = &ring->queue[ring->ntu];
@@ -396,6 +397,26 @@ static int hbg_rx_fill_one_buffer(struct hbg_priv *priv)
 	return 0;
 }
 
+static int hbg_rx_fill_buffers(struct hbg_priv *priv)
+{
+	u32 remained = hbg_hw_get_fifo_used_num(priv, HBG_DIR_RX);
+	u32 max_count = priv->dev_specs.rx_fifo_num;
+	u32 refill_count;
+	int ret;
+
+	if (unlikely(remained >= max_count))
+		return 0;
+
+	refill_count = max_count - remained;
+	while (refill_count--) {
+		ret = hbg_rx_fill_one_buffer(priv);
+		if (unlikely(ret))
+			break;
+	}
+
+	return ret;
+}
+
 static bool hbg_sync_data_from_hw(struct hbg_priv *priv,
 				  struct hbg_buffer *buffer)
 {
@@ -420,6 +441,7 @@ static int hbg_napi_rx_poll(struct napi_struct *napi, int budget)
 	u32 packet_done = 0;
 	u32 pkt_len;
 
+	hbg_rx_fill_buffers(priv);
 	while (packet_done < budget) {
 		if (unlikely(hbg_queue_is_empty(ring->ntc, ring->ntu, ring)))
 			break;
@@ -497,6 +519,16 @@ static int hbg_ring_init(struct hbg_priv *priv, struct hbg_ring *ring,
 	u32 i, len;
 
 	len = hbg_get_spec_fifo_max_num(priv, dir) + 1;
+	/* To improve receiving performance under high-stress scenarios,
+	 * in the `hbg_napi_rx_poll()`, we first use the other half of
+	 * the buffer to receive packets from the hardware via the
+	 * `hbg_rx_fill_buffers()`, and then process the packets in the
+	 * original half of the buffer to avoid packet loss caused by
+	 * hardware overflow as much as possible.
+	 */
+	if (dir == HBG_DIR_RX)
+		len += hbg_get_spec_fifo_max_num(priv, dir);
+
 	ring->queue = dma_alloc_coherent(&priv->pdev->dev,
 					 len * sizeof(*ring->queue),
 					 &ring->queue_dma, GFP_KERNEL);
@@ -545,21 +577,16 @@ static int hbg_tx_ring_init(struct hbg_priv *priv)
 static int hbg_rx_ring_init(struct hbg_priv *priv)
 {
 	int ret;
-	u32 i;
 
 	ret = hbg_ring_init(priv, &priv->rx_ring, hbg_napi_rx_poll, HBG_DIR_RX);
 	if (ret)
 		return ret;
 
-	for (i = 0; i < priv->rx_ring.len - 1; i++) {
-		ret = hbg_rx_fill_one_buffer(priv);
-		if (ret) {
-			hbg_ring_uninit(&priv->rx_ring);
-			return ret;
-		}
-	}
+	ret = hbg_rx_fill_buffers(priv);
+	if (ret)
+		hbg_ring_uninit(&priv->rx_ring);
 
-	return 0;
+	return ret;
 }
 
 int hbg_txrx_init(struct hbg_priv *priv)
Signature · 1 line
2.33.0
author maintainer
#3 lore raw

PATCH v2 3/3 net: hibmcge: add support for pagepool on rx

In reply to Jijie Shao

add support for pagepool on rx, and remove the legacy path

---
ChangeLog:
v1 -> v2:
- remove the legacy path after using pagepool, suggested by Jakub.
v1: https://lore.kernel.org/all/[email protected]/

---
 drivers/net/ethernet/hisilicon/Kconfig        |   1 +
 .../ethernet/hisilicon/hibmcge/hbg_common.h   |   8 +
 .../net/ethernet/hisilicon/hibmcge/hbg_txrx.c | 166 ++++++++++++++----
 3 files changed, 142 insertions(+), 33 deletions(-)
drivers/net/ethernet/hisilicon/Kconfig +1 -0
index 38875c196cb6..18eca7d12c20 100644
@@ -151,6 +151,7 @@ config HIBMCGE
 	select FIXED_PHY
 	select MOTORCOMM_PHY
 	select REALTEK_PHY
+	select PAGE_POOL
 	help
 	  If you wish to compile a kernel for a BMC with HIBMC-xx_gmac
 	  then you should answer Y to this. This makes this driver suitable for use
drivers/net/ethernet/hisilicon/hibmcge/hbg_common.h +8 -0
index 2097e4c2b3d7..8e134da3e217 100644
@@ -7,6 +7,7 @@
 #include <linux/ethtool.h>
 #include <linux/netdevice.h>
 #include <linux/pci.h>
+#include <net/page_pool/helpers.h>
 #include "hbg_reg.h"
 
 #define HBG_STATUS_DISABLE		0x0
@@ -55,6 +56,12 @@ struct hbg_buffer {
 	dma_addr_t skb_dma;
 	u32 skb_len;
 
+	struct page *page;
+	void *page_addr;
+	dma_addr_t page_dma;
+	u32 page_size;
+	u32 page_offset;
+
 	enum hbg_dir dir;
 	struct hbg_ring *ring;
 	struct hbg_priv *priv;
@@ -78,6 +85,7 @@ struct hbg_ring {
 	struct hbg_priv *priv;
 	struct napi_struct napi;
 	char *tout_log_buf; /* tx timeout log buffer */
+	struct page_pool *page_pool; /* only for rx */
 };
 
 enum hbg_hw_event_type {
drivers/net/ethernet/hisilicon/hibmcge/hbg_txrx.c +133 -33

257 lines not on this page · raw message

Signature · 1 line
2.33.0
#4 lore raw
In reply to Jijie Shao
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Quoted 5 lines · On Sat, 22 Nov 2025 11:46:54 +0800 you wrote:

In this patch set:
1: add support for tracepoint for rx descriptor 2: double the rx queue depth to reduce packet drop 3: add support for pagepool on rx

Quoted 7 lines

---
ChangeLog:
v1 -> v2:
- remove the legacy path after using pagepool, suggested by Jakub.
v1: https://lore.kernel.org/all/[email protected]/

[...]

Here is the summary with links:
- [V2,net-next,1/3] net: hibmcge: add support for tracepoint to dump some fields of rx_desc

    https://git.kernel.org/netdev/net-next/c/91f3305b97fc
  - [V2,net-next,2/3] net: hibmcge: reduce packet drop under stress testing
    https://git.kernel.org/netdev/net-next/c/2e68bb2e0f77
  - [V2,net-next,3/3] net: hibmcge: add support for pagepool on rx
    https://git.kernel.org/netdev/net-next/c/c30595917585

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html