diff options
author | Scott Wood <scottwood@freescale.com> | 2007-10-01 15:20:52 -0400 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2007-10-10 19:54:02 -0400 |
commit | 0d0d9c150c046cbd3e507adcfa2d78db82f1f452 (patch) | |
tree | 9061d687f765b7cd831d8a6dce83ae925a58d994 /drivers/net | |
parent | c6565331b7162a8348c70c37b4c33bedb6d4f02d (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')
-rw-r--r-- | drivers/net/fs_enet/fs_enet-main.c | 21 | ||||
-rw-r--r-- | 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 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 | ||
73 | static 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 */ |
74 | static int fs_enet_rx_napi(struct napi_struct *napi, int budget) | 82 | static 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, |
diff --git a/drivers/net/fs_enet/fs_enet.h b/drivers/net/fs_enet/fs_enet.h index fbe2087d0d79..85571e49ec72 100644 --- a/drivers/net/fs_enet/fs_enet.h +++ b/drivers/net/fs_enet/fs_enet.h | |||
@@ -82,7 +82,8 @@ struct phy_info { | |||
82 | /* Must be a multiple of 32 (to cover both FEC & FCC) */ | 82 | /* Must be a multiple of 32 (to cover both FEC & FCC) */ |
83 | #define PKT_MAXBLR_SIZE ((PKT_MAXBUF_SIZE + 31) & ~31) | 83 | #define PKT_MAXBLR_SIZE ((PKT_MAXBUF_SIZE + 31) & ~31) |
84 | /* This is needed so that invalidate_xxx wont invalidate too much */ | 84 | /* This is needed so that invalidate_xxx wont invalidate too much */ |
85 | #define ENET_RX_FRSIZE L1_CACHE_ALIGN(PKT_MAXBUF_SIZE) | 85 | #define ENET_RX_ALIGN 16 |
86 | #define ENET_RX_FRSIZE L1_CACHE_ALIGN(PKT_MAXBUF_SIZE + ENET_RX_ALIGN - 1) | ||
86 | 87 | ||
87 | struct fs_enet_mii_bus { | 88 | struct fs_enet_mii_bus { |
88 | struct list_head list; | 89 | struct list_head list; |