diff options
Diffstat (limited to 'drivers/net')
-rw-r--r-- | drivers/net/fs_enet/fs_enet-main.c | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/drivers/net/fs_enet/fs_enet-main.c b/drivers/net/fs_enet/fs_enet-main.c index 4297021214d1..0770e2f6da6b 100644 --- a/drivers/net/fs_enet/fs_enet-main.c +++ b/drivers/net/fs_enet/fs_enet-main.c | |||
@@ -580,6 +580,40 @@ void fs_cleanup_bds(struct net_device *dev) | |||
580 | 580 | ||
581 | /**********************************************************************************/ | 581 | /**********************************************************************************/ |
582 | 582 | ||
583 | #ifdef CONFIG_FS_ENET_MPC5121_FEC | ||
584 | /* | ||
585 | * MPC5121 FEC requeries 4-byte alignment for TX data buffer! | ||
586 | */ | ||
587 | static struct sk_buff *tx_skb_align_workaround(struct net_device *dev, | ||
588 | struct sk_buff *skb) | ||
589 | { | ||
590 | struct sk_buff *new_skb; | ||
591 | struct fs_enet_private *fep = netdev_priv(dev); | ||
592 | |||
593 | /* Alloc new skb */ | ||
594 | new_skb = dev_alloc_skb(skb->len + 4); | ||
595 | if (!new_skb) { | ||
596 | if (net_ratelimit()) { | ||
597 | dev_warn(fep->dev, | ||
598 | "Memory squeeze, dropping tx packet.\n"); | ||
599 | } | ||
600 | return NULL; | ||
601 | } | ||
602 | |||
603 | /* Make sure new skb is properly aligned */ | ||
604 | skb_align(new_skb, 4); | ||
605 | |||
606 | /* Copy data to new skb ... */ | ||
607 | skb_copy_from_linear_data(skb, new_skb->data, skb->len); | ||
608 | skb_put(new_skb, skb->len); | ||
609 | |||
610 | /* ... and free an old one */ | ||
611 | dev_kfree_skb_any(skb); | ||
612 | |||
613 | return new_skb; | ||
614 | } | ||
615 | #endif | ||
616 | |||
583 | static int fs_enet_start_xmit(struct sk_buff *skb, struct net_device *dev) | 617 | static int fs_enet_start_xmit(struct sk_buff *skb, struct net_device *dev) |
584 | { | 618 | { |
585 | struct fs_enet_private *fep = netdev_priv(dev); | 619 | struct fs_enet_private *fep = netdev_priv(dev); |
@@ -588,6 +622,19 @@ static int fs_enet_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
588 | u16 sc; | 622 | u16 sc; |
589 | unsigned long flags; | 623 | unsigned long flags; |
590 | 624 | ||
625 | #ifdef CONFIG_FS_ENET_MPC5121_FEC | ||
626 | if (((unsigned long)skb->data) & 0x3) { | ||
627 | skb = tx_skb_align_workaround(dev, skb); | ||
628 | if (!skb) { | ||
629 | /* | ||
630 | * We have lost packet due to memory allocation error | ||
631 | * in tx_skb_align_workaround(). Hopefully original | ||
632 | * skb is still valid, so try transmit it later. | ||
633 | */ | ||
634 | return NETDEV_TX_BUSY; | ||
635 | } | ||
636 | } | ||
637 | #endif | ||
591 | spin_lock_irqsave(&fep->tx_lock, flags); | 638 | spin_lock_irqsave(&fep->tx_lock, flags); |
592 | 639 | ||
593 | /* | 640 | /* |