2014-11-14 00:38:34

by Joe Stringer

[permalink] [raw]
Subject: [PATCHv2 net 0/4] Implement ndo_gso_check() for vxlan nics

Most NICs that report NETIF_F_GSO_UDP_TUNNEL support VXLAN, and not other
UDP-based encapsulation protocols where the format and size of the header may
differ. This patch series implements a generic ndo_gso_check() for detecting
VXLAN, then reuses it for these NICs.

Implementation shamelessly stolen from Tom Herbert (with minor fixups):
http://thread.gmane.org/gmane.linux.network/332428/focus=333111

v2: Drop i40e/fm10k patches (code diverged; handling separately).
Refactor common code into vxlan_gso_check() helper.
Minor style fixes.

Joe Stringer (4):
net: Add vxlan_gso_check() helper
be2net: Implement ndo_gso_check()
net/mlx4_en: Implement ndo_gso_check()
qlcnic: Implement ndo_gso_check()

drivers/net/ethernet/emulex/benet/be_main.c | 6 ++++++
drivers/net/ethernet/mellanox/mlx4/en_netdev.c | 6 ++++++
drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c | 6 ++++++
drivers/net/vxlan.c | 13 +++++++++++++
include/net/vxlan.h | 2 ++
5 files changed, 33 insertions(+)

--
1.7.10.4


2014-11-14 00:38:38

by Joe Stringer

[permalink] [raw]
Subject: [PATCHv2 net 1/4] net: Add vxlan_gso_check() helper

Most NICs that report NETIF_F_GSO_UDP_TUNNEL support VXLAN, and not
other UDP-based encapsulation protocols where the format and size of the
header differs. This patch implements a generic ndo_gso_check() for
VXLAN which will only advertise GSO support when the skb looks like it
contains VXLAN (or no UDP tunnelling at all).

Implementation shamelessly stolen from Tom Herbert:
http://thread.gmane.org/gmane.linux.network/332428/focus=333111

Signed-off-by: Joe Stringer <[email protected]>
---
v2: Merge helpers for be2net, mlx4, qlcnic
Use (sizeof(struct udphdr) + sizeof(struct vxlanhdr))
v1: Initial post
---
drivers/net/vxlan.c | 13 +++++++++++++
include/net/vxlan.h | 2 ++
2 files changed, 15 insertions(+)

diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
index fa9dc45..6b65863 100644
--- a/drivers/net/vxlan.c
+++ b/drivers/net/vxlan.c
@@ -1571,6 +1571,19 @@ static bool route_shortcircuit(struct net_device *dev, struct sk_buff *skb)
return false;
}

