netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Ethernet Bridging: Enable Hardware Checksumming
@ 2005-05-18 23:53 Jon Mason
  2005-05-19  0:03 ` Nivedita Singhvi
                   ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: Jon Mason @ 2005-05-18 23:53 UTC (permalink / raw)
  To: shemminger; +Cc: netdev

Currently, locally generated ethernet traffic does not take advantage of
hardware checksum offload when acting as a child device under a bridge
device.  This is because the upper layers do not see the available
features of the child devices only the features of the bridge device
(which is empty).  

There is an easy solution for this (see patch below), include hardware
checksum and scatter gather as features of the bridge device.  In the 
case that the physical ethernet device does not support scatter 
gather or hardware checksum, dev_queue_xmit() will check the
dev->features and do the necessary linearization and calculate the
checksum.

Signed-off-by: Jon Mason <jdmason@us.ibm.com>

--- net/bridge/br_device.c.orig	2005-05-13 11:23:02.552751024 -0500
+++ net/bridge/br_device.c	2005-05-13 11:25:39.155943720 -0500
@@ -101,4 +101,5 @@ void br_dev_setup(struct net_device *dev
 	dev->tx_queue_len = 0;
 	dev->set_mac_address = NULL;
 	dev->priv_flags = IFF_EBRIDGE;
+	dev->features = NETIF_F_HW_CSUM | NETIF_F_SG;
 }

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] Ethernet Bridging: Enable Hardware Checksumming
  2005-05-18 23:53 [PATCH] Ethernet Bridging: Enable Hardware Checksumming Jon Mason
@ 2005-05-19  0:03 ` Nivedita Singhvi
  2005-05-19  5:00   ` David S. Miller
  2005-05-19  2:41 ` Herbert Xu
  2005-05-19 20:33 ` Stephen Hemminger
  2 siblings, 1 reply; 13+ messages in thread
From: Nivedita Singhvi @ 2005-05-19  0:03 UTC (permalink / raw)
  To: Jon Mason; +Cc: shemminger, netdev

Jon Mason wrote:

> Currently, locally generated ethernet traffic does not take advantage of
> hardware checksum offload when acting as a child device under a bridge
> device.  This is because the upper layers do not see the available
> features of the child devices only the features of the bridge device
> (which is empty).  
> 
> There is an easy solution for this (see patch below), include hardware
> checksum and scatter gather as features of the bridge device.  In the 
> case that the physical ethernet device does not support scatter 
> gather or hardware checksum, dev_queue_xmit() will check the
> dev->features and do the necessary linearization and calculate the
> checksum.
> 
> Signed-off-by: Jon Mason <jdmason@us.ibm.com>
> 
> --- net/bridge/br_device.c.orig	2005-05-13 11:23:02.552751024 -0500
> +++ net/bridge/br_device.c	2005-05-13 11:25:39.155943720 -0500
> @@ -101,4 +101,5 @@ void br_dev_setup(struct net_device *dev
>  	dev->tx_queue_len = 0;
>  	dev->set_mac_address = NULL;
>  	dev->priv_flags = IFF_EBRIDGE;
> +	dev->features = NETIF_F_HW_CSUM | NETIF_F_SG;
>  }

Stephen,

I think this is a good thing to have, gives us performance
gain (equivalent to using/not using checksum offload) and
has very little impact on the bridging layer, and is
independent of the virtualization stuff..

thanks,
Nivedita

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] Ethernet Bridging: Enable Hardware Checksumming
  2005-05-18 23:53 [PATCH] Ethernet Bridging: Enable Hardware Checksumming Jon Mason
  2005-05-19  0:03 ` Nivedita Singhvi
@ 2005-05-19  2:41 ` Herbert Xu
  2005-05-19 15:10   ` Nivedita Singhvi
  2005-05-19 20:33 ` Stephen Hemminger
  2 siblings, 1 reply; 13+ messages in thread
From: Herbert Xu @ 2005-05-19  2:41 UTC (permalink / raw)
  To: Jon Mason; +Cc: shemminger, netdev

Jon Mason <jdmason@us.ibm.com> wrote:
> 
> checksum and scatter gather as features of the bridge device.  In the 
> case that the physical ethernet device does not support scatter 
> gather or hardware checksum, dev_queue_xmit() will check the
> dev->features and do the necessary linearization and calculate the
> checksum.

Unfortunately skb_linearize is a lot more expensive than not
generating the non-linear skb's in the first place.

So this is going to hurt people using the bridge devices over
physical devices that don't support SG.

Cheers,
-- 
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] Ethernet Bridging: Enable Hardware Checksumming
  2005-05-19  0:03 ` Nivedita Singhvi
