From: Scott Wood <scottwood@freescale.com>
To: jgarzik@pobox.com
Cc: netdev@vger.kernel.org
Subject: [PATCH 5/9] fs_enet: Align receive buffers.
Date: Mon, 1 Oct 2007 14:20:52 -0500 [thread overview]
Message-ID: <20071001192052.GD28429@loki.buserror.net> (raw)
In-Reply-To: <20071001192017.GA28410@loki.buserror.net>
At least some hardware driven by this driver needs receive buffers
to be aligned on a 16-byte boundary. This usually happens by chance,
but it breaks if slab debugging is enabled.
Signed-off-by: Scott Wood <scottwood@freescale.com>
---
drivers/net/fs_enet/fs_enet-main.c | 21 +++++++++++++++++++--
drivers/net/fs_enet/fs_enet.h | 3 ++-
2 files changed, 21 insertions(+), 3 deletions(-)
diff --git a/drivers/net/fs_enet/fs_enet-main.c b/drivers/net/fs_enet/fs_enet-main.c
index a15345b..7a02986 100644
--- a/drivers/net/fs_enet/fs_enet-main.c
+++ b/drivers/net/fs_enet/fs_enet-main.c
@@ -70,6 +70,14 @@ static void fs_set_multicast_list(struct net_device *dev)
(*fep->ops->set_multicast_list)(dev);
}
+static void skb_align(struct sk_buff *skb, int align)
+{
+ int off = ((unsigned long)skb->data) & (align - 1);
+
+ if (off)
+ skb_reserve(skb, align - off);
+}
+
/* NAPI receive function */
static int fs_enet_rx_napi(struct napi_struct *napi, int budget)
{
@@ -159,9 +167,13 @@ static int fs_enet_rx_napi(struct napi_struct *napi, int budget)
skb = skbn;
skbn = skbt;
}
- } else
+ } else {
skbn = dev_alloc_skb(ENET_RX_FRSIZE);
+ if (skbn)
+ skb_align(skbn, ENET_RX_ALIGN);
+ }
+
if (skbn != NULL) {
skb_put(skb, pkt_len); /* Make room */
skb->protocol = eth_type_trans(skb, dev);
@@ -290,9 +302,13 @@ static int fs_enet_rx_non_napi(struct net_device *dev)
skb = skbn;
skbn = skbt;
}
- } else
+ } else {
skbn = dev_alloc_skb(ENET_RX_FRSIZE);
+ if (skbn)
+ skb_align(skbn, ENET_RX_ALIGN);
+ }
+
if (skbn != NULL) {
skb_put(skb, pkt_len); /* Make room */
skb->protocol = eth_type_trans(skb, dev);
@@ -502,6 +518,7 @@ void fs_init_bds(struct net_device *dev)
dev->name);
break;
}
+ skb_align(skb, ENET_RX_ALIGN);
fep->rx_skbuff[i] = skb;
CBDW_BUFADDR(bdp,
dma_map_single(fep->dev, skb->data,
diff --git a/drivers/net/fs_enet/fs_enet.h b/drivers/net/fs_enet/fs_enet.h
index fbe2087..85571e4 100644
--- a/drivers/net/fs_enet/fs_enet.h
+++ b/drivers/net/fs_enet/fs_enet.h
@@ -82,7 +82,8 @@ struct phy_info {
/* Must be a multiple of 32 (to cover both FEC & FCC) */
#define PKT_MAXBLR_SIZE ((PKT_MAXBUF_SIZE + 31) & ~31)
/* This is needed so that invalidate_xxx wont invalidate too much */
-#define ENET_RX_FRSIZE L1_CACHE_ALIGN(PKT_MAXBUF_SIZE)
+#define ENET_RX_ALIGN 16
+#define ENET_RX_FRSIZE L1_CACHE_ALIGN(PKT_MAXBUF_SIZE + ENET_RX_ALIGN - 1)
struct fs_enet_mii_bus {
struct list_head list;
--
1.5.3.2
next prev parent reply other threads:[~2007-10-01 19:21 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-10-01 19:20 [PATCH 1/9] fs_enet: Whitespace cleanup Scott Wood
2007-10-01 19:20 ` [PATCH 2/9] fs_enet: Fix build breakage Scott Wood
2007-10-01 19:20 ` [PATCH 3/9] fs_enet: Include linux/string.h from linux/fs_enet_pd.h Scott Wood
2007-10-01 19:20 ` [PATCH 4/9] fs_enet: mac-fcc: Eliminate __fcc-* macros Scott Wood
2007-10-01 19:20 ` Scott Wood [this message]
2007-10-01 19:20 ` [PATCH 6/9] fs_enet: Be an of_platform device when CONFIG_PPC_CPM_NEW_BINDING is set Scott Wood
2007-10-01 19:20 ` [PATCH 7/9] Generic bitbanged MDIO library Scott Wood
2007-10-01 19:20 ` [PATCH 8/9] fs_enet: Convert mii-bitbang to use the generic bitbang MDIO code Scott Wood
2007-10-01 19:20 ` [PATCH 9/9] fs_enet: sparse fixes Scott Wood
2007-10-02 15:55 ` [PATCH v2 6/9] fs_enet: Be an of_platform device when CONFIG_PPC_CPM_NEW_BINDING is set Scott Wood
2007-10-02 17:31 ` [PATCH 1/9] fs_enet: Whitespace cleanup Jeff Garzik
-- strict thread matches above, loose matches on Subject: below --
2007-09-20 22:00 [PATCH 0/9] fs enet and mdio bitbang patches Scott Wood
2007-09-20 22:01 ` [PATCH 5/9] fs_enet: Align receive buffers Scott Wood
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=20071001192052.GD28429@loki.buserror.net \
--to=scottwood@freescale.com \
--cc=jgarzik@pobox.com \
--cc=netdev@vger.kernel.org \
/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).