FAILED: patch "[PATCH] net/mlx5e: do not HW-GRO coalesce small frames" failed to apply to 6.6-stable tree
[email protected]
maintainerThe patch below does not apply to the 6.6-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.6.y
git checkout FETCH_HEAD
git cherry-pick -x e2466392a0b8496000e12181cb1ee1535eb0da25
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026090309-herbicide-eaten-1f09@gregkh' --subject-prefix 'PATCH 6.6.y' 'HEAD^..'
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From e2466392a0b8496000e12181cb1ee1535eb0da25 Mon Sep 17 00:00:00 2001
From: Glenn Judd <[email protected]>
Date: Sun, 16 Aug 2026 09:42:59 +0300
Subject: [PATCH] net/mlx5e: do not HW-GRO coalesce small frames
When hardware GRO (SHAMPO) coalesces a small IPv4/TCP segment that was padded up to the 60-byte minimum Ethernet frame, the trailing padding is folded into the merged payload causing padding to be delivered to the user as payload.
Detecting and reproducing the issue: the selftest tools/testing/selftests/drivers/net/gro.py subtest hw_ipv4_data_lrg_1byte sends {100, 1} expecting to receive {101}. In current code, it receives {106} (100 + 1 payload + 5 pad) instead.
This patch avoids giving the user padding as payload by simply not coalescing small packets (which fails the subtest; the same approach and behavior as sw gro). This gains code simplicity at the cost of more computation (passing an extra skb up the stack) for small packets that could be coalesced.
The threshold is chosen as ETH_ZLEN + 2 * VLAN_HLEN. This is the largest frame that may still contain minimum-frame padding (+ 2 VLAN tags), so anything larger is safe to consider for coalesce. (We do not include ETH_FCS_LEN in that threshold computation as netdev_fix_features() drops NETIF_F_GRO_HW whenever NETIF_F_RXFCS is set, so retained FCS can't reach this path.)
drivers/net/ethernet/mellanox/mlx5/core/en_rx.c +5 -0
@@ -2263,6 +2263,11 @@ static void mlx5e_handle_rx_cqe_mpwrq_shampo(struct mlx5e_rq *rq, struct mlx5_cq data_offset = wqe_offset & (page_size -1 ); page_idx = wqe_offset >> rq->mpwqe.page_shift; +if (unlikely (cqe_bcnt <=ETH_ZLEN +2 *VLAN_HLEN )) { + match = false; + flush = true; + } +if (*skb && !(match &&mlx5e_hw_gro_skb_has_enough_space (*skb, data_bcnt, page_size))) {
Sasha Levin
maintainerPATCH 1/4 net/mlx5e: SHAMPO, Specialize mlx5e_fill_skb_data()
From: Dragos Tatulea <[email protected]>
[ Upstream commit d34d7d1973c4d1125c430a9612d97bfc10cf6382 ]
mlx5e_fill_skb_data() used to have multiple callers. But after the XDP multibuf refactoring from commit 2cb0e27d43b4 ("net/mlx5e: RX, Prepare non-linear striding RQ for XDP multi-buffer support") the SHAMPO code path is the only caller.
Take advantage of this and specialize the function:
- Drop the redundant check.
- Assume that data_bcnt is > 0. This is needed in a downstream patch.
Rename the function as well to make things clear.
Stable-dep-of: e2466392a0b8 ("net/mlx5e: do not HW-GRO coalesce small frames")
--- .../net/ethernet/mellanox/mlx5/core/en_rx.c | 25 ++++++++----------- 1 file changed, 11 insertions(+), 14 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en_rx.c +11 -14
@@ -1985,21 +1985,16 @@ const struct mlx5e_rx_handlers mlx5e_rx_handlers_rep = {#endif static void -mlx5e_fill_skb_data (struct sk_buff *skb,struct mlx5e_rq *rq, -struct mlx5e_frag_page *frag_page, -u32 data_bcnt,u32 data_offset) +mlx5e_shampo_fill_skb_data(struct sk_buff *skb, struct mlx5e_rq *rq, + struct mlx5e_frag_page *frag_page, + u32 data_bcnt, u32 data_offset) { net_prefetchw(skb->data); -while (data_bcnt) { + do { /* Non-linear mode, hence non-XSK, which always uses PAGE_SIZE. */ u32 pg_consumed_bytes = min_t(u32, PAGE_SIZE - data_offset, data_bcnt); -unsigned int truesize; - -if (test_bit (MLX5E_RQ_STATE_SHAMPO , &rq->state)) - truesize = pg_consumed_bytes; -else - truesize =ALIGN (pg_consumed_bytes,BIT (rq->mpwqe.log_stride_sz)); + unsigned int truesize = pg_consumed_bytes; frag_page->frags++; mlx5e_add_skb_frag(rq, skb, frag_page->page, data_offset,
@@ -2008,7 +2003,7 @@ mlx5e_fill_skb_data(struct sk_buff *skb, struct mlx5e_rq *rq, data_bcnt -= pg_consumed_bytes; data_offset =0 ; frag_page++; - } + }while (data_bcnt); } static struct sk_buff *
@@ -2407,10 +2402,12 @@ static void mlx5e_handle_rx_cqe_mpwrq_shampo(struct mlx5e_rq *rq, struct mlx5_cq }if (likely (head_size)) { -struct mlx5e_frag_page *frag_page; +if (data_bcnt) { +struct mlx5e_frag_page *frag_page; - frag_page = &wi->alloc_units.frag_pages[page_idx]; -mlx5e_fill_skb_data (*skb, rq, frag_page, data_bcnt, data_offset); + frag_page = &wi->alloc_units.frag_pages[page_idx]; +mlx5e_shampo_fill_skb_data (*skb, rq, frag_page, data_bcnt, data_offset); + } }mlx5e_shampo_complete_rx_cqe (rq, cqe, cqe_bcnt, *skb);
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 2/4 net/mlx5e: SHAMPO, Drop rx_gro_match_packets counter
From: Dragos Tatulea <[email protected]>
[ Upstream commit 16f448d47a86825a421fc1211336454c42c5254f ]
After modifying rx_gro_packets to be more accurate, the rx_gro_match_packets counter is redundant.
Stable-dep-of: e2466392a0b8 ("net/mlx5e: do not HW-GRO coalesce small frames")
--- .../device_drivers/ethernet/mellanox/mlx5/counters.rst | 5 ----- drivers/net/ethernet/mellanox/mlx5/core/en_rx.c | 2 -- drivers/net/ethernet/mellanox/mlx5/core/en_stats.c | 3 --- drivers/net/ethernet/mellanox/mlx5/core/en_stats.h | 2 -- 4 files changed, 12 deletions(-)
Documentation/networking/device_drivers/ethernet/mellanox/mlx5/counters.rst +0 -5
@@ -202,11 +202,6 @@ the software port. hardware-accelerated GRO. - Informative - * - `rx[i]_gro_match_packets` - - Number of received packets processed using hardware-accelerated GRO that - met the flow table match criteria. - - Informative - * - `rx[i]_gro_large_hds` - Number of receive packets using hardware-accelerated GRO that have large headers that require additional memory to be allocated.
drivers/net/ethernet/mellanox/mlx5/core/en_rx.c +0 -2
@@ -2370,8 +2370,6 @@ static void mlx5e_handle_rx_cqe_mpwrq_shampo(struct mlx5e_rq *rq, struct mlx5_cq goto mpwrq_cqe_out; } - stats->gro_match_packets += match; -if (*skb && (!match || !(mlx5e_hw_gro_skb_has_enough_space (*skb, data_bcnt)))) { match = false;mlx5e_shampo_flush_skb (rq, cqe, match);
drivers/net/ethernet/mellanox/mlx5/core/en_stats.c +0 -3
@@ -136,7 +136,6 @@ static const struct counter_desc sw_stats_desc[] = { { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_gro_packets) }, { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_gro_bytes) }, { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_gro_skbs) }, - { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_gro_match_packets) }, { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_gro_large_hds) }, { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_ecn_mark) }, { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_removed_vlan_packets) },
@@ -338,7 +337,6 @@ static void mlx5e_stats_grp_sw_update_stats_rq_stats(struct mlx5e_sw_stats *s, s->rx_gro_packets += rq_stats->gro_packets; s->rx_gro_bytes += rq_stats->gro_bytes; s->rx_gro_skbs += rq_stats->gro_skbs; - s->rx_gro_match_packets += rq_stats->gro_match_packets; s->rx_gro_large_hds += rq_stats->gro_large_hds; s->rx_ecn_mark += rq_stats->ecn_mark; s->rx_removed_vlan_packets += rq_stats->removed_vlan_packets;
@@ -1988,7 +1986,6 @@ static const struct counter_desc rq_stats_desc[] = { { MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, gro_packets) }, { MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, gro_bytes) }, { MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, gro_skbs) }, - { MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, gro_match_packets) }, { MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, gro_large_hds) }, { MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, ecn_mark) }, { MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, removed_vlan_packets) },
drivers/net/ethernet/mellanox/mlx5/core/en_stats.h +0 -2
@@ -149,7 +149,6 @@ struct mlx5e_sw_stats {u64 rx_gro_packets;u64 rx_gro_bytes;u64 rx_gro_skbs; -u64 rx_gro_match_packets;u64 rx_gro_large_hds;u64 rx_mcast_packets;u64 rx_ecn_mark;
@@ -348,7 +347,6 @@ struct mlx5e_rq_stats {u64 gro_packets;u64 gro_bytes;u64 gro_skbs; -u64 gro_match_packets;u64 gro_large_hds;u64 mcast_packets;u64 ecn_mark;
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 3/4 net/mlx5e: SHAMPO, Always calculate page size
In reply to Sasha LevinFrom: Dragos Tatulea <[email protected]>
[ Upstream commit dff1c3164a69284ac9fedb1c25d4c008139e9fb8 ]
Adapt the rx path in SHAMPO mode to calculate page size based on configured page_shift when dealing with payload data.
This is necessary as an upcoming patch will add support for using different page sizes.
This change has no functional changes.
Stable-dep-of: e2466392a0b8 ("net/mlx5e: do not HW-GRO coalesce small frames")
--- .../net/ethernet/mellanox/mlx5/core/en_rx.c | 34 ++++++++++++------- 1 file changed, 22 insertions(+), 12 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en_rx.c +22 -12
@@ -1989,11 +1989,14 @@ mlx5e_shampo_fill_skb_data(struct sk_buff *skb, struct mlx5e_rq *rq,struct mlx5e_frag_page *frag_page, u32 data_bcnt, u32 data_offset) { + u32 page_size = BIT(rq->mpwqe.page_shift); +net_prefetchw (skb->data); do { /* Non-linear mode, hence non-XSK, which always uses PAGE_SIZE. */ - u32 pg_consumed_bytes = min_t(u32, PAGE_SIZE - data_offset, data_bcnt); + u32 pg_consumed_bytes = min_t(u32, page_size - data_offset, + data_bcnt); unsigned int truesize = pg_consumed_bytes; frag_page->frags++;
@@ -2015,6 +2018,7 @@ mlx5e_skb_from_cqe_mpwrq_nonlinear(struct mlx5e_rq *rq, struct mlx5e_mpw_info *wu16 headlen =min_t (u16,MLX5E_RX_MAX_HEAD , cqe_bcnt);struct mlx5e_frag_page *head_page = frag_page;struct mlx5e_xdp_buff *mxbuf = &rq->mxbuf; +u32 page_size =BIT (rq->mpwqe.page_shift);u32 frag_offset = head_offset;u32 byte_cnt = cqe_bcnt;struct skb_shared_info *sinfo;
@@ -2058,9 +2062,9 @@ mlx5e_skb_from_cqe_mpwrq_nonlinear(struct mlx5e_rq *rq, struct mlx5e_mpw_info *w linear_hr =skb_headroom (skb); linear_data_len = headlen; linear_frame_sz =MLX5_SKB_FRAG_SZ (skb_end_offset (skb)); -if (unlikely (frag_offset >=PAGE_SIZE )) { +if (unlikely (frag_offset >= page_size)) { frag_page++; - frag_offset -=PAGE_SIZE ; + frag_offset -= page_size; } }
@@ -2072,7 +2076,7 @@ mlx5e_skb_from_cqe_mpwrq_nonlinear(struct mlx5e_rq *rq, struct mlx5e_mpw_info *wwhile (byte_cnt) {/* Non-linear mode, hence non-XSK, which always uses PAGE_SIZE. */ pg_consumed_bytes = -min_t (u32,PAGE_SIZE - frag_offset, byte_cnt); +min_t (u32, page_size - frag_offset, byte_cnt);if (test_bit (MLX5E_RQ_STATE_SHAMPO , &rq->state)) truesize += pg_consumed_bytes;
@@ -2109,7 +2113,7 @@ mlx5e_skb_from_cqe_mpwrq_nonlinear(struct mlx5e_rq *rq, struct mlx5e_mpw_info *w nr_frags_free = old_nr_frags - sinfo->nr_frags;if (unlikely (nr_frags_free)) { frag_page -= nr_frags_free; - truesize -= (nr_frags_free -1 ) *PAGE_SIZE + + truesize -= (nr_frags_free -1 ) * page_size +ALIGN (pg_consumed_bytes,BIT (rq->mpwqe.log_stride_sz)); }
@@ -2311,15 +2315,16 @@ mlx5e_shampo_flush_skb(struct mlx5e_rq *rq, struct mlx5_cqe64 *cqe, bool match) rq->hw_gro_data->skb =NULL ; } -static bool -mlx5e_hw_gro_skb_has_enough_space (struct sk_buff *skb,u16 data_bcnt) +static bool mlx5e_hw_gro_skb_has_enough_space (struct sk_buff *skb, +u16 data_bcnt, +u32 page_size) {int nr_frags =skb_shinfo (skb)->nr_frags; -if (PAGE_SIZE >=GRO_LEGACY_MAX_SIZE ) +if (page_size >=GRO_LEGACY_MAX_SIZE )return skb->len + data_bcnt <=GRO_LEGACY_MAX_SIZE ;else -return PAGE_SIZE * nr_frags + data_bcnt <=GRO_LEGACY_MAX_SIZE ; +return page_size * nr_frags + data_bcnt <=GRO_LEGACY_MAX_SIZE ; } static void
@@ -2343,18 +2348,19 @@ static void mlx5e_handle_rx_cqe_mpwrq_shampo(struct mlx5e_rq *rq, struct mlx5_cqu16 header_index =mlx5e_shampo_get_cqe_header_index (rq, cqe);u32 wqe_offset =be32_to_cpu (cqe->shampo.data_offset);u16 cstrides =mpwrq_get_cqe_consumed_strides (cqe); -u32 data_offset = wqe_offset & (PAGE_SIZE -1 );u32 cqe_bcnt =mpwrq_get_cqe_byte_cnt (cqe);u16 wqe_id =be16_to_cpu (cqe->wqe_id); -u32 page_idx = wqe_offset >>PAGE_SHIFT ;u16 head_size = cqe->shampo.header_size;struct sk_buff **skb = &rq->hw_gro_data->skb;bool flush = cqe->shampo.flush;bool match = cqe->shampo.match; +u32 page_size =BIT (rq->mpwqe.page_shift);struct mlx5e_rq_stats *stats = rq->stats;struct mlx5e_rx_wqe_ll *wqe;struct mlx5e_mpw_info *wi;struct mlx5_wq_ll *wq; +u32 data_offset; +u32 page_idx; wi =mlx5e_get_mpw_info (rq, wqe_id); wi->consumed_strides += cstrides;
@@ -2370,7 +2376,11 @@ static void mlx5e_handle_rx_cqe_mpwrq_shampo(struct mlx5e_rq *rq, struct mlx5_cq goto mpwrq_cqe_out; } -if (*skb && (!match || !(mlx5e_hw_gro_skb_has_enough_space (*skb, data_bcnt)))) { + data_offset = wqe_offset & (page_size -1 ); + page_idx = wqe_offset >> rq->mpwqe.page_shift; +if (*skb && + !(match &&mlx5e_hw_gro_skb_has_enough_space (*skb, data_bcnt, + page_size))) { match = false;mlx5e_shampo_flush_skb (rq, cqe, match); }
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 4/4 net/mlx5e: do not HW-GRO coalesce small frames
In reply to Sasha LevinFrom: Glenn Judd <[email protected]>
[ Upstream commit e2466392a0b8496000e12181cb1ee1535eb0da25 ]
When hardware GRO (SHAMPO) coalesces a small IPv4/TCP segment that was padded up to the 60-byte minimum Ethernet frame, the trailing padding is folded into the merged payload causing padding to be delivered to the user as payload.
Detecting and reproducing the issue: the selftest tools/testing/selftests/drivers/net/gro.py subtest hw_ipv4_data_lrg_1byte sends {100, 1} expecting to receive {101}. In current code, it receives {106} (100 + 1 payload + 5 pad) instead.
This patch avoids giving the user padding as payload by simply not coalescing small packets (which fails the subtest; the same approach and behavior as sw gro). This gains code simplicity at the cost of more computation (passing an extra skb up the stack) for small packets that could be coalesced.
The threshold is chosen as ETH_ZLEN + 2 * VLAN_HLEN. This is the largest frame that may still contain minimum-frame padding (+ 2 VLAN tags), so anything larger is safe to consider for coalesce. (We do not include ETH_FCS_LEN in that threshold computation as netdev_fix_features() drops NETIF_F_GRO_HW whenever NETIF_F_RXFCS is set, so retained FCS can't reach this path.)
--- drivers/net/ethernet/mellanox/mlx5/core/en_rx.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/net/ethernet/mellanox/mlx5/core/en_rx.c +5 -0
@@ -2378,6 +2378,11 @@ static void mlx5e_handle_rx_cqe_mpwrq_shampo(struct mlx5e_rq *rq, struct mlx5_cq data_offset = wqe_offset & (page_size -1 ); page_idx = wqe_offset >> rq->mpwqe.page_shift; +if (unlikely (cqe_bcnt <=ETH_ZLEN +2 *VLAN_HLEN )) { + match = false; + flush = true; + } +if (*skb && !(match &&mlx5e_hw_gro_skb_has_enough_space (*skb, data_bcnt, page_size))) {
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/4 net/mlx5e: SHAMPO, Specialize mlx5e_fill_skb_data()
In reply to [email protected]From: Dragos Tatulea <[email protected]>
[ Upstream commit d34d7d1973c4d1125c430a9612d97bfc10cf6382 ]
mlx5e_fill_skb_data() used to have multiple callers. But after the XDP multibuf refactoring from commit 2cb0e27d43b4 ("net/mlx5e: RX, Prepare non-linear striding RQ for XDP multi-buffer support") the SHAMPO code path is the only caller.
Take advantage of this and specialize the function:
- Drop the redundant check.
- Assume that data_bcnt is > 0. This is needed in a downstream patch.
Rename the function as well to make things clear.
Stable-dep-of: e2466392a0b8 ("net/mlx5e: do not HW-GRO coalesce small frames")
--- .../net/ethernet/mellanox/mlx5/core/en_rx.c | 25 ++++++++----------- 1 file changed, 11 insertions(+), 14 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en_rx.c +11 -14
@@ -1985,21 +1985,16 @@ const struct mlx5e_rx_handlers mlx5e_rx_handlers_rep = {#endif static void -mlx5e_fill_skb_data (struct sk_buff *skb,struct mlx5e_rq *rq, -struct mlx5e_frag_page *frag_page, -u32 data_bcnt,u32 data_offset) +mlx5e_shampo_fill_skb_data(struct sk_buff *skb, struct mlx5e_rq *rq, + struct mlx5e_frag_page *frag_page, + u32 data_bcnt, u32 data_offset) { net_prefetchw(skb->data); -while (data_bcnt) { + do { /* Non-linear mode, hence non-XSK, which always uses PAGE_SIZE. */ u32 pg_consumed_bytes = min_t(u32, PAGE_SIZE - data_offset, data_bcnt); -unsigned int truesize; - -if (test_bit (MLX5E_RQ_STATE_SHAMPO , &rq->state)) - truesize = pg_consumed_bytes; -else - truesize =ALIGN (pg_consumed_bytes,BIT (rq->mpwqe.log_stride_sz)); + unsigned int truesize = pg_consumed_bytes; frag_page->frags++; mlx5e_add_skb_frag(rq, skb, frag_page->page, data_offset,
@@ -2008,7 +2003,7 @@ mlx5e_fill_skb_data(struct sk_buff *skb, struct mlx5e_rq *rq, data_bcnt -= pg_consumed_bytes; data_offset =0 ; frag_page++; - } + }while (data_bcnt); } static struct sk_buff *
@@ -2407,10 +2402,12 @@ static void mlx5e_handle_rx_cqe_mpwrq_shampo(struct mlx5e_rq *rq, struct mlx5_cq }if (likely (head_size)) { -struct mlx5e_frag_page *frag_page; +if (data_bcnt) { +struct mlx5e_frag_page *frag_page; - frag_page = &wi->alloc_units.frag_pages[page_idx]; -mlx5e_fill_skb_data (*skb, rq, frag_page, data_bcnt, data_offset); + frag_page = &wi->alloc_units.frag_pages[page_idx]; +mlx5e_shampo_fill_skb_data (*skb, rq, frag_page, data_bcnt, data_offset); + } }mlx5e_shampo_complete_rx_cqe (rq, cqe, cqe_bcnt, *skb);
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 2/4 net/mlx5e: SHAMPO, Drop rx_gro_match_packets counter
From: Dragos Tatulea <[email protected]>
[ Upstream commit 16f448d47a86825a421fc1211336454c42c5254f ]
After modifying rx_gro_packets to be more accurate, the rx_gro_match_packets counter is redundant.
Stable-dep-of: e2466392a0b8 ("net/mlx5e: do not HW-GRO coalesce small frames")
--- .../device_drivers/ethernet/mellanox/mlx5/counters.rst | 5 ----- drivers/net/ethernet/mellanox/mlx5/core/en_rx.c | 2 -- drivers/net/ethernet/mellanox/mlx5/core/en_stats.c | 3 --- drivers/net/ethernet/mellanox/mlx5/core/en_stats.h | 2 -- 4 files changed, 12 deletions(-)
Documentation/networking/device_drivers/ethernet/mellanox/mlx5/counters.rst +0 -5
@@ -202,11 +202,6 @@ the software port. hardware-accelerated GRO. - Informative - * - `rx[i]_gro_match_packets` - - Number of received packets processed using hardware-accelerated GRO that - met the flow table match criteria. - - Informative - * - `rx[i]_gro_large_hds` - Number of receive packets using hardware-accelerated GRO that have large headers that require additional memory to be allocated.
drivers/net/ethernet/mellanox/mlx5/core/en_rx.c +0 -2
@@ -2370,8 +2370,6 @@ static void mlx5e_handle_rx_cqe_mpwrq_shampo(struct mlx5e_rq *rq, struct mlx5_cq goto mpwrq_cqe_out; } - stats->gro_match_packets += match; -if (*skb && (!match || !(mlx5e_hw_gro_skb_has_enough_space (*skb, data_bcnt)))) { match = false;mlx5e_shampo_flush_skb (rq, cqe, match);
drivers/net/ethernet/mellanox/mlx5/core/en_stats.c +0 -3
@@ -136,7 +136,6 @@ static const struct counter_desc sw_stats_desc[] = { { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_gro_packets) }, { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_gro_bytes) }, { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_gro_skbs) }, - { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_gro_match_packets) }, { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_gro_large_hds) }, { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_ecn_mark) }, { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_removed_vlan_packets) },
@@ -338,7 +337,6 @@ static void mlx5e_stats_grp_sw_update_stats_rq_stats(struct mlx5e_sw_stats *s, s->rx_gro_packets += rq_stats->gro_packets; s->rx_gro_bytes += rq_stats->gro_bytes; s->rx_gro_skbs += rq_stats->gro_skbs; - s->rx_gro_match_packets += rq_stats->gro_match_packets; s->rx_gro_large_hds += rq_stats->gro_large_hds; s->rx_ecn_mark += rq_stats->ecn_mark; s->rx_removed_vlan_packets += rq_stats->removed_vlan_packets;
@@ -1988,7 +1986,6 @@ static const struct counter_desc rq_stats_desc[] = { { MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, gro_packets) }, { MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, gro_bytes) }, { MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, gro_skbs) }, - { MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, gro_match_packets) }, { MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, gro_large_hds) }, { MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, ecn_mark) }, { MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, removed_vlan_packets) },
drivers/net/ethernet/mellanox/mlx5/core/en_stats.h +0 -2
@@ -149,7 +149,6 @@ struct mlx5e_sw_stats {u64 rx_gro_packets;u64 rx_gro_bytes;u64 rx_gro_skbs; -u64 rx_gro_match_packets;u64 rx_gro_large_hds;u64 rx_mcast_packets;u64 rx_ecn_mark;
@@ -348,7 +347,6 @@ struct mlx5e_rq_stats {u64 gro_packets;u64 gro_bytes;u64 gro_skbs; -u64 gro_match_packets;u64 gro_large_hds;u64 mcast_packets;u64 ecn_mark;
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 3/4 net/mlx5e: SHAMPO, Always calculate page size
In reply to Sasha LevinFrom: Dragos Tatulea <[email protected]>
[ Upstream commit dff1c3164a69284ac9fedb1c25d4c008139e9fb8 ]
Adapt the rx path in SHAMPO mode to calculate page size based on configured page_shift when dealing with payload data.
This is necessary as an upcoming patch will add support for using different page sizes.
This change has no functional changes.
Stable-dep-of: e2466392a0b8 ("net/mlx5e: do not HW-GRO coalesce small frames")
--- .../net/ethernet/mellanox/mlx5/core/en_rx.c | 34 ++++++++++++------- 1 file changed, 22 insertions(+), 12 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en_rx.c +22 -12
@@ -1989,11 +1989,14 @@ mlx5e_shampo_fill_skb_data(struct sk_buff *skb, struct mlx5e_rq *rq,struct mlx5e_frag_page *frag_page, u32 data_bcnt, u32 data_offset) { + u32 page_size = BIT(rq->mpwqe.page_shift); +net_prefetchw (skb->data); do { /* Non-linear mode, hence non-XSK, which always uses PAGE_SIZE. */ - u32 pg_consumed_bytes = min_t(u32, PAGE_SIZE - data_offset, data_bcnt); + u32 pg_consumed_bytes = min_t(u32, page_size - data_offset, + data_bcnt); unsigned int truesize = pg_consumed_bytes; frag_page->frags++;
@@ -2015,6 +2018,7 @@ mlx5e_skb_from_cqe_mpwrq_nonlinear(struct mlx5e_rq *rq, struct mlx5e_mpw_info *wu16 headlen =min_t (u16,MLX5E_RX_MAX_HEAD , cqe_bcnt);struct mlx5e_frag_page *head_page = frag_page;struct mlx5e_xdp_buff *mxbuf = &rq->mxbuf; +u32 page_size =BIT (rq->mpwqe.page_shift);u32 frag_offset = head_offset;u32 byte_cnt = cqe_bcnt;struct skb_shared_info *sinfo;
@@ -2058,9 +2062,9 @@ mlx5e_skb_from_cqe_mpwrq_nonlinear(struct mlx5e_rq *rq, struct mlx5e_mpw_info *w linear_hr =skb_headroom (skb); linear_data_len = headlen; linear_frame_sz =MLX5_SKB_FRAG_SZ (skb_end_offset (skb)); -if (unlikely (frag_offset >=PAGE_SIZE )) { +if (unlikely (frag_offset >= page_size)) { frag_page++; - frag_offset -=PAGE_SIZE ; + frag_offset -= page_size; } }
@@ -2072,7 +2076,7 @@ mlx5e_skb_from_cqe_mpwrq_nonlinear(struct mlx5e_rq *rq, struct mlx5e_mpw_info *wwhile (byte_cnt) {/* Non-linear mode, hence non-XSK, which always uses PAGE_SIZE. */ pg_consumed_bytes = -min_t (u32,PAGE_SIZE - frag_offset, byte_cnt); +min_t (u32, page_size - frag_offset, byte_cnt);if (test_bit (MLX5E_RQ_STATE_SHAMPO , &rq->state)) truesize += pg_consumed_bytes;
@@ -2109,7 +2113,7 @@ mlx5e_skb_from_cqe_mpwrq_nonlinear(struct mlx5e_rq *rq, struct mlx5e_mpw_info *w nr_frags_free = old_nr_frags - sinfo->nr_frags;if (unlikely (nr_frags_free)) { frag_page -= nr_frags_free; - truesize -= (nr_frags_free -1 ) *PAGE_SIZE + + truesize -= (nr_frags_free -1 ) * page_size +ALIGN (pg_consumed_bytes,BIT (rq->mpwqe.log_stride_sz)); }
@@ -2311,15 +2315,16 @@ mlx5e_shampo_flush_skb(struct mlx5e_rq *rq, struct mlx5_cqe64 *cqe, bool match) rq->hw_gro_data->skb =NULL ; } -static bool -mlx5e_hw_gro_skb_has_enough_space (struct sk_buff *skb,u16 data_bcnt) +static bool mlx5e_hw_gro_skb_has_enough_space (struct sk_buff *skb, +u16 data_bcnt, +u32 page_size) {int nr_frags =skb_shinfo (skb)->nr_frags; -if (PAGE_SIZE >=GRO_LEGACY_MAX_SIZE ) +if (page_size >=GRO_LEGACY_MAX_SIZE )return skb->len + data_bcnt <=GRO_LEGACY_MAX_SIZE ;else -return PAGE_SIZE * nr_frags + data_bcnt <=GRO_LEGACY_MAX_SIZE ; +return page_size * nr_frags + data_bcnt <=GRO_LEGACY_MAX_SIZE ; } static void
@@ -2343,18 +2348,19 @@ static void mlx5e_handle_rx_cqe_mpwrq_shampo(struct mlx5e_rq *rq, struct mlx5_cqu16 header_index =mlx5e_shampo_get_cqe_header_index (rq, cqe);u32 wqe_offset =be32_to_cpu (cqe->shampo.data_offset);u16 cstrides =mpwrq_get_cqe_consumed_strides (cqe); -u32 data_offset = wqe_offset & (PAGE_SIZE -1 );u32 cqe_bcnt =mpwrq_get_cqe_byte_cnt (cqe);u16 wqe_id =be16_to_cpu (cqe->wqe_id); -u32 page_idx = wqe_offset >>PAGE_SHIFT ;u16 head_size = cqe->shampo.header_size;struct sk_buff **skb = &rq->hw_gro_data->skb;bool flush = cqe->shampo.flush;bool match = cqe->shampo.match; +u32 page_size =BIT (rq->mpwqe.page_shift);struct mlx5e_rq_stats *stats = rq->stats;struct mlx5e_rx_wqe_ll *wqe;struct mlx5e_mpw_info *wi;struct mlx5_wq_ll *wq; +u32 data_offset; +u32 page_idx; wi =mlx5e_get_mpw_info (rq, wqe_id); wi->consumed_strides += cstrides;
@@ -2370,7 +2376,11 @@ static void mlx5e_handle_rx_cqe_mpwrq_shampo(struct mlx5e_rq *rq, struct mlx5_cq goto mpwrq_cqe_out; } -if (*skb && (!match || !(mlx5e_hw_gro_skb_has_enough_space (*skb, data_bcnt)))) { + data_offset = wqe_offset & (page_size -1 ); + page_idx = wqe_offset >> rq->mpwqe.page_shift; +if (*skb && + !(match &&mlx5e_hw_gro_skb_has_enough_space (*skb, data_bcnt, + page_size))) { match = false;mlx5e_shampo_flush_skb (rq, cqe, match); }
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 4/4 net/mlx5e: do not HW-GRO coalesce small frames
In reply to Sasha LevinFrom: Glenn Judd <[email protected]>
[ Upstream commit e2466392a0b8496000e12181cb1ee1535eb0da25 ]
When hardware GRO (SHAMPO) coalesces a small IPv4/TCP segment that was padded up to the 60-byte minimum Ethernet frame, the trailing padding is folded into the merged payload causing padding to be delivered to the user as payload.
Detecting and reproducing the issue: the selftest tools/testing/selftests/drivers/net/gro.py subtest hw_ipv4_data_lrg_1byte sends {100, 1} expecting to receive {101}. In current code, it receives {106} (100 + 1 payload + 5 pad) instead.
This patch avoids giving the user padding as payload by simply not coalescing small packets (which fails the subtest; the same approach and behavior as sw gro). This gains code simplicity at the cost of more computation (passing an extra skb up the stack) for small packets that could be coalesced.
The threshold is chosen as ETH_ZLEN + 2 * VLAN_HLEN. This is the largest frame that may still contain minimum-frame padding (+ 2 VLAN tags), so anything larger is safe to consider for coalesce. (We do not include ETH_FCS_LEN in that threshold computation as netdev_fix_features() drops NETIF_F_GRO_HW whenever NETIF_F_RXFCS is set, so retained FCS can't reach this path.)
--- drivers/net/ethernet/mellanox/mlx5/core/en_rx.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/net/ethernet/mellanox/mlx5/core/en_rx.c +5 -0
@@ -2378,6 +2378,11 @@ static void mlx5e_handle_rx_cqe_mpwrq_shampo(struct mlx5e_rq *rq, struct mlx5_cq data_offset = wqe_offset & (page_size -1 ); page_idx = wqe_offset >> rq->mpwqe.page_shift; +if (unlikely (cqe_bcnt <=ETH_ZLEN +2 *VLAN_HLEN )) { + match = false; + flush = true; + } +if (*skb && !(match &&mlx5e_hw_gro_skb_has_enough_space (*skb, data_bcnt, page_size))) {
Signature · 1 line
2.53.0