@ 2005-05-19  5:00   ` David S. Miller
  2005-05-19 15:13     ` Nivedita Singhvi
  0 siblings, 1 reply; 13+ messages in thread
From: David S. Miller @ 2005-05-19  5:00 UTC (permalink / raw)
  To: niv; +Cc: jdmason, shemminger, netdev

From: Nivedita Singhvi <niv@us.ibm.com>
Date: Wed, 18 May 2005 17:03:51 -0700

> I think this is a good thing to have, gives us performance
> gain (equivalent to using/not using checksum offload) and
> has very little impact on the bridging layer, and is
> independent of the virtualization stuff..

I agree but keep in mind that when bridging over non-checksumming
devices it will be more expensive.  Especially for TCP.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] Ethernet Bridging: Enable Hardware Checksumming
  2005-05-19  2:41 ` Herbert Xu
@ 2005-05-19 15:10   ` Nivedita Singhvi
  2005-05-19 18:51     ` David S. Miller
  0 siblings, 1 reply; 13+ messages in thread
From: Nivedita Singhvi @ 2005-05-19 15:10 UTC (permalink / raw)
  To: Herbert Xu; +Cc: Jon Mason, shemminger, netdev

Herbert Xu wrote:

> Jon Mason <jdmason@us.ibm.com> wrote:
> 
>>checksum and scatter gather as features of the bridge device.  In the 
>>case that the physical ethernet device does not support scatter 
>>gather or hardware checksum, dev_queue_xmit() will check the
>>dev->features and do the necessary linearization and calculate the
>>checksum.
> 
> 
> Unfortunately skb_linearize is a lot more expensive than not
> generating the non-linear skb's in the first place.
> 
> So this is going to hurt people using the bridge devices over
> physical devices that don't support SG.

Fair point - though I would argue that devices that
support SG are much more common now - so optimizing
for the more common case might be preferable - since
people using bridging with devices that support
checksum offload are taking quite a hit when they
do bridging - perhaps this could be a conditional?

thanks,
Nivedita

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] Ethernet Bridging: Enable Hardware Checksumming
  2005-05-19  5:00   ` David S. Miller
@ 2005-05-19 15:13     ` Nivedita Singhvi
  2005-05-19 20:34       ` Stephen Hemminger
  0 siblings, 1 reply; 13+ messages in thread
From: Nivedita Singhvi @ 2005-05-19 15:13 UTC (permalink / raw)
  To: David S. Miller; +Cc: jdmason, shemminger, netdev

David S. Miller wrote:

>>I think this is a good thing to have, gives us performance
>>gain (equivalent to using/not using checksum offload) and
>>has very little impact on the bridging layer, and is
>>independent of the virtualization stuff..
> 
> 
> I agree but keep in mind that when bridging over non-checksumming
> devices it will be more expensive.  Especially for TCP.

Yep - as I just said to Herbert - perhaps worthwhile then
conditional upon support of checksum offload & SG?

