linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] net: dsa: ksz: pad frame to 64 bytes for transmission
@ 2020-11-29 10:23 Jean Pihet
  2020-11-29 10:24 ` [PATCH 2/2] net: dsa: ksz8795: adjust CPU link to host interface Jean Pihet
                   ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Jean Pihet @ 2020-11-29 10:23 UTC (permalink / raw)
  To: netdev, linux-kernel
  Cc: Ryan Barnett, Conrad Ratschan, Hugo Cornelis,
	Arnout Vandecappelle, Jean Pihet

Some ethernet controllers (e.g. TI CPSW) pad the frames to a minimum
of 64 bytes before the FCS is appended. This causes an issue with the
KSZ tail tag which could not be the last byte before the FCS.
Solve this by padding the frame to 64 bytes minus the tail tag size,
before the tail tag is added and the frame is passed for transmission.

Signed-off-by: Jean Pihet <jean.pihet@newoldbits.com>
---
 net/dsa/tag_ksz.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/net/dsa/tag_ksz.c b/net/dsa/tag_ksz.c
index 0a5aa982c60d..0074702dcbbc 100644
--- a/net/dsa/tag_ksz.c
+++ b/net/dsa/tag_ksz.c
@@ -19,8 +19,13 @@ static struct sk_buff *ksz_common_xmit(struct sk_buff *skb,
 {
 	struct sk_buff *nskb;
 	int padlen;
+	const int min_len = ETH_ZLEN + ETH_FCS_LEN;
 
-	padlen = (skb->len >= ETH_ZLEN) ? 0 : ETH_ZLEN - skb->len;
+	/*
+	 * Pad to the minimum ethernet frame size, minus the size of the
+	 * tail tag which will be appended at the very end, before the FCS.
+	 */
+	padlen = (skb->len >= min_len) ? 0 : min_len - skb->len - len;
 
 	if (skb_tailroom(skb) >= padlen + len) {
 		/* Let dsa_slave_xmit() free skb */
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2020-11-29 19:49 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-29 10:23 [PATCH 1/2] net: dsa: ksz: pad frame to 64 bytes for transmission Jean Pihet
2020-11-29 10:24 ` [PATCH 2/2] net: dsa: ksz8795: adjust CPU link to host interface Jean Pihet
2020-11-29 12:51   ` kernel test robot
2020-11-29 12:51   ` [RFC PATCH] net: dsa: ksz8795: ksz8795_adjust_link() can be static kernel test robot
2020-11-29 13:17   ` [PATCH 2/2] net: dsa: ksz8795: adjust CPU link to host interface kernel test robot
2020-11-29 17:07   ` Andrew Lunn
2020-11-29 16:56 ` [PATCH 1/2] net: dsa: ksz: pad frame to 64 bytes for transmission Andrew Lunn
2020-11-29 19:34   ` Jean Pihet
2020-11-29 19:38     ` Andrew Lunn
2020-11-29 19:48       ` Jean Pihet
2020-11-29 16:57 ` Andrew Lunn
2020-11-29 19:35   ` Jean Pihet

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).