netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] net: vlan: add support for tunnel offload
@ 2018-11-07 10:28 Davide Caratti
  2018-11-08  6:23 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Davide Caratti @ 2018-11-07 10:28 UTC (permalink / raw)
  To: David S. Miller, Cong Wang, netdev, Flavio Leitner, Florian Westphal

GSO tunneled packets are always segmented in software before they are
transmitted by a VLAN, even when the lower device can offload tunnel
encapsulation and VLAN together (i.e., some bits in NETIF_F_GSO_ENCAP_ALL
mask are set in the lower device 'vlan_features'). If we let VLANs have
the same tunnel offload capabilities as their lower device, throughput
can improve significantly when CPU is limited on the transmitter side.

 - set NETIF_F_GSO_ENCAP_ALL bits in the VLAN 'hw_features', to ensure
 that 'features' will have those bits zeroed only when the lower device
 has no hardware support for tunnel encapsulation.
 - for the same reason, copy GSO-related bits of 'hw_enc_features' from
 lower device to VLAN, and ensure to update that value when the lower
 device changes its features.
 - set NETIF_F_HW_CSUM bit in the VLAN 'hw_enc_features' if 'real_dev'
 is able to compute checksums at least for a kind of packets, like done
 with commit 8403debeead8 ("vlan: Keep NETIF_F_HW_CSUM similar to other
 software devices"). This avoids software segmentation due to mismatching
 checksum capabilities between VLAN's 'features' and 'hw_enc_features'.

Reported-by: Flavio Leitner <fbl@redhat.com>
Signed-off-by: Davide Caratti <dcaratti@redhat.com>
---
 net/8021q/vlan.c     |  1 +
 net/8021q/vlan.h     | 12 ++++++++++++
 net/8021q/vlan_dev.c |  2 ++
 3 files changed, 15 insertions(+)

diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c
index 5e9950453955..1b7a375c6616 100644
--- a/net/8021q/vlan.c
+++ b/net/8021q/vlan.c
@@ -330,6 +330,7 @@ static void vlan_transfer_features(struct net_device *dev,
 
 	vlandev->priv_flags &= ~IFF_XMIT_DST_RELEASE;
 	vlandev->priv_flags |= (vlan->real_dev->priv_flags & IFF_XMIT_DST_RELEASE);
+	vlandev->hw_enc_features = vlan_tnl_features(vlan->real_dev);
 
 	netdev_update_features(vlandev);
 }
diff --git a/net/8021q/vlan.h b/net/8021q/vlan.h
index 44df1c3df02d..c46daf09a501 100644
--- a/net/8021q/vlan.h
+++ b/net/8021q/vlan.h
@@ -92,6 +92,18 @@ static inline struct net_device *vlan_find_dev(struct net_device *real_dev,
 	return NULL;
 }
 
+static inline netdev_features_t vlan_tnl_features(struct net_device *real_dev)
+{
+	netdev_features_t ret;
+
+	ret = real_dev->hw_enc_features &
+	      (NETIF_F_CSUM_MASK | NETIF_F_ALL_TSO | NETIF_F_GSO_ENCAP_ALL);
+
+	if ((ret & NETIF_F_GSO_ENCAP_ALL) && (ret & NETIF_F_CSUM_MASK))
+		return (ret & ~NETIF_F_CSUM_MASK) | NETIF_F_HW_CSUM;
+	return 0;
+}
+
 #define vlan_group_for_each_dev(grp, i, dev) \
 	for ((i) = 0; i < VLAN_PROTO_NUM * VLAN_N_VID; i++) \
 		if (((dev) = __vlan_group_get_device((grp), (i) / VLAN_N_VID, \
diff --git a/net/8021q/vlan_dev.c b/net/8021q/vlan_dev.c
index ff720f1ebf73..b2d9c8f27cd7 100644
--- a/net/8021q/vlan_dev.c
+++ b/net/8021q/vlan_dev.c
@@ -562,6 +562,7 @@ static int vlan_dev_init(struct net_device *dev)
 
 	dev->hw_features = NETIF_F_HW_CSUM | NETIF_F_SG |
 			   NETIF_F_FRAGLIST | NETIF_F_GSO_SOFTWARE |
+			   NETIF_F_GSO_ENCAP_ALL |
 			   NETIF_F_HIGHDMA | NETIF_F_SCTP_CRC |
 			   NETIF_F_ALL_FCOE;
 
@@ -572,6 +573,7 @@ static int vlan_dev_init(struct net_device *dev)
 		netdev_warn(real_dev, "VLAN features are set incorrectly.  Q-in-Q configurations may not work correctly.\n");
 
 	dev->vlan_features = real_dev->vlan_features & ~NETIF_F_ALL_FCOE;
+	dev->hw_enc_features = vlan_tnl_features(real_dev);
 
 	/* ipv6 shared card related stuff */
 	dev->dev_id = real_dev->dev_id;
-- 
2.19.1

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

* Re: [PATCH net-next] net: vlan: add support for tunnel offload
  2018-11-07 10:28 [PATCH net-next] net: vlan: add support for tunnel offload Davide Caratti
@ 2018-11-08  6:23 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2018-11-08  6:23 UTC (permalink / raw)
  To: dcaratti; +Cc: xiyou.wangcong, netdev, fbl, fw

From: Davide Caratti <dcaratti@redhat.com>
Date: Wed,  7 Nov 2018 11:28:18 +0100

> GSO tunneled packets are always segmented in software before they are
> transmitted by a VLAN, even when the lower device can offload tunnel
> encapsulation and VLAN together (i.e., some bits in NETIF_F_GSO_ENCAP_ALL
> mask are set in the lower device 'vlan_features'). If we let VLANs have
> the same tunnel offload capabilities as their lower device, throughput
> can improve significantly when CPU is limited on the transmitter side.
> 
>  - set NETIF_F_GSO_ENCAP_ALL bits in the VLAN 'hw_features', to ensure
>  that 'features' will have those bits zeroed only when the lower device
>  has no hardware support for tunnel encapsulation.
>  - for the same reason, copy GSO-related bits of 'hw_enc_features' from
>  lower device to VLAN, and ensure to update that value when the lower
>  device changes its features.
>  - set NETIF_F_HW_CSUM bit in the VLAN 'hw_enc_features' if 'real_dev'
>  is able to compute checksums at least for a kind of packets, like done
>  with commit 8403debeead8 ("vlan: Keep NETIF_F_HW_CSUM similar to other
>  software devices"). This avoids software segmentation due to mismatching
>  checksum capabilities between VLAN's 'features' and 'hw_enc_features'.
> 
> Reported-by: Flavio Leitner <fbl@redhat.com>
> Signed-off-by: Davide Caratti <dcaratti@redhat.com>

Applied.

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

end of thread, other threads:[~2018-11-08 15:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-07 10:28 [PATCH net-next] net: vlan: add support for tunnel offload Davide Caratti
2018-11-08  6:23 ` 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).