thanks,
Nivedita

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] Ethernet Bridging: Enable Hardware Checksumming
  2005-05-19 15:10   ` Nivedita Singhvi
@ 2005-05-19 18:51     ` David S. Miller
  2005-05-19 20:43       ` Nivedita Singhvi
  0 siblings, 1 reply; 13+ messages in thread
From: David S. Miller @ 2005-05-19 18:51 UTC (permalink / raw)
  To: niv; +Cc: herbert, jdmason, shemminger, netdev

From: Nivedita Singhvi <niv@us.ibm.com>
Date: Thu, 19 May 2005 08:10:13 -0700

> Fair point - though I would argue that devices that
> support SG are much more common now - so optimizing
> for the more common case might be preferable - since
> people using bridging with devices that support
> checksum offload are taking quite a hit when they
> do bridging - perhaps this could be a conditional?

I disagree.  Many low costs devices are non-SG still,
there is no reason to penalize them explicitly.

I think instead we should look at ways to propagate
the hardware device features to the bridge.  Even if
a bridge is composed of multiple devices, we just
advertise the subset of features actually supported.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] Ethernet Bridging: Enable Hardware Checksumming
  2005-05-18 23:53 [PATCH] Ethernet Bridging: Enable Hardware Checksumming Jon Mason
  2005-05-19  0:03 ` Nivedita Singhvi
  2005-05-19  2:41 ` Herbert Xu
@ 2005-05-19 20:33 ` Stephen Hemminger
  2005-05-19 21:48   ` David S. Miller
  2 siblings, 1 reply; 13+ messages in thread
From: Stephen Hemminger @ 2005-05-19 20:33 UTC (permalink / raw)
  To: Jon Mason; +Cc: netdev

Here is a somewhat different patch from 2.6.12-rc4-bridge
http://developer.osdl.org/shemminger/patches/2.6.12-rc4-bridge/

The bridge doesn't need locking, or checksumming and can allow highdma
buffers; all of which are handled by net/core/dev.c if needed.


===================================================================
--- netem-2.6.12-rc4.orig/net/bridge/br_device.c
+++ netem-2.6.12-rc4/net/bridge/br_device.c
@@ -101,4 +99,6 @@ void br_dev_setup(struct net_device *dev
 	dev->tx_queue_len = 0;
 	dev->set_mac_address = NULL;
 	dev->priv_flags = IFF_EBRIDGE;
+	dev->features |= NETIF_F_SG | NETIF_F_NO_CSUM 
+		| NETIF_F_HIGHDMA | NETIF_F_LLTX;
 }

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] Ethernet Bridging: Enable Hardware Checksumming
  2005-05-19 15:13     ` Nivedita Singhvi
@ 2005-05-19 20:34       ` Stephen Hemminger
  0 siblings, 0 replies; 13+ messages in thread
From: Stephen Hemminger @ 2005-05-19 20:34 UTC (permalink / raw)
  To: Nivedita Singhvi; +Cc: David S. Miller, jdmason, netdev

On Thu, 19 May 2005 08:13:40 -0700
Nivedita Singhvi <niv@us.ibm.com> wrote:

> David S. Miller wrote:
> 
> >>I think this is a good thing to have, gives us performance
> >>gain (equivalent to using/not using checksum offload) and
> >>has very little impact on the bridging layer, and is
> >>independent of the virtualization stuff..
> > 
> > 
> > I agree but keep in mind that when bridging over non-checksumming
> > devices it will be more expensive.  Especially for TCP.
> 
> Yep - as I just said to Herbert - perhaps worthwhile then
> conditional upon support of checksum offload & SG?

What about mixed device bridges? 

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] Ethernet Bridging: Enable Hardware Checksumming
  2005-05-19 18:51     ` David S. Miller
@ 2005-05-19 20:43       ` Nivedita Singhvi
  0 siblings, 0 replies; 13+ messages in thread
From: Nivedita Singhvi @ 2005-05-19 20:43 UTC (permalink / raw)
  To: David S. Miller; +Cc: herbert, jdmason, shemminger, netdev

David S. Miller wrote:

> I think instead we should look at ways to propagate
> the hardware device features to the bridge.  Even if
> a bridge is composed of multiple devices, we just
> advertise the subset of features actually supported.

Just for some background:

In the typical Xen virtual environment, the primary
interface is typically bridged with virtual interfaces
that talk to other partitions.

Since currently the bridge doesn't advertise them,
this results in the loss of hw checksum offload,
segmentation offload, and sendfile exploitation
(sendfile() falls down to the usual tcp_sendmsg()
case) etc on the primary partition traffic talking
to remote hosts.

This can be rather painful, and performance comparisons
with other OSs which don't do this are even more of
an apples to oranges comparison since this is
somewhat silently happening.

Hence the need for enhancing the bridging environment
somewhat :).

thanks,
Nivedita

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] Ethernet Bridging: Enable Hardware Checksumming
  2005-05-19 20:33 ` Stephen Hemminger
@ 2005-05-19 21:48   ` David S. Miller
  2005-05-19 23:23     ` Jon Mason
  0 siblings, 1 reply; 13+ messages in thread
From: David S. Miller @ 2005-05-19 21:48 UTC (permalink / raw)
  To: shemminger; +Cc: jdmason, netdev

From: Stephen Hemminger <shemminger@osdl.org>
Date: Thu, 19 May 2005 13:33:33 -0700

> The bridge doesn't need locking, or checksumming and can allow highdma
> buffers; all of which are handled by net/core/dev.c if needed.

As discuesed elsewhere, this handling by net/core/dev.c makes
TCP sending much more expensive when it is actually used.

Furthermore, I just found another hole in the idea to propagate
sub-device features into the bridge device.

