Message ID | 1254735200-2718-3-git-send-email-thomas@wytron.com.tw |
---|---|
State | Accepted, archived |
Delegated to: | David Miller |
Headers | show |
From: Thomas Chou <thomas@wytron.com.tw> Date: Mon, 5 Oct 2009 17:33:19 +0800 > 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> Applied. -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
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.
From: Stephen Hemminger <shemminger@vyatta.com> Date: Wed, 7 Oct 2009 09:13:37 -0700 > On Mon, 5 Oct 2009 17:33:19 +0800 > Thomas Chou <thomas@wytron.com.tw> wrote: > >> 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. Indeed. Thomas please send a patch to fix this up, thanks. -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On 10/08/2009 04:52 AM, David Miller wrote: > From: Stephen Hemminger<shemminger@vyatta.com> > Date: Wed, 7 Oct 2009 09:13:37 -0700 > >> On Mon, 5 Oct 2009 17:33:19 +0800 >> Thomas Chou<thomas@wytron.com.tw> wrote: >> >>> 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. > > Indeed. > > Thomas please send a patch to fix this up, thanks. > > Submitted. Thanks. - Thomas -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
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 */ + if (likely(skb)) { void *src = phys_to_virt(bd.addr); memcpy_fromio(skb_put(skb, size), src, size);
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(-)