Skip to contentSkip to conversation

net/mlx5e: Add support for devmem and io_uring TCP zero-copy

PATCH Superseded Mark Bloch 5 participants 20 messages Jun 9, 2025 – Jun 12, 2025

Subsystems (6)

v3 of 6 Superseded Latest is v6 →

lore
Share & tools
lore

Mark Bloch

author maintainer
#0 lore raw

v3 cover net/mlx5e: Add support for devmem and io_uring TCP zero-copy

Quick note before diving into the series details, Tariq is on vacation for a few days, I’ll be handling the mlx5 core/netdev submissions in his absence.

This series adds support for zerocopy rx TCP with devmem and io_uring for ConnectX7 NICs and above. For performance reasons and simplicity HW-GRO will also be turned on when header-data split mode is on.

Performance
===========

Test setup:

* CPU: Intel(R) Xeon(R) Platinum 8380 CPU @ 2.30GHz (single NUMA)
* NIC: ConnectX7
* Benchmarking tool: kperf [0]
* Single TCP flow
* Test duration: 60s

With application thread and interrupts pinned to the *same* core:

|------+-----------+----------|
| MTU  | epoll     | io_uring |
|------+-----------+----------|
| 1500 | 61.6 Gbps | 114 Gbps |
| 4096 | 69.3 Gbps | 151 Gbps |
| 9000 | 67.8 Gbps | 187 Gbps |
|------+-----------+----------|

The CPU usage for io_uring is 95%.

Reproduction steps for io_uring:

server --no-daemon -a 2001:db8::1 --no-memcmp --iou --iou_sendzc \
	--iou_zcrx --iou_dev_name eth2 --iou_zcrx_queue_id 2

server --no-daemon -a 2001:db8::2 --no-memcmp --iou --iou_sendzc

client --src 2001:db8::2 --dst 2001:db8::1 \
	--msg-zerocopy -t 60 --cpu-min=2 --cpu-max=2

Patch overview:
================

First, a netmem API for skb_can_coalesce is added to the core to be able to do skb fragment coalescing on netmems.

The next patches introduce some cleanups in the internal SHAMPO code and improvements to hw gro capability checks in FW.

A separate page_pool is introduced for headers, to be used only when the rxq has a memory provider. Ethtool stats are added as well.

Then the driver is converted to use the netmem API and to allow support for unreadable netmem page pool.

The queue management ops are implemented.

Finally, the tcp-data-split ring parameter is exposed.

Changelog
=========

Changes from v2 [2]:
- Added support for netmem TX.
- Changed skb_can_coalesce_netmem() based on Mina's suggestion.
- Reworked tcp_data_split setting to no longer change HW-GRO in wanted_features.
- Switched to a single page pool when rxq has no memory providers.

Changes from v1 [1]:
- Added support for skb_can_coalesce_netmem().
- Avoid netmem_to_page() casts in the driver.
- Fixed code to abide 80 char limit with some exceptions to avoid code churn.

References
==========
[0] kperf: git://git.kernel.dk/kperf.git
[1] v1: https://lore.kernel.org/all/[email protected]/
[2] v2: https://lore.kernel.org/all/[email protected]/

Dragos Tatulea (3):
net: Allow const args for of page_to_netmem()
net: Add skb_can_coalesce for netmem
net/mlx5e: Add TX support for netmems

Saeed Mahameed (9):
net/mlx5e: SHAMPO: Reorganize mlx5_rq_shampo_alloc net/mlx5e: SHAMPO: Remove redundant params net/mlx5e: SHAMPO: Improve hw gro capability checking net/mlx5e: SHAMPO: Separate pool for headers net/mlx5e: SHAMPO: Headers page pool stats net/mlx5e: Convert over to netmem
net/mlx5e: Add support for UNREADABLE netmem page pools net/mlx5e: Implement queue mgmt ops and single channel swap net/mlx5e: Support ethtool tcp-data-split settings

 drivers/net/ethernet/mellanox/mlx5/core/en.h  |  11 +-
 .../ethernet/mellanox/mlx5/core/en/params.c   |  36 ++-
 .../net/ethernet/mellanox/mlx5/core/en/txrx.h |   3 +-
 .../ethernet/mellanox/mlx5/core/en_ethtool.c  |  33 +-
 .../net/ethernet/mellanox/mlx5/core/en_main.c | 305 +++++++++++++-----
 .../net/ethernet/mellanox/mlx5/core/en_rx.c   | 136 ++++----
 .../ethernet/mellanox/mlx5/core/en_stats.c    |  54 ++++
 .../ethernet/mellanox/mlx5/core/en_stats.h    |  24 ++
 include/linux/skbuff.h                        |  12 +-
 include/net/netmem.h                          |   2 +-
 10 files changed, 449 insertions(+), 167 deletions(-)

base-commit: 2c7e4a2663a1ab5a740c59c31991579b6b865a26

Signature · 1 line
2.34.1
author maintainer
#1 lore raw

PATCH v3 1/12 net: Allow const args for of page_to_netmem()

From: Dragos Tatulea <[email protected]>

This allows calling page_to_netmem() with a const page * argument.

---
 include/net/netmem.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/net/netmem.h +1 -1
index 386164fb9c18..caf2e773c915 100644
@@ -143,7 +143,7 @@ static inline netmem_ref net_iov_to_netmem(struct net_iov *niov)
 	return (__force netmem_ref)((unsigned long)niov | NET_IOV);
 }
 
-static inline netmem_ref page_to_netmem(struct page *page)
+static inline netmem_ref page_to_netmem(const struct page *page)
 {
 	return (__force netmem_ref)page;
 }
Signature · 1 line
2.34.1
author maintainer
#2 lore raw

PATCH v3 2/12 net: Add skb_can_coalesce for netmem

In reply to Mark Bloch

From: Dragos Tatulea <[email protected]>

Allow drivers that have moved over to netmem to do fragment coalescing.

---
 include/linux/skbuff.h | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
