Skip to content

Commit 4d215ae

Browse files
ffainellidavem330
authored andcommitted
net: bgmac: Pad packets to a minimum size
In preparation for enabling Broadcom tags with b53, pad packets to a minimum size of 64 bytes (sans FCS) in order for the Broadcom switch to accept ingressing frames. Without this, we would typically be able to DHCP, but not resolve with ARP because packets are too small and get rejected by the switch. Signed-off-by: Florian Fainelli <f.fainelli@gmail.com> Reviewed-by: Andrew Lunn <andrew@lunn.ch> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent f444ef5 commit 4d215ae

File tree

1 file changed

+16
-0
lines changed
  • drivers/net/ethernet/broadcom

1 file changed

+16
-0
lines changed

drivers/net/ethernet/broadcom/bgmac.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <linux/bcm47xx_nvram.h>
1616
#include <linux/phy.h>
1717
#include <linux/phy_fixed.h>
18+
#include <net/dsa.h>
1819
#include "bgmac.h"
1920

2021
static bool bgmac_wait_value(struct bgmac *bgmac, u16 reg, u32 mask,
@@ -127,6 +128,8 @@ bgmac_dma_tx_add_buf(struct bgmac *bgmac, struct bgmac_dma_ring *ring,
127128
dma_desc->ctl1 = cpu_to_le32(ctl1);
128129
}
129130

131+
#define ENET_BRCM_TAG_LEN 4
132+
130133
static netdev_tx_t bgmac_dma_tx_add(struct bgmac *bgmac,
131134
struct bgmac_dma_ring *ring,
132135
struct sk_buff *skb)
@@ -139,6 +142,18 @@ static netdev_tx_t bgmac_dma_tx_add(struct bgmac *bgmac,
139142
u32 flags;
140143
int i;
141144

145+
/* The Ethernet switch we are interfaced with needs packets to be at
146+
* least 64 bytes (including FCS) otherwise they will be discarded when
147+
* they enter the switch port logic. When Broadcom tags are enabled, we
148+
* need to make sure that packets are at least 68 bytes
149+
* (including FCS and tag) because the length verification is done after
150+
* the Broadcom tag is stripped off the ingress packet.
151+
*/
152+
if (netdev_uses_dsa(net_dev)) {
153+
if (skb_put_padto(skb, ETH_ZLEN + ENET_BRCM_TAG_LEN))
154+
goto err_stats;
155+
}
156+
142157
if (skb->len > BGMAC_DESC_CTL1_LEN) {
143158
netdev_err(bgmac->net_dev, "Too long skb (%d)\n", skb->len);
144159
goto err_drop;
@@ -225,6 +240,7 @@ static netdev_tx_t bgmac_dma_tx_add(struct bgmac *bgmac,
225240

226241
err_drop:
227242
dev_kfree_skb(skb);
243+
err_stats:
228244
net_dev->stats.tx_dropped++;
229245
net_dev->stats.tx_errors++;
230246
return NETDEV_TX_OK;

0 commit comments

Comments
 (0)