public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Antoine Tenart <antoine.tenart@bootlin.com>
To: Florian Fainelli <f.fainelli@gmail.com>
Cc: Antoine Tenart <antoine.tenart@bootlin.com>,
	davem@davemloft.net, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org, thomas.petazzoni@bootlin.com,
	alexandre.belloni@bootlin.com, quentin.schulz@bootlin.com,
	allan.nielsen@microchip.com
Subject: Re: [PATCH net-next] net: mscc: allow extracting the FCS into the skb
Date: Tue, 2 Oct 2018 08:59:37 +0200	[thread overview]
Message-ID: <20181002065937.GB3368@kwain> (raw)
In-Reply-To: <25a88126-2397-a1fb-0c0d-06504bb348ca@gmail.com>

Hi FLorian,

On Mon, Oct 01, 2018 at 09:35:45AM -0700, Florian Fainelli wrote:
> On 10/01/2018 02:57 AM, Antoine Tenart wrote:
> >  
> >  	memcpy(dev->dev_addr, ocelot->base_mac, ETH_ALEN);
> > diff --git a/drivers/net/ethernet/mscc/ocelot_board.c b/drivers/net/ethernet/mscc/ocelot_board.c
> > index 3cdf63e35b53..245452a0f244 100644
> > --- a/drivers/net/ethernet/mscc/ocelot_board.c
> > +++ b/drivers/net/ethernet/mscc/ocelot_board.c
> > @@ -126,11 +126,16 @@ static irqreturn_t ocelot_xtr_irq_handler(int irq, void *arg)
> >  			len += sz;
> >  		} while (len < buf_len);
> >  
> > -		/* Read the FCS and discard it */
> > +		/* Read the FCS */
> >  		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;
> >  
> Don't this needs to be len -= sz;

No, part of the FCS could be read in the loop before. This subtraction
removes those bytes from the stats.

> > +		if (unlikely(dev->features & NETIF_F_RXFCS)) {
> > +			buf = (u32 *)skb_put(skb, ETH_FCS_LEN);
> > +			*buf = val;
> 
> and here len -= ETH_FCS_LEN

len doesn't contain the FCS len at this point, no need to remove it
again. The extraction logic is already designed to drop the FCS and to
not count it in the stats, this patch makes use of it depending on
NETIF_F_RXFCS.

> since "len" is later used for accounting how many bytes have been
> received by the network device?

The question could be "do we need len += ETH_FCS_LEN" to account for the
FCS when NETIF_F_RXFCS is used", but I looked at other drivers and it
seemed to me the FCS is not accounted in the stats. Should it be?

> I am bit confused by the use of "buf", but presumably if NETIF_F_RXCFS
> is turned on, the FCS needs to be part of the buffer passed to the
> network stack, so adjusting len accordingly is required anyway.

This is the way we extract the data to the skb, I'm following the same
logic (I could use buf++ as well, as it's done in the loop before).

Thanks!
Antoine

-- 
Antoine Ténart, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

  reply	other threads:[~2018-10-02  6:59 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-01  9:57 [PATCH net-next] net: mscc: allow extracting the FCS into the skb Antoine Tenart
2018-10-01 14:59 ` Alexandre Belloni
2018-10-01 16:35 ` Florian Fainelli
2018-10-02  6:59   ` Antoine Tenart [this message]
2018-10-02 12:43     ` Andrew Lunn
2018-10-10 14:46       ` Antoine Tenart
2018-10-10 16:25         ` Florian Fainelli
2018-10-10 17:26           ` David Miller
2018-10-11  6:57             ` Antoine Tenart

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=20181002065937.GB3368@kwain \
    --to=antoine.tenart@bootlin.com \
    --cc=alexandre.belloni@bootlin.com \
    --cc=allan.nielsen@microchip.com \
    --cc=davem@davemloft.net \
    --cc=f.fainelli@gmail.com \
    --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