diff mbox series

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

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

Commit Message

Florian Fainelli Oct. 15, 2017, 1 a.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 | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Stefan Roese Oct. 16, 2017, 9:36 a.m. UTC | #1
On 15.10.2017 03:00, 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. 5, 2017, 8:27 p.m. UTC | #2
On Sat, Oct 14, 2017 at 8:00 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>
> ---
>  drivers/net/designware.c | 4 ++++
>  1 file changed, 4 insertions(+)
>
> diff --git a/drivers/net/designware.c b/drivers/net/designware.c
> index 036d231071ca..10356a9abd0e 100644
> --- a/drivers/net/designware.c
> +++ b/drivers/net/designware.c
> @@ -343,6 +343,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 +371,8 @@ static int _dw_eth_send(struct dw_eth_dev *priv, void *packet, int length)
>                 return -EPERM;
>         }
>
> +       length = (length < ETH_ZLEN) ? ETH_ZLEN : length;

Why not use max() from include/linux/kernel.h here?


> +
>         memcpy((void *)data_start, packet, length);
>
>         /* Flush data to be sent */
> --
> 2.11.0
diff mbox series

Patch

diff --git a/drivers/net/designware.c b/drivers/net/designware.c
index 036d231071ca..10356a9abd0e 100644
--- a/drivers/net/designware.c
+++ b/drivers/net/designware.c
@@ -343,6 +343,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 +371,8 @@  static int _dw_eth_send(struct dw_eth_dev *priv, void *packet, int length)
 		return -EPERM;
 	}
 
+	length = (length < ETH_ZLEN) ? ETH_ZLEN : length;
+
 	memcpy((void *)data_start, packet, length);
 
 	/* Flush data to be sent */