common/cnxk: support UDP encapsulation
authorSrujana Challa <schalla@marvell.com>
Tue, 13 Jul 2021 07:42:17 +0000 (13:12 +0530)
committerAkhil Goyal <gakhil@marvell.com>
Tue, 20 Jul 2021 08:32:05 +0000 (10:32 +0200)
Adds support for UDP encapsulation in crypto_cn10k
PMD.

Signed-off-by: Srujana Challa <schalla@marvell.com>
Acked-by: Akhil Goyal <gakhil@marvell.com>
drivers/common/cnxk/cnxk_security.c
drivers/common/cnxk/meson.build

index 2f5003e..6c6728f 100644 (file)
@@ -2,6 +2,8 @@
  * Copyright(C) 2021 Marvell.
  */
 
+#include <rte_udp.h>
+
 #include "cnxk_security.h"
 
 static int
@@ -71,6 +73,10 @@ ot_ipsec_sa_common_param_fill(union roc_ot_ipsec_sa_word2 *w2,
                return -ENOTSUP;
        }
 
+       /* Set encapsulation type */
+       if (ipsec_xfrm->options.udp_encap)
+               w2->s.encap_type = ROC_IE_OT_SA_ENCAP_UDP;
+
        w2->s.spi = ipsec_xfrm->spi;
 
        /* Copy encryption key */
@@ -149,6 +155,10 @@ cnxk_ot_ipsec_inb_sa_fill(struct roc_ot_ipsec_inb_sa *sa,
 
        /* ESN */
        sa->w2.s.esn_en = !!ipsec_xfrm->options.esn;
+       if (ipsec_xfrm->options.udp_encap) {
+               sa->w10.s.udp_src_port = 4500;
+               sa->w10.s.udp_dst_port = 4500;
+       }
 
        offset = offsetof(struct roc_ot_ipsec_inb_sa, ctx);
        /* Word offset for HW managed SA field */
@@ -267,6 +277,11 @@ skip_tunnel_info:
        /* ESN */
        sa->w0.s.esn_en = !!ipsec_xfrm->options.esn;
 
+       if (ipsec_xfrm->options.udp_encap) {
+               sa->w10.s.udp_src_port = 4500;
+               sa->w10.s.udp_dst_port = 4500;
+       }
+
        offset = offsetof(struct roc_ot_ipsec_outb_sa, ctx);
        /* Word offset for HW managed SA field */
        sa->w0.s.hw_ctx_off = offset / 8;
@@ -460,6 +475,9 @@ cnxk_ipsec_outb_rlens_get(struct cnxk_ipsec_outb_rlens *rlens,
        partial_len += cnxk_ipsec_icvlen_get(c_algo, a_algo, aead_algo);
        roundup_byte = cnxk_ipsec_outb_roundup_byte(c_algo, aead_algo);
 
+       if (ipsec_xfrm->options.udp_encap)
+               partial_len += sizeof(struct rte_udp_hdr);
+
        rlens->partial_len = partial_len;
        rlens->roundup_len = roundup_len;
        rlens->roundup_byte = roundup_byte;
index 37ef2b0..6a7849f 100644 (file)
@@ -61,3 +61,4 @@ sources = files(
 sources += files('cnxk_security.c')
 
 includes += include_directories('../../bus/pci')
+includes += include_directories('../../../lib/net')