include/linux/skbuff.h +9 -3
index 5520524c93bf..9508968cb300 100644
@@ -3873,20 +3873,26 @@ static inline int __must_check skb_put_padto(struct sk_buff *skb, unsigned int l
 bool csum_and_copy_from_iter_full(void *addr, size_t bytes, __wsum *csum, struct iov_iter *i)
 	__must_check;
 
-static inline bool skb_can_coalesce(struct sk_buff *skb, int i,
-				    const struct page *page, int off)
+static inline bool skb_can_coalesce_netmem(struct sk_buff *skb, int i,
+					   netmem_ref netmem, int off)
 {
 	if (skb_zcopy(skb))
 		return false;
 	if (i) {
 		const skb_frag_t *frag = &skb_shinfo(skb)->frags[i - 1];
 
-		return page == skb_frag_page(frag) &&
+		return netmem == skb_frag_netmem(frag) &&
 		       off == skb_frag_off(frag) + skb_frag_size(frag);
 	}
 	return false;
 }
 
+static inline bool skb_can_coalesce(struct sk_buff *skb, int i,
+				    const struct page *page, int off)
+{
+	return skb_can_coalesce_netmem(skb, i, page_to_netmem(page), off);
+}
+
 static inline int __skb_linearize(struct sk_buff *skb)
 {
 	return __pskb_pull_tail(skb, skb->data_len) ? 0 : -ENOMEM;
Signature · 1 line
2.34.1
author maintainer
#3 lore raw

PATCH v3 3/12 net/mlx5e: SHAMPO: Reorganize mlx5_rq_shampo_alloc

In reply to Mark Bloch

From: Saeed Mahameed <[email protected]>

Drop redundant SHAMPO structure alloc/free functions.

Gather together function calls pertaining to header split info, pass header per WQE (hd_per_wqe) as parameter to those function to avoid use before initialization future mistakes.

Allocate HW GRO related info outside of the header related info scope.

---
 drivers/net/ethernet/mellanox/mlx5/core/en.h  |   1 -
 .../net/ethernet/mellanox/mlx5/core/en_main.c | 135 +++++++++---------
 2 files changed, 66 insertions(+), 70 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en.h +0 -1
index 5b0d03b3efe8..211ea429ea89 100644
@@ -638,7 +638,6 @@ struct mlx5e_shampo_hd {
 	struct mlx5e_frag_page *pages;
 	u32 hd_per_wq;
 	u16 hd_per_wqe;
-	u16 pages_per_wq;
 	unsigned long *bitmap;
 	u16 pi;
 	u16 ci;
drivers/net/ethernet/mellanox/mlx5/core/en_main.c +66 -69

187 lines not on this page · raw message

Signature · 1 line
2.34.1
author maintainer
#4 lore raw

PATCH v3 4/12 net/mlx5e: SHAMPO: Remove redundant params

In reply to Mark Bloch

From: Saeed Mahameed <[email protected]>

Two SHAMPO params are static and always the same, remove them from the global mlx5e_params struct.

---
 drivers/net/ethernet/mellanox/mlx5/core/en.h  |  4 ---
 .../ethernet/mellanox/mlx5/core/en/params.c   | 36 ++++++++++---------
 .../net/ethernet/mellanox/mlx5/core/en_main.c |  4 ---
 3 files changed, 20 insertions(+), 24 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en.h +0 -4
index 211ea429ea89..581eef34f512 100644
@@ -278,10 +278,6 @@ enum packet_merge {
 struct mlx5e_packet_merge_param {
 	enum packet_merge type;
 	u32 timeout;
-	struct {
-		u8 match_criteria_type;
-		u8 alignment_granularity;
-	} shampo;
 };
 
 struct mlx5e_params {
drivers/net/ethernet/mellanox/mlx5/core/en/params.c +20 -16
index 58ec5e44aa7a..fc945bce933a 100644
@@ -901,6 +901,7 @@ int mlx5e_build_rq_param(struct mlx5_core_dev *mdev,
 {
 	void *rqc = param->rqc;
 	void *wq = MLX5_ADDR_OF(rqc, rqc, wq);
+	u32 lro_timeout;
 	int ndsegs = 1;
 	int err;
 
@@ -926,22 +927,25 @@ int mlx5e_build_rq_param(struct mlx5_core_dev *mdev,
 		MLX5_SET(wq, wq, log_wqe_stride_size,
 			 log_wqe_stride_size - MLX5_MPWQE_LOG_STRIDE_SZ_BASE);
 		MLX5_SET(wq, wq, log_wq_sz, mlx5e_mpwqe_get_log_rq_size(mdev, params, xsk));
-		if (params->packet_merge.type == MLX5E_PACKET_MERGE_SHAMPO) {
-			MLX5_SET(wq, wq, shampo_enable, true);
-			MLX5_SET(wq, wq, log_reservation_size,
-				 mlx5e_shampo_get_log_rsrv_size(mdev, params));
-			MLX5_SET(wq, wq,
-				 log_max_num_of_packets_per_reservation,
-				 mlx5e_shampo_get_log_pkt_per_rsrv(mdev, params));
-			MLX5_SET(wq, wq, log_headers_entry_size,
-				 mlx5e_shampo_get_log_hd_entry_size(mdev, params));
-			MLX5_SET(rqc, rqc, reservation_timeout,
-				 mlx5e_choose_lro_timeout(mdev, MLX5E_DEFAULT_SHAMPO_TIMEOUT));
-			MLX5_SET(rqc, rqc, shampo_match_criteria_type,
-				 params->packet_merge.shampo.match_criteria_type);
-			MLX5_SET(rqc, rqc, shampo_no_match_alignment_granularity,
-				 params->packet_merge.shampo.alignment_granularity);
-		}
+		if (params->packet_merge.type != MLX5E_PACKET_MERGE_SHAMPO)
+			break;
+
+		MLX5_SET(wq, wq, shampo_enable, true);
+		MLX5_SET(wq, wq, log_reservation_size,
+			 mlx5e_shampo_get_log_rsrv_size(mdev, params));
+		MLX5_SET(wq, wq,
+			 log_max_num_of_packets_per_reservation,
+			 mlx5e_shampo_get_log_pkt_per_rsrv(mdev, params));
+		MLX5_SET(wq, wq, log_headers_entry_size,
+			 mlx5e_shampo_get_log_hd_entry_size(mdev, params));
+		lro_timeout =
+			mlx5e_choose_lro_timeout(mdev,
+						 MLX5E_DEFAULT_SHAMPO_TIMEOUT);
+		MLX5_SET(rqc, rqc, reservation_timeout, lro_timeout);
+		MLX5_SET(rqc, rqc, shampo_match_criteria_type,
+			 MLX5_RQC_SHAMPO_MATCH_CRITERIA_TYPE_EXTENDED);
+		MLX5_SET(rqc, rqc, shampo_no_match_alignment_granularity,
+			 MLX5_RQC_SHAMPO_NO_MATCH_ALIGNMENT_GRANULARITY_STRIDE);
 		break;
 	}
 	default: /* MLX5_WQ_TYPE_CYCLIC */
drivers/net/ethernet/mellanox/mlx5/core/en_main.c +0 -4
index 3d11c9f87171..e1e44533b744 100644
@@ -4040,10 +4040,6 @@ static int set_feature_hw_gro(struct net_device *netdev, bool enable)
 
 	if (enable) {
 		new_params.packet_merge.type = MLX5E_PACKET_MERGE_SHAMPO;
-		new_params.packet_merge.shampo.match_criteria_type =
-			MLX5_RQC_SHAMPO_MATCH_CRITERIA_TYPE_EXTENDED;
-		new_params.packet_merge.shampo.alignment_granularity =
-			MLX5_RQC_SHAMPO_NO_MATCH_ALIGNMENT_GRANULARITY_STRIDE;
 	} else if (new_params.packet_merge.type == MLX5E_PACKET_MERGE_SHAMPO) {
 		new_params.packet_merge.type = MLX5E_PACKET_MERGE_NONE;
 	} else {
Signature · 1 line
2.34.1
author maintainer
#5 lore raw

PATCH v3 5/12 net/mlx5e: SHAMPO: Improve hw gro capability checking

In reply to Mark Bloch

From: Saeed Mahameed <[email protected]>

Add missing HW capabilities, declare the feature in netdev->vlan_features, similar to other features in mlx5e_build_nic_netdev. No functional change here as all by default disabled features are explicitly disabled at the bottom of the function.

---
 drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en_main.c +7 -6
index e1e44533b744..a81d354af7c8 100644
@@ -78,7 +78,8 @@
 
 static bool mlx5e_hw_gro_supported(struct mlx5_core_dev *mdev)
 {
-	if (!MLX5_CAP_GEN(mdev, shampo))
+	if (!MLX5_CAP_GEN(mdev, shampo) ||
+	    !MLX5_CAP_SHAMPO(mdev, shampo_header_split_data_merge))
 		return false;
 
 	/* Our HW-GRO implementation relies on "KSM Mkey" for
@@ -5499,17 +5500,17 @@ static void mlx5e_build_nic_netdev(struct net_device *netdev)
 						   MLX5E_MPWRQ_UMR_MODE_ALIGNED))
 		netdev->vlan_features    |= NETIF_F_LRO;
 
+	if (mlx5e_hw_gro_supported(mdev) &&
+	    mlx5e_check_fragmented_striding_rq_cap(mdev, PAGE_SHIFT,
+						   MLX5E_MPWRQ_UMR_MODE_ALIGNED))
+		netdev->vlan_features |= NETIF_F_GRO_HW;
+
 	netdev->hw_features       = netdev->vlan_features;
 	netdev->hw_features      |= NETIF_F_HW_VLAN_CTAG_TX;
 	netdev->hw_features      |= NETIF_F_HW_VLAN_CTAG_RX;
 	netdev->hw_features      |= NETIF_F_HW_VLAN_CTAG_FILTER;
 	netdev->hw_features      |= NETIF_F_HW_VLAN_STAG_TX;
 
-	if (mlx5e_hw_gro_supported(mdev) &&
-	    mlx5e_check_fragmented_striding_rq_cap(mdev, PAGE_SHIFT,
-						   MLX5E_MPWRQ_UMR_MODE_ALIGNED))
-		netdev->hw_features    |= NETIF_F_GRO_HW;
-
 	if (mlx5e_tunnel_any_tx_proto_supported(mdev)) {
 		netdev->hw_enc_features |= NETIF_F_HW_CSUM;
 		netdev->hw_enc_features |= NETIF_F_TSO;
Signature · 1 line
2.34.1
author maintainer
#6 lore raw

PATCH v3 6/12 net/mlx5e: SHAMPO: Separate pool for headers

In reply to Mark Bloch

From: Saeed Mahameed <[email protected]>

Allow allocating a separate page pool for headers when SHAMPO is on. This will be useful for adding support to zc page pool, which has to be different from the headers page pool.
For now, the pools are the same.

---
 drivers/net/ethernet/mellanox/mlx5/core/en.h  |  4 ++
 .../net/ethernet/mellanox/mlx5/core/en_main.c | 43 ++++++++++++++++++-
 .../net/ethernet/mellanox/mlx5/core/en_rx.c   | 41 ++++++++++--------
 3 files changed, 69 insertions(+), 19 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en.h +4 -0
index 581eef34f512..c329de1d4f0a 100644
@@ -716,7 +716,11 @@ struct mlx5e_rq {
 	struct bpf_prog __rcu *xdp_prog;
 	struct mlx5e_xdpsq    *xdpsq;
 	DECLARE_BITMAP(flags, 8);
+
+	/* page pools */
 	struct page_pool      *page_pool;
+	struct page_pool      *hd_page_pool;
+
 	struct mlx5e_xdp_buff mxbuf;
 
 	/* AF_XDP zero-copy */
drivers/net/ethernet/mellanox/mlx5/core/en_main.c +41 -2

85 lines not on this page · raw message

drivers/net/ethernet/mellanox/mlx5/core/en_rx.c +24 -17

143 lines not on this page · raw message

Signature · 1 line
2.34.1
author maintainer
#7 lore raw

PATCH v3 7/12 net/mlx5e: SHAMPO: Headers page pool stats

In reply to Mark Bloch

From: Saeed Mahameed <[email protected]>

Expose the stats of the new headers page pool.

---
 .../ethernet/mellanox/mlx5/core/en_stats.c    | 54 +++++++++++++++++++
 .../ethernet/mellanox/mlx5/core/en_stats.h    | 24 +++++++++
 2 files changed, 78 insertions(+)
drivers/net/ethernet/mellanox/mlx5/core/en_stats.c +54 -0
index 19664fa7f217..8422afbfa419 100644
@@ -205,6 +205,18 @@ static const struct counter_desc sw_stats_desc[] = {
 	{ MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_pp_recycle_ring) },
 	{ MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_pp_recycle_ring_full) },
 	{ MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_pp_recycle_released_ref) },
+
+	{ MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_pp_hd_alloc_fast) },
+	{ MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_pp_hd_alloc_slow) },
+	{ MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_pp_hd_alloc_slow_high_order) },
+	{ MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_pp_hd_alloc_empty) },
+	{ MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_pp_hd_alloc_refill) },
+	{ MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_pp_hd_alloc_waive) },
+	{ MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_pp_hd_recycle_cached) },
+	{ MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_pp_hd_recycle_cache_full) },
+	{ MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_pp_hd_recycle_ring) },
+	{ MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_pp_hd_recycle_ring_full) },
+	{ MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_pp_hd_recycle_released_ref) },
 #ifdef CONFIG_MLX5_EN_TLS
 	{ MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_tls_decrypted_packets) },
 	{ MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_tls_decrypted_bytes) },
