From: Li Yang <leoli@freescale.com>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org, Li Yang <leoli@freescale.com>
Subject: [PATCH] gianfar: reallocate skb when headroom is not enough for fcb
Date: Wed, 25 Mar 2009 17:15:33 +0800 [thread overview]
Message-ID: <1237972533-11195-1-git-send-email-leoli@freescale.com> (raw)
In-Reply-To: <20090325.000643.55804624.davem@davemloft.net>
Gianfar uses a hardware header FCB for offloading. However when used
with bridging or IP forwarding, TX skb might not have enough headroom
for the FCB. Reallocate skb for such cases.
Signed-off-by: Li Yang <leoli@freescale.com>
---
drivers/net/gianfar.c | 31 +++++++++++++++++++++----------
1 files changed, 21 insertions(+), 10 deletions(-)
diff --git a/drivers/net/gianfar.c b/drivers/net/gianfar.c
index 9831b3f..29dc4ee 100644
--- a/drivers/net/gianfar.c
+++ b/drivers/net/gianfar.c
@@ -1206,10 +1206,19 @@ static int gfar_enet_open(struct net_device *dev)
return err;
}
-static inline struct txfcb *gfar_add_fcb(struct sk_buff *skb)
+static inline struct txfcb *gfar_add_fcb(struct sk_buff **skbp)
{
- struct txfcb *fcb = (struct txfcb *)skb_push (skb, GMAC_FCB_LEN);
-
+ 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);
cacheable_memzero(fcb, GMAC_FCB_LEN);
return fcb;
@@ -1330,18 +1339,20 @@ static int gfar_start_xmit(struct sk_buff *skb, struct net_device *dev)
/* Set up checksumming */
if (CHECKSUM_PARTIAL == skb->ip_summed) {
- fcb = gfar_add_fcb(skb);
- lstatus |= BD_LFLAG(TXBD_TOE);
- gfar_tx_checksum(skb, fcb);
+ fcb = gfar_add_fcb(&skb);
+ if (likely(fcb != NULL)) {
+ 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 (unlikely(NULL == fcb))
+ fcb = gfar_add_fcb(&skb);
+ if (likely(fcb != NULL)) {
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 */
--
1.5.4
next prev parent reply other threads:[~2009-03-25 8:50 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-03-20 9:04 [PATCH] net/bridge: use the maximum hard_header_len of ports for bridging device Li Yang
2009-03-23 7:59 ` Li Yang
2009-03-23 8:02 ` David Miller
2009-03-23 8:15 ` Li Yang
2009-03-23 8:16 ` David Miller
2009-03-23 15:51 ` Stephen Hemminger
2009-03-23 22:20 ` David Miller
2009-03-23 22:45 ` Stephen Hemminger
2009-03-23 22:47 ` David Miller
2009-03-25 8:43 ` Li Yang
2009-03-25 21:35 ` David Miller
2009-03-25 6:40 ` David Miller
2009-03-25 7:05 ` Li Yang
2009-03-25 7:06 ` David Miller
2009-03-25 8:38 ` Li Yang
2009-03-25 9:15 ` Li Yang [this message]
2009-03-25 15:53 ` [PATCH] gianfar: reallocate skb when headroom is not enough for fcb Stephen Hemminger
2009-03-25 21:49 ` 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=1237972533-11195-1-git-send-email-leoli@freescale.com \
--to=leoli@freescale.com \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
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;
as well as URLs for NNTP newsgroup(s).