diff mbox series

[U-Boot,v4,2/4] net: designware: Pad small packets

Message ID 20171209225957.23458-3-f.fainelli@gmail.com
State Accepted
Commit a409d91
Delegated to: Joe Hershberger
Headers show
Series net: phy: Add Broadcom BCM53xx switch driver | expand

Commit Message

Florian Fainelli Dec. 9, 2017, 10:59 p.m. UTC
Make sure that we pad small packets to a minimum length of 60 bytes
(without FCS). This is necessary to interface with Ethernet switches
that will reject RUNT frames unless padded correctly.

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
 drivers/net/designware.c | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Stefan Roese Dec. 11, 2017, 5:47 a.m. UTC | #1
On 09.12.2017 23:59, Florian Fainelli wrote:
> Make sure that we pad small packets to a minimum length of 60 bytes
> (without FCS). This is necessary to interface with Ethernet switches
> that will reject RUNT frames unless padded correctly.
> 
> Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>

Reviewed-by: Stefan Roese <sr@denx.de>

Thanks,
Stefan
Joe Hershberger Dec. 11, 2017, 4:48 p.m. UTC | #2
On Sat, Dec 9, 2017 at 4:59 PM, Florian Fainelli <f.fainelli@gmail.com> wrote:
> Make sure that we pad small packets to a minimum length of 60 bytes
> (without FCS). This is necessary to interface with Ethernet switches
> that will reject RUNT frames unless padded correctly.
>
> Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>

Acked-by: Joe Hershberger <joe.hershberger@ni.com>
Joe Hershberger Jan. 22, 2018, 4:49 p.m. UTC | #3
Hi Florian,

https://patchwork.ozlabs.org/patch/846613/ was applied to http://git.denx.de/?p=u-boot/u-boot-net.git

Thanks!
-Joe
diff mbox series

Patch

diff --git a/drivers/net/designware.c b/drivers/net/designware.c
index 036d231071ca..56fa0ebd8f31 100644
--- a/drivers/net/designware.c
+++ b/drivers/net/designware.c
@@ -17,6 +17,7 @@ 
 #include <pci.h>
 #include <linux/compiler.h>
 #include <linux/err.h>
+#include <linux/kernel.h>
 #include <asm/io.h>
 #include <power/regulator.h>
 #include "designware.h"
@@ -343,6 +344,8 @@  int designware_eth_enable(struct dw_eth_dev *priv)
 	return 0;
 }
 
+#define ETH_ZLEN	60
+
 static int _dw_eth_send(struct dw_eth_dev *priv, void *packet, int length)
 {
 	struct eth_dma_regs *dma_p = priv->dma_regs_p;
@@ -369,6 +372,8 @@  static int _dw_eth_send(struct dw_eth_dev *priv, void *packet, int length)
 		return -EPERM;
 	}
 
+	length = max(length, ETH_ZLEN);
+
 	memcpy((void *)data_start, packet, length);
 
 	/* Flush data to be sent */