netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Grant Likely <grant.likely@secretlab.ca>
To: Anatolij Gustschin <agust@denx.de>
Cc: netdev@vger.kernel.org, linuxppc-dev@ozlabs.org,
	"David S. Miller" <davem@davemloft.net>,
	Detlev Zundel <dzu@denx.de>, Wolfgang Denk <wd@denx.de>,
	John Rigby <jcrigby@gmail.com>, Piotr Ziecik <kosmo@semihalf.com>
Subject: Re: [net-next-2.6 PATCH v2 3/3] fs_enet: add FEC TX buffer alignment workaround for MPC5121
Date: Wed, 17 Feb 2010 08:13:52 -0700	[thread overview]
Message-ID: <fa686aa41002170713g1ece7377l73142f854807f3f@mail.gmail.com> (raw)
In-Reply-To: <1266418530-2727-4-git-send-email-agust@denx.de>

On Wed, Feb 17, 2010 at 7:55 AM, Anatolij Gustschin <agust@denx.de> wrote:
> MPC5121 FEC requeries 4-byte alignmnent for TX data buffers.
> This patch is a work around that copies misaligned tx packets
> to an aligned skb before sending.
>
> Signed-off-by: John Rigby <jcrigby@gmail.com>
> Signed-off-by: Piotr Ziecik <kosmo@semihalf.com>
> Signed-off-by: Wolfgang Denk <wd@denx.de>
> Signed-off-by: Anatolij Gustschin <agust@denx.de>

Acked-by: Grant Likely <grant.likely@secretlab.ca>

> ---
>  drivers/net/fs_enet/fs_enet-main.c |   44 ++++++++++++++++++++++++++++++++++++
>  1 files changed, 44 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/net/fs_enet/fs_enet-main.c b/drivers/net/fs_enet/fs_enet-main.c
> index 4297021..166a89d 100644
> --- a/drivers/net/fs_enet/fs_enet-main.c
> +++ b/drivers/net/fs_enet/fs_enet-main.c
> @@ -580,6 +580,37 @@ 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(ENET_RX_FRSIZE + 4);
> +       if (!new_skb) {
> +               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);
> @@ -588,6 +619,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

Instead of
>        spin_lock_irqsave(&fep->tx_lock, flags);
>
>        /*
> --
> 1.6.3.3
>
>



-- 
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.

  reply	other threads:[~2010-02-17 15:14 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-17 14:55 [net-next-2.6 PATCH v2 0/3] Support for MPC512x FEC Anatolij Gustschin
2010-02-17 14:55 ` [net-next-2.6 PATCH v2 1/3] fs_enet: use dev_xxx instead of printk Anatolij Gustschin
2010-02-17 14:55   ` [net-next-2.6 PATCH v2 2/3] fs_enet: Add support for MPC512x to fs_enet driver Anatolij Gustschin
2010-02-17 14:55     ` [net-next-2.6 PATCH v2 3/3] fs_enet: add FEC TX buffer alignment workaround for MPC5121 Anatolij Gustschin
2010-02-17 15:13       ` Grant Likely [this message]
2010-02-17 15:17       ` Eric Dumazet
2010-02-17 21:31         ` Anatolij Gustschin
2010-02-17 22:08       ` [net-next-2.6 PATCH v3 " Anatolij Gustschin
2010-02-17 15:11     ` [net-next-2.6 PATCH v2 2/3] fs_enet: Add support for MPC512x to fs_enet driver Grant Likely
2010-02-22 11:37 ` [net-next-2.6 PATCH v2 0/3] Support for MPC512x FEC Anatolij Gustschin
2010-02-22 11:44   ` David Miller
2010-02-26 20:18     ` Anatolij Gustschin
2010-02-26 20:48       ` 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=fa686aa41002170713g1ece7377l73142f854807f3f@mail.gmail.com \
    --to=grant.likely@secretlab.ca \
    --cc=agust@denx.de \
    --cc=davem@davemloft.net \
    --cc=dzu@denx.de \
    --cc=jcrigby@gmail.com \
    --cc=kosmo@semihalf.com \
    --cc=linuxppc-dev@ozlabs.org \
    --cc=netdev@vger.kernel.org \
    --cc=wd@denx.de \
    /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).