All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stephen Hemminger <shemminger@vyatta.com>
To: Li Yang <leoli@freescale.com>
Cc: davem@davemloft.net, netdev@vger.kernel.org,
	Li Yang <leoli@freescale.com>
Subject: Re: [PATCH] gianfar: reallocate skb when headroom is not enough for fcb
Date: Wed, 25 Mar 2009 08:53:33 -0700	[thread overview]
Message-ID: <20090325085333.4bb73f55@nehalam> (raw)
In-Reply-To: <1237972533-11195-1-git-send-email-leoli@freescale.com>

On Wed, 25 Mar 2009 17:15:33 +0800
Li Yang <leoli@freescale.com> wrote:

> 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);
> 

Overall, this looks like the wrong code (not copying back new skb)
and in awkward place. Also your version doesn't handle case where
skb headroom is not writable.

Why not:

--- a/drivers/net/gianfar.c	2009-03-25 08:39:03.890718197 -0700
+++ b/drivers/net/gianfar.c	2009-03-25 08:51:39.733279404 -0700
@@ -1309,6 +1309,17 @@ static int gfar_start_xmit(struct sk_buf
 	unsigned long flags;
 	unsigned int nr_frags, length;
 
+	/* make sure there is space and can write FCB */
+	if (!skb_clone_writeable(skb, GMAC_FCB_LEN)) {
+		struct sk_buff *skb2;
+
+		skb2 = skb_realloc_headroom(skb, GMAC_FCB_LEN);
+		kfree_skb(skb);
+		if (!skb2)
+			return NETDEV_TX_OK;
+		skb = skb2;
+	}
+
 	base = priv->tx_bd_base;
 
 	/* total number of fragments in the SKB */


  reply	other threads:[~2009-03-25 15:53 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-20  9:04 [Bridge] [PATCH] net/bridge: use the maximum hard_header_len of ports for bridging device Li Yang
2009-03-20  9:04 ` Li Yang
2009-03-23  7:59 ` [Bridge] " Li Yang
2009-03-23  7:59   ` Li Yang
2009-03-23  8:02   ` [Bridge] " David Miller
2009-03-23  8:02     ` David Miller
2009-03-23  8:15     ` [Bridge] " Li Yang
2009-03-23  8:15       ` Li Yang
2009-03-23  8:16       ` [Bridge] " David Miller
2009-03-23  8:16         ` David Miller
2009-03-23 15:51 ` [Bridge] " Stephen Hemminger
2009-03-23 15:51   ` Stephen Hemminger
2009-03-23 22:20   ` [Bridge] " David Miller
2009-03-23 22:20     ` David Miller
2009-03-23 22:45     ` [Bridge] " Stephen Hemminger
2009-03-23 22:45       ` Stephen Hemminger
2009-03-23 22:47       ` [Bridge] " David Miller
2009-03-23 22:47         ` David Miller
2009-03-25  8:43     ` [Bridge] " Li Yang
2009-03-25  8:43       ` Li Yang
2009-03-25 21:35       ` [Bridge] " David Miller
2009-03-25 21:35         ` David Miller
2009-03-25  6:40 ` [Bridge] " David Miller
2009-03-25  6:40   ` David Miller
2009-03-25  7:05   ` [Bridge] " Li Yang
2009-03-25  7:05     ` Li Yang
2009-03-25  7:06     ` [Bridge] " David Miller
2009-03-25  7:06       ` David Miller
2009-03-25  8:38       ` [Bridge] " Li Yang
2009-03-25  8:38         ` Li Yang
2009-03-25  9:15       ` [PATCH] gianfar: reallocate skb when headroom is not enough for fcb Li Yang
2009-03-25 15:53         ` Stephen Hemminger [this message]
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=20090325085333.4bb73f55@nehalam \
    --to=shemminger@vyatta.com \
    --cc=davem@davemloft.net \
    --cc=leoli@freescale.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.