If one device has NETIF_F_HW_CSUM and the others have NETIF_F_IP_CSUM,
both bits will be set in the bridge device and things will entirely
break.  The two checksumming on output schemes are different, and all
of the stack assumes that only one of these two bits are set.

I have such a setup in two of my sparc64 systems (sunhme does
NETIF_F_HW_CSUM, and tg3 does NETIF_F_IP_CSUM).  Also, my PowerMAC G5
has this problem too, the onboard sungem chip does NETIF_F_HW_CSUM and
the tg3 I have in a PCI slot does NETIF_F_P_CSUM.  So given that
half the machines I have powered on right here could trigger the
problem, it's far from theoretical :-)

There are multiple spots that want to do this kind of stuff
now (bridging, vlan, bonding) which indicates that some sort
of common infrastructure should be written to implement this
kind of stuff.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] Ethernet Bridging: Enable Hardware Checksumming
  2005-05-19 21:48   ` David S. Miller
@ 2005-05-19 23:23     ` Jon Mason
  2005-05-19 23:36       ` David S. Miller
  0 siblings, 1 reply; 13+ messages in thread
From: Jon Mason @ 2005-05-19 23:23 UTC (permalink / raw)
  To: David S. Miller; +Cc: shemminger, netdev

On Thursday 19 May 2005 04:48 pm, David S. Miller wrote:
> From: Stephen Hemminger <shemminger@osdl.org>
> Date: Thu, 19 May 2005 13:33:33 -0700
>
> > The bridge doesn't need locking, or checksumming and can allow highdma
> > buffers; all of which are handled by net/core/dev.c if needed.
>
> As discuesed elsewhere, this handling by net/core/dev.c makes
> TCP sending much more expensive when it is actually used.
>
> Furthermore, I just found another hole in the idea to propagate
> sub-device features into the bridge device.
>
> If one device has NETIF_F_HW_CSUM and the others have NETIF_F_IP_CSUM,
> both bits will be set in the bridge device and things will entirely
> break.  The two checksumming on output schemes are different, and all
> of the stack assumes that only one of these two bits are set.
>
> I have such a setup in two of my sparc64 systems (sunhme does
> NETIF_F_HW_CSUM, and tg3 does NETIF_F_IP_CSUM).  Also, my PowerMAC G5
> has this problem too, the onboard sungem chip does NETIF_F_HW_CSUM and
> the tg3 I have in a PCI slot does NETIF_F_IP_CSUM.  So given that
> half the machines I have powered on right here could trigger the
> problem, it's far from theoretical :-)
>
> There are multiple spots that want to do this kind of stuff
> now (bridging, vlan, bonding) which indicates that some sort
> of common infrastructure should be written to implement this
> kind of stuff.

Since NETIF_F_HW_CSUM encompasses NETIF_F_IP_CSUM, perhaps it would be better 
to use the latter until such time as a new infrastructure can be implimented.

Thanks,
Jon

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] Ethernet Bridging: Enable Hardware Checksumming
  2005-05-19 23:23     ` Jon Mason
@ 2005-05-19 23:36       ` David S. Miller
  0 siblings, 0 replies; 13+ messages in thread
From: David S. Miller @ 2005-05-19 23:36 UTC (permalink / raw)
  To: jdmason; +Cc: shemminger, netdev

From: Jon Mason <jdmason@us.ibm.com>
Date: Thu, 19 May 2005 18:23:31 -0500

> Since NETIF_F_HW_CSUM encompasses NETIF_F_IP_CSUM, perhaps it would
> be better to use the latter until such time as a new infrastructure
> can be implimented.

Probably, that is the best idea, it is again another
definition of "subset".

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2005-05-19 23:36 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-05-18 23:53 [PATCH] Ethernet Bridging: Enable Hardware Checksumming Jon Mason
2005-05-19  0:03 ` Nivedita Singhvi
2005-05-19  5:00   ` David S. Miller
2005-05-19 15:13     ` Nivedita Singhvi
2005-05-19 20:34       ` Stephen Hemminger
2005-05-19  2:41 ` Herbert Xu
2005-05-19 15:10   ` Nivedita Singhvi
2005-05-19 18:51     ` David S. Miller
2005-05-19 20:43       ` Nivedita Singhvi
2005-05-19 20:33 ` Stephen Hemminger
2005-05-19 21:48   ` David S. Miller
2005-05-19 23:23     ` Jon Mason
2005-05-19 23:36       ` David S. Miller

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