Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 184547
b: refs/heads/master
c: cb395ea
h: refs/heads/master
i:
  184545: b70a450
  184543: 0182bcb
v: v3
  • Loading branch information
Anatolij Gustschin authored and David S. Miller committed Feb 27, 2010
1 parent 7b9fa96 commit 015f6c5
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 60ab4361adc188fb47da1c4892cc7a2bb621efef
refs/heads/master: cb395eaf439625f26c8527bb05bb905774a54c36
47 changes: 47 additions & 0 deletions trunk/drivers/net/fs_enet/fs_enet-main.c
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,40 @@ void fs_cleanup_bds(struct net_device *dev)

/**********************************************************************************/

#ifdef CONFIG_FS_ENET_MPC5121_FEC
/*
* MPC5121 FEC requeries 4-byte alignment for TX data buffer!
*/
static struct sk_buff *tx_skb_align_workaround(struct net_device *dev,
struct sk_buff *skb)
{
struct sk_buff *new_skb;
struct fs_enet_private *fep = netdev_priv(dev);

/* Alloc new skb */
new_skb = dev_alloc_skb(skb->len + 4);
if (!new_skb) {
if (net_ratelimit()) {
dev_warn(fep->dev,
"Memory squeeze, dropping tx packet.\n");
}
return NULL;
}

/* Make sure new skb is properly aligned */
skb_align(new_skb, 4);

/* Copy data to new skb ... */
skb_copy_from_linear_data(skb, new_skb->data, skb->len);
skb_put(new_skb, skb->len);

/* ... and free an old one */
dev_kfree_skb_any(skb);

return new_skb;
}
#endif

static int fs_enet_start_xmit(struct sk_buff *skb, struct net_device *dev)
{
struct fs_enet_private *fep = netdev_priv(dev);
Expand All @@ -588,6 +622,19 @@ static int fs_enet_start_xmit(struct sk_buff *skb, struct net_device *dev)
u16 sc;
unsigned long flags;

#ifdef CONFIG_FS_ENET_MPC5121_FEC
if (((unsigned long)skb->data) & 0x3) {
skb = tx_skb_align_workaround(dev, skb);
if (!skb) {
/*
* We have lost packet due to memory allocation error
* in tx_skb_align_workaround(). Hopefully original
* skb is still valid, so try transmit it later.
*/
return NETDEV_TX_BUSY;
}
}
#endif
spin_lock_irqsave(&fep->tx_lock, flags);

/*
Expand Down

0 comments on commit 015f6c5

Please sign in to comment.