summaryrefslogtreecommitdiff
path: root/drivers/net/fs_enet/fs_enet-main.c
diff options
context:
space:
mode:
authorScott Wood <scottwood@freescale.com>2007-10-01 23:20:52 +0400
committerDavid S. Miller <davem@sunset.davemloft.net>2007-10-11 03:54:02 +0400
commit0d0d9c150c046cbd3e507adcfa2d78db82f1f452 (patch)
tree9061d687f765b7cd831d8a6dce83ae925a58d994 /drivers/net/fs_enet/fs_enet-main.c
parentc6565331b7162a8348c70c37b4c33bedb6d4f02d (diff)
downloadlinux-0d0d9c150c046cbd3e507adcfa2d78db82f1f452.tar.xz
fs_enet: Align receive buffers.
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> Signed-off-by: Jeff Garzik <jeff@garzik.org>
Diffstat (limited to 'drivers/net/fs_enet/fs_enet-main.c')
-rw-r--r--drivers/net/fs_enet/fs_enet-main.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/drivers/net/fs_enet/fs_enet-main.c b/drivers/net/fs_enet/fs_enet-main.c
index a15345ba1e59..7a0298687875 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,