Skip to content

Commit 53da5b4

Browse files
committed
Merge branch 'tunnel-features-and-gso-partial'
Alexander Duyck says: ==================== Fix Tunnel features and enable GSO partial for several drivers This patch series is meant to allow us to get the best performance possible for Mellanox ConnectX-3/4 and Broadcom NetXtreme-C/E adapters in terms of VXLAN and GRE tunnels. The first 3 patches address issues I found in regards to GSO_PARTIAL and TSO_MANGLEID. The next 4 patches go through and enable GSO_PARTIAL for VXLAN tunnels that have an outer checksum enabled, and then enable IPv6 support where I can. One outstanding issue is that I wasn't able to get offloads working with outer IPv6 headers on mlx4. However that wasn't a feature that was enabled before so it isn't technically a regression, however I believe Engineers from Mellanox said they would look into it since they thought it should be supported. The last patch enables GSO_PARTIAL for VXLAN and GRE tunnels on the bnxt driver. One piece of feedback I received on the patch was that the hardware has globally set IPv6 UDP tunnels to always have the checksum field computed. I plan to work with Broadcom to get that addressed so that we only populate the checksum field if it was requested by the network stack. v2: Rebased patches off of latest changes to the mlx4/mlx5 drivers. Added bnxt driver patch as I received feedback on the RFC. v3: Moved 2 patches into series for net as they were generic fixes. Added patch to disable GSO partial if frame is less than 2x size of MSS There are outstanding issues as called out above that need to be addressed, however they were present before these patches so it isn't as if they introduce a regression. In addition gains can be easily seen so there should be no issue with applying the driver patches while the IPv6 mlx4_en and bnxt issues are being researched. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
2 parents f132ae7 + 152971e commit 53da5b4

6 files changed

Lines changed: 69 additions & 18 deletions

File tree

‎drivers/net/ethernet/broadcom/bnxt/bnxt.c‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6219,14 +6219,19 @@ static int bnxt_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
62196219
NETIF_F_TSO | NETIF_F_TSO6 |
62206220
NETIF_F_GSO_UDP_TUNNEL | NETIF_F_GSO_GRE |
62216221
NETIF_F_GSO_IPIP | NETIF_F_GSO_SIT |
6222-
NETIF_F_RXHASH |
6222+
NETIF_F_GSO_UDP_TUNNEL_CSUM | NETIF_F_GSO_GRE_CSUM |
6223+
NETIF_F_GSO_PARTIAL | NETIF_F_RXHASH |
62236224
NETIF_F_RXCSUM | NETIF_F_LRO | NETIF_F_GRO;
62246225

62256226
dev->hw_enc_features =
62266227
NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM | NETIF_F_SG |
62276228
NETIF_F_TSO | NETIF_F_TSO6 |
62286229
NETIF_F_GSO_UDP_TUNNEL | NETIF_F_GSO_GRE |
6229-
NETIF_F_GSO_IPIP | NETIF_F_GSO_SIT;
6230+
NETIF_F_GSO_UDP_TUNNEL_CSUM | NETIF_F_GSO_GRE_CSUM |
6231+
NETIF_F_GSO_IPIP | NETIF_F_GSO_SIT |
6232+
NETIF_F_GSO_PARTIAL;
6233+
dev->gso_partial_features = NETIF_F_GSO_UDP_TUNNEL_CSUM |
6234+
NETIF_F_GSO_GRE_CSUM;
62306235
dev->vlan_features = dev->hw_features | NETIF_F_HIGHDMA;
62316236
dev->hw_features |= NETIF_F_HW_VLAN_CTAG_RX | NETIF_F_HW_VLAN_CTAG_TX |
62326237
NETIF_F_HW_VLAN_STAG_RX | NETIF_F_HW_VLAN_STAG_TX;

‎drivers/net/ethernet/mellanox/mlx4/en_netdev.c‎

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2357,8 +2357,12 @@ static void mlx4_en_add_vxlan_offloads(struct work_struct *work)
23572357
}
23582358

23592359
/* set offloads */
2360-
priv->dev->hw_enc_features |= NETIF_F_IP_CSUM | NETIF_F_RXCSUM |
2361-
NETIF_F_TSO | NETIF_F_GSO_UDP_TUNNEL;
2360+
priv->dev->hw_enc_features |= NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM |
2361+
NETIF_F_RXCSUM |
2362+
NETIF_F_TSO | NETIF_F_TSO6 |
2363+
NETIF_F_GSO_UDP_TUNNEL |
2364+
NETIF_F_GSO_UDP_TUNNEL_CSUM |
2365+
NETIF_F_GSO_PARTIAL;
23622366
}
23632367