+bool vxlan_gso_check(struct sk_buff *skb)
+{
+ if ((skb_shinfo(skb)->gso_type & SKB_GSO_UDP_TUNNEL) &&
+ (skb->inner_protocol_type != ENCAP_TYPE_ETHER ||
+ skb->inner_protocol != htons(ETH_P_TEB) ||
+ (skb_inner_mac_header(skb) - skb_transport_header(skb) !=
+ sizeof(struct udphdr) + sizeof(struct vxlanhdr))))
+ return false;
+
+ return true;
+}
+EXPORT_SYMBOL_GPL(vxlan_gso_check);
+
#if IS_ENABLED(CONFIG_IPV6)
static int vxlan6_xmit_skb(struct vxlan_sock *vs,
struct dst_entry *dst, struct sk_buff *skb,
diff --git a/include/net/vxlan.h b/include/net/vxlan.h
index d5f59f3..afadf8e 100644
--- a/include/net/vxlan.h
+++ b/include/net/vxlan.h
@@ -45,6 +45,8 @@ int vxlan_xmit_skb(struct vxlan_sock *vs,
__be32 src, __be32 dst, __u8 tos, __u8 ttl, __be16 df,
__be16 src_port, __be16 dst_port, __be32 vni, bool xnet);

+bool vxlan_gso_check(struct sk_buff *skb);
+
/* IP header + UDP + VXLAN + Ethernet header */
#define VXLAN_HEADROOM (20 + 8 + 8 + 14)
/* IPv6 header + UDP + VXLAN + Ethernet header */
--
1.7.10.4

2014-11-14 00:38:48

by Joe Stringer

[permalink] [raw]
Subject: [PATCHv2 net 3/4] net/mlx4_en: Implement ndo_gso_check()

Use vxlan_gso_check() to advertise offload support for this NIC.

Signed-off-by: Joe Stringer <[email protected]>
---
v2: Refactor out vxlan helper.
---
drivers/net/ethernet/mellanox/mlx4/en_netdev.c | 6 ++++++
1 file changed, 6 insertions(+)

diff --git a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
index 02266e3..c5fcc56 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
@@ -2355,6 +2355,11 @@ static void mlx4_en_del_vxlan_port(struct net_device *dev,

queue_work(priv->mdev->workqueue, &priv->vxlan_del_task);
}
+
+static bool mlx4_en_gso_check(struct sk_buff *skb, struct net_device *dev)
+{
+ return vxlan_gso_check(skb);
+}
#endif

static const struct net_device_ops mlx4_netdev_ops = {
@@ -2386,6 +2391,7 @@ static const struct net_device_ops mlx4_netdev_ops = {
#ifdef CONFIG_MLX4_EN_VXLAN
.ndo_add_vxlan_port = mlx4_en_add_vxlan_port,
.ndo_del_vxlan_port = mlx4_en_del_vxlan_port,
+ .ndo_gso_check = mlx4_en_gso_check,
#endif
};

--
1.7.10.4

2014-11-14 00:38:46

by Joe Stringer

[permalink] [raw]
Subject: [PATCHv2 net 4/4] qlcnic: Implement ndo_gso_check()

Use vxlan_gso_check() to advertise offload support for this NIC.

Signed-off-by: Joe Stringer <[email protected]>
---
v2: Refactor out vxlan helper.
---
drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c | 6 ++++++
1 file changed, 6 insertions(+)

diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c
index f5e29f7..a913b3a 100644
--- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c
+++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c
@@ -503,6 +503,11 @@ static void qlcnic_del_vxlan_port(struct net_device *netdev,

adapter->flags |= QLCNIC_DEL_VXLAN_PORT;
}
+
+static bool qlcnic_gso_check(struct sk_buff *skb, struct net_device *dev)
+{
+ return vxlan_gso_check(skb);
+}
#endif

static const struct net_device_ops qlcnic_netdev_ops = {
@@ -526,6 +531,7 @@ static const struct net_device_ops qlcnic_netdev_ops = {
#ifdef CONFIG_QLCNIC_VXLAN
.ndo_add_vxlan_port = qlcnic_add_vxlan_port,
.ndo_del_vxlan_port = qlcnic_del_vxlan_port,
+ .ndo_gso_check = qlcnic_gso_check,
#endif
#ifdef CONFIG_NET_POLL_CONTROLLER
.ndo_poll_controller = qlcnic_poll_controller,
--
1.7.10.4

2014-11-14 00:39:41

by Joe Stringer

[permalink] [raw]
Subject: [PATCHv2 net 2/4] be2net: Implement ndo_gso_check()

Use vxlan_gso_check() to advertise offload support for this NIC.

Signed-off-by: Joe Stringer <[email protected]>
---
v2: Refactor out vxlan helper.
---
drivers/net/ethernet/emulex/benet/be_main.c | 6 ++++++
1 file changed, 6 insertions(+)

diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c
index 9a18e79..3e8475c 100644
--- a/drivers/net/ethernet/emulex/benet/be_main.c
+++ b/drivers/net/ethernet/emulex/benet/be_main.c
@@ -4421,6 +4421,11 @@ static void be_del_vxlan_port(struct net_device *netdev, sa_family_t sa_family,
"Disabled VxLAN offloads for UDP port %d\n",
be16_to_cpu(port));
}
+
+static bool be_gso_check(struct sk_buff *skb, struct net_device *dev)
+{
+ return vxlan_gso_check(skb);
+}
#endif

static const struct net_device_ops be_netdev_ops = {
@@ -4450,6 +4455,7 @@ static const struct net_device_ops be_netdev_ops = {
#ifdef CONFIG_BE2NET_VXLAN
.ndo_add_vxlan_port = be_add_vxlan_port,
.ndo_del_vxlan_port = be_del_vxlan_port,
+ .ndo_gso_check = be_gso_check,
#endif
};

--
1.7.10.4

2014-11-14 05:08:49

by Shahed Shaikh

[permalink] [raw]
Subject: RE: [PATCHv2 net 4/4] qlcnic: Implement ndo_gso_check()

> -----Original Message-----
> From: Joe Stringer [mailto:[email protected]]
> Sent: Friday, November 14, 2014 6:08 AM
> To: netdev
> Cc: [email protected]; Shahed Shaikh; [email protected]; Dept-
> GE Linux NIC Dev; Tom Herbert (Partner - google); [email protected];
> [email protected]; linux-kernel
> Subject: [PATCHv2 net 4/4] qlcnic: Implement ndo_gso_check()
>
> Use vxlan_gso_check() to advertise offload support for this NIC.
>
> Signed-off-by: Joe Stringer <[email protected]>
> ---
> v2: Refactor out vxlan helper.
> ---
> drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c | 6 ++++++
> 1 file changed, 6 insertions(+)

Acked-by: Shahed Shaikh <[email protected]>

Thanks Joe.

-Shahed
>
> diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c
> b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c
> index f5e29f7..a913b3a 100644
> --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c
> +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c
> @@ -503,6 +503,11 @@ static void qlcnic_del_vxlan_port(struct net_device
> *netdev,
>
> adapter->flags |= QLCNIC_DEL_VXLAN_PORT; }
> +
> +static bool qlcnic_gso_check(struct sk_buff *skb, struct net_device
> +*dev) {
> + return vxlan_gso_check(skb);
> +}
> #endif
>
> static const struct net_device_ops qlcnic_netdev_ops = { @@ -526,6 +531,7
> @@ static const struct net_device_ops qlcnic_netdev_ops = { #ifdef
> CONFIG_QLCNIC_VXLAN
> .ndo_add_vxlan_port = qlcnic_add_vxlan_port,
> .ndo_del_vxlan_port = qlcnic_del_vxlan_port,
> + .ndo_gso_check = qlcnic_gso_check,
> #endif
> #ifdef CONFIG_NET_POLL_CONTROLLER
> .ndo_poll_controller = qlcnic_poll_controller,
> --
> 1.7.10.4

2014-11-14 09:44:27

by Sathya Perla

[permalink] [raw]
Subject: RE: [PATCHv2 net 2/4] be2net: Implement ndo_gso_check()

> -----Original Message-----
> From: Joe Stringer [mailto:[email protected]]
>
> Use vxlan_gso_check() to advertise offload support for this NIC.
>
> Signed-off-by: Joe Stringer <[email protected]>

Acked-by: Sathya Perla <[email protected]>

Thanks!

> ---
> v2: Refactor out vxlan helper.
> ---
> drivers/net/ethernet/emulex/benet/be_main.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/drivers/net/ethernet/emulex/benet/be_main.c
> b/drivers/net/ethernet/emulex/benet/be_main.c
> index 9a18e79..3e8475c 100644
> --- a/drivers/net/ethernet/emulex/benet/be_main.c
> +++ b/drivers/net/ethernet/emulex/benet/be_main.c
> @@ -4421,6 +4421,11 @@ static void be_del_vxlan_port(struct net_device
> *netdev, sa_family_t sa_family,
> "Disabled VxLAN offloads for UDP port %d\n",
> be16_to_cpu(port));
> }
> +
> +static bool be_gso_check(struct sk_buff *skb, struct net_device *dev)
> +{
> + return vxlan_gso_check(skb);
> +}
> #endif
>
> static const struct net_device_ops be_netdev_ops = {
> @@ -4450,6 +4455,7 @@ static const struct net_device_ops be_netdev_ops
> = {
> #ifdef CONFIG_BE2NET_VXLAN
> .ndo_add_vxlan_port = be_add_vxlan_port,
> .ndo_del_vxlan_port = be_del_vxlan_port,
> + .ndo_gso_check = be_gso_check,
> #endif
> };
>
> --
> 1.7.10.4

2014-11-14 22:13:26

by David Miller

[permalink] [raw]
Subject: Re: [PATCHv2 net 0/4] Implement ndo_gso_check() for vxlan nics

From: Joe Stringer <[email protected]>
Date: Thu, 13 Nov 2014 16:38:11 -0800

> Most NICs that report NETIF_F_GSO_UDP_TUNNEL support VXLAN, and not other
> UDP-based encapsulation protocols where the format and size of the header may
> differ. This patch series implements a generic ndo_gso_check() for detecting
> VXLAN, then reuses it for these NICs.
>
> Implementation shamelessly stolen from Tom Herbert (with minor fixups):
> http://thread.gmane.org/gmane.linux.network/332428/focus=333111
>
> v2: Drop i40e/fm10k patches (code diverged; handling separately).
> Refactor common code into vxlan_gso_check() helper.
> Minor style fixes.

Series applied, thanks Joe.

2014-11-16 09:32:34

by Or Gerlitz

[permalink] [raw]
Subject: Re: [PATCHv2 net 3/4] net/mlx4_en: Implement ndo_gso_check()

On Fri, Nov 14, 2014 at 2:38 AM, Joe Stringer <[email protected]> wrote:
> Use vxlan_gso_check() to advertise offload support for this NIC.
>
> Signed-off-by: Joe Stringer <[email protected]>

FWIW (since the patches is applied already...)

Acked-by: Or Gerlitz <[email protected]>

thanks for addressing this piece.

2014-11-17 17:50:13

by Joe Stringer

[permalink] [raw]
Subject: Re: [PATCHv2 net 0/4] Implement ndo_gso_check() for vxlan nics

On Friday, November 14, 2014 14:13:21 David Miller wrote:
> From: Joe Stringer <[email protected]>
> Date: Thu, 13 Nov 2014 16:38:11 -0800
>
> > Most NICs that report NETIF_F_GSO_UDP_TUNNEL support VXLAN, and not other
> > UDP-based encapsulation protocols where the format and size of the header
> > may differ. This patch series implements a generic ndo_gso_check() for
> > detecting VXLAN, then reuses it for these NICs.
> >
> > Implementation shamelessly stolen from Tom Herbert (with minor fixups):
> > http://thread.gmane.org/gmane.linux.network/332428/focus=333111
> >
> > v2: Drop i40e/fm10k patches (code diverged; handling separately).
> >
> > Refactor common code into vxlan_gso_check() helper.
> > Minor style fixes.
>
> Series applied, thanks Joe.

Thanks.