From: Anatolij Gustschin <agust@denx.de>
To: linuxppc-dev@ozlabs.org
Cc: dzu@denx.de, wd@denx.de, John Rigby <jcrigby@gmail.com>,
John Rigby <jrigby@freescale.com>,
Piotr Ziecik <kosmo@semihalf.com>,
Anatolij Gustschin <agust@denx.de>, <netdev@vger.kernel.org>,
Grant Likely <grant.likely@secretlab.ca>
Subject: [PATCH 02/11] fs_enet: Add FEC TX Alignment workaround for MPC5121
Date: Tue, 19 Jan 2010 21:24:04 +0100 [thread overview]
Message-ID: <1263932653-3634-3-git-send-email-agust@denx.de> (raw)
In-Reply-To: <1263932653-3634-1-git-send-email-agust@denx.de>
From: John Rigby <jcrigby@gmail.com>
The FEC on 5121 has problems with misaligned tx buffers.
The RM says any alignment is ok but empirical results
show that packet buffers ending in 0x1E will sometimes
hang the FEC. Other bad alignment does not hang but will
cause silent TX failures resulting in about a 1% packet
loss as tested by ping -f from a remote host.
This patch is a work around that copies every tx packet
to an aligned skb before sending.
Signed-off-by: John Rigby <jrigby@freescale.com>
Signed-off-by: Piotr Ziecik <kosmo@semihalf.com>
Signed-off-by: Wolfgang Denk <wd@denx.de>
Signed-off-by: Anatolij Gustschin <agust@denx.de>
Cc: <netdev@vger.kernel.org>
Cc: Grant Likely <grant.likely@secretlab.ca>
Cc: John Rigby <jcrigby@gmail.com>
---
drivers/net/fs_enet/fs_enet-main.c | 39 ++++++++++++++++++++++++++++++++++++
1 files changed, 39 insertions(+), 0 deletions(-)
diff --git a/drivers/net/fs_enet/fs_enet-main.c b/drivers/net/fs_enet/fs_enet-main.c
index 909b78d..a391219 100644
--- a/drivers/net/fs_enet/fs_enet-main.c
+++ b/drivers/net/fs_enet/fs_enet-main.c
@@ -587,6 +587,33 @@ void fs_cleanup_bds(struct net_device *dev)
/**********************************************************************************/
+static struct sk_buff *tx_skb_align_workaround(struct net_device *dev,
+ struct sk_buff *skb)
+{
+ struct sk_buff *new_skb;
+
+ /* Alloc new skb */
+ new_skb = dev_alloc_skb(ENET_RX_FRSIZE + 32);
+ if (!new_skb) {
+ printk(KERN_WARNING DRV_MODULE_NAME
+ ": %s Memory squeeze, dropping tx packet.\n",
+ dev->name);
+ return NULL;
+ }
+
+ /* Make sure new skb is properly aligned */
+ skb_align(new_skb, 32);
+
+ /* Copy data to new skb ... */
+ skb_copy_from_linear_data(skb, new_skb->data, skb->len);
+ skb_put(new_skb, skb->len);
+
+ /* ... and free an old one */
+ dev_kfree_skb_any(skb);
+
+ return new_skb;
+}
+
static int fs_enet_start_xmit(struct sk_buff *skb, struct net_device *dev)
{
struct fs_enet_private *fep = netdev_priv(dev);
@@ -595,6 +622,18 @@ static int fs_enet_start_xmit(struct sk_buff *skb, struct net_device *dev)
u16 sc;
unsigned long flags;
+ if (fep->fec.fec_id == FS_ENET_MPC5121_FEC) {
+ skb = tx_skb_align_workaround(dev, skb);
+ if (!skb) {
+ /*
+ * We have lost packet due to memory allocation error
+ * in tx_skb_align_workaround(). Hopefully original skb
+ * is still valid, so try transmit it later.
+ */
+ return NETDEV_TX_BUSY;
+ }
+ }
+
spin_lock_irqsave(&fep->tx_lock, flags);
/*
--
1.5.6.3
next prev parent reply other threads:[~2010-01-19 20:24 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-01-19 20:24 [PATCH 0/11] Update support for MPC512x Anatolij Gustschin
2010-01-19 20:24 ` [PATCH 01/11] fs_enet: Add support for MPC512x to fs_enet driver Anatolij Gustschin
2010-01-19 20:48 ` Scott Wood
2010-01-20 11:20 ` Anatolij Gustschin
2010-01-20 17:02 ` Scott Wood
2010-01-19 20:24 ` Anatolij Gustschin [this message]
2010-01-19 20:37 ` [PATCH 02/11] fs_enet: Add FEC TX Alignment workaround for MPC5121 David Miller
2010-01-19 23:42 ` Stephen Rothwell
2010-01-20 4:04 ` David Miller
2010-01-20 10:22 ` Wolfram Sang
[not found] ` <1263932653-3634-1-git-send-email-agust-ynQEQJNshbs@public.gmane.org>
2010-01-20 11:22 ` [PATCH 0/11] Update support for MPC512x Wolfram Sang
[not found] ` <20100120112232.GD5041-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2010-01-26 8:06 ` Anatolij Gustschin
2010-01-26 12:16 ` Wolfram Sang
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=1263932653-3634-3-git-send-email-agust@denx.de \
--to=agust@denx.de \
--cc=dzu@denx.de \
--cc=grant.likely@secretlab.ca \
--cc=jcrigby@gmail.com \
--cc=jrigby@freescale.com \
--cc=kosmo@semihalf.com \
--cc=linuxppc-dev@ozlabs.org \
--cc=netdev@vger.kernel.org \
--cc=wd@denx.de \
/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).