Netdev List
 help / color / mirror / Atom feed
From: Alexandre Belloni <alexandre.belloni@bootlin.com>
To: Antoine Tenart <antoine.tenart@bootlin.com>
Cc: davem@davemloft.net, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org, thomas.petazzoni@bootlin.com,
	quentin.schulz@bootlin.com, allan.nielsen@microchip.com
Subject: Re: [PATCH net] net: mscc: fix the frame extraction into the skb
Date: Mon, 1 Oct 2018 11:49:00 +0200	[thread overview]
Message-ID: <20181001094900.GB2967@piout.net> (raw)
In-Reply-To: <20180920100854.19044-1-antoine.tenart@bootlin.com>

On 20/09/2018 12:08:54+0200, Antoine Ténart wrote:
> 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>
Reviewed-by: Alexandre Belloni <alexandre.belloni@bootlin.com>

> ---
> 
> Hi all,
> 
> Once this patch will be accepted and net merged into net-next, I'll
> probably send another patch to fill skb->csum with the FCS based on
> NETIF_F_RXFCS.
> 
> Thanks!
> Antoine
> 
>  drivers/net/ethernet/mscc/ocelot_board.c | 12 +++++++++---
>  1 file changed, 9 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/net/ethernet/mscc/ocelot_board.c b/drivers/net/ethernet/mscc/ocelot_board.c
> index 26bb3b18f3be..3cdf63e35b53 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;
> -- 
> 2.17.1
> 

-- 
Alexandre Belloni, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

      reply	other threads:[~2018-10-01  9:49 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-20 10:08 [PATCH net] net: mscc: fix the frame extraction into the skb Antoine Tenart
2018-10-01  9:49 ` Alexandre Belloni [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181001094900.GB2967@piout.net \
    --to=alexandre.belloni@bootlin.com \
    --cc=allan.nielsen@microchip.com \
    --cc=antoine.tenart@bootlin.com \
    --cc=davem@davemloft.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=quentin.schulz@bootlin.com \
    --cc=thomas.petazzoni@bootlin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox