gianfar: fix headroom expansion code
The code that was added to increase headroom was wrong. It doesn't handle the case where gfar_add_fcb() changes the skb. Better to do check at start of transmit (outside of lock), where error handling is better anyway. Signed-off-by: Stephen Hemminger <shemminger@vyatta.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
83e0bbcbe2
commit
54dc79fe0d
1 changed files with 24 additions and 22 deletions
|
@ -1239,19 +1239,9 @@ static int gfar_enet_open(struct net_device *dev)
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline struct txfcb *gfar_add_fcb(struct sk_buff **skbp)
|
static inline struct txfcb *gfar_add_fcb(struct sk_buff *skb)
|
||||||
{
|
{
|
||||||
struct txfcb *fcb;
|
struct txfcb *fcb = (struct txfcb *)skb_push(skb, GMAC_FCB_LEN);
|
||||||
struct sk_buff *skb = *skbp;
|
|
||||||
|
|
||||||
if (unlikely(skb_headroom(skb) < GMAC_FCB_LEN)) {
|
|
||||||
struct sk_buff *old_skb = skb;
|
|
||||||
skb = skb_realloc_headroom(old_skb, GMAC_FCB_LEN);
|
|
||||||
if (!skb)
|
|
||||||
return NULL;
|
|
||||||
dev_kfree_skb_any(old_skb);
|
|
||||||
}
|
|
||||||
fcb = (struct txfcb *)skb_push(skb, GMAC_FCB_LEN);
|
|
||||||
cacheable_memzero(fcb, GMAC_FCB_LEN);
|
cacheable_memzero(fcb, GMAC_FCB_LEN);
|
||||||
|
|
||||||
return fcb;
|
return fcb;
|
||||||
|
@ -1320,6 +1310,20 @@ static int gfar_start_xmit(struct sk_buff *skb, struct net_device *dev)
|
||||||
|
|
||||||
base = priv->tx_bd_base;
|
base = priv->tx_bd_base;
|
||||||
|
|
||||||
|
/* make space for additional header */
|
||||||
|
if (skb_headroom(skb) < GMAC_FCB_LEN) {
|
||||||
|
struct sk_buff *skb_new;
|
||||||
|
|
||||||
|
skb_new = skb_realloc_headroom(skb, GMAC_FCB_LEN);
|
||||||
|
if (!skb_new) {
|
||||||
|
dev->stats.tx_errors++;
|
||||||
|
kfree(skb);
|
||||||
|
return NETDEV_TX_OK;
|
||||||
|
}
|
||||||
|
kfree_skb(skb);
|
||||||
|
skb = skb_new;
|
||||||
|
}
|
||||||
|
|
||||||
/* total number of fragments in the SKB */
|
/* total number of fragments in the SKB */
|
||||||
nr_frags = skb_shinfo(skb)->nr_frags;
|
nr_frags = skb_shinfo(skb)->nr_frags;
|
||||||
|
|
||||||
|
@ -1372,20 +1376,18 @@ static int gfar_start_xmit(struct sk_buff *skb, struct net_device *dev)
|
||||||
|
|
||||||
/* Set up checksumming */
|
/* Set up checksumming */
|
||||||
if (CHECKSUM_PARTIAL == skb->ip_summed) {
|
if (CHECKSUM_PARTIAL == skb->ip_summed) {
|
||||||
fcb = gfar_add_fcb(&skb);
|
fcb = gfar_add_fcb(skb);
|
||||||
if (likely(fcb != NULL)) {
|
lstatus |= BD_LFLAG(TXBD_TOE);
|
||||||
lstatus |= BD_LFLAG(TXBD_TOE);
|
gfar_tx_checksum(skb, fcb);
|
||||||
gfar_tx_checksum(skb, fcb);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (priv->vlgrp && vlan_tx_tag_present(skb)) {
|
if (priv->vlgrp && vlan_tx_tag_present(skb)) {
|
||||||
if (unlikely(NULL == fcb))
|
if (unlikely(NULL == fcb)) {
|
||||||
fcb = gfar_add_fcb(&skb);
|
fcb = gfar_add_fcb(skb);
|
||||||
if (likely(fcb != NULL)) {
|
|
||||||
lstatus |= BD_LFLAG(TXBD_TOE);
|
lstatus |= BD_LFLAG(TXBD_TOE);
|
||||||
gfar_tx_vlan(skb, fcb);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gfar_tx_vlan(skb, fcb);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* setup the TxBD length and buffer pointer for the first BD */
|
/* setup the TxBD length and buffer pointer for the first BD */
|
||||||
|
@ -1433,7 +1435,7 @@ static int gfar_start_xmit(struct sk_buff *skb, struct net_device *dev)
|
||||||
/* Unlock priv */
|
/* Unlock priv */
|
||||||
spin_unlock_irqrestore(&priv->txlock, flags);
|
spin_unlock_irqrestore(&priv->txlock, flags);
|
||||||
|
|
||||||
return 0;
|
return NETDEV_TX_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Stops the kernel queue, and halts the controller */
|
/* Stops the kernel queue, and halts the controller */
|
||||||
|
|
Loading…
Reference in a new issue