@@ -384,6 +396,18 @@ static void mlx5e_stats_grp_sw_update_stats_rq_stats(struct mlx5e_sw_stats *s,
 	s->rx_pp_recycle_ring			+= rq_stats->pp_recycle_ring;
 	s->rx_pp_recycle_ring_full		+= rq_stats->pp_recycle_ring_full;
 	s->rx_pp_recycle_released_ref		+= rq_stats->pp_recycle_released_ref;
+
+	s->rx_pp_hd_alloc_fast          += rq_stats->pp_hd_alloc_fast;
+	s->rx_pp_hd_alloc_slow          += rq_stats->pp_hd_alloc_slow;
+	s->rx_pp_hd_alloc_empty         += rq_stats->pp_hd_alloc_empty;
+	s->rx_pp_hd_alloc_refill        += rq_stats->pp_hd_alloc_refill;
+	s->rx_pp_hd_alloc_waive         += rq_stats->pp_hd_alloc_waive;
+	s->rx_pp_hd_alloc_slow_high_order	+= rq_stats->pp_hd_alloc_slow_high_order;
+	s->rx_pp_hd_recycle_cached		+= rq_stats->pp_hd_recycle_cached;
+	s->rx_pp_hd_recycle_cache_full		+= rq_stats->pp_hd_recycle_cache_full;
+	s->rx_pp_hd_recycle_ring		+= rq_stats->pp_hd_recycle_ring;
+	s->rx_pp_hd_recycle_ring_full		+= rq_stats->pp_hd_recycle_ring_full;
+	s->rx_pp_hd_recycle_released_ref	+= rq_stats->pp_hd_recycle_released_ref;
 #ifdef CONFIG_MLX5_EN_TLS
 	s->rx_tls_decrypted_packets   += rq_stats->tls_decrypted_packets;
 	s->rx_tls_decrypted_bytes     += rq_stats->tls_decrypted_bytes;
@@ -511,6 +535,24 @@ static void mlx5e_stats_update_stats_rq_page_pool(struct mlx5e_channel *c)
 	rq_stats->pp_recycle_ring = stats.recycle_stats.ring;
 	rq_stats->pp_recycle_ring_full = stats.recycle_stats.ring_full;
 	rq_stats->pp_recycle_released_ref = stats.recycle_stats.released_refcnt;
+
+	pool = c->rq.hd_page_pool;
+	if (!pool || pool == c->rq.page_pool ||
+	    !page_pool_get_stats(pool, &stats))
+		return;
+
+	rq_stats->pp_hd_alloc_fast = stats.alloc_stats.fast;
+	rq_stats->pp_hd_alloc_slow = stats.alloc_stats.slow;
+	rq_stats->pp_hd_alloc_slow_high_order = stats.alloc_stats.slow_high_order;
+	rq_stats->pp_hd_alloc_empty = stats.alloc_stats.empty;
+	rq_stats->pp_hd_alloc_waive = stats.alloc_stats.waive;
+	rq_stats->pp_hd_alloc_refill = stats.alloc_stats.refill;
+
+	rq_stats->pp_hd_recycle_cached = stats.recycle_stats.cached;
+	rq_stats->pp_hd_recycle_cache_full = stats.recycle_stats.cache_full;
+	rq_stats->pp_hd_recycle_ring = stats.recycle_stats.ring;
+	rq_stats->pp_hd_recycle_ring_full = stats.recycle_stats.ring_full;
+	rq_stats->pp_hd_recycle_released_ref = stats.recycle_stats.released_refcnt;
 }
 
 static MLX5E_DECLARE_STATS_GRP_OP_UPDATE_STATS(sw)
