* [PATCH] drivers: net: xgene: Fix regression in CRC stripping
@ 2022-03-17 14:42 Stéphane Graber
2022-03-18 21:12 ` Jakub Kicinski
0 siblings, 1 reply; 4+ messages in thread
From: Stéphane Graber @ 2022-03-17 14:42 UTC (permalink / raw)
To: netdev
Cc: linux-kernel, Iyappan Subramanian, Keyur Chudgar, Quan Nguyen,
David S . Miller, Jakub Kicinski, Toan Le, Stephane Graber,
stable
From: Stephane Graber <stgraber@ubuntu.com>
All packets on ingress (except for jumbo) are terminated with a 4-bytes
CRC checksum. It's the responsability of the driver to strip those 4
bytes. Unfortunately a change dating back to March 2017 re-shuffled some
code and made the CRC stripping code effectively dead.
This change re-orders that part a bit such that the datalen is
immediately altered if needed.
Fixes: 4902a92270fb ("drivers: net: xgene: Add workaround for errata 10GE_8/ENET_11")
Signed-off-by: Stephane Graber <stgraber@ubuntu.com>
Tested-by: Stephane Graber <stgraber@ubuntu.com>
Cc: stable@vger.kernel.org
---
drivers/net/ethernet/apm/xgene/xgene_enet_main.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/drivers/net/ethernet/apm/xgene/xgene_enet_main.c b/drivers/net/ethernet/apm/xgene/xgene_enet_main.c
index ff2d099aab21..3892790f04e0 100644
--- a/drivers/net/ethernet/apm/xgene/xgene_enet_main.c
+++ b/drivers/net/ethernet/apm/xgene/xgene_enet_main.c
@@ -696,6 +696,12 @@ static int xgene_enet_rx_frame(struct xgene_enet_desc_ring *rx_ring,
buf_pool->rx_skb[skb_index] = NULL;
datalen = xgene_enet_get_data_len(le64_to_cpu(raw_desc->m1));
+
+ /* strip off CRC as HW isn't doing this */
+ nv = GET_VAL(NV, le64_to_cpu(raw_desc->m0));
+ if (!nv)
+ datalen -= 4;
+
skb_put(skb, datalen);
prefetch(skb->data - NET_IP_ALIGN);
skb->protocol = eth_type_trans(skb, ndev);
@@ -717,10 +723,7 @@ static int xgene_enet_rx_frame(struct xgene_enet_desc_ring *rx_ring,
}
}
- nv = GET_VAL(NV, le64_to_cpu(raw_desc->m0));
if (!nv) {
- /* strip off CRC as HW isn't doing this */
- datalen -= 4;
goto skip_jumbo;
}
--
2.34.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] drivers: net: xgene: Fix regression in CRC stripping
2022-03-17 14:42 [PATCH] drivers: net: xgene: Fix regression in CRC stripping Stéphane Graber
@ 2022-03-18 21:12 ` Jakub Kicinski
2022-03-22 22:42 ` [PATCH v2] " Stéphane Graber
0 siblings, 1 reply; 4+ messages in thread
From: Jakub Kicinski @ 2022-03-18 21:12 UTC (permalink / raw)
To: Stéphane Graber
Cc: netdev, linux-kernel, Iyappan Subramanian, Keyur Chudgar,
Quan Nguyen, David S . Miller, Toan Le, stable
On Thu, 17 Mar 2022 10:42:25 -0400 Stéphane Graber wrote:
> From: Stephane Graber <stgraber@ubuntu.com>
>
> All packets on ingress (except for jumbo) are terminated with a 4-bytes
> CRC checksum. It's the responsability of the driver to strip those 4
> bytes. Unfortunately a change dating back to March 2017 re-shuffled some
> code and made the CRC stripping code effectively dead.
>
> This change re-orders that part a bit such that the datalen is
> immediately altered if needed.
>
> Fixes: 4902a92270fb ("drivers: net: xgene: Add workaround for errata 10GE_8/ENET_11")
> Signed-off-by: Stephane Graber <stgraber@ubuntu.com>
> Tested-by: Stephane Graber <stgraber@ubuntu.com>
> Cc: stable@vger.kernel.org
> ---
> drivers/net/ethernet/apm/xgene/xgene_enet_main.c | 9 ++++++---
> 1 file changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/net/ethernet/apm/xgene/xgene_enet_main.c b/drivers/net/ethernet/apm/xgene/xgene_enet_main.c
> index ff2d099aab21..3892790f04e0 100644
> --- a/drivers/net/ethernet/apm/xgene/xgene_enet_main.c
> +++ b/drivers/net/ethernet/apm/xgene/xgene_enet_main.c
> @@ -696,6 +696,12 @@ static int xgene_enet_rx_frame(struct xgene_enet_desc_ring *rx_ring,
> buf_pool->rx_skb[skb_index] = NULL;
>
> datalen = xgene_enet_get_data_len(le64_to_cpu(raw_desc->m1));
> +
> + /* strip off CRC as HW isn't doing this */
> + nv = GET_VAL(NV, le64_to_cpu(raw_desc->m0));
> + if (!nv)
> + datalen -= 4;
Alternatively we could call skb_trim() below to remove the FCS.
You call, but..
> skb_put(skb, datalen);
> prefetch(skb->data - NET_IP_ALIGN);
> skb->protocol = eth_type_trans(skb, ndev);
> @@ -717,10 +723,7 @@ static int xgene_enet_rx_frame(struct xgene_enet_desc_ring *rx_ring,
> }
> }
>
> - nv = GET_VAL(NV, le64_to_cpu(raw_desc->m0));
> if (!nv) {
> - /* strip off CRC as HW isn't doing this */
> - datalen -= 4;
> goto skip_jumbo;
> }
If you stick to moving the datalen adjustments this if will have a
single statement so according to the kernel code style it has to lose
the brackets.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v2] drivers: net: xgene: Fix regression in CRC stripping
2022-03-18 21:12 ` Jakub Kicinski
@ 2022-03-22 22:42 ` Stéphane Graber
2022-03-23 17:40 ` patchwork-bot+netdevbpf
0 siblings, 1 reply; 4+ messages in thread
From: Stéphane Graber @ 2022-03-22 22:42 UTC (permalink / raw)
To: kuba
Cc: davem, iyappan, keyur, linux-kernel, netdev, quan, stable,
stgraber, toan
From: Stephane Graber <stgraber@ubuntu.com>
All packets on ingress (except for jumbo) are terminated with a 4-bytes
CRC checksum. It's the responsability of the driver to strip those 4
bytes. Unfortunately a change dating back to March 2017 re-shuffled some
code and made the CRC stripping code effectively dead.
This change re-orders that part a bit such that the datalen is
immediately altered if needed.
Fixes: 4902a92270fb ("drivers: net: xgene: Add workaround for errata 10GE_8/ENET_11")
Signed-off-by: Stephane Graber <stgraber@ubuntu.com>
Tested-by: Stephane Graber <stgraber@ubuntu.com>
Cc: Jakub Kicinski <kuba@kernel.org>
Cc: stable@vger.kernel.org
---
drivers/net/ethernet/apm/xgene/xgene_enet_main.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/drivers/net/ethernet/apm/xgene/xgene_enet_main.c b/drivers/net/ethernet/apm/xgene/xgene_enet_main.c
index ff2d099aab21..53dc8d5fede8 100644
--- a/drivers/net/ethernet/apm/xgene/xgene_enet_main.c
+++ b/drivers/net/ethernet/apm/xgene/xgene_enet_main.c
@@ -696,6 +696,12 @@ static int xgene_enet_rx_frame(struct xgene_enet_desc_ring *rx_ring,
buf_pool->rx_skb[skb_index] = NULL;
datalen = xgene_enet_get_data_len(le64_to_cpu(raw_desc->m1));
+
+ /* strip off CRC as HW isn't doing this */
+ nv = GET_VAL(NV, le64_to_cpu(raw_desc->m0));
+ if (!nv)
+ datalen -= 4;
+
skb_put(skb, datalen);
prefetch(skb->data - NET_IP_ALIGN);
skb->protocol = eth_type_trans(skb, ndev);
@@ -717,12 +723,8 @@ static int xgene_enet_rx_frame(struct xgene_enet_desc_ring *rx_ring,
}
}
- nv = GET_VAL(NV, le64_to_cpu(raw_desc->m0));
- if (!nv) {
- /* strip off CRC as HW isn't doing this */
- datalen -= 4;
+ if (!nv)
goto skip_jumbo;
- }
slots = page_pool->slots - 1;
head = page_pool->head;
--
2.34.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v2] drivers: net: xgene: Fix regression in CRC stripping
2022-03-22 22:42 ` [PATCH v2] " Stéphane Graber
@ 2022-03-23 17:40 ` patchwork-bot+netdevbpf
0 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-03-23 17:40 UTC (permalink / raw)
To: =?utf-8?q?St=C3=A9phane_Graber_=3Cstgraber=40ubuntu=2Ecom=3E?=
Cc: kuba, davem, iyappan, keyur, linux-kernel, netdev, quan, stable, toan
Hello:
This patch was applied to netdev/net-next.git (master)
by Jakub Kicinski <kuba@kernel.org>:
On Tue, 22 Mar 2022 18:42:06 -0400 you wrote:
> From: Stephane Graber <stgraber@ubuntu.com>
>
> All packets on ingress (except for jumbo) are terminated with a 4-bytes
> CRC checksum. It's the responsability of the driver to strip those 4
> bytes. Unfortunately a change dating back to March 2017 re-shuffled some
> code and made the CRC stripping code effectively dead.
>
> [...]
Here is the summary with links:
- [v2] drivers: net: xgene: Fix regression in CRC stripping
https://git.kernel.org/netdev/net-next/c/e9e6faeafaa0
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-03-23 17:40 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-17 14:42 [PATCH] drivers: net: xgene: Fix regression in CRC stripping Stéphane Graber
2022-03-18 21:12 ` Jakub Kicinski
2022-03-22 22:42 ` [PATCH v2] " Stéphane Graber
2022-03-23 17:40 ` patchwork-bot+netdevbpf
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).