23642368
static void mlx4_en_del_vxlan_offloads(struct work_struct *work)
@@ -2367,8 +2371,12 @@ static void mlx4_en_del_vxlan_offloads(struct work_struct *work)
23672371
struct mlx4_en_priv *priv = container_of(work, struct mlx4_en_priv,
23682372
vxlan_del_task);
23692373
/* unset offloads */
2370-
priv->dev->hw_enc_features &= ~(NETIF_F_IP_CSUM | NETIF_F_RXCSUM |
2371-
NETIF_F_TSO | NETIF_F_GSO_UDP_TUNNEL);
2374+
priv->dev->hw_enc_features &= ~(NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM |
2375+
NETIF_F_RXCSUM |
2376+
NETIF_F_TSO | NETIF_F_TSO6 |
2377+
NETIF_F_GSO_UDP_TUNNEL |
2378+
NETIF_F_GSO_UDP_TUNNEL_CSUM |
2379+
NETIF_F_GSO_PARTIAL);
23722380

23732381
ret = mlx4_SET_PORT_VXLAN(priv->mdev->dev, priv->port,
23742382
VXLAN_STEER_BY_OUTER_MAC, 0);
@@ -2427,7 +2435,18 @@ static netdev_features_t mlx4_en_features_check(struct sk_buff *skb,
24272435
netdev_features_t features)
24282436
{
24292437
features = vlan_features_check(skb, features);
2430-
return vxlan_features_check(skb, features);
2438+
features = vxlan_features_check(skb, features);
2439+
2440+
/* The ConnectX-3 doesn't support outer IPv6 checksums but it does
2441+
* support inner IPv6 checksums and segmentation so we need to
2442+
* strip that feature if this is an IPv6 encapsulated frame.
2443+
*/
2444+
if (skb->encapsulation &&
2445+
(skb->ip_summed == CHECKSUM_PARTIAL) &&
2446+
(ip_hdr(skb)->version != 4))
2447+
features &= ~(NETIF_F_CSUM_MASK | NETIF_F_GSO_MASK);
2448+
2449+
return features;
24312450
}
24322451
#endif
24332452

@@ -2992,8 +3011,13 @@ int mlx4_en_init_netdev(struct mlx4_en_dev *mdev, int port,
29923011
}
29933012

29943013
if (mdev->dev->caps.tunnel_offload_mode == MLX4_TUNNEL_OFFLOAD_MODE_VXLAN) {
2995-
dev->hw_features |= NETIF_F_GSO_UDP_TUNNEL;
2996-
dev->features |= NETIF_F_GSO_UDP_TUNNEL;
3014+
dev->hw_features |= NETIF_F_GSO_UDP_TUNNEL |
3015+
NETIF_F_GSO_UDP_TUNNEL_CSUM |
3016+
NETIF_F_GSO_PARTIAL;
3017+
dev->features |= NETIF_F_GSO_UDP_TUNNEL |
3018+
NETIF_F_GSO_UDP_TUNNEL_CSUM |
3019+
NETIF_F_GSO_PARTIAL;
3020+
dev->gso_partial_features = NETIF_F_GSO_UDP_TUNNEL_CSUM;
29973021
}
29983022

29993023
mdev->pndev[port] = dev;

‎drivers/net/ethernet/mellanox/mlx4/en_tx.c‎

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
#include <linux/vmalloc.h>
4242
#include <linux/tcp.h>
4343
#include <linux/ip.h>
44+
#include <linux/ipv6.h>
4445
#include <linux/moduleparam.h>
4546

4647
#include "mlx4_en.h"
@@ -920,8 +921,18 @@ netdev_tx_t mlx4_en_xmit(struct sk_buff *skb, struct net_device *dev)
920921
tx_ind, fragptr);
921922

