summaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet
diff options
context:
space:
mode:
authorAntoine Tenart <antoine.tenart@bootlin.com>2018-09-20 12:08:54 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2018-10-18 09:18:11 +0200
commit6133d8e499e6a88b9a938243e1b8a6aa1f79ec8c (patch)
tree86bcab15036e66131e95a6a2df07cba05e1fa620 /drivers/net/ethernet
parentd29a558b56ee952e452969ac7c90d0a7bf2f58bb (diff)
downloadlinux-stable-6133d8e499e6a88b9a938243e1b8a6aa1f79ec8c.tar.gz
linux-stable-6133d8e499e6a88b9a938243e1b8a6aa1f79ec8c.tar.bz2
linux-stable-6133d8e499e6a88b9a938243e1b8a6aa1f79ec8c.zip
net: mscc: fix the frame extraction into the skb
[ Upstream commit 652ef42c134da1bbb03bd4c9b4291dfaf8d7febb ] 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: a556c76adc05 ("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> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/net/ethernet')
-rw-r--r--drivers/net/ethernet/mscc/ocelot_board.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/drivers/net/ethernet/mscc/ocelot_board.c b/drivers/net/ethernet/mscc/ocelot_board.c
index 18df7d934e81..ccfcf3048cd0 100644
--- a/drivers/net/ethernet/mscc/ocelot_board.c
+++ b/drivers/net/ethernet/mscc/ocelot_board.c
@@ -91,7 +91,7 @@ static irqreturn_t ocelot_xtr_irq_handler(int irq, void *arg)
struct sk_buff *skb;
struct net_device *dev;
u32 *buf;
- int sz, len;
+ int sz, len, buf_len;
u32 ifh[4];
u32 val;
struct frame_info info;
@@ -116,14 +116,20 @@ static irqreturn_t ocelot_xtr_irq_handler(int irq, void *arg)
err = -ENOMEM;
break;
}
- buf = (u32 *)skb_put(skb, info.len);
+ buf_len = info.len - ETH_FCS_LEN;
+ buf = (u32 *)skb_put(skb, buf_len);
len = 0;
do {
sz = ocelot_rx_frame_word(ocelot, grp, false, &val);
*buf++ = val;
len += sz;
- } while ((sz == 4) && (len < info.len));
+ } while (len < buf_len);
+
+ /* Read the FCS and discard it */
+ sz = ocelot_rx_frame_word(ocelot, grp, false, &val);
+ /* Update the statistics if part of the FCS was read before */
+ len -= ETH_FCS_LEN - sz;
if (sz < 0) {
err = sz;