Skip to content

Commit 70da682

Browse files
Shannon NelsonJeff Kirsher
Shannon Nelson
authored and
Jeff Kirsher
committed
ixgbe: enable TSO with IPsec offload
Fix things up to support TSO offload in conjunction with IPsec hw offload. This raises throughput with IPsec offload on to nearly line rate. Signed-off-by: Shannon Nelson <[email protected]> Tested-by: Andrew Bowers <[email protected]> Signed-off-by: Jeff Kirsher <[email protected]>
1 parent 1db685e commit 70da682

File tree

2 files changed

+29
-11
lines changed

2 files changed

+29
-11
lines changed

drivers/net/ethernet/intel/ixgbe/ixgbe_ipsec.c

+7-2
Original file line numberDiff line numberDiff line change
@@ -929,8 +929,13 @@ void ixgbe_init_ipsec_offload(struct ixgbe_adapter *adapter)
929929
ixgbe_ipsec_clear_hw_tables(adapter);
930930

931931
adapter->netdev->xfrmdev_ops = &ixgbe_xfrmdev_ops;
932-
adapter->netdev->features |= NETIF_F_HW_ESP;
933-
adapter->netdev->hw_enc_features |= NETIF_F_HW_ESP;
932+
933+
#define IXGBE_ESP_FEATURES (NETIF_F_HW_ESP | \
934+
NETIF_F_HW_ESP_TX_CSUM | \
935+
NETIF_F_GSO_ESP)
936+
937+
adapter->netdev->features |= IXGBE_ESP_FEATURES;
938+
adapter->netdev->hw_enc_features |= IXGBE_ESP_FEATURES;
934939

935940
return;
936941

drivers/net/ethernet/intel/ixgbe/ixgbe_main.c

+22-9
Original file line numberDiff line numberDiff line change
@@ -7730,7 +7730,8 @@ static void ixgbe_service_task(struct work_struct *work)
77307730

77317731
static int ixgbe_tso(struct ixgbe_ring *tx_ring,
77327732
struct ixgbe_tx_buffer *first,
7733-
u8 *hdr_len)
7733+
u8 *hdr_len,
7734+
struct ixgbe_ipsec_tx_data *itd)
77347735
{
77357736
u32 vlan_macip_lens, type_tucmd, mss_l4len_idx;
77367737
struct sk_buff *skb = first->skb;
@@ -7744,6 +7745,7 @@ static int ixgbe_tso(struct ixgbe_ring *tx_ring,
77447745
unsigned char *hdr;
77457746
} l4;
77467747
u32 paylen, l4_offset;
7748+
u32 fceof_saidx = 0;
77477749
int err;
77487750

77497751
if (skb->ip_summed != CHECKSUM_PARTIAL)
@@ -7769,13 +7771,15 @@ static int ixgbe_tso(struct ixgbe_ring *tx_ring,
77697771
if (ip.v4->version == 4) {
77707772
unsigned char *csum_start = skb_checksum_start(skb);
77717773
unsigned char *trans_start = ip.hdr + (ip.v4->ihl * 4);
7774+
int len = csum_start - trans_start;
77727775

77737776
/* IP header will have to cancel out any data that
7774-
* is not a part of the outer IP header
7777+
* is not a part of the outer IP header, so set to
7778+
* a reverse csum if needed, else init check to 0.
77757779
*/
7776-
ip.v4->check = csum_fold(csum_partial(trans_start,
7777-
csum_start - trans_start,
7778-
0));
7780+
ip.v4->check = (skb_shinfo(skb)->gso_type & SKB_GSO_PARTIAL) ?
7781+
csum_fold(csum_partial(trans_start,
7782+
len, 0)) : 0;
77797783
type_tucmd |= IXGBE_ADVTXD_TUCMD_IPV4;
77807784

77817785
ip.v4->tot_len = 0;
@@ -7806,12 +7810,15 @@ static int ixgbe_tso(struct ixgbe_ring *tx_ring,
78067810
mss_l4len_idx = (*hdr_len - l4_offset) << IXGBE_ADVTXD_L4LEN_SHIFT;
78077811
mss_l4len_idx |= skb_shinfo(skb)->gso_size << IXGBE_ADVTXD_MSS_SHIFT;
78087812

7813+
fceof_saidx |= itd->sa_idx;
7814+
type_tucmd |= itd->flags | itd->trailer_len;
7815+
78097816
/* vlan_macip_lens: HEADLEN, MACLEN, VLAN tag */
78107817
vlan_macip_lens = l4.hdr - ip.hdr;
78117818
vlan_macip_lens |= (ip.hdr - skb->data) << IXGBE_ADVTXD_MACLEN_SHIFT;
78127819
vlan_macip_lens |= first->tx_flags & IXGBE_TX_FLAGS_VLAN_MASK;
78137820

7814-
ixgbe_tx_ctxtdesc(tx_ring, vlan_macip_lens, 0, type_tucmd,
7821+
ixgbe_tx_ctxtdesc(tx_ring, vlan_macip_lens, fceof_saidx, type_tucmd,
78157822
mss_l4len_idx);
78167823

78177824
return 1;
@@ -8502,7 +8509,7 @@ netdev_tx_t ixgbe_xmit_frame_ring(struct sk_buff *skb,
85028509
if (skb->sp && !ixgbe_ipsec_tx(tx_ring, first, &ipsec_tx))
85038510
goto out_drop;
85048511
#endif
8505-
tso = ixgbe_tso(tx_ring, first, &hdr_len);
8512+
tso = ixgbe_tso(tx_ring, first, &hdr_len, &ipsec_tx);
85068513
if (tso < 0)
85078514
goto out_drop;
85088515
else if (!tso)
@@ -9911,9 +9918,15 @@ ixgbe_features_check(struct sk_buff *skb, struct net_device *dev,
99119918

99129919
/* We can only support IPV4 TSO in tunnels if we can mangle the
99139920
* inner IP ID field, so strip TSO if MANGLEID is not supported.
9921+
* IPsec offoad sets skb->encapsulation but still can handle
9922+
* the TSO, so it's the exception.
99149923
*/
9915-
if (skb->encapsulation && !(features & NETIF_F_TSO_MANGLEID))
9916-
features &= ~NETIF_F_TSO;
9924+
if (skb->encapsulation && !(features & NETIF_F_TSO_MANGLEID)) {
9925+
#ifdef CONFIG_XFRM
9926+
if (!skb->sp)
9927+
#endif
9928+
features &= ~NETIF_F_TSO;
9929+
}
99179930

99189931
return features;
99199932
}

0 commit comments

Comments
 (0)