linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Anton Vorontsov <cbouatmailru@gmail.com>
To: Alex Dubov <oakad@yahoo.com>
Cc: linuxppc-dev@lists.ozlabs.org, davem@davemloft.net, mlcreech@gmail.com
Subject: Re: [PATCH] gianfar: Fall back to software tcp/udp checksum on older controllers
Date: Thu, 27 Jan 2011 12:51:00 +0300	[thread overview]
Message-ID: <20110127095100.GA5411@oksana.dev.rtsoft.ru> (raw)
In-Reply-To: <468529.34173.qm@web37605.mail.mud.yahoo.com>

Hello Alex,

On Thu, Jan 27, 2011 at 12:14:21AM -0800, Alex Dubov wrote:
> As specified by errata eTSEC49 of MPC8548 and errata eTSEC12 of MPC83xx,
> older revisions of gianfar controllers will be unable to calculate a TCP/UDP
> packet checksum for some aligments of the appropriate FCB. This patch checks
> for FCB alignment on such controllers and falls back to software checksumming
> if the aligment is known to be bad.
> 
> Signed-off-by: Alex Dubov <oakad@yahoo.com>
> ---
> This is my, somewhat different approach to Matthew Creech proposed solution.
> 
>  drivers/net/gianfar.c |   21 +++++++++++++++++++--
>  drivers/net/gianfar.h |    1 +
>  2 files changed, 20 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/gianfar.c b/drivers/net/gianfar.c
> index 5ed8f9f..b4f0e99 100644
> --- a/drivers/net/gianfar.c
> +++ b/drivers/net/gianfar.c
> @@ -950,6 +950,11 @@ static void gfar_detect_errata(struct gfar_private *priv)
>  			(pvr == 0x80861010 && (mod & 0xfff9) == 0x80c0))
>  		priv->errata |= GFAR_ERRATA_A002;
>  
> +	/* MPC8313 Rev < 2.0, MPC8548 rev 2.0 */
> +	if ((pvr == 0x80850010 && mod == 0x80b0 && rev < 0x0020)
> +	    || (pvr == 0x80210020 && mod == 0x8030 && rev == 0x0020))

Please indent it like the above: with two tabs. This is
to keep things consistent.

> +		priv->errata |= GFAR_ERRATA_12;
> +
>  	if (priv->errata)
>  		dev_info(dev, "enabled errata workarounds, flags: 0x%x\n",
>  			 priv->errata);
> @@ -2156,8 +2161,20 @@ static int gfar_start_xmit(struct sk_buff *skb, struct net_device *dev)
>  	/* Set up checksumming */
>  	if (CHECKSUM_PARTIAL == skb->ip_summed) {
>  		fcb = gfar_add_fcb(skb);
> -		lstatus |= BD_LFLAG(TXBD_TOE);
> -		gfar_tx_checksum(skb, fcb);
> +		switch (unlikely(gfar_has_errata(priv, GFAR_ERRATA_12))
> +			? 1 : 0) {

The switch construction is quite bizarre. ;-) Why not

if (gfar_has_errata() && (ulong)fcb % 0x20 > 18) {
	csum_help();
} else {
	lstatus |=...
	tx_csum();
}

?

Thanks,

> +		case 1:
> +			/* as specified by errata */
> +			if (((unsigned long)fcb % 0x20) > 0x18) { 
> +				__skb_pull(skb, GMAC_FCB_LEN);
> +				skb_checksum_help(skb);
> +				break;
> +			}
> +			/* otherwise, fall through */
> +		default:
> +			lstatus |= BD_LFLAG(TXBD_TOE);
> +			gfar_tx_checksum(skb, fcb);
> +		}
>  	}

-- 
Anton Vorontsov
Email: cbouatmailru@gmail.com

  reply	other threads:[~2011-01-27  9:51 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-27  8:14 [PATCH] gianfar: Fall back to software tcp/udp checksum on older controllers Alex Dubov
2011-01-27  9:51 ` Anton Vorontsov [this message]
2011-01-27 22:23   ` David Miller
2011-01-28  2:43   ` Alex Dubov
2011-01-28  4:37   ` [PATCH v2] " Alex Dubov
2011-01-28  9:10     ` [PATCH v2] gianfar: Fall back to software tcp/udp checksum on oldercontrollers David Laight
2011-01-28 16:56       ` Scott Wood
2011-01-28 19:59         ` David Miller

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=20110127095100.GA5411@oksana.dev.rtsoft.ru \
    --to=cbouatmailru@gmail.com \
    --cc=davem@davemloft.net \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=mlcreech@gmail.com \
    --cc=oakad@yahoo.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;
as well as URLs for NNTP newsgroup(s).