Commit bda301c9 authored by David S. Miller's avatar David S. Miller

Merge branch 'sit_tso'

Eric Dumazet says:

====================
ipv6: sit: Implement TSO/GSO support

This patch series implements GSO/TSO support for SIT tunnels

Broadcom bnx2x driver is now enabled for TSO support of SIT traffic

Before patches :

lpq84:~# ./netperf -H 2002:af6:1153:: -Cc
MIGRATED TCP STREAM TEST from ::0 (::) port 0 AF_INET6 to 2002:af6:1153:: () port 0 AF_INET6
Recv   Send    Send                          Utilization       Service Demand
Socket Socket  Message  Elapsed              Send     Recv     Send    Recv
Size   Size    Size     Time     Throughput  local    remote   local   remote
bytes  bytes   bytes    secs.    10^6bits/s  % S      % S      us/KB   us/KB

 87380  16384  16384    10.00      3168.31   4.81     4.64     2.988   2.877

After patches :

lpq84:~# ./netperf -H 2002:af6:1153:: -Cc
MIGRATED TCP STREAM TEST from ::0 (::) port 0 AF_INET6 to 2002:af6:1153:: () port 0 AF_INET6
Recv   Send    Send                          Utilization       Service Demand
Socket Socket  Message  Elapsed              Send     Recv     Send    Recv
Size   Size    Size     Time     Throughput  local    remote   local   remote
bytes  bytes   bytes    secs.    10^6bits/s  % S      % S      us/KB   us/KB

 87380  16384  16384    10.00      6006.97   1.86     5.48     0.608   1.795
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 212124dd 2e3bd6a4
...@@ -12261,11 +12261,12 @@ static int bnx2x_init_dev(struct bnx2x *bp, struct pci_dev *pdev, ...@@ -12261,11 +12261,12 @@ static int bnx2x_init_dev(struct bnx2x *bp, struct pci_dev *pdev,
NETIF_F_RXHASH | NETIF_F_HW_VLAN_CTAG_TX; NETIF_F_RXHASH | NETIF_F_HW_VLAN_CTAG_TX;
if (!CHIP_IS_E1x(bp)) { if (!CHIP_IS_E1x(bp)) {
dev->hw_features |= NETIF_F_GSO_GRE | NETIF_F_GSO_UDP_TUNNEL | dev->hw_features |= NETIF_F_GSO_GRE | NETIF_F_GSO_UDP_TUNNEL |
NETIF_F_GSO_IPIP; NETIF_F_GSO_IPIP | NETIF_F_GSO_SIT;
dev->hw_enc_features = dev->hw_enc_features =
NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM | NETIF_F_SG | NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM | NETIF_F_SG |
NETIF_F_TSO | NETIF_F_TSO_ECN | NETIF_F_TSO6 | NETIF_F_TSO | NETIF_F_TSO_ECN | NETIF_F_TSO6 |
NETIF_F_GSO_IPIP | NETIF_F_GSO_IPIP |
NETIF_F_GSO_SIT |
NETIF_F_GSO_GRE | NETIF_F_GSO_UDP_TUNNEL; NETIF_F_GSO_GRE | NETIF_F_GSO_UDP_TUNNEL;
} }
......
...@@ -43,6 +43,7 @@ enum { ...@@ -43,6 +43,7 @@ enum {
NETIF_F_FSO_BIT, /* ... FCoE segmentation */ NETIF_F_FSO_BIT, /* ... FCoE segmentation */
NETIF_F_GSO_GRE_BIT, /* ... GRE with TSO */ NETIF_F_GSO_GRE_BIT, /* ... GRE with TSO */
NETIF_F_GSO_IPIP_BIT, /* ... IPIP tunnel with TSO */ NETIF_F_GSO_IPIP_BIT, /* ... IPIP tunnel with TSO */
NETIF_F_GSO_SIT_BIT, /* ... SIT tunnel with TSO */
NETIF_F_GSO_UDP_TUNNEL_BIT, /* ... UDP TUNNEL with TSO */ NETIF_F_GSO_UDP_TUNNEL_BIT, /* ... UDP TUNNEL with TSO */
NETIF_F_GSO_MPLS_BIT, /* ... MPLS segmentation */ NETIF_F_GSO_MPLS_BIT, /* ... MPLS segmentation */
/**/NETIF_F_GSO_LAST = /* last bit, see GSO_MASK */ /**/NETIF_F_GSO_LAST = /* last bit, see GSO_MASK */
...@@ -109,6 +110,7 @@ enum { ...@@ -109,6 +110,7 @@ enum {
#define NETIF_F_RXALL __NETIF_F(RXALL) #define NETIF_F_RXALL __NETIF_F(RXALL)
#define NETIF_F_GSO_GRE __NETIF_F(GSO_GRE) #define NETIF_F_GSO_GRE __NETIF_F(GSO_GRE)
#define NETIF_F_GSO_IPIP __NETIF_F(GSO_IPIP) #define NETIF_F_GSO_IPIP __NETIF_F(GSO_IPIP)
#define NETIF_F_GSO_SIT __NETIF_F(GSO_SIT)
#define NETIF_F_GSO_UDP_TUNNEL __NETIF_F(GSO_UDP_TUNNEL) #define NETIF_F_GSO_UDP_TUNNEL __NETIF_F(GSO_UDP_TUNNEL)
#define NETIF_F_GSO_MPLS __NETIF_F(GSO_MPLS) #define NETIF_F_GSO_MPLS __NETIF_F(GSO_MPLS)
#define NETIF_F_HW_VLAN_STAG_FILTER __NETIF_F(HW_VLAN_STAG_FILTER) #define NETIF_F_HW_VLAN_STAG_FILTER __NETIF_F(HW_VLAN_STAG_FILTER)
......
...@@ -320,9 +320,11 @@ enum { ...@@ -320,9 +320,11 @@ enum {
SKB_GSO_IPIP = 1 << 7, SKB_GSO_IPIP = 1 << 7,
SKB_GSO_UDP_TUNNEL = 1 << 8, SKB_GSO_SIT = 1 << 8,
SKB_GSO_MPLS = 1 << 9, SKB_GSO_UDP_TUNNEL = 1 << 9,
SKB_GSO_MPLS = 1 << 10,
}; };
#if BITS_PER_LONG > 32 #if BITS_PER_LONG > 32
......
...@@ -82,6 +82,7 @@ static const char netdev_features_strings[NETDEV_FEATURE_COUNT][ETH_GSTRING_LEN] ...@@ -82,6 +82,7 @@ static const char netdev_features_strings[NETDEV_FEATURE_COUNT][ETH_GSTRING_LEN]
[NETIF_F_FSO_BIT] = "tx-fcoe-segmentation", [NETIF_F_FSO_BIT] = "tx-fcoe-segmentation",
[NETIF_F_GSO_GRE_BIT] = "tx-gre-segmentation", [NETIF_F_GSO_GRE_BIT] = "tx-gre-segmentation",
[NETIF_F_GSO_IPIP_BIT] = "tx-ipip-segmentation", [NETIF_F_GSO_IPIP_BIT] = "tx-ipip-segmentation",
[NETIF_F_GSO_SIT_BIT] = "tx-sit-segmentation",
[NETIF_F_GSO_UDP_TUNNEL_BIT] = "tx-udp_tnl-segmentation", [NETIF_F_GSO_UDP_TUNNEL_BIT] = "tx-udp_tnl-segmentation",
[NETIF_F_GSO_MPLS_BIT] = "tx-mpls-segmentation", [NETIF_F_GSO_MPLS_BIT] = "tx-mpls-segmentation",
......
...@@ -1265,6 +1265,7 @@ static struct sk_buff *inet_gso_segment(struct sk_buff *skb, ...@@ -1265,6 +1265,7 @@ static struct sk_buff *inet_gso_segment(struct sk_buff *skb,
SKB_GSO_TCP_ECN | SKB_GSO_TCP_ECN |
SKB_GSO_GRE | SKB_GSO_GRE |
SKB_GSO_IPIP | SKB_GSO_IPIP |
SKB_GSO_SIT |
SKB_GSO_TCPV6 | SKB_GSO_TCPV6 |
SKB_GSO_UDP_TUNNEL | SKB_GSO_UDP_TUNNEL |
SKB_GSO_MPLS | SKB_GSO_MPLS |
......
...@@ -57,6 +57,7 @@ struct sk_buff *tcp_gso_segment(struct sk_buff *skb, ...@@ -57,6 +57,7 @@ struct sk_buff *tcp_gso_segment(struct sk_buff *skb,
SKB_GSO_TCPV6 | SKB_GSO_TCPV6 |
SKB_GSO_GRE | SKB_GSO_GRE |
SKB_GSO_IPIP | SKB_GSO_IPIP |
SKB_GSO_SIT |
SKB_GSO_MPLS | SKB_GSO_MPLS |
SKB_GSO_UDP_TUNNEL | SKB_GSO_UDP_TUNNEL |
0) || 0) ||
......
...@@ -90,6 +90,7 @@ static struct sk_buff *ipv6_gso_segment(struct sk_buff *skb, ...@@ -90,6 +90,7 @@ static struct sk_buff *ipv6_gso_segment(struct sk_buff *skb,
u8 *prevhdr; u8 *prevhdr;
int offset = 0; int offset = 0;
bool tunnel; bool tunnel;
int nhoff;
if (unlikely(skb_shinfo(skb)->gso_type & if (unlikely(skb_shinfo(skb)->gso_type &
~(SKB_GSO_UDP | ~(SKB_GSO_UDP |
...@@ -97,16 +98,23 @@ static struct sk_buff *ipv6_gso_segment(struct sk_buff *skb, ...@@ -97,16 +98,23 @@ static struct sk_buff *ipv6_gso_segment(struct sk_buff *skb,
SKB_GSO_TCP_ECN | SKB_GSO_TCP_ECN |
SKB_GSO_GRE | SKB_GSO_GRE |
SKB_GSO_IPIP | SKB_GSO_IPIP |
SKB_GSO_SIT |
SKB_GSO_UDP_TUNNEL | SKB_GSO_UDP_TUNNEL |
SKB_GSO_MPLS | SKB_GSO_MPLS |
SKB_GSO_TCPV6 | SKB_GSO_TCPV6 |
0))) 0)))
goto out; goto out;
skb_reset_network_header(skb);
nhoff = skb_network_header(skb) - skb_mac_header(skb);
if (unlikely(!pskb_may_pull(skb, sizeof(*ipv6h)))) if (unlikely(!pskb_may_pull(skb, sizeof(*ipv6h))))
goto out; goto out;
tunnel = skb->encapsulation; tunnel = SKB_GSO_CB(skb)->encap_level > 0;
if (tunnel)
features = skb->dev->hw_enc_features & netif_skb_features(skb);
SKB_GSO_CB(skb)->encap_level += sizeof(*ipv6h);
ipv6h = ipv6_hdr(skb); ipv6h = ipv6_hdr(skb);
__skb_pull(skb, sizeof(*ipv6h)); __skb_pull(skb, sizeof(*ipv6h));
segs = ERR_PTR(-EPROTONOSUPPORT); segs = ERR_PTR(-EPROTONOSUPPORT);
...@@ -123,13 +131,17 @@ static struct sk_buff *ipv6_gso_segment(struct sk_buff *skb, ...@@ -123,13 +131,17 @@ static struct sk_buff *ipv6_gso_segment(struct sk_buff *skb,
goto out; goto out;
for (skb = segs; skb; skb = skb->next) { for (skb = segs; skb; skb = skb->next) {
ipv6h = ipv6_hdr(skb); ipv6h = (struct ipv6hdr *)(skb_mac_header(skb) + nhoff);
ipv6h->payload_len = htons(skb->len - skb->mac_len - ipv6h->payload_len = htons(skb->len - nhoff - sizeof(*ipv6h));
sizeof(*ipv6h)); if (tunnel) {
skb_reset_inner_headers(skb);
skb->encapsulation = 1;
}
skb->network_header = (u8 *)ipv6h - skb->head;
if (!tunnel && proto == IPPROTO_UDP) { if (!tunnel && proto == IPPROTO_UDP) {
unfrag_ip6hlen = ip6_find_1stfragopt(skb, &prevhdr); unfrag_ip6hlen = ip6_find_1stfragopt(skb, &prevhdr);
fptr = (struct frag_hdr *)(skb_network_header(skb) + fptr = (struct frag_hdr *)((u8 *)ipv6h + unfrag_ip6hlen);
unfrag_ip6hlen);
fptr->frag_off = htons(offset); fptr->frag_off = htons(offset);
if (skb->next != NULL) if (skb->next != NULL)
fptr->frag_off |= htons(IP6_MF); fptr->frag_off |= htons(IP6_MF);
...@@ -265,6 +277,13 @@ static struct packet_offload ipv6_packet_offload __read_mostly = { ...@@ -265,6 +277,13 @@ static struct packet_offload ipv6_packet_offload __read_mostly = {
}, },
}; };
static const struct net_offload sit_offload = {
.callbacks = {
.gso_send_check = ipv6_gso_send_check,
.gso_segment = ipv6_gso_segment,
},
};
static int __init ipv6_offload_init(void) static int __init ipv6_offload_init(void)
{ {
...@@ -276,6 +295,9 @@ static int __init ipv6_offload_init(void) ...@@ -276,6 +295,9 @@ static int __init ipv6_offload_init(void)
pr_crit("%s: Cannot add EXTHDRS protocol offload\n", __func__); pr_crit("%s: Cannot add EXTHDRS protocol offload\n", __func__);
dev_add_offload(&ipv6_packet_offload); dev_add_offload(&ipv6_packet_offload);
inet_add_offload(&sit_offload, IPPROTO_IPV6);
return 0; return 0;
} }
......
...@@ -933,10 +933,9 @@ static netdev_tx_t ipip6_tunnel_xmit(struct sk_buff *skb, ...@@ -933,10 +933,9 @@ static netdev_tx_t ipip6_tunnel_xmit(struct sk_buff *skb,
ttl = iph6->hop_limit; ttl = iph6->hop_limit;
tos = INET_ECN_encapsulate(tos, ipv6_get_dsfield(iph6)); tos = INET_ECN_encapsulate(tos, ipv6_get_dsfield(iph6));
if (likely(!skb->encapsulation)) { skb = iptunnel_handle_offloads(skb, false, SKB_GSO_SIT);
skb_reset_inner_headers(skb); if (IS_ERR(skb))
skb->encapsulation = 1; goto out;
}
err = iptunnel_xmit(rt, skb, fl4.saddr, fl4.daddr, IPPROTO_IPV6, tos, err = iptunnel_xmit(rt, skb, fl4.saddr, fl4.daddr, IPPROTO_IPV6, tos,
ttl, df, !net_eq(tunnel->net, dev_net(dev))); ttl, df, !net_eq(tunnel->net, dev_net(dev)));
...@@ -946,8 +945,9 @@ static netdev_tx_t ipip6_tunnel_xmit(struct sk_buff *skb, ...@@ -946,8 +945,9 @@ static netdev_tx_t ipip6_tunnel_xmit(struct sk_buff *skb,
tx_error_icmp: tx_error_icmp:
dst_link_failure(skb); dst_link_failure(skb);
tx_error: tx_error:
dev->stats.tx_errors++;
dev_kfree_skb(skb); dev_kfree_skb(skb);
out:
dev->stats.tx_errors++;
return NETDEV_TX_OK; return NETDEV_TX_OK;
} }
...@@ -956,13 +956,15 @@ static netdev_tx_t ipip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev) ...@@ -956,13 +956,15 @@ static netdev_tx_t ipip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev)
struct ip_tunnel *tunnel = netdev_priv(dev); struct ip_tunnel *tunnel = netdev_priv(dev);
const struct iphdr *tiph = &tunnel->parms.iph; const struct iphdr *tiph = &tunnel->parms.iph;
if (likely(!skb->encapsulation)) { skb = iptunnel_handle_offloads(skb, false, SKB_GSO_IPIP);
skb_reset_inner_headers(skb); if (IS_ERR(skb))
skb->encapsulation = 1; goto out;
}
ip_tunnel_xmit(skb, dev, tiph, IPPROTO_IPIP); ip_tunnel_xmit(skb, dev, tiph, IPPROTO_IPIP);
return NETDEV_TX_OK; return NETDEV_TX_OK;
out:
dev->stats.tx_errors++;
return NETDEV_TX_OK;
} }
static netdev_tx_t sit_tunnel_xmit(struct sk_buff *skb, static netdev_tx_t sit_tunnel_xmit(struct sk_buff *skb,
...@@ -1292,6 +1294,12 @@ static void ipip6_dev_free(struct net_device *dev) ...@@ -1292,6 +1294,12 @@ static void ipip6_dev_free(struct net_device *dev)
free_netdev(dev); free_netdev(dev);
} }
#define SIT_FEATURES (NETIF_F_SG | \
NETIF_F_FRAGLIST | \
NETIF_F_HIGHDMA | \
NETIF_F_GSO_SOFTWARE | \
NETIF_F_HW_CSUM)
static void ipip6_tunnel_setup(struct net_device *dev) static void ipip6_tunnel_setup(struct net_device *dev)
{ {
dev->netdev_ops = &ipip6_netdev_ops; dev->netdev_ops = &ipip6_netdev_ops;
...@@ -1305,6 +1313,8 @@ static void ipip6_tunnel_setup(struct net_device *dev) ...@@ -1305,6 +1313,8 @@ static void ipip6_tunnel_setup(struct net_device *dev)
dev->iflink = 0; dev->iflink = 0;
dev->addr_len = 4; dev->addr_len = 4;
dev->features |= NETIF_F_LLTX; dev->features |= NETIF_F_LLTX;
dev->features |= SIT_FEATURES;
dev->hw_features |= SIT_FEATURES;
} }
static int ipip6_tunnel_init(struct net_device *dev) static int ipip6_tunnel_init(struct net_device *dev)
......
...@@ -65,6 +65,7 @@ static struct sk_buff *udp6_ufo_fragment(struct sk_buff *skb, ...@@ -65,6 +65,7 @@ static struct sk_buff *udp6_ufo_fragment(struct sk_buff *skb,
SKB_GSO_UDP_TUNNEL | SKB_GSO_UDP_TUNNEL |
SKB_GSO_GRE | SKB_GSO_GRE |
SKB_GSO_IPIP | SKB_GSO_IPIP |
SKB_GSO_SIT |
SKB_GSO_MPLS) || SKB_GSO_MPLS) ||
!(type & (SKB_GSO_UDP)))) !(type & (SKB_GSO_UDP))))
goto out; goto out;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment