Skip to content

Commit 0906712

Browse files
Alexander Duyckdavem330
authored andcommitted
net/mlx4_en: Add support for inner IPv6 checksum offloads and TSO
>From what I can tell the ConnectX-3 will support an inner IPv6 checksum and segmentation offload, however it cannot support outer IPv6 headers. This assumption is based on the fact that I could see the checksum being offloaded for inner header on IPv4 tunnels, but not on IPv6 tunnels. For this reason I am adding the feature to the hw_enc_features and adding an extra check to the features_check call that will disable GSO and checksum offload in the case that the encapsulated frame has an outer IP version of that is not 4. The check in mlx4_en_features_check could be removed if at some point in the future a fix is found that allows the hardware to offload segmentation/checksum on tunnels with an outer IPv6 header. Signed-off-by: Alexander Duyck <aduyck@mirantis.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 3c9346b commit 0906712

2 files changed

Lines changed: 33 additions & 7 deletions

File tree

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

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2357,8 +2357,10 @@ 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 |
23622364
NETIF_F_GSO_UDP_TUNNEL_CSUM |
23632365
NETIF_F_GSO_PARTIAL;
23642366
}
@@ -2369,8 +2371,10 @@ static void mlx4_en_del_vxlan_offloads(struct work_struct *work)
23692371
struct mlx4_en_priv *priv = container_of(work, struct mlx4_en_priv,
23702372
vxlan_del_task);
23712373
/* unset offloads */
2372-
priv->dev->hw_enc_features &= ~(NETIF_F_IP_CSUM | NETIF_F_RXCSUM |
2373-
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 |
23742378
NETIF_F_GSO_UDP_TUNNEL_CSUM |
23752379
NETIF_F_GSO_PARTIAL);
23762380

@@ -2431,7 +2435,18 @@ static netdev_features_t mlx4_en_features_check(struct sk_buff *skb,
24312435
netdev_features_t features)
24322436
{
24332437
features = vlan_features_check(skb, features);
2434-
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;
24352450
}
24362451
#endif
24372452

‎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);

0 commit comments

Comments
 (0)