diff options
author | stephen hemminger <shemminger@vyatta.com> | 2012-04-04 08:10:27 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2012-04-04 18:14:04 -0400 |
commit | 857504d06d565ad5b401d505937932775ddf1c47 (patch) | |
tree | f251c66ca24133498c3d496d78daee0f7ff54fc4 /drivers/net/ethernet/marvell | |
parent | 234bcf8a499ee206145c7007d12d9706a254f790 (diff) |
sky2: copy received packets on inefficient unaligned architecture
Modified from original patch from Chris.
The sky2 driver has to have 8 byte alignment of receive buffer
on some chip versions. On architectures which don't support efficient
unaligned access this doesn't work very well. The solution is to
just copy all received packets which is what the driver already
does for small packets.
This allows the driver to be used on the Tilera TILEmpower-Gx, since
the tile architecture doesn't currently handle kernel unaligned accesses,
just userspace.
Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
Acked-by: Chris Metcalf <cmetcalf@tilera.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/marvell')
-rw-r--r-- | drivers/net/ethernet/marvell/sky2.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/drivers/net/ethernet/marvell/sky2.c b/drivers/net/ethernet/marvell/sky2.c index b806d9b4defb..c9b504e2dfc3 100644 --- a/drivers/net/ethernet/marvell/sky2.c +++ b/drivers/net/ethernet/marvell/sky2.c | |||
@@ -2469,6 +2469,17 @@ static int sky2_change_mtu(struct net_device *dev, int new_mtu) | |||
2469 | return err; | 2469 | return err; |
2470 | } | 2470 | } |
2471 | 2471 | ||
2472 | static inline bool needs_copy(const struct rx_ring_info *re, | ||
2473 | unsigned length) | ||
2474 | { | ||
2475 | #ifndef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS | ||
2476 | /* Some architectures need the IP header to be aligned */ | ||
2477 | if (!IS_ALIGNED(re->data_addr + ETH_HLEN, sizeof(u32))) | ||
2478 | return true; | ||
2479 | #endif | ||
2480 | return length < copybreak; | ||
2481 | } | ||
2482 | |||
2472 | /* For small just reuse existing skb for next receive */ | 2483 | /* For small just reuse existing skb for next receive */ |
2473 | static struct sk_buff *receive_copy(struct sky2_port *sky2, | 2484 | static struct sk_buff *receive_copy(struct sky2_port *sky2, |
2474 | const struct rx_ring_info *re, | 2485 | const struct rx_ring_info *re, |
@@ -2599,7 +2610,7 @@ static struct sk_buff *sky2_receive(struct net_device *dev, | |||
2599 | goto error; | 2610 | goto error; |
2600 | 2611 | ||
2601 | okay: | 2612 | okay: |
2602 | if (length < copybreak) | 2613 | if (needs_copy(re, length)) |
2603 | skb = receive_copy(sky2, re, length); | 2614 | skb = receive_copy(sky2, re, length); |
2604 | else | 2615 | else |
2605 | skb = receive_new(sky2, re, length); | 2616 | skb = receive_new(sky2, re, length); |