From: Stephen Hemminger <shemminger@vyatta•com>
To: David Miller <davem@davemloft•net>
Cc: leoli@freescale•com, netdev@vger•kernel.org
Subject: [PATCH] gianfar: fix headroom expansion code
Date: Thu, 26 Mar 2009 10:08:56 -0700 [thread overview]
Message-ID: <20090326100856.265f7872@nehalam> (raw)
In-Reply-To: <20090325.172139.142233386.davem@davemloft.net>
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>
--- a/drivers/net/gianfar.c 2009-03-26 09:14:39.273669929 -0700
+++ b/drivers/net/gianfar.c 2009-03-26 09:22:46.477545004 -0700
@@ -1239,19 +1239,9 @@ static int gfar_enet_open(struct net_dev
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 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);
+ struct txfcb *fcb = (struct txfcb *)skb_push(skb, GMAC_FCB_LEN);
cacheable_memzero(fcb, GMAC_FCB_LEN);
return fcb;
@@ -1320,6 +1310,20 @@ static int gfar_start_xmit(struct sk_buf
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 */
nr_frags = skb_shinfo(skb)->nr_frags;
@@ -1372,20 +1376,18 @@ static int gfar_start_xmit(struct sk_buf
/* Set up checksumming */
if (CHECKSUM_PARTIAL == skb->ip_summed) {
- fcb = gfar_add_fcb(&skb);
- if (likely(fcb != NULL)) {
- lstatus |= BD_LFLAG(TXBD_TOE);
- gfar_tx_checksum(skb, fcb);
- }
+ fcb = gfar_add_fcb(skb);
+ lstatus |= BD_LFLAG(TXBD_TOE);
+ gfar_tx_checksum(skb, fcb);
}
if (priv->vlgrp && vlan_tx_tag_present(skb)) {
- if (unlikely(NULL == fcb))
- fcb = gfar_add_fcb(&skb);
- if (likely(fcb != NULL)) {
+ if (unlikely(NULL == fcb)) {
+ fcb = gfar_add_fcb(skb);
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 */
@@ -1433,7 +1435,7 @@ static int gfar_start_xmit(struct sk_buf
/* Unlock priv */
spin_unlock_irqrestore(&priv->txlock, flags);
- return 0;
+ return NETDEV_TX_OK;
}
/* Stops the kernel queue, and halts the controller */
next prev parent reply other threads:[~2009-03-26 17:09 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-03-26 0:21 gianfar: reallocate skb when headroom is not enough for fcb David Miller
2009-03-26 17:08 ` Stephen Hemminger [this message]
2009-03-27 4:26 ` [PATCH] gianfar: fix headroom expansion code Li Yang
2009-03-27 7:39 ` David Miller
2009-03-27 8:06 ` Li Yang
2009-03-27 8:11 ` David Miller
2009-03-27 8:01 ` [PATCH] gianfar: only check headroom when FCB is needed Li Yang
2009-03-27 22:54 ` David Miller
2009-03-27 7:38 ` [PATCH] gianfar: fix headroom expansion code David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20090326100856.265f7872@nehalam \
--to=shemminger@vyatta$(echo .)com \
--cc=davem@davemloft$(echo .)net \
--cc=leoli@freescale$(echo .)com \
--cc=netdev@vger$(echo .)kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox