aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/fs_enet/fs_enet-main.c
diff options
context:
space:
mode:
authorScott Wood <scottwood@freescale.com>2007-10-01 15:20:52 -0400
committerDavid S. Miller <davem@sunset.davemloft.net>2007-10-10 19:54:02 -0400
commit0d0d9c150c046cbd3e507adcfa2d78db82f1f452 (patch)
tree9061d687f765b7cd831d8a6dce83ae925a58d994 /drivers/net/fs_enet/fs_enet-main.c
parentc6565331b7162a8348c70c37b4c33bedb6d4f02d (diff)
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)
70 (*fep->ops->set_multicast_list)(dev); 70 (*fep->ops->set_multicast_list)(dev);
71} 71}
72 72
73static void skb_align(struct sk_buff *skb, int align)
74{
75 int off = ((unsigned long)skb->data) & (align - 1);
76
77 if (off)
78 skb_reserve(skb, align - off);
79}
80
73/* NAPI receive function */ 81/* NAPI receive function */
74static int fs_enet_rx_napi(struct napi_struct *napi, int budget) 82static int fs_enet_rx_napi(struct napi_struct *napi, int budget)
75{ 83{
@@ -159,9 +167,13 @@ static int fs_enet_rx_napi(struct napi_struct *napi, int budget)
159 skb = skbn; 167 skb = skbn;
160 skbn = skbt; 168 skbn = skbt;
161 } 169 }
162 } else 170 } else {
163 skbn = dev_alloc_skb(ENET_RX_FRSIZE); 171 skbn = dev_alloc_skb(ENET_RX_FRSIZE);
164 172
173 if (skbn)
174 skb_align(skbn, ENET_RX_ALIGN);
175 }
176
165 if (skbn != NULL) { 177 if (skbn != NULL) {
166 skb_put(skb, pkt_len); /* Make room */ 178 skb_put(skb, pkt_len); /* Make room */
167 skb->protocol = eth_type_trans(skb, dev); 179 skb->protocol = eth_type_trans(skb, dev);
@@ -290,9 +302,13 @@ static int fs_enet_rx_non_napi(struct net_device *dev)
290 skb = skbn; 302 skb = skbn;
291 skbn = skbt; 303 skbn = skbt;
292 } 304 }
293 } else 305 } else {
294 skbn = dev_alloc_skb(ENET_RX_FRSIZE); 306 skbn = dev_alloc_skb(ENET_RX_FRSIZE);
295 307
308 if (skbn)
309 skb_align(skbn, ENET_RX_ALIGN);
310 }
311
296 if (skbn != NULL) { 312 if (skbn != NULL) {
297 skb_put(skb, pkt_len); /* Make room */ 313 skb_put(skb, pkt_len); /* Make room */
298 skb->protocol = eth_type_trans(skb, dev); 314 skb->protocol = eth_type_trans(skb, dev);
@@ -502,6 +518,7 @@ void fs_init_bds(struct net_device *dev)
502 dev->name); 518 dev->name);
503 break; 519 break;
504 } 520 }
521 skb_align(skb, ENET_RX_ALIGN);
505 fep->rx_skbuff[i] = skb; 522 fep->rx_skbuff[i] = skb;
506 CBDW_BUFADDR(bdp, 523 CBDW_BUFADDR(bdp,
507 dma_map_single(fep->dev, skb->data, 524 dma_map_single(fep->dev, skb->data,