Skip to content

Commit

Permalink
datapath: Enable tunnel GSO features.
Browse files Browse the repository at this point in the history
Following patch enables all available tunnel GSO features for OVS
bridge device so that ovs can use hardware offloads available to
underling device.

Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
Acked-by: Andy Zhou <azhou@nicira.com>
  • Loading branch information
Pravin B Shelar committed Sep 29, 2014
1 parent 3109f49 commit f17f159
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 1 deletion.
42 changes: 42 additions & 0 deletions datapath/linux/compat/include/linux/netdev_features.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,46 @@
#define NETIF_F_HW_VLAN_CTAG_TX NETIF_F_HW_VLAN_TX
#endif

#if LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0)
#define NETIF_F_GSO_ENCAP_ALL 0

#else

#ifndef NETIF_F_GSO_GRE
#define NETIF_F_GSO_GRE 0
#endif

#ifndef NETIF_F_GSO_GRE_CSUM
#define NETIF_F_GSO_GRE_CSUM 0
#endif

#ifndef NETIF_F_GSO_IPIP
#define NETIF_F_GSO_IPIP 0
#endif

#ifndef NETIF_F_GSO_SIT
#define NETIF_F_GSO_SIT 0
#endif

#ifndef NETIF_F_GSO_UDP_TUNNEL
#define NETIF_F_GSO_UDP_TUNNEL 0
#endif

#ifndef NETIF_F_GSO_UDP_TUNNEL_CSUM
#define NETIF_F_GSO_UDP_TUNNEL_CSUM 0
#endif

#ifndef NETIF_F_GSO_MPLS
#define NETIF_F_GSO_MPLS 0
#endif

#define NETIF_F_GSO_ENCAP_ALL (NETIF_F_GSO_GRE | \
NETIF_F_GSO_GRE_CSUM | \
NETIF_F_GSO_IPIP | \
NETIF_F_GSO_SIT | \
NETIF_F_GSO_UDP_TUNNEL | \
NETIF_F_GSO_UDP_TUNNEL_CSUM | \
NETIF_F_GSO_MPLS)
#endif

#endif
11 changes: 11 additions & 0 deletions datapath/linux/compat/include/net/gre.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,17 @@ static inline int ip_gre_calc_hlen(__be16 o_flags)
addend += 4;
return addend;
}
#else
static inline struct sk_buff *rpl_gre_handle_offloads(struct sk_buff *skb,
bool gre_csum)
{
if (skb->encapsulation && skb_is_gso(skb)) {
kfree_skb(skb);
return ERR_PTR(-ENOSYS);
}
return gre_handle_offloads(skb, gre_csum);
}
#define gre_handle_offloads rpl_gre_handle_offloads
#endif

#endif
16 changes: 16 additions & 0 deletions datapath/linux/compat/include/net/vxlan.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,22 @@
#include <linux/version.h>
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0)
#include_next <net/vxlan.h>

static inline int rpl_vxlan_xmit_skb(struct vxlan_sock *vs,
struct rtable *rt, struct sk_buff *skb,
__be32 src, __be32 dst, __u8 tos, __u8 ttl, __be16 df,
__be16 src_port, __be16 dst_port, __be32 vni)
{
if (skb->encapsulation && skb_is_gso(skb)) {
kfree_skb(skb);
return -ENOSYS;
}

return vxlan_xmit_skb(vs, rt, skb, src, dst, tos, ttl, df,
src_port, dst_port, vni);
}

#define vxlan_xmit_skb rpl_vxlan_xmit_skb
#else

struct vxlan_sock;
Expand Down
8 changes: 7 additions & 1 deletion datapath/vport-internal_dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -155,14 +155,20 @@ static void do_setup(struct net_device *netdev)
netdev->tx_queue_len = 0;

netdev->features = NETIF_F_LLTX | NETIF_F_SG | NETIF_F_FRAGLIST |
NETIF_F_HIGHDMA | NETIF_F_HW_CSUM | NETIF_F_GSO_SOFTWARE;
NETIF_F_HIGHDMA | NETIF_F_HW_CSUM |
NETIF_F_GSO_SOFTWARE | NETIF_F_GSO_ENCAP_ALL;

netdev->vlan_features = netdev->features;
netdev->features |= NETIF_F_HW_VLAN_CTAG_TX;

#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39)
netdev->hw_features = netdev->features & ~NETIF_F_LLTX;
#endif

#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
netdev->hw_enc_features = netdev->features;
#endif

eth_hw_addr_random(netdev);
}

Expand Down
5 changes: 5 additions & 0 deletions datapath/vport-lisp.c
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,11 @@ static int handle_offloads(struct sk_buff *skb)
#else
static int handle_offloads(struct sk_buff *skb)
{
if (skb->encapsulation && skb_is_gso(skb)) {
kfree_skb(skb);
return -ENOSYS;
}

if (skb_is_gso(skb)) {
int err = skb_unclone(skb, GFP_ATOMIC);
if (unlikely(err))
Expand Down

0 comments on commit f17f159

Please sign in to comment.