netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] vlan: Keep NETIF_F_HW_CSUM similar to other software devices
@ 2017-05-05 20:17 Vladislav Yasevich
  2017-05-05 20:37 ` Alexander Duyck
  2017-05-08 18:39 ` David Miller
  0 siblings, 2 replies; 3+ messages in thread
From: Vladislav Yasevich @ 2017-05-05 20:17 UTC (permalink / raw)
  To: netdev; +Cc: mkubecek, alexander.duyck, avagin, Vladislav Yasevich

Vlan devices, like all other software devices, enable
NETIF_F_HW_CSUM feature.  However, unlike all the othe other
software devices, vlans will switch to using IP|IPV6_CSUM
features, if the underlying devices uses them.  In these situations,
checksum offload features on the vlan device can't be controlled
via ethtool.

This patch makes vlans keep HW_CSUM feature if the underlying
device supports checksum offloading.  This makes vlan devices
behave like other software devices, and restores control to the
user.

A side-effect is that some offload settings (typically UFO)
may be enabled on the vlan device while being disabled on the HW.
However, the GSO code will correctly process the packets. This
actually results in slightly better raw throughput.

Signed-off-by: Vladislav Yasevich <vyasevic@redhat.com>
---
V2:  posted the right patch.

 net/8021q/vlan_dev.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/net/8021q/vlan_dev.c b/net/8021q/vlan_dev.c
index 9ee5787..ff12cf3 100644
--- a/net/8021q/vlan_dev.c
+++ b/net/8021q/vlan_dev.c
@@ -626,11 +626,18 @@ static netdev_features_t vlan_dev_fix_features(struct net_device *dev,
 {
 	struct net_device *real_dev = vlan_dev_priv(dev)->real_dev;
 	netdev_features_t old_features = features;
+	netdev_features_t lower_features;
 
-	features = netdev_intersect_features(features, real_dev->vlan_features);
-	features |= NETIF_F_RXCSUM;
-	features = netdev_intersect_features(features, real_dev->features);
+	lower_features = netdev_intersect_features((real_dev->vlan_features |
+						    NETIF_F_RXCSUM),
+						   real_dev->features);
 
+	/* Add HW_CSUM setting to preserve user ability to control
+	 * checksum offload on the vlan device.
+	 */
+	if (lower_features & (NETIF_F_IP_CSUM|NETIF_F_IPV6_CSUM))
+		lower_features |= NETIF_F_HW_CSUM;
+	features = netdev_intersect_features(features, lower_features);
 	features |= old_features & (NETIF_F_SOFT_FEATURES | NETIF_F_GSO_SOFTWARE);
 	features |= NETIF_F_LLTX;
 
-- 
2.7.4

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

* Re: [PATCH v2] vlan: Keep NETIF_F_HW_CSUM similar to other software devices
  2017-05-05 20:17 [PATCH v2] vlan: Keep NETIF_F_HW_CSUM similar to other software devices Vladislav Yasevich
@ 2017-05-05 20:37 ` Alexander Duyck
  2017-05-08 18:39 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: Alexander Duyck @ 2017-05-05 20:37 UTC (permalink / raw)
  To: Vladislav Yasevich; +Cc: Netdev, Michal Kubecek, avagin, Vladislav Yasevich

On Fri, May 5, 2017 at 1:17 PM, Vladislav Yasevich <vyasevich@gmail.com> wrote:
> Vlan devices, like all other software devices, enable
> NETIF_F_HW_CSUM feature.  However, unlike all the othe other
> software devices, vlans will switch to using IP|IPV6_CSUM
> features, if the underlying devices uses them.  In these situations,
> checksum offload features on the vlan device can't be controlled
> via ethtool.
>
> This patch makes vlans keep HW_CSUM feature if the underlying
> device supports checksum offloading.  This makes vlan devices
> behave like other software devices, and restores control to the
> user.
>
> A side-effect is that some offload settings (typically UFO)
> may be enabled on the vlan device while being disabled on the HW.
> However, the GSO code will correctly process the packets. This
> actually results in slightly better raw throughput.
>
> Signed-off-by: Vladislav Yasevich <vyasevic@redhat.com>

Acked-by: Alexander Duyck <alexander.h.duyck@intel.com>

> ---
> V2:  posted the right patch.
>
>  net/8021q/vlan_dev.c | 13 ++++++++++---
>  1 file changed, 10 insertions(+), 3 deletions(-)
>
> diff --git a/net/8021q/vlan_dev.c b/net/8021q/vlan_dev.c
> index 9ee5787..ff12cf3 100644
> --- a/net/8021q/vlan_dev.c
> +++ b/net/8021q/vlan_dev.c
> @@ -626,11 +626,18 @@ static netdev_features_t vlan_dev_fix_features(struct net_device *dev,
>  {
>         struct net_device *real_dev = vlan_dev_priv(dev)->real_dev;
>         netdev_features_t old_features = features;
> +       netdev_features_t lower_features;
>
> -       features = netdev_intersect_features(features, real_dev->vlan_features);
> -       features |= NETIF_F_RXCSUM;
> -       features = netdev_intersect_features(features, real_dev->features);
> +       lower_features = netdev_intersect_features((real_dev->vlan_features |
> +                                                   NETIF_F_RXCSUM),
> +                                                  real_dev->features);
>
> +       /* Add HW_CSUM setting to preserve user ability to control
> +        * checksum offload on the vlan device.
> +        */
> +       if (lower_features & (NETIF_F_IP_CSUM|NETIF_F_IPV6_CSUM))
> +               lower_features |= NETIF_F_HW_CSUM;
> +       features = netdev_intersect_features(features, lower_features);
>         features |= old_features & (NETIF_F_SOFT_FEATURES | NETIF_F_GSO_SOFTWARE);
>         features |= NETIF_F_LLTX;
>
> --
> 2.7.4
>

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

* Re: [PATCH v2] vlan: Keep NETIF_F_HW_CSUM similar to other software devices
  2017-05-05 20:17 [PATCH v2] vlan: Keep NETIF_F_HW_CSUM similar to other software devices Vladislav Yasevich
  2017-05-05 20:37 ` Alexander Duyck
@ 2017-05-08 18:39 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2017-05-08 18:39 UTC (permalink / raw)
  To: vyasevich; +Cc: netdev, mkubecek, alexander.duyck, avagin, vyasevic

From: Vladislav Yasevich <vyasevich@gmail.com>
Date: Fri,  5 May 2017 16:17:41 -0400

> Vlan devices, like all other software devices, enable
> NETIF_F_HW_CSUM feature.  However, unlike all the othe other
> software devices, vlans will switch to using IP|IPV6_CSUM
> features, if the underlying devices uses them.  In these situations,
> checksum offload features on the vlan device can't be controlled
> via ethtool.
> 
> This patch makes vlans keep HW_CSUM feature if the underlying
> device supports checksum offloading.  This makes vlan devices
> behave like other software devices, and restores control to the
> user.
> 
> A side-effect is that some offload settings (typically UFO)
> may be enabled on the vlan device while being disabled on the HW.
> However, the GSO code will correctly process the packets. This
> actually results in slightly better raw throughput.
> 
> Signed-off-by: Vladislav Yasevich <vyasevic@redhat.com>
> ---
> V2:  posted the right patch.

Applied, thanks.

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

end of thread, other threads:[~2017-05-08 18:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-05-05 20:17 [PATCH v2] vlan: Keep NETIF_F_HW_CSUM similar to other software devices Vladislav Yasevich
2017-05-05 20:37 ` Alexander Duyck
2017-05-08 18:39 ` David 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).