Skip to content

Commit 652ef42

Browse files
atenartdavem330
authored andcommitted
net: mscc: fix the frame extraction into the skb
When extracting frames from the Ocelot switch, the frame check sequence (FCS) is present at the end of the data extracted. The FCS was put into the sk buffer which introduced some issues (as length related ones), as the FCS shouldn't be part of an Rx sk buffer. This patch fixes the Ocelot switch extraction behaviour by discarding the FCS. Fixes: a556c76 ("net: mscc: Add initial Ocelot switch support") Signed-off-by: Antoine Tenart <antoine.tenart@bootlin.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 10bc6a6 commit 652ef42

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

drivers/net/ethernet/mscc/ocelot_board.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ static irqreturn_t ocelot_xtr_irq_handler(int irq, void *arg)
9191
struct sk_buff *skb;
9292
struct net_device *dev;
9393
u32 *buf;
94-
int sz, len;
94+
int sz, len, buf_len;
9595
u32 ifh[4];
9696
u32 val;
9797
struct frame_info info;
@@ -116,14 +116,20 @@ static irqreturn_t ocelot_xtr_irq_handler(int irq, void *arg)
116116
err = -ENOMEM;
117117
break;
118118
}
119-
buf = (u32 *)skb_put(skb, info.len);
119+
buf_len = info.len - ETH_FCS_LEN;
120+
buf = (u32 *)skb_put(skb, buf_len);
120121

121122
len = 0;
122123
do {
123124
sz = ocelot_rx_frame_word(ocelot, grp, false, &val);
124125
*buf++ = val;
125126
len += sz;
126-
} while ((sz == 4) && (len < info.len));
127+
} while (len < buf_len);
128+
129+
/* Read the FCS and discard it */
130+
sz = ocelot_rx_frame_word(ocelot, grp, false, &val);
131+
/* Update the statistics if part of the FCS was read before */
132+
len -= ETH_FCS_LEN - sz;
127133

128134
if (sz < 0) {
129135
err = sz;

0 commit comments

Comments
 (0)