Skip to content

Commit

Permalink
nfp: fix incorrectly set csum flag for nfdk path
Browse files Browse the repository at this point in the history
The csum flag of IPsec packet are set repeatedly. Therefore, the csum
flag set of IPsec and non-IPsec packet need to be distinguished.

As the ipv6 header does not have a csum field, so l3-csum flag is not
required to be set for ipv6 case.

Fixes: 436396f ("nfp: support IPsec offloading for NFP3800")
Signed-off-by: Huanhuan Wang <[email protected]>
Reviewed-by: Louis Peens <[email protected]>
Signed-off-by: Simon Horman <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
wanghuanhuan12 authored and davem330 committed Mar 3, 2023
1 parent 3e04419 commit 8b46168
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
6 changes: 4 additions & 2 deletions drivers/net/ethernet/netronome/nfp/nfdk/dp.c
Original file line number Diff line number Diff line change
Expand Up @@ -387,15 +387,17 @@ netdev_tx_t nfp_nfdk_tx(struct sk_buff *skb, struct net_device *netdev)
if (!skb_is_gso(skb)) {
real_len = skb->len;
/* Metadata desc */
metadata = nfp_nfdk_tx_csum(dp, r_vec, 1, skb, metadata);
if (!ipsec)
metadata = nfp_nfdk_tx_csum(dp, r_vec, 1, skb, metadata);
txd->raw = cpu_to_le64(metadata);
txd++;
} else {
/* lso desc should be placed after metadata desc */
(txd + 1)->raw = nfp_nfdk_tx_tso(r_vec, txbuf, skb);
real_len = txbuf->real_len;
/* Metadata desc */
metadata = nfp_nfdk_tx_csum(dp, r_vec, txbuf->pkt_cnt, skb, metadata);
if (!ipsec)
metadata = nfp_nfdk_tx_csum(dp, r_vec, txbuf->pkt_cnt, skb, metadata);
txd->raw = cpu_to_le64(metadata);
txd += 2;
txbuf++;
Expand Down
8 changes: 6 additions & 2 deletions drivers/net/ethernet/netronome/nfp/nfdk/ipsec.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,13 @@
u64 nfp_nfdk_ipsec_tx(u64 flags, struct sk_buff *skb)
{
struct xfrm_state *x = xfrm_input_state(skb);
struct iphdr *iph = ip_hdr(skb);

if (x->xso.dev && (x->xso.dev->features & NETIF_F_HW_ESP_TX_CSUM))
flags |= NFDK_DESC_TX_L3_CSUM | NFDK_DESC_TX_L4_CSUM;
if (x->xso.dev && (x->xso.dev->features & NETIF_F_HW_ESP_TX_CSUM)) {
if (iph->version == 4)
flags |= NFDK_DESC_TX_L3_CSUM;
flags |= NFDK_DESC_TX_L4_CSUM;
}

return flags;
}

0 comments on commit 8b46168

Please sign in to comment.