ixgbe: Add support for VXLAN RX offloads
Subsystems (2)
v3 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 Changes in V3:
- don't clear bits that were never set
- add unlikely to a header offset check
- change __constant_htons to simply htons
---
Mark 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 v3 1/2 ixgbe: Add support for UDP-encapsulated tx checksum offload
From: Mark Rustad <[email protected]>
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
Changes in V3:
- do not clear bits that were never set
- add unlikely to a header offset check
--- 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
@@ -6933,31 +6933,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 :
@@ -6983,7 +7007,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,
@@ -8227,6 +8250,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 (unlikely (skb_inner_mac_header (skb) -skb_transport_header (skb) > +IXGBE_MAX_TUNNEL_HDR_LEN )) +return features & ~NETIF_F_ALL_CSUM ; + +return features; +} +static const struct net_device_ops ixgbe_netdev_ops = { .ndo_open = ixgbe_open, .ndo_stop = ixgbe_close,
@@ -8275,6 +8313,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, };/**
@@ -8634,6 +8673,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 v3 1/2 ixgbe: Add support for UDP-encapsulated tx checksum offload
Quoted 8 lines · Mark D Rustad
From: Mark Rustad <[email protected]>
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.
Signed-off-by Mark Rustad <[email protected]>
Thanks, this looks nice to me now.
PATCH v3 2/2 ixgbe: Add support for VXLAN RX offloads
In reply to Mark D RustadFrom: Mark Rustad <[email protected]>
Add support for VXLAN RX offloads for the X55x devices that support them.
---
Changes in V3:
- change __constant_htons to simply htons
--- 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
@@ -632,6 +632,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)
@@ -646,6 +647,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;
@@ -759,7 +763,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
@@ -1519,20 +1519,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 :
@@ -1548,8 +1556,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
@@ -2566,9 +2566,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
@@ -2859,12 +2861,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 ,