* [PATCH v2] gianfar: Fall back to software tcp/udp checksum on older controllers [not found] <20110127095100.GA5411@oksana.dev.rtsoft.ru> @ 2011-01-28 4:37 ` Alex Dubov 2011-01-28 9:10 ` [PATCH v2] gianfar: Fall back to software tcp/udp checksum on oldercontrollers David Laight 0 siblings, 1 reply; 4+ messages in thread From: Alex Dubov @ 2011-01-28 4:37 UTC (permalink / raw) To: Anton Vorontsov; +Cc: mlcreech, linuxppc-dev, davem, netdev 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 alignments of the appropriate FCB. This patch checks for FCB alignment on such controllers and falls back to software checksumming if the alignment is known to be bad. Signed-off-by: Alex Dubov <oakad@yahoo.com> --- Changes for v2: - Make indentation slightly more consistent. - Replace bizarre switch-based condition with plain boring one. drivers/net/gianfar.c | 16 ++++++++++++++-- drivers/net/gianfar.h | 1 + 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/drivers/net/gianfar.c b/drivers/net/gianfar.c index 5ed8f9f..3da19a5 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)) + priv->errata |= GFAR_ERRATA_12; + if (priv->errata) dev_info(dev, "enabled errata workarounds, flags: 0x%x\n", priv->errata); @@ -2156,8 +2161,15 @@ 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); + /* as specified by errata */ + if (unlikely(gfar_has_errata(priv, GFAR_ERRATA_12) + && ((unsigned long)fcb % 0x20) > 0x18)) { + __skb_pull(skb, GMAC_FCB_LEN); + skb_checksum_help(skb); + } else { + lstatus |= BD_LFLAG(TXBD_TOE); + gfar_tx_checksum(skb, fcb); + } } if (vlan_tx_tag_present(skb)) { diff --git a/drivers/net/gianfar.h b/drivers/net/gianfar.h index 54de413..ec5d595 100644 --- a/drivers/net/gianfar.h +++ b/drivers/net/gianfar.h @@ -1039,6 +1039,7 @@ enum gfar_errata { GFAR_ERRATA_74 = 0x01, GFAR_ERRATA_76 = 0x02, GFAR_ERRATA_A002 = 0x04, + GFAR_ERRATA_12 = 0x08, /* a.k.a errata eTSEC49 */ }; /* Struct stolen almost completely (and shamelessly) from the FCC enet source -- 1.7.3.2 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* RE: [PATCH v2] gianfar: Fall back to software tcp/udp checksum on oldercontrollers 2011-01-28 4:37 ` [PATCH v2] gianfar: Fall back to software tcp/udp checksum on older controllers Alex Dubov @ 2011-01-28 9:10 ` David Laight 2011-01-28 16:56 ` Scott Wood 0 siblings, 1 reply; 4+ messages in thread From: David Laight @ 2011-01-28 9:10 UTC (permalink / raw) Cc: netdev, linuxppc-dev > + if (unlikely(gfar_has_errata(priv, GFAR_ERRATA_12) > + && ((unsigned long)fcb % 0x20) > 0x18)) { You need to check the generated code, but I think you need: if (unlikely(gfar_has_errata(priv, GFAR_ERRATA_12)) && unlikely(((unsigned long)fcb % 0x20) > 0x18)) ie unlikely() around both the primitive comparisons. David ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] gianfar: Fall back to software tcp/udp checksum on oldercontrollers 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 0 siblings, 1 reply; 4+ messages in thread From: Scott Wood @ 2011-01-28 16:56 UTC (permalink / raw) To: David Laight; +Cc: netdev, linuxppc-dev On Fri, 28 Jan 2011 09:10:46 +0000 David Laight <David.Laight@ACULAB.COM> wrote: > > > + if (unlikely(gfar_has_errata(priv, GFAR_ERRATA_12) > > + && ((unsigned long)fcb % 0x20) > 0x18)) { > > You need to check the generated code, but I think you need: > > if (unlikely(gfar_has_errata(priv, GFAR_ERRATA_12)) > && unlikely(((unsigned long)fcb % 0x20) > 0x18)) > > ie unlikely() around both the primitive comparisons. Is the first condition actually unlikely? If you've got affected hardware, you'll hit it every time. If packets with the problematic alignment are rare, seems like it'd be better to check that first. -Scott ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] gianfar: Fall back to software tcp/udp checksum on oldercontrollers 2011-01-28 16:56 ` Scott Wood @ 2011-01-28 19:59 ` David Miller 0 siblings, 0 replies; 4+ messages in thread From: David Miller @ 2011-01-28 19:59 UTC (permalink / raw) To: scottwood; +Cc: David.Laight, netdev, linuxppc-dev From: Scott Wood <scottwood@freescale.com> Date: Fri, 28 Jan 2011 10:56:10 -0600 > On Fri, 28 Jan 2011 09:10:46 +0000 > David Laight <David.Laight@ACULAB.COM> wrote: > >> >> > + if (unlikely(gfar_has_errata(priv, GFAR_ERRATA_12) >> > + && ((unsigned long)fcb % 0x20) > 0x18)) { >> >> You need to check the generated code, but I think you need: >> >> if (unlikely(gfar_has_errata(priv, GFAR_ERRATA_12)) >> && unlikely(((unsigned long)fcb % 0x20) > 0x18)) >> >> ie unlikely() around both the primitive comparisons. > > Is the first condition actually unlikely? If you've got affected > hardware, you'll hit it every time. > > If packets with the problematic alignment are rare, seems like it'd be > better to check that first. In cases like this gfar_has_errata() case, better to leave it's likelyhood unmarked. And yes, since it's cheaper, checking the alignment should be done first. ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2011-01-28 19:59 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- [not found] <20110127095100.GA5411@oksana.dev.rtsoft.ru> 2011-01-28 4:37 ` [PATCH v2] gianfar: Fall back to software tcp/udp checksum on older controllers 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
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).