crypto/dpaa_sec: enable PDCP-SDAP sessions
authorAkhil Goyal <akhil.goyal@nxp.com>
Mon, 12 Oct 2020 14:10:03 +0000 (19:40 +0530)
committerAkhil Goyal <akhil.goyal@nxp.com>
Wed, 14 Oct 2020 20:24:41 +0000 (22:24 +0200)
Based on the new field in PDCP xform, a decision is made
to create a PDCP session with or without SDAP enabled.

Signed-off-by: Akhil Goyal <akhil.goyal@nxp.com>
drivers/crypto/dpaa_sec/dpaa_sec.c
drivers/crypto/dpaa_sec/dpaa_sec.h

index 0495422..f69cb57 100644 (file)
@@ -36,6 +36,7 @@
 #include <desc/algo.h>
 #include <desc/ipsec.h>
 #include <desc/pdcp.h>
+#include <desc/sdap.h>
 
 #include <rte_dpaa_bus.h>
 #include <dpaa_sec.h>
@@ -293,24 +294,49 @@ dpaa_sec_prep_pdcp_cdb(dpaa_sec_session *ses)
                                        &cipherdata, &authdata,
                                        0);
        } else {
-               if (ses->dir == DIR_ENC)
-                       shared_desc_len = cnstr_shdsc_pdcp_u_plane_encap(
-                                       cdb->sh_desc, 1, swap,
-                                       ses->pdcp.sn_size,
-                                       ses->pdcp.hfn,
-                                       ses->pdcp.bearer,
-                                       ses->pdcp.pkt_dir,
-                                       ses->pdcp.hfn_threshold,
-                                       &cipherdata, p_authdata, 0);
-               else if (ses->dir == DIR_DEC)
-                       shared_desc_len = cnstr_shdsc_pdcp_u_plane_decap(
-                                       cdb->sh_desc, 1, swap,
-                                       ses->pdcp.sn_size,
-                                       ses->pdcp.hfn,
-                                       ses->pdcp.bearer,
-                                       ses->pdcp.pkt_dir,
-                                       ses->pdcp.hfn_threshold,
-                                       &cipherdata, p_authdata, 0);
+               if (ses->dir == DIR_ENC) {
+                       if (ses->pdcp.sdap_enabled)
+                               shared_desc_len =
+                                       cnstr_shdsc_pdcp_sdap_u_plane_encap(
+                                               cdb->sh_desc, 1, swap,
+                                               ses->pdcp.sn_size,
+                                               ses->pdcp.hfn,
+                                               ses->pdcp.bearer,
+                                               ses->pdcp.pkt_dir,
+                                               ses->pdcp.hfn_threshold,
+                                               &cipherdata, p_authdata, 0);
+                       else
+                               shared_desc_len =
+                                       cnstr_shdsc_pdcp_u_plane_encap(
+                                               cdb->sh_desc, 1, swap,
+                                               ses->pdcp.sn_size,
+                                               ses->pdcp.hfn,
+                                               ses->pdcp.bearer,
+                                               ses->pdcp.pkt_dir,
+                                               ses->pdcp.hfn_threshold,
+                                               &cipherdata, p_authdata, 0);
+               } else if (ses->dir == DIR_DEC) {
+                       if (ses->pdcp.sdap_enabled)
+                               shared_desc_len =
+                                       cnstr_shdsc_pdcp_sdap_u_plane_decap(
+                                               cdb->sh_desc, 1, swap,
+                                               ses->pdcp.sn_size,
+                                               ses->pdcp.hfn,
+                                               ses->pdcp.bearer,
+                                               ses->pdcp.pkt_dir,
+                                               ses->pdcp.hfn_threshold,
+                                               &cipherdata, p_authdata, 0);
+                       else
+                               shared_desc_len =
+                                       cnstr_shdsc_pdcp_u_plane_decap(
+                                               cdb->sh_desc, 1, swap,
+                                               ses->pdcp.sn_size,
+                                               ses->pdcp.hfn,
+                                               ses->pdcp.bearer,
+                                               ses->pdcp.pkt_dir,
+                                               ses->pdcp.hfn_threshold,
+                                               &cipherdata, p_authdata, 0);
+               }
        }
        return shared_desc_len;
 }
@@ -2949,6 +2975,7 @@ dpaa_sec_set_pdcp_session(struct rte_cryptodev *dev,
        session->pdcp.hfn = pdcp_xform->hfn;
        session->pdcp.hfn_threshold = pdcp_xform->hfn_threshold;
        session->pdcp.hfn_ovd = pdcp_xform->hfn_ovrd;
+       session->pdcp.sdap_enabled = pdcp_xform->sdap_enabled;
        if (cipher_xform)
                session->pdcp.hfn_ovd_offset = cipher_xform->iv.offset;
 
index 2cd50cc..ddba529 100644 (file)
@@ -109,7 +109,8 @@ struct sec_pdcp_ctxt {
        int8_t pkt_dir;/*!< PDCP Frame Direction 0:UL 1:DL*/
        int8_t hfn_ovd;/*!< Overwrite HFN per packet*/
        uint8_t sn_size;        /*!< Sequence number size, 5/7/12/15/18 */
-       uint32_t hfn_ovd_offset;/*!< offset from rte_crypto_op at which
+       uint8_t sdap_enabled;   /*!< SDAP header is enabled */
+       uint16_t hfn_ovd_offset;/*!< offset from rte_crypto_op at which
                                 * per packet hfn is stored
                                 */
        uint32_t hfn;   /*!< Hyper Frame Number */