ixgbe: Add support for VXLAN RX offloads
Subsystems (2)
v2 cover ixgbe: Add support for VXLAN RX offloads
VXLAN tx checksum offload support is added for all devices and VXLAN rx offload support, including ATR, is added for X55x devices that support it.
---
Changes in V2:
- UDP-encapsulated tx offload should now support more than VXLAN
- no longer set NETIF_F_GSO_UDP_TUNNEL
- validate inner header offset for tx offload support
---
Mark D Rustad (2):
ixgbe: Add support for UDP-encapsulated tx checksum offload
ixgbe: Add support for VXLAN RX offloads
drivers/net/ethernet/intel/ixgbe/ixgbe.h | 6 + drivers/net/ethernet/intel/ixgbe/ixgbe_82599.c | 18 ++ drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 178 ++++++++++++++++++++---- drivers/net/ethernet/intel/ixgbe/ixgbe_type.h | 15 +- 4 files changed, 177 insertions(+), 40 deletions(-)
Signature · 1 line
Mark Rustad, Network Division, Intel Corporation
PATCH v2 1/2 ixgbe: Add support for UDP-encapsulated tx checksum offload
By using GSO for UDP-encapsulated packets, all ixgbe devices can be directed to generate checksums for the inner headers because the outer UDP checksum can be zero. So point the machinery at the inner headers and have the hardware generate the checksum.
---
Changes in V2:
- do not set NETIF_F_GSO_UDP_TUNNEL
- allow more than VXLAN encapsulation
- check for inner header offset constraints
- clear TSO bits on encapsulated packets
--- drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 66 ++++++++++++++++++++----- 1 file changed, 54 insertions(+), 12 deletions(-)
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +54 -12
@@ -6896,31 +6896,55 @@ static void ixgbe_tx_csum(struct ixgbe_ring *tx_ring,if (!(first->tx_flags &IXGBE_TX_FLAGS_HW_VLAN ) && !(first->tx_flags &IXGBE_TX_FLAGS_CC ))return ; + vlan_macip_lens =skb_network_offset (skb) << +IXGBE_ADVTXD_MACLEN_SHIFT ; }else {u8 l4_hdr =0 ; -switch (first->protocol) { -case htons (ETH_P_IP ): - vlan_macip_lens |=skb_network_header_len (skb); +union { +struct iphdr *ipv4; +struct ipv6hdr *ipv6; +u8 *raw; + } network_hdr; +union { +struct tcphdr *tcphdr; +u8 *raw; + } transport_hdr; + +if (skb->encapsulation) { + network_hdr.raw =skb_inner_network_header (skb); + transport_hdr.raw =skb_inner_transport_header (skb); + vlan_macip_lens =skb_inner_network_offset (skb) << +IXGBE_ADVTXD_MACLEN_SHIFT ; + }else { + network_hdr.raw =skb_network_header (skb); + transport_hdr.raw =skb_transport_header (skb); + vlan_macip_lens =skb_network_offset (skb) << +IXGBE_ADVTXD_MACLEN_SHIFT ; + } + +/* use first 4 bits to determine IP version */ +switch (network_hdr.ipv4->version) { +case IPVERSION : + vlan_macip_lens |= transport_hdr.raw - network_hdr.raw; type_tucmd |=IXGBE_ADVTXD_TUCMD_IPV4 ; - l4_hdr =ip_hdr (skb)->protocol; + l4_hdr = network_hdr.ipv4->protocol;break ; -case htons (ETH_P_IPV6 ): - vlan_macip_lens |=skb_network_header_len (skb); - l4_hdr =ipv6_hdr (skb)->nexthdr; +case 6 : + vlan_macip_lens |= transport_hdr.raw - network_hdr.raw; + l4_hdr = network_hdr.ipv6->nexthdr;break ;default :if (unlikely (net_ratelimit ())) {dev_warn (tx_ring->dev, -"partial checksum but proto=%x!\n" , - first->protocol); +"partial checksum but version=%d\n" , + network_hdr.ipv4->version); } -break ; }switch (l4_hdr) {case IPPROTO_TCP : type_tucmd |=IXGBE_ADVTXD_TUCMD_L4T_TCP ; - mss_l4len_idx =tcp_hdrlen (skb) << + mss_l4len_idx = (transport_hdr.tcphdr->doff *4 ) <<IXGBE_ADVTXD_L4LEN_SHIFT ;break ;case IPPROTO_SCTP :
@@ -6946,7 +6970,6 @@ static void ixgbe_tx_csum(struct ixgbe_ring *tx_ring, }/* vlan_macip_lens: MACLEN, VLAN tag */ - vlan_macip_lens |=skb_network_offset (skb) <<IXGBE_ADVTXD_MACLEN_SHIFT ; vlan_macip_lens |= first->tx_flags &IXGBE_TX_FLAGS_VLAN_MASK ; ixgbe_tx_ctxtdesc(tx_ring, vlan_macip_lens, 0,
@@ -8190,6 +8213,21 @@ static void ixgbe_fwd_del(struct net_device *pdev, void *priv)kfree (fwd_adapter); } +#define IXGBE_MAX_TUNNEL_HDR_LEN 80 +static netdev_features_t +ixgbe_features_check (struct sk_buff *skb,struct net_device *dev, +netdev_features_t features) +{ +if (!skb->encapsulation) +return features; + +if (skb_inner_mac_header (skb) -skb_transport_header (skb) > +IXGBE_MAX_TUNNEL_HDR_LEN ) +return features & ~(NETIF_F_ALL_CSUM |NETIF_F_GSO_MASK ); + +return features & ~NETIF_F_ALL_TSO ; +} +static const struct net_device_ops ixgbe_netdev_ops = { .ndo_open = ixgbe_open, .ndo_stop = ixgbe_close,
@@ -8237,6 +8275,7 @@ static const struct net_device_ops ixgbe_netdev_ops = { .ndo_dfwd_del_station = ixgbe_fwd_del, .ndo_add_vxlan_port = ixgbe_add_vxlan_port, .ndo_del_vxlan_port = ixgbe_del_vxlan_port, + .ndo_features_check = ixgbe_features_check, };/**
@@ -8596,6 +8635,9 @@ skip_sriov: netdev->vlan_features |=NETIF_F_IPV6_CSUM ; netdev->vlan_features |=NETIF_F_SG ; + netdev->hw_enc_features |=NETIF_F_SG |NETIF_F_IP_CSUM | +NETIF_F_IPV6_CSUM ; + netdev->priv_flags |=IFF_UNICAST_FLT ; netdev->priv_flags |=IFF_SUPP_NOFCS ;
PATCH v2 1/2 ixgbe: Add support for UDP-encapsulated tx checksum offload
Quoted 4 lines · Mark D Rustad
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +0
-0
[...]
Quoted 4 lines
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +4
-0+#define IXGBE_MAX_TUNNEL_HDR_LEN 80 +static netdev_features_t +ixgbe_features_check (struct sk_buff *skb,struct net_device *dev, +netdev_features_t features)
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c static void ixgbe_fwd_del(struct net_device *pdev, void *priv) · line 8229
Quoted 10 lines
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +10
-0+{ +if (!skb->encapsulation) +return features; + +if (skb_inner_mac_header (skb) -skb_transport_header (skb) > +IXGBE_MAX_TUNNEL_HDR_LEN ) +return features & ~(NETIF_F_ALL_CSUM |NETIF_F_GSO_MASK ); + +return features & ~NETIF_F_ALL_TSO ; +}
Thanks, this looks nice. One suggestion - you shouldn't need to remove either NETIF_F_GSO_MASK or NETIF_F_ALL_TSO. Since neither of these were included in the original encapsulation flags we don't need to remove them at this point.
Rustad
PATCH v2 1/2 ixgbe: Add support for UDP-encapsulated tx checksum offload
Quoted 19 lines · Jesse Gross
Quoted 4 lines · Mark D Rustad
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +0
-0[...]
Quoted 11 lines
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +11
-0+#define IXGBE_MAX_TUNNEL_HDR_LEN 80 +static netdev_features_t +ixgbe_features_check (struct sk_buff *skb,struct net_device *dev, +netdev_features_t features) +{ +if (!skb->encapsulation) +return features; + +if (skb_inner_mac_header (skb) -skb_transport_header (skb) > +IXGBE_MAX_TUNNEL_HDR_LEN ) +return features & ~(NETIF_F_ALL_CSUM |NETIF_F_GSO_MASK );
Quoted 8 lines
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c static void ixgbe_fwd_del(struct net_device *pdev, void *priv) · line 8229
Quoted 3 lines
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +3
-0+ +return features & ~NETIF_F_ALL_TSO ; +}Thanks, this looks nice. One suggestion - you shouldn't need to remove either
NETIF_F_GSO_MASKorNETIF_F_ALL_TSO. Since neither of these were included in the original encapsulation flags we don't need to remove them at this point.
Yes, I was thinking too pedantically as I wrote this. Making that change will take instructions out of the encapsulation hot path, so I will certainly make that change. Maybe I should also put an unlikely around the offset check, since that should be very unlikely to be true.
Thank you so much for your reviews!
--
Mark Rustad, Networking Division, Intel Corporation
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 841 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://lists.osuosl.org/pipermail/intel-wired-lan/attachments/20150612/e75eb40c/attachment.asc>
PATCH v2 2/2 ixgbe: Add support for VXLAN RX offloads
In reply to Mark D RustadAdd support for VXLAN RX offloads for the X55x devices that support them.
--- drivers/net/ethernet/intel/ixgbe/ixgbe.h | 6 + drivers/net/ethernet/intel/ixgbe/ixgbe_82599.c | 18 +++- drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 112 ++++++++++++++++++++---- drivers/net/ethernet/intel/ixgbe/ixgbe_type.h | 15 ++- 4 files changed, 123 insertions(+), 28 deletions(-)
drivers/net/ethernet/intel/ixgbe/ixgbe.h +6 -0
@@ -630,6 +630,7 @@ struct ixgbe_adapter {#define IXGBE_FLAG_FCOE_ENABLED (u32)(1 << 21)#define IXGBE_FLAG_SRIOV_CAPABLE (u32)(1 << 22)#define IXGBE_FLAG_SRIOV_ENABLED (u32)(1 << 23) +#define IXGBE_FLAG_VXLAN_OFFLOAD_CAPABLE BIT(24)u32 flags2;#define IXGBE_FLAG2_RSC_CAPABLE (u32)(1 << 0)
@@ -644,6 +645,9 @@ struct ixgbe_adapter {#define IXGBE_FLAG2_RSS_FIELD_IPV6_UDP (u32)(1 << 9)#define IXGBE_FLAG2_PTP_PPS_ENABLED (u32)(1 << 10)#define IXGBE_FLAG2_PHY_INTERRUPT (u32)(1 << 11) +#ifdef CONFIG_IXGBE_VXLAN +#define IXGBE_FLAG2_VXLAN_REREG_NEEDED BIT(12) +#endif /* Tx fast path data */ int num_tx_queues;
@@ -757,7 +761,9 @@ struct ixgbe_adapter {u32 timer_event_accumulator;u32 vferr_refcount;struct ixgbe_mac_addr *mac_table; +#ifdef CONFIG_IXGBE_VXLAN u16 vxlan_port; +#endif struct kobject *info_kobj;#ifdef CONFIG_IXGBE_HWMON struct hwmon_buff *ixgbe_hwmon_buff;
drivers/net/ethernet/intel/ixgbe/ixgbe_82599.c +14 -4
@@ -1509,20 +1509,28 @@ static u32 ixgbe_atr_compute_sig_hash_82599(union ixgbe_atr_hash_dword input,* @input: unique input dword * @common: compressed common input dword * @queue: queue index to direct traffic to +* +* Note that the tunnel bit in input must not be set when the hardware +* tunneling support does not exist. **/ s32 ixgbe_fdir_add_signature_filter_82599 (struct ixgbe_hw *hw,union ixgbe_atr_hash_dword input,union ixgbe_atr_hash_dword common,u8 queue) { -u64 fdirhashcmd; -u32 fdircmd; +u64 fdirhashcmd; +u8 flow_type; +bool tunnel; +u32 fdircmd;/* * Get the flow_type in order to program FDIRCMD properly * lowest 2 bits are FDIRCMD.L4TYPE, third lowest bit is FDIRCMD.IPV6 */ -switch (input.formatted.flow_type) { + tunnel = !!(input.formatted.flow_type &IXGBE_ATR_L4TYPE_TUNNEL_MASK ); + flow_type = input.formatted.flow_type & + (IXGBE_ATR_L4TYPE_TUNNEL_MASK -1 ); +switch (flow_type) {case IXGBE_ATR_FLOW_TYPE_TCPV4 :case IXGBE_ATR_FLOW_TYPE_UDPV4 :case IXGBE_ATR_FLOW_TYPE_SCTPV4 :
@@ -1538,8 +1546,10 @@ s32 ixgbe_fdir_add_signature_filter_82599(struct ixgbe_hw *hw,/* configure FDIRCMD register */ fdircmd =IXGBE_FDIRCMD_CMD_ADD_FLOW |IXGBE_FDIRCMD_FILTER_UPDATE |IXGBE_FDIRCMD_LAST |IXGBE_FDIRCMD_QUEUE_EN ; - fdircmd |= input.formatted.flow_type <<IXGBE_FDIRCMD_FLOW_TYPE_SHIFT ; + fdircmd |= (u32 )flow_type <<IXGBE_FDIRCMD_FLOW_TYPE_SHIFT ; fdircmd |= (u32 )queue <<IXGBE_FDIRCMD_RX_QUEUE_SHIFT ; +if (tunnel) + fdircmd |=IXGBE_FDIRCMD_TUNNEL_FILTER ;/* * The lower 32-bits of fdirhashcmd is for FDIRHASH, the upper 32-bits
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +94 -18
241 lines not on this page · raw message
drivers/net/ethernet/intel/ixgbe/ixgbe_type.h +9 -6
@@ -2540,9 +2540,11 @@ enum ixgbe_fdir_pballoc_type {#define IXGBE_FDIRCMD_QUEUE_EN 0x00008000#define IXGBE_FDIRCMD_FLOW_TYPE_SHIFT 5#define IXGBE_FDIRCMD_RX_QUEUE_SHIFT 16 +#define IXGBE_FDIRCMD_RX_TUNNEL_FILTER_SHIFT 23#define IXGBE_FDIRCMD_VT_POOL_SHIFT 24#define IXGBE_FDIR_INIT_DONE_POLL 10#define IXGBE_FDIRCMD_CMD_POLL 10 +#define IXGBE_FDIRCMD_TUNNEL_FILTER 0x00800000#define IXGBE_FDIR_DROP_QUEUE 127
@@ -2833,12 +2835,13 @@ typedef u32 ixgbe_link_speed;#define IXGBE_ATR_SIGNATURE_HASH_KEY 0x174D3614/* Software ATR input stream values and masks */ -#define IXGBE_ATR_HASH_MASK 0x7fff -#define IXGBE_ATR_L4TYPE_MASK 0x3 -#define IXGBE_ATR_L4TYPE_UDP 0x1 -#define IXGBE_ATR_L4TYPE_TCP 0x2 -#define IXGBE_ATR_L4TYPE_SCTP 0x3 -#define IXGBE_ATR_L4TYPE_IPV6_MASK 0x4 +#define IXGBE_ATR_HASH_MASK 0x7fff +#define IXGBE_ATR_L4TYPE_MASK 0x3 +#define IXGBE_ATR_L4TYPE_UDP 0x1 +#define IXGBE_ATR_L4TYPE_TCP 0x2 +#define IXGBE_ATR_L4TYPE_SCTP 0x3 +#define IXGBE_ATR_L4TYPE_IPV6_MASK 0x4 +#define IXGBE_ATR_L4TYPE_TUNNEL_MASK 0x10enum ixgbe_atr_flow_type {IXGBE_ATR_FLOW_TYPE_IPV4 =0x0 ,IXGBE_ATR_FLOW_TYPE_UDPV4 =0x1 ,