net/mlx5e: SHAMPO, Switch to header memcpy
Subsystems (5)
Tariq Toukan
maintainerPATCH v2 1/1 net/mlx5e: SHAMPO, Switch to header memcpy
From: Dragos Tatulea <[email protected]>
Previously the HW-GRO code was using a separate page_pool for the header buffer. The pages of the header buffer were replenished via UMR. This mechanism has some drawbacks:
- Reference counting on the page_pool page frags is not cheap.
- UMRs have HW overhead for updating and also for access. Especially for the KLM type which was previously used.
- UMR code for headers is complex.
This patch switches to using a static memory area (static MTT MKEY) for the header buffer and does a header memcpy. This happens only once per GRO session. The SKB is allocated from the per-cpu NAPI SKB cache.
Performance numbers for x86:
+---------------------------------------------------------+ | Test | Baseline | Header Copy | Change | |---------------------+------------+-------------+--------| | iperf3 oncpu | 59.5 Gbps | 64.00 Gbps | 7 % | | iperf3 offcpu | 102.5 Gbps | 104.20 Gbps | 2 % | | kperf oncpu | 115.0 Gbps | 130.00 Gbps | 12 % | | XDP_DROP (skb mode) | 3.9 Mpps | 3.9 Mpps | 0 % | +---------------------------------------------------------+
Notes on test:
- System: Intel(R) Xeon(R) Platinum 8380 CPU @ 2.30GHz
- oncpu: NAPI and application running on same CPU
- offcpu: NAPI and application running on different CPUs
- MTU: 1500
- iperf3 tests are single stream, 60s with IPv6 (for slightly larger headers)
- kperf version [1]
[1] git://git.kernel.dk/kperf.git
--- drivers/net/ethernet/mellanox/mlx5/core/en.h | 20 +- .../ethernet/mellanox/mlx5/core/en/params.c | 23 -- .../net/ethernet/mellanox/mlx5/core/en/txrx.h | 1 - .../net/ethernet/mellanox/mlx5/core/en_main.c | 287 +++++++-------- .../net/ethernet/mellanox/mlx5/core/en_rx.c | 341 +++--------------- 5 files changed, 188 insertions(+), 484 deletions(-)
V2:
- Consolidated mlx5e_shampo_get_header_offset() into a bigger function
to avoid code duplication in the callers (Paolo).
- Dropped inline from static function (Paolo).
- Removed icosq resize for SHAMPO UMR headers. No longer needed.
- Link to V1: https://lore.kernel.org/all/[email protected]/
drivers/net/ethernet/mellanox/mlx5/core/en.h +8 -12
@@ -82,9 +82,10 @@ struct page_pool;#define MLX5E_RX_MAX_HEAD (256)#define MLX5E_SHAMPO_LOG_HEADER_ENTRY_SIZE (8) -#define MLX5E_SHAMPO_LOG_MAX_HEADER_ENTRY_SIZE (9) -#define MLX5E_SHAMPO_WQ_HEADER_PER_PAGE (PAGE_SIZE >> MLX5E_SHAMPO_LOG_MAX_HEADER_ENTRY_SIZE) -#define MLX5E_SHAMPO_LOG_WQ_HEADER_PER_PAGE (PAGE_SHIFT - MLX5E_SHAMPO_LOG_MAX_HEADER_ENTRY_SIZE) +#define MLX5E_SHAMPO_WQ_HEADER_PER_PAGE \ + (PAGE_SIZE >> MLX5E_SHAMPO_LOG_HEADER_ENTRY_SIZE) +#define MLX5E_SHAMPO_LOG_WQ_HEADER_PER_PAGE \ + (PAGE_SHIFT - MLX5E_SHAMPO_LOG_HEADER_ENTRY_SIZE)#define MLX5E_SHAMPO_WQ_BASE_HEAD_ENTRY_SIZE_SHIFT (6)#define MLX5E_SHAMPO_WQ_RESRV_SIZE_BASE_SHIFT (12)#define MLX5E_SHAMPO_WQ_LOG_RESRV_SIZE (16)
@@ -638,16 +639,11 @@ struct mlx5e_dma_info { };struct mlx5e_shampo_hd { -struct mlx5e_frag_page *pages;u32 hd_per_wq; -u32 hd_per_page; -u16 hd_per_wqe; -u8 log_hd_per_page; -u8 log_hd_entry_size; -unsigned long *bitmap; -u16 pi; -u16 ci; -__be32 mkey_be; +u32 hd_buf_size; +u32 mkey; +u32 nentries; + DECLARE_FLEX_ARRAY(struct mlx5e_dma_info, hd_buf_pages); };struct mlx5e_hw_gro_data {
drivers/net/ethernet/mellanox/mlx5/core/en/params.c +0 -23
@@ -1068,26 +1068,6 @@ u32 mlx5e_shampo_hd_per_wq(struct mlx5_core_dev *mdev,return hd_per_wq; } -static u32 mlx5e_shampo_icosq_sz (struct mlx5_core_dev *mdev, -struct mlx5e_params *params, -struct mlx5e_rq_param *rq_param) -{ -int max_num_of_umr_per_wqe, max_hd_per_wqe, max_ksm_per_umr, rest; -void *wqc =MLX5_ADDR_OF (rqc, rq_param->rqc, wq); -int wq_size =BIT (MLX5_GET (wq, wqc, log_wq_sz)); -u32 wqebbs; - - max_ksm_per_umr =MLX5E_MAX_KSM_PER_WQE (mdev); - max_hd_per_wqe =mlx5e_shampo_hd_per_wqe (mdev, params, rq_param); - max_num_of_umr_per_wqe = max_hd_per_wqe / max_ksm_per_umr; - rest = max_hd_per_wqe % max_ksm_per_umr; - wqebbs =MLX5E_KSM_UMR_WQEBBS (max_ksm_per_umr) * max_num_of_umr_per_wqe; -if (rest) - wqebbs +=MLX5E_KSM_UMR_WQEBBS (rest); - wqebbs *= wq_size; -return wqebbs; -} -#define MLX5E_LRO_TIMEOUT_ARR_SIZE 4u32 mlx5e_choose_lro_timeout (struct mlx5_core_dev *mdev,u32 wanted_timeout)
@@ -1173,9 +1153,6 @@ static u8 mlx5e_build_icosq_log_wq_sz(struct mlx5_core_dev *mdev, wqebbs += max_xsk_wqebbs; } -if (params->packet_merge.type ==MLX5E_PACKET_MERGE_SHAMPO ) - wqebbs +=mlx5e_shampo_icosq_sz (mdev, params, rqp); -/* UMR WQEs don't cross the page boundary, they are padded with NOPs. * This padding is always smaller than the max WQE size. That gives us * at least (PAGE_SIZE - (max WQE size - MLX5_SEND_WQE_BB)) useful bytes
drivers/net/ethernet/mellanox/mlx5/core/en/txrx.h +0 -1
@@ -65,7 +65,6 @@ ktime_t mlx5e_cqe_ts_to_ns(cqe_ts_to_ns func, struct mlx5_clock *clock, u64 cqe_enum mlx5e_icosq_wqe_type {MLX5E_ICOSQ_WQE_NOP ,MLX5E_ICOSQ_WQE_UMR_RX , -MLX5E_ICOSQ_WQE_SHAMPO_HD_UMR ,#ifdef CONFIG_MLX5_EN_TLS MLX5E_ICOSQ_WQE_UMR_TLS ,MLX5E_ICOSQ_WQE_SET_PSV_TLS ,
drivers/net/ethernet/mellanox/mlx5/core/en_main.c +121 -166
373 lines not on this page · raw message
drivers/net/ethernet/mellanox/mlx5/core/en_rx.c +59 -282
433 lines not on this page · raw message
base-commit: 9a9424c756feee9ee6e717405a9d6fa7bacdef08
Signature · 1 line
2.44.0
Quoted 24 lines · Tariq Toukan
Performance numbers for x86:
+---------------------------------------------------------+ | Test | Baseline | Header Copy | Change | |---------------------+------------+-------------+--------| | iperf3 oncpu | 59.5 Gbps | 64.00 Gbps | 7 % | | iperf3 offcpu | 102.5 Gbps | 104.20 Gbps | 2 % | | kperf oncpu | 115.0 Gbps | 130.00 Gbps | 12 % | | XDP_DROP (skb mode) | 3.9 Mpps | 3.9 Mpps | 0 % | +---------------------------------------------------------+Notes on test:
- System: Intel(R) Xeon(R) Platinum 8380 CPU @ 2.30GHz
- oncpu: NAPI and application running on same CPU
- offcpu: NAPI and application running on different CPUs
- MTU: 1500
- iperf3 tests are single stream, 60s with IPv6 (for slightly larger headers)
- kperf version [1][1]
git://git.kernel.dk/kperf.gitSuggested-by Eric Dumazet <[email protected]>Signed-off-by Dragos Tatulea <[email protected]>Signed-off-by Tariq Toukan <[email protected]>
Quoted 8 lines
--- drivers/net/ethernet/mellanox/mlx5/core/en.h | 20 +- .../ethernet/mellanox/mlx5/core/en/params.c | 23 -- .../net/ethernet/mellanox/mlx5/core/en/txrx.h | 1 - .../net/ethernet/mellanox/mlx5/core/en_main.c | 287 +++++++-------- .../net/ethernet/mellanox/mlx5/core/en_rx.c | 341 +++--------------- 5 files changed, 188 insertions(+), 484 deletions(-)
Faster and less code is always a nice thing to see.
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 11 lines · On Wed, 4 Feb 2026 22:03:45 +0200 you wrote:
From: Dragos Tatulea <[email protected]>
Previously the HW-GRO code was using a separate
page_poolfor the header buffer. The pages of the header buffer were replenished via UMR. This mechanism has some drawbacks:
- Reference counting on thepage_poolpage frags is not cheap.
- UMRs have HW overhead for updating and also for access. Especially for the KLM type which was previously used.
- UMR code for headers is complex.[...]
Here is the summary with links:
- [net-next,V2] net/mlx5e: SHAMPO, Switch to header memcpy
https://git.kernel.org/netdev/net-next/c/24cf78c73831
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html