@@ -2130,6 +2172,18 @@ static const struct counter_desc rq_stats_desc[] = {
 	{ MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, pp_recycle_ring) },
 	{ MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, pp_recycle_ring_full) },
 	{ MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, pp_recycle_released_ref) },
+
+	{ MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, pp_hd_alloc_fast) },
+	{ MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, pp_hd_alloc_slow) },
+	{ MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, pp_hd_alloc_slow_high_order) },
+	{ MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, pp_hd_alloc_empty) },
+	{ MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, pp_hd_alloc_refill) },
+	{ MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, pp_hd_alloc_waive) },
+	{ MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, pp_hd_recycle_cached) },
+	{ MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, pp_hd_recycle_cache_full) },
+	{ MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, pp_hd_recycle_ring) },
+	{ MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, pp_hd_recycle_ring_full) },
+	{ MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, pp_hd_recycle_released_ref) },
 #ifdef CONFIG_MLX5_EN_TLS
 	{ MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, tls_decrypted_packets) },
 	{ MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, tls_decrypted_bytes) },
drivers/net/ethernet/mellanox/mlx5/core/en_stats.h +24 -0
index def5dea1463d..113221dfcdfa 100644
@@ -226,6 +226,18 @@ struct mlx5e_sw_stats {
 	u64 rx_pp_recycle_ring;
 	u64 rx_pp_recycle_ring_full;
 	u64 rx_pp_recycle_released_ref;
+
+	u64 rx_pp_hd_alloc_fast;
+	u64 rx_pp_hd_alloc_slow;
+	u64 rx_pp_hd_alloc_slow_high_order;
+	u64 rx_pp_hd_alloc_empty;
+	u64 rx_pp_hd_alloc_refill;
+	u64 rx_pp_hd_alloc_waive;
+	u64 rx_pp_hd_recycle_cached;
+	u64 rx_pp_hd_recycle_cache_full;
+	u64 rx_pp_hd_recycle_ring;
+	u64 rx_pp_hd_recycle_ring_full;
+	u64 rx_pp_hd_recycle_released_ref;
 #ifdef CONFIG_MLX5_EN_TLS
 	u64 tx_tls_encrypted_packets;
 	u64 tx_tls_encrypted_bytes;
@@ -394,6 +406,18 @@ struct mlx5e_rq_stats {
 	u64 pp_recycle_ring;
 	u64 pp_recycle_ring_full;
 	u64 pp_recycle_released_ref;
+
+	u64 pp_hd_alloc_fast;
+	u64 pp_hd_alloc_slow;
+	u64 pp_hd_alloc_slow_high_order;
+	u64 pp_hd_alloc_empty;
+	u64 pp_hd_alloc_refill;
+	u64 pp_hd_alloc_waive;
+	u64 pp_hd_recycle_cached;
+	u64 pp_hd_recycle_cache_full;
+	u64 pp_hd_recycle_ring;
+	u64 pp_hd_recycle_ring_full;
+	u64 pp_hd_recycle_released_ref;
 #ifdef CONFIG_MLX5_EN_TLS
 	u64 tls_decrypted_packets;
 	u64 tls_decrypted_bytes;
Signature · 1 line
2.34.1
maintainer
#8 lore raw

Re: [PATCH net-next v3 07/12] net/mlx5e: SHAMPO: Headers page pool stats

Quoted 1 line · On Mon, 9 Jun 2025 17:58:28 +0300 Mark Bloch wrote:

Expose the stats of the new headers page pool.

Y'all asked for clarifications on this patch 2 weeks after v2 was posted and then reposted v3 before I could answer. This patch must go.

Signature · 1 line
pw-bot: cr
#9 lore raw

Re: [PATCH net-next v3 07/12] net/mlx5e: SHAMPO: Headers page pool stats

Quoted 5 lines · Jakub Kicinski
Quoted 1 line · On Mon, 9 Jun 2025 17:58:28 +0300 Mark Bloch wrote:

Expose the stats of the new headers page pool.

Y'all asked for clarifications on this patch 2 weeks after v2 was posted and then reposted v3 before I could answer. This patch must go.

Ack. Sorry about the too short window of response. Patch will be dropped in v4.

Thanks,
Dragos

maintainer
#10 lore raw

Re: [PATCH net-next v3 07/12] net/mlx5e: SHAMPO: Headers page pool stats

Quoted 8 lines · On Mon, 9 Jun 2025 15:31:00 +0000 Dragos Tatulea wrote:
Quoted 5 lines · Jakub Kicinski
Quoted 1 line · On Mon, 9 Jun 2025 17:58:28 +0300 Mark Bloch wrote:

Expose the stats of the new headers page pool.

Y'all asked for clarifications on this patch 2 weeks after v2 was posted and then reposted v3 before I could answer. This patch must go.

Ack. Sorry about the too short window of response. Patch will be dropped in v4.

Thanks! FWIW the rest indeed LGTM.

author maintainer
#11 lore raw

PATCH v3 8/12 net/mlx5e: Convert over to netmem

In reply to Mark Bloch

From: Saeed Mahameed <[email protected]>

mlx5e_page_frag holds the physical page itself, to naturally support zc page pools, remove physical page reference from mlx5 and replace it with netmem_ref, to avoid internal handling in mlx5 for net_iov backed pages.

SHAMPO can issue packets that are not split into header and data. These packets will be dropped if the data part resides in a net_iov as the driver can't read into this area.

No performance degradation observed.

---
 drivers/net/ethernet/mellanox/mlx5/core/en.h  |   2 +-
 .../net/ethernet/mellanox/mlx5/core/en_rx.c   | 103 ++++++++++--------
 2 files changed, 61 insertions(+), 44 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en.h +1 -1
index c329de1d4f0a..65a73913b9a2 100644
@@ -553,7 +553,7 @@ struct mlx5e_icosq {
 } ____cacheline_aligned_in_smp;
 
 struct mlx5e_frag_page {
-	struct page *page;
+	netmem_ref netmem;
 	u16 frags;
 };
 
drivers/net/ethernet/mellanox/mlx5/core/en_rx.c +60 -43

253 lines not on this page · raw message

Signature · 1 line
2.34.1
author maintainer
#12 lore raw

PATCH v3 9/12 net/mlx5e: Add support for UNREADABLE netmem page pools

In reply to Mark Bloch

From: Saeed Mahameed <[email protected]>

On netdev_rx_queue_restart, a special type of page pool maybe expected.

In this patch declare support for UNREADABLE netmem iov pages in the pool params only when header data split shampo RQ mode is enabled, also set the queue index in the page pool params struct.

Shampo mode requirement: Without header split rx needs to peek at the data, we can't do UNREADABLE_NETMEM.

The patch also enables the use of a separate page pool for headers when a memory provider is installed for the queue, otherwise the same common page pool continues to be used.

---
 drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx5/core/en_main.c +8 -1
index 5e649705e35f..a51e204bd364 100644
@@ -749,7 +749,9 @@ static void mlx5e_rq_shampo_hd_info_free(struct mlx5e_rq *rq)
 
 static bool mlx5_rq_needs_separate_hd_pool(struct mlx5e_rq *rq)
 {
-	return false;
+	struct netdev_rx_queue *rxq = __netif_get_rx_queue(rq->netdev, rq->ix);
+
+	return !!rxq->mp_params.mp_ops;
 }
 
 static int mlx5_rq_shampo_alloc(struct mlx5_core_dev *mdev,
@@ -964,6 +966,11 @@ static int mlx5e_alloc_rq(struct mlx5e_params *params,
 		pp_params.netdev    = rq->netdev;
 		pp_params.dma_dir   = rq->buff.map_dir;
 		pp_params.max_len   = PAGE_SIZE;
+		pp_params.queue_idx = rq->ix;
+
+		/* Shampo header data split allow for unreadable netmem */
+		if (test_bit(MLX5E_RQ_STATE_SHAMPO, &rq->state))
+			pp_params.flags |= PP_FLAG_ALLOW_UNREADABLE_NETMEM;
 
 		/* page_pool can be used even when there is no rq->xdp_prog,
 		 * given page_pool does not handle DMA mapping there is no
Signature · 1 line
2.34.1
author maintainer
#13 lore raw

PATCH v3 10/12 net/mlx5e: Implement queue mgmt ops and single channel swap

In reply to Mark Bloch

From: Saeed Mahameed <[email protected]>

The bulk of the work is done in mlx5e_queue_mem_alloc, where we allocate and create the new channel resources, similar to mlx5e_safe_switch_params, but here we do it for a single channel using existing params, sort of a clone channel.
To swap the old channel with the new one, we deactivate and close the old channel then replace it with the new one, since the swap procedure doesn't fail in mlx5, we do it all in one place (mlx5e_queue_start).

---
 .../net/ethernet/mellanox/mlx5/core/en_main.c | 97 +++++++++++++++++++
 1 file changed, 97 insertions(+)
drivers/net/ethernet/mellanox/mlx5/core/en_main.c +97 -0
index a51e204bd364..90687392545c 100644
@@ -5494,6 +5494,102 @@ static const struct netdev_stat_ops mlx5e_stat_ops = {
 	.get_base_stats      = mlx5e_get_base_stats,
 };
 
+struct mlx5_qmgmt_data {
+	struct mlx5e_channel *c;
+	struct mlx5e_channel_param cparam;
+};
+
+static int mlx5e_queue_mem_alloc(struct net_device *dev, void *newq,
+				 int queue_index)
+{
+	struct mlx5_qmgmt_data *new = (struct mlx5_qmgmt_data *)newq;
+	struct mlx5e_priv *priv = netdev_priv(dev);
+	struct mlx5e_channels *chs = &priv->channels;
+	struct mlx5e_params params = chs->params;
+	struct mlx5_core_dev *mdev;
+	int err;
+
+	mutex_lock(&priv->state_lock);
+	if (!test_bit(MLX5E_STATE_OPENED, &priv->state)) {
+		err = -ENODEV;
+		goto unlock;
+	}
+
+	if (queue_index >= chs->num) {
+		err = -ERANGE;
+		goto unlock;
+	}
+
+	if (MLX5E_GET_PFLAG(&chs->params, MLX5E_PFLAG_TX_PORT_TS) ||
+	    chs->params.ptp_rx   ||
+	    chs->params.xdp_prog ||
+	    priv->htb) {
+		netdev_err(priv->netdev,
+			   "Cloning channels with Port/rx PTP, XDP or HTB is not supported\n");
+		err = -EOPNOTSUPP;
+		goto unlock;
+	}
+
+	mdev = mlx5_sd_ch_ix_get_dev(priv->mdev, queue_index);
+	err = mlx5e_build_channel_param(mdev, &params, &new->cparam);
+	if (err) {
+		return err;
+		goto unlock;
+	}
+
+	err = mlx5e_open_channel(priv, queue_index, &params, NULL, &new->c);
+unlock:
+	mutex_unlock(&priv->state_lock);
+	return err;
+}
+
+static void mlx5e_queue_mem_free(struct net_device *dev, void *mem)
+{
+	struct mlx5_qmgmt_data *data = (struct mlx5_qmgmt_data *)mem;
+
+	/* not supposed to happen since mlx5e_queue_start never fails
+	 * but this is how this should be implemented just in case
+	 */
+	if (data->c)
+		mlx5e_close_channel(data->c);
+}
+
+static int mlx5e_queue_stop(struct net_device *dev, void *oldq, int queue_index)
+{
+	/* mlx5e_queue_start does not fail, we stop the old queue there */
+	return 0;
+}
+
+static int mlx5e_queue_start(struct net_device *dev, void *newq,
+			     int queue_index)
+{
+	struct mlx5_qmgmt_data *new = (struct mlx5_qmgmt_data *)newq;
+	struct mlx5e_priv *priv = netdev_priv(dev);
+	struct mlx5e_channel *old;
+
+	mutex_lock(&priv->state_lock);
+
+	/* stop and close the old */
+	old = priv->channels.c[queue_index];
+	mlx5e_deactivate_priv_channels(priv);
+	/* close old before activating new, to avoid napi conflict */
+	mlx5e_close_channel(old);
+
+	/* start the new */
+	priv->channels.c[queue_index] = new->c;
+	mlx5e_activate_priv_channels(priv);
+	mutex_unlock(&priv->state_lock);
+	return 0;
+}
+
+static const struct netdev_queue_mgmt_ops mlx5e_queue_mgmt_ops = {
+	.ndo_queue_mem_size	=	sizeof(struct mlx5_qmgmt_data),
+	.ndo_queue_mem_alloc	=	mlx5e_queue_mem_alloc,
+	.ndo_queue_mem_free	=	mlx5e_queue_mem_free,
+	.ndo_queue_start	=	mlx5e_queue_start,
+	.ndo_queue_stop		=	mlx5e_queue_stop,
+};
+
 static void mlx5e_build_nic_netdev(struct net_device *netdev)
 {
 	struct mlx5e_priv *priv = netdev_priv(netdev);
@@ -5504,6 +5600,7 @@ static void mlx5e_build_nic_netdev(struct net_device *netdev)
 	SET_NETDEV_DEV(netdev, mdev->device);
 
 	netdev->netdev_ops = &mlx5e_netdev_ops;
+	netdev->queue_mgmt_ops = &mlx5e_queue_mgmt_ops;
 	netdev->xdp_metadata_ops = &mlx5e_xdp_metadata_ops;
 	netdev->xsk_tx_metadata_ops = &mlx5e_xsk_tx_metadata_ops;
 	netdev->request_ops_lock = true;
Signature · 1 line
2.34.1
#14 lore raw

Re: [PATCH net-next v3 10/12] net/mlx5e: Implement queue mgmt ops and single channel swap

Quoted 83 lines · Mark Bloch

From: Saeed Mahameed <[email protected]>

The bulk of the work is done in mlx5e_queue_mem_alloc, where we allocate and create the new channel resources, similar to mlx5e_safe_switch_params, but here we do it for a single channel using existing params, sort of a clone channel.
To swap the old channel with the new one, we deactivate and close the old channel then replace it with the new one, since the swap procedure doesn't fail in mlx5, we do it all in one place (mlx5e_queue_start).

---
 .../net/ethernet/mellanox/mlx5/core/en_main.c | 97 +++++++++++++++++++
 1 file changed, 97 insertions(+)
drivers/net/ethernet/mellanox/mlx5/core/en_main.c +55 -0
index a51e204bd364..90687392545c 100644
@@ -5494,6 +5494,102 @@ static const struct netdev_stat_ops mlx5e_stat_ops = {
        .get_base_stats      = mlx5e_get_base_stats,
 };
 
+struct mlx5_qmgmt_data {
+       struct mlx5e_channel *c;
+       struct mlx5e_channel_param cparam;
+};
+
+static int mlx5e_queue_mem_alloc(struct net_device *dev, void *newq,
+                                int queue_index)
+{
+       struct mlx5_qmgmt_data *new = (struct mlx5_qmgmt_data *)newq;
+       struct mlx5e_priv *priv = netdev_priv(dev);
+       struct mlx5e_channels *chs = &priv->channels;
+       struct mlx5e_params params = chs->params;
+       struct mlx5_core_dev *mdev;
+       int err;
+
+       mutex_lock(&priv->state_lock);
+       if (!test_bit(MLX5E_STATE_OPENED, &priv->state)) {
+               err = -ENODEV;
+               goto unlock;
+       }
+
+       if (queue_index >= chs->num) {
+               err = -ERANGE;
+               goto unlock;
+       }
+
+       if (MLX5E_GET_PFLAG(&chs->params, MLX5E_PFLAG_TX_PORT_TS) ||
+           chs->params.ptp_rx   ||
+           chs->params.xdp_prog ||
+           priv->htb) {
+               netdev_err(priv->netdev,
+                          "Cloning channels with Port/rx PTP, XDP or HTB is not supported\n");
+               err = -EOPNOTSUPP;
+               goto unlock;
+       }
+
+       mdev = mlx5_sd_ch_ix_get_dev(priv->mdev, queue_index);
+       err = mlx5e_build_channel_param(mdev, &params, &new->cparam);
+       if (err) {
+               return err;
+               goto unlock;
+       }
+
+       err = mlx5e_open_channel(priv, queue_index, &params, NULL, &new->c);
+unlock:
+       mutex_unlock(&priv->state_lock);
+       return err;
+}
+
+static void mlx5e_queue_mem_free(struct net_device *dev, void *mem)
+{
+       struct mlx5_qmgmt_data *data = (struct mlx5_qmgmt_data *)mem;
+
+       /* not supposed to happen since mlx5e_queue_start never fails
+        * but this is how this should be implemented just in case

drivers/net/ethernet/mellanox/mlx5/core/en_main.c static const struct netdev_stat_ops mlx5e_stat_ops = { · line 5561

Quoted 10 lines
drivers/net/ethernet/mellanox/mlx5/core/en_main.c +10 -0
+        */
+       if (data->c)
+               mlx5e_close_channel(data->c);
+}
+
+static int mlx5e_queue_stop(struct net_device *dev, void *oldq, int queue_index)
+{
+       /* mlx5e_queue_start does not fail, we stop the old queue there */
+       return 0;
+}

Is this really better than maintaining uniformity of behavior between the drivers that support the queue mgmt api and just doing the mlx5e_deactivate_priv_channels and mlx5e_close_channel in the stop like core sorta expects?

We currently use the ndos to restart a queue, but I'm imagining in the future we can expand it to create queues on behalf of the queues. The stop queue API may be reused in other contexts, like maybe to kill a dynamically created devmem queue or something, and this specific driver may stop working because stop actually doesn't do anything?

Signature · 2 lines
Thanks,
Mina
#15 lore raw

Re: [PATCH net-next v3 10/12] net/mlx5e: Implement queue mgmt ops and single channel swap

Quoted 5 lines · Mina Almasry

Is this really better than maintaining uniformity of behavior between the drivers that support the queue mgmt api and just doing the mlx5e_deactivate_priv_channels and mlx5e_close_channel in the stop like core sorta expects?

Quoted 7 lines

We currently use the ndos to restart a queue, but I'm imagining in the
future we can expand it to create queues on behalf of the queues. The stop queue API may be reused in other contexts, like maybe to kill a dynamically created devmem queue or something, and this specific driver may stop working because stop actually doesn't do anything?

The .ndo_queue_stop operation doesn't make sense by itself for mlx5, because the current mlx5 architecture is to atomically swap in all of the channels.
The scenario you are describing, with a hypothetical ndo_queue_stop for dynamically created devmem queues would leave all of the queues stopped and the old channel deallocated in the channel array. Worse problems would happen in that state than with today's approach, which leaves the driver in functional state.

Perhaps Saeed can add more details to this?

Cosmin.

#16 lore raw

Re: [PATCH net-next v3 10/12] net/mlx5e: Implement queue mgmt ops and single channel swap

Quoted 24 lines · Cosmin Ratiu
Quoted 5 lines · Mina Almasry

Is this really better than maintaining uniformity of behavior between the drivers that support the queue mgmt api and just doing the mlx5e_deactivate_priv_channels and mlx5e_close_channel in the stop like core sorta expects?

Quoted 7 lines

We currently use the ndos to restart a queue, but I'm imagining in the
future we can expand it to create queues on behalf of the queues. The stop queue API may be reused in other contexts, like maybe to kill a dynamically created devmem queue or something, and this specific driver may stop working because stop actually doesn't do anything?

The .ndo_queue_stop operation doesn't make sense by itself for mlx5, because the current mlx5 architecture is to atomically swap in all of the channels.
The scenario you are describing, with a hypothetical ndo_queue_stop for dynamically created devmem queues would leave all of the queues stopped and the old channel deallocated in the channel array. Worse problems would happen in that state than with today's approach, which leaves the driver in functional state.

Quoted 1 line

Perhaps Saeed can add more details to this?

I see, so essentially mlx5 supports restarting a queue but not necessarily stopping and starting a queue as separate actions?

If so, can maybe the comment on the function be reworded to more strongly indicate that this is a limitation? Just asking because future driver authors interested in implementing the queue API will probably look at one of mlx5/gve/bnxt to see what an existing implementation looks like, and I would rather them follow bnxt/gve that is more in line with core's expectations if possible. But that's a minor concern; I'm fine with this patch.

FWIW this may break in the future if core decides to add code that actually uses the stop operation as a 'stop', not as a stepping stone to 'restart', but I'm not sure we can do anything about that if it's a driver limitation.

Signature · 2 lines
Thanks,
Mina
maintainer
#17 lore raw

Re: [PATCH net-next v3 10/12] net/mlx5e: Implement queue mgmt ops and single channel swap

Quoted 36 lines · On Thu, 12 Jun 2025 13:44:44 -0700 Mina Almasry wrote:
Quoted 23 lines · Mina Almasry
Quoted 5 lines

Is this really better than maintaining uniformity of behavior between the drivers that support the queue mgmt api and just doing the mlx5e_deactivate_priv_channels and mlx5e_close_channel in the stop like core sorta expects?

Quoted 7 lines

We currently use the ndos to restart a queue, but I'm imagining in the
future we can expand it to create queues on behalf of the queues. The stop queue API may be reused in other contexts, like maybe to kill a dynamically created devmem queue or something, and this specific driver may stop working because stop actually doesn't do anything?

The .ndo_queue_stop operation doesn't make sense by itself for mlx5, because the current mlx5 architecture is to atomically swap in all of the channels.
The scenario you are describing, with a hypothetical ndo_queue_stop for dynamically created devmem queues would leave all of the queues stopped and the old channel deallocated in the channel array. Worse problems would happen in that state than with today's approach, which leaves the driver in functional state.

Quoted 1 line

Perhaps Saeed can add more details to this?

I see, so essentially mlx5 supports restarting a queue but not necessarily stopping and starting a queue as separate actions?

If so, can maybe the comment on the function be reworded to more strongly indicate that this is a limitation? Just asking because future driver authors interested in implementing the queue API will probably look at one of mlx5/gve/bnxt to see what an existing implementation looks like, and I would rather them follow bnxt/gve that is more in line with core's expectations if possible. But that's a minor concern; I'm fine with this patch.

Quoted 4 lines

FWIW this may break in the future if core decides to add code that actually uses the stop operation as a 'stop', not as a stepping stone to 'restart', but I'm not sure we can do anything about that if it's a driver limitation.

Agreed, would be good to add a TODO and follow up on this. It will bite us sooner or later. I suppose state_lock may need to be dropped in favor of the netdev instance lock first?

I'm disappointed that mlx5 once again disrupts all rings to restart a single one. But all existing drivers seem to do this, so I guess it'd be unfair to push back based on just that :|

author maintainer
#18 lore raw

PATCH v3 11/12 net/mlx5e: Support ethtool tcp-data-split settings

In reply to Mark Bloch

From: Saeed Mahameed <[email protected]>

In mlx5, tcp header-data split requires HW GRO to be on.

Enabling it fails when HW GRO is off.
mlx5e_fix_features now keeps HW GRO on when tcp data split is enabled. Finally, when tcp data split is disabled, features are updated to maybe remove the forced HW GRO.

---
 .../ethernet/mellanox/mlx5/core/en_ethtool.c  | 33 ++++++++++++++++---
 .../net/ethernet/mellanox/mlx5/core/en_main.c |  8 +++++
 2 files changed, 36 insertions(+), 5 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c +28 -5
index ea078c9f5d15..21005cc4eb06 100644
@@ -32,6 +32,7 @@
 
 #include <linux/dim.h>
 #include <linux/ethtool_netlink.h>
+#include <net/netdev_queues.h>
 
 #include "en.h"
 #include "en/channels.h"
@@ -366,11 +367,6 @@ void mlx5e_ethtool_get_ringparam(struct mlx5e_priv *priv,
 	param->tx_max_pending = 1 << MLX5E_PARAMS_MAXIMUM_LOG_SQ_SIZE;
 	param->rx_pending     = 1 << priv->channels.params.log_rq_mtu_frames;
 	param->tx_pending     = 1 << priv->channels.params.log_sq_size;
-
-	kernel_param->tcp_data_split =
-		(priv->channels.params.packet_merge.type == MLX5E_PACKET_MERGE_SHAMPO) ?
-		ETHTOOL_TCP_DATA_SPLIT_ENABLED :
-		ETHTOOL_TCP_DATA_SPLIT_DISABLED;
 }
 
 static void mlx5e_get_ringparam(struct net_device *dev,
@@ -383,6 +379,27 @@ static void mlx5e_get_ringparam(struct net_device *dev,
 	mlx5e_ethtool_get_ringparam(priv, param, kernel_param);
 }
 
+static bool mlx5e_ethtool_set_tcp_data_split(struct mlx5e_priv *priv,
+					     u8 tcp_data_split,
+					     struct netlink_ext_ack *extack)
+{
+	struct net_device *dev = priv->netdev;
+
+	if (tcp_data_split == ETHTOOL_TCP_DATA_SPLIT_ENABLED &&
+	    !(dev->features & NETIF_F_GRO_HW)) {
+		NL_SET_ERR_MSG(extack,
+			       "TCP-data-split is not supported when GRO HW is disabled\n");
+		return false; /* GRO HW is not enabled */
+	}
+
+	/* Might need to disable HW-GRO if it was kept on due to hds. */
+	if (tcp_data_split == ETHTOOL_TCP_DATA_SPLIT_DISABLED &&
+	    dev->cfg->hds_config == ETHTOOL_TCP_DATA_SPLIT_ENABLED)
+		netdev_update_features(priv->netdev);
+
+	return true;
+}
+
 int mlx5e_ethtool_set_ringparam(struct mlx5e_priv *priv,
 				struct ethtool_ringparam *param,
 				struct netlink_ext_ack *extack)
@@ -441,6 +458,11 @@ static int mlx5e_set_ringparam(struct net_device *dev,
 {
 	struct mlx5e_priv *priv = netdev_priv(dev);
 
+	if (!mlx5e_ethtool_set_tcp_data_split(priv,
+					      kernel_param->tcp_data_split,
+					      extack))
+		return -EINVAL;
+
 	return mlx5e_ethtool_set_ringparam(priv, param, extack);
 }
 
@@ -2625,6 +2647,7 @@ const struct ethtool_ops mlx5e_ethtool_ops = {
 				     ETHTOOL_COALESCE_USE_ADAPTIVE |
 				     ETHTOOL_COALESCE_USE_CQE,
 	.supported_input_xfrm = RXH_XFRM_SYM_OR_XOR,
+	.supported_ring_params = ETHTOOL_RING_USE_TCP_DATA_SPLIT,
 	.get_drvinfo       = mlx5e_get_drvinfo,
 	.get_link          = ethtool_op_get_link,
 	.get_link_ext_state  = mlx5e_get_link_ext_state,
drivers/net/ethernet/mellanox/mlx5/core/en_main.c +8 -0
index 90687392545c..026bd479c6dd 100644
@@ -4413,6 +4413,7 @@ static netdev_features_t mlx5e_fix_uplink_rep_features(struct net_device *netdev
 static netdev_features_t mlx5e_fix_features(struct net_device *netdev,
 					    netdev_features_t features)
 {
+	struct netdev_config *cfg = netdev->cfg_pending;
 	struct mlx5e_priv *priv = netdev_priv(netdev);
 	struct mlx5e_vlan_table *vlan;
 	struct mlx5e_params *params;
@@ -4479,6 +4480,13 @@ static netdev_features_t mlx5e_fix_features(struct net_device *netdev,
 		}
 	}
 
+	/* The header-data split ring param requires HW GRO to stay enabled. */
+	if (cfg && cfg->hds_config == ETHTOOL_TCP_DATA_SPLIT_ENABLED &&
+	    !(features & NETIF_F_GRO_HW)) {
+		netdev_warn(netdev, "Keeping HW-GRO enabled, TCP header-data split depends on it\n");
+		features |= NETIF_F_GRO_HW;
+	}
+
 	if (mlx5e_is_uplink_rep(priv)) {
 		features = mlx5e_fix_uplink_rep_features(netdev, features);
 		netdev->netns_immutable = true;
Signature · 1 line
2.34.1
author maintainer
#19 lore raw

PATCH v3 12/12 net/mlx5e: Add TX support for netmems

In reply to Mark Bloch

From: Dragos Tatulea <[email protected]>

Declare netmem TX support in netdev.

As required, use the netmem aware dma unmapping APIs for unmapping netmems in tx completion path.

---
 drivers/net/ethernet/mellanox/mlx5/core/en/txrx.h | 3 ++-
 drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 2 ++
 2 files changed, 4 insertions(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx5/core/en/txrx.h +2 -1
index e837c21d3d21..6501252359b0 100644
@@ -362,7 +362,8 @@ mlx5e_tx_dma_unmap(struct device *pdev, struct mlx5e_sq_dma *dma)
 		dma_unmap_single(pdev, dma->addr, dma->size, DMA_TO_DEVICE);
 		break;
 	case MLX5E_DMA_MAP_PAGE:
-		dma_unmap_page(pdev, dma->addr, dma->size, DMA_TO_DEVICE);
+		netmem_dma_unmap_page_attrs(pdev, dma->addr, dma->size,
+					    DMA_TO_DEVICE, 0);
 		break;
 	default:
 		WARN_ONCE(true, "mlx5e_tx_dma_unmap unknown DMA type!\n");
drivers/net/ethernet/mellanox/mlx5/core/en_main.c +2 -0
index 026bd479c6dd..1f2973e82733 100644
@@ -5740,6 +5740,8 @@ static void mlx5e_build_nic_netdev(struct net_device *netdev)
 
 	netdev->priv_flags       |= IFF_UNICAST_FLT;
 
+	netdev->netmem_tx = true;
+
 	netif_set_tso_max_size(netdev, GSO_MAX_SIZE);
 	mlx5e_set_xdp_feature(netdev);
 	mlx5e_set_netdev_dev_addr(netdev);
Signature · 1 line
2.34.1