netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stephen Hemminger <shemminger@vyatta.com>
To: Thomas Chou <thomas@wytron.com.tw>
Cc: netdev@vger.kernel.org
Subject: Re: [PATCH 3/4] ethoc: align received packet to make IP header at word boundary
Date: Wed, 7 Oct 2009 09:13:37 -0700	[thread overview]
Message-ID: <20091007091337.532d9ed1@nehalam> (raw)
In-Reply-To: <1254735200-2718-3-git-send-email-thomas@wytron.com.tw>

On Mon,  5 Oct 2009 17:33:19 +0800
Thomas Chou <thomas@wytron.com.tw> wrote:

> The packet buffer is allocated at 4 bytes boundary, but the IP header
> length and version bits is located at byte 14. These bit fields access
> as 32 bits word and caused exception on processors that do not support
> unaligned access.
> 
> The patch adds 2 bytes offset to make the bit fields word aligned.
> 
> Signed-off-by: Thomas Chou <thomas@wytron.com.tw>
> ---
>  drivers/net/ethoc.c |    4 ++++
>  1 files changed, 4 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/net/ethoc.c b/drivers/net/ethoc.c
> index f92747f..0c6c7f4 100644
> --- a/drivers/net/ethoc.c
> +++ b/drivers/net/ethoc.c
> @@ -399,6 +399,10 @@ static int ethoc_rx(struct net_device *dev, int limit)
>  		if (ethoc_update_rx_stats(priv, &bd) == 0) {
>  			int size = bd.stat >> 16;
>  			struct sk_buff *skb = netdev_alloc_skb(dev, size);
> +
> +			size -= 4; /* strip the CRC */
> +			skb_reserve(skb, 2); /* align TCP/IP header */

Please use NET_IP_ALIGN rather than hard coding 2 so that the value
can be changed on a per-cpu architecture basis if desired.

-- 

  parent reply	other threads:[~2009-10-07 16:14 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-05  9:33 [PATCH 1/4] ethoc: fix typo to compute number of tx descriptors Thomas Chou
2009-10-05  9:33 ` [PATCH 2/4] ethoc: fix buffer address mapping Thomas Chou
2009-10-05  9:33   ` [PATCH 3/4] ethoc: align received packet to make IP header at word boundary Thomas Chou
2009-10-05  9:33     ` [PATCH 4/4] ethoc: use system memory as buffer Thomas Chou
2009-10-07 10:42       ` David Miller
2009-10-07 10:42     ` [PATCH 3/4] ethoc: align received packet to make IP header at word boundary David Miller
2009-10-07 16:13     ` Stephen Hemminger [this message]
2009-10-07 20:52       ` David Miller
2009-10-08  2:42         ` Thomas Chou
2009-10-07 10:42   ` [PATCH 2/4] ethoc: fix buffer address mapping David Miller
2009-10-07 10:41 ` [PATCH 1/4] ethoc: fix typo to compute number of tx descriptors 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=20091007091337.532d9ed1@nehalam \
    --to=shemminger@vyatta.com \
    --cc=netdev@vger.kernel.org \
    --cc=thomas@wytron.com.tw \
    /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).