Merge tag 'trace-printf-v6.13' of git://git.kernel.org/pub/scm/linux/kernel/git/trace...
[drm/drm-misc.git] / drivers / net / ethernet / netronome / nfp / nfd3 / ipsec.c
blob51087693072c289671a40fb8930d037c4913d301
1 // SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
2 /* Copyright (C) 2018 Netronome Systems, Inc */
3 /* Copyright (C) 2021 Corigine, Inc */
5 #include <net/xfrm.h>
7 #include "../nfp_net.h"
8 #include "nfd3.h"
10 void nfp_nfd3_ipsec_tx(struct nfp_nfd3_tx_desc *txd, struct sk_buff *skb)
12 struct xfrm_state *x = xfrm_input_state(skb);
13 struct xfrm_offload *xo = xfrm_offload(skb);
14 struct iphdr *iph = ip_hdr(skb);
15 int l4_proto;
17 if (x->xso.dev && (x->xso.dev->features & NETIF_F_HW_ESP_TX_CSUM)) {
18 txd->flags |= NFD3_DESC_TX_CSUM;
20 if (iph->version == 4)
21 txd->flags |= NFD3_DESC_TX_IP4_CSUM;
23 if (x->props.mode == XFRM_MODE_TRANSPORT)
24 l4_proto = xo->proto;
25 else if (x->props.mode == XFRM_MODE_TUNNEL)
26 l4_proto = xo->inner_ipproto;
27 else
28 return;
30 switch (l4_proto) {
31 case IPPROTO_UDP:
32 txd->flags |= NFD3_DESC_TX_UDP_CSUM;
33 return;
34 case IPPROTO_TCP:
35 txd->flags |= NFD3_DESC_TX_TCP_CSUM;
36 return;