922923
if (skb->encapsulation) {
923-
struct iphdr *ipv4 = (struct iphdr *)skb_inner_network_header(skb);
924-
if (ipv4->protocol == IPPROTO_TCP || ipv4->protocol == IPPROTO_UDP)
924+
union {
925+
struct iphdr *v4;
926+
struct ipv6hdr *v6;
927+
unsigned char *hdr;
928+
} ip;
929+
u8 proto;
930+
931+
ip.hdr = skb_inner_network_header(skb);
932+
proto = (ip.v4->version == 4) ? ip.v4->protocol :
933+
ip.v6->nexthdr;
934+
935+
if (proto == IPPROTO_TCP || proto == IPPROTO_UDP)
925936
op_own |= cpu_to_be32(MLX4_WQE_CTRL_IIP | MLX4_WQE_CTRL_ILP);
926937
else
927938
op_own |= cpu_to_be32(MLX4_WQE_CTRL_IIP);

‎drivers/net/ethernet/mellanox/mlx5/core/en_main.c‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2802,13 +2802,17 @@ static void mlx5e_build_netdev(struct net_device *netdev)
28022802
netdev->hw_features |= NETIF_F_HW_VLAN_CTAG_FILTER;
28032803

28042804
if (mlx5e_vxlan_allowed(mdev)) {
2805-
netdev->hw_features |= NETIF_F_GSO_UDP_TUNNEL;
2805+
netdev->hw_features |= NETIF_F_GSO_UDP_TUNNEL |
2806+
NETIF_F_GSO_UDP_TUNNEL_CSUM |
2807+
NETIF_F_GSO_PARTIAL;
28062808
netdev->hw_enc_features |= NETIF_F_IP_CSUM;
2807-
netdev->hw_enc_features |= NETIF_F_RXCSUM;
2809+
netdev->hw_enc_features |= NETIF_F_IPV6_CSUM;
28082810
netdev->hw_enc_features |= NETIF_F_TSO;
28092811
netdev->hw_enc_features |= NETIF_F_TSO6;
2810-
netdev->hw_enc_features |= NETIF_F_RXHASH;
28112812
netdev->hw_enc_features |= NETIF_F_GSO_UDP_TUNNEL;
2813+
netdev->hw_enc_features |= NETIF_F_GSO_UDP_TUNNEL_CSUM |
2814+
NETIF_F_GSO_PARTIAL;
2815+
netdev->gso_partial_features = NETIF_F_GSO_UDP_TUNNEL_CSUM;
28122816
}
28132817

28142818
mlx5_query_port_fcs(mdev, &fcs_supported, &fcs_enabled);

‎net/core/dev.c‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6721,6 +6721,10 @@ static netdev_features_t netdev_fix_features(struct net_device *dev,
67216721
features &= ~NETIF_F_TSO6;
67226722
}
67236723

6724+
/* TSO with IPv4 ID mangling requires IPv4 TSO be enabled */
6725+
if ((features & NETIF_F_TSO_MANGLEID) && !(features & NETIF_F_TSO))
6726+
features &= ~NETIF_F_TSO_MANGLEID;
6727+
67246728
/* TSO ECN requires that TSO is present as well. */
67256729
if ((features & NETIF_F_ALL_TSO) == NETIF_F_TSO_ECN)
67266730
features &= ~NETIF_F_TSO_ECN;

‎net/core/skbuff.c‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3080,8 +3080,7 @@ struct sk_buff *skb_segment(struct sk_buff *head_skb,
30803080
unsigned int headroom;
30813081
unsigned int len = head_skb->len;
30823082
__be16 proto;
3083-
bool csum;
3084-
int sg = !!(features & NETIF_F_SG);
3083+
bool csum, sg;
30853084
int nfrags = skb_shinfo(head_skb)->nr_frags;
30863085
int err = -ENOMEM;
30873086
int i = 0;
@@ -3093,15 +3092,19 @@ struct sk_buff *skb_segment(struct sk_buff *head_skb,
30933092
if (unlikely(!proto))
30943093
return ERR_PTR(-EINVAL);
30953094

3095+
sg = !!(features & NETIF_F_SG);
30963096
csum = !!can_checksum_protocol(features, proto);
30973097

30983098
/* GSO partial only requires that we trim off any excess that
30993099
* doesn't fit into an MSS sized block, so take care of that
31003100
* now.
31013101
*/
3102-
if (features & NETIF_F_GSO_PARTIAL) {
3102+
if (sg && csum && (features & NETIF_F_GSO_PARTIAL)) {
31033103
partial_segs = len / mss;
3104-
mss *= partial_segs;
3104+
if (partial_segs > 1)
3105+
mss *= partial_segs;
3106+
else
3107+
partial_segs = 0;
31053108
}
31063109

31073110
headroom = skb_headroom(head_skb);

0 commit comments

Comments
 (0)