New upstream version 17.11.3
[deb_dpdk.git] / drivers / crypto / dpaa2_sec / dpaa2_sec_priv.h
index 3849a05..ae8c0c3 100644 (file)
@@ -67,6 +67,11 @@ enum shr_desc_type {
 #define DIR_ENC                 1
 #define DIR_DEC                 0
 
+#define DPAA2_SET_FLC_EWS(flc)  (flc->word1_bits23_16 |= 0x1)
+#define DPAA2_SET_FLC_RSC(flc)  (flc->word1_bits31_24 |= 0x1)
+#define DPAA2_SET_FLC_REUSE_BS(flc) (flc->mode_bits |= 0x8000)
+#define DPAA2_SET_FLC_REUSE_FF(flc) (flc->mode_bits |= 0x2000)
+
 /* SEC Flow Context Descriptor */
 struct sec_flow_context {
        /* word 0 */
@@ -164,6 +169,7 @@ typedef struct dpaa2_sec_session_entry {
        uint8_t dir;         /*!< Operation Direction */
        enum rte_crypto_cipher_algorithm cipher_alg; /*!< Cipher Algorithm*/
        enum rte_crypto_auth_algorithm auth_alg; /*!< Authentication Algorithm*/
+       enum rte_crypto_aead_algorithm aead_alg; /*!< AEAD Algorithm*/
        union {
                struct {
                        uint8_t *data;  /**< pointer to key data */
@@ -205,9 +211,9 @@ static const struct rte_cryptodev_capabilities dpaa2_sec_capabilities[] = {
                                        .increment = 1
                                },
                                .digest_size = {
-                                       .min = 16,
+                                       .min = 1,
                                        .max = 16,
-                                       .increment = 0
+                                       .increment = 1
                                },
                                .iv_size = { 0 }
                        }, }
@@ -226,9 +232,9 @@ static const struct rte_cryptodev_capabilities dpaa2_sec_capabilities[] = {
                                        .increment = 1
                                },
                                .digest_size = {
-                                       .min = 20,
+                                       .min = 1,
                                        .max = 20,
-                                       .increment = 0
+                                       .increment = 1
                                },
                                .iv_size = { 0 }
                        }, }
@@ -247,9 +253,9 @@ static const struct rte_cryptodev_capabilities dpaa2_sec_capabilities[] = {
                                        .increment = 1
                                },
                                .digest_size = {
-                                       .min = 28,
+                                       .min = 1,
                                        .max = 28,
-                                       .increment = 0
+                                       .increment = 1
                                },
                                .iv_size = { 0 }
                        }, }
@@ -268,9 +274,9 @@ static const struct rte_cryptodev_capabilities dpaa2_sec_capabilities[] = {
                                        .increment = 1
                                },
                                .digest_size = {
-                                               .min = 32,
-                                               .max = 32,
-                                               .increment = 0
+                                       .min = 1,
+                                       .max = 32,
+                                       .increment = 1
                                },
                                .iv_size = { 0 }
                                }, }
@@ -289,9 +295,9 @@ static const struct rte_cryptodev_capabilities dpaa2_sec_capabilities[] = {
                                        .increment = 1
                                },
                                .digest_size = {
-                                       .min = 48,
+                                       .min = 1,
                                        .max = 48,
-                                       .increment = 0
+                                       .increment = 1
                                },
                                .iv_size = { 0 }
                        }, }
@@ -310,9 +316,9 @@ static const struct rte_cryptodev_capabilities dpaa2_sec_capabilities[] = {
                                        .increment = 1
                                },
                                .digest_size = {
-                                       .min = 64,
+                                       .min = 1,
                                        .max = 64,
-                                       .increment = 0
+                                       .increment = 1
                                },
                                .iv_size = { 0 }
                        }, }
@@ -411,4 +417,61 @@ static const struct rte_cryptodev_capabilities dpaa2_sec_capabilities[] = {
 
        RTE_CRYPTODEV_END_OF_CAPABILITIES_LIST()
 };
+
+static const struct rte_security_capability dpaa2_sec_security_cap[] = {
+       { /* IPsec Lookaside Protocol offload ESP Transport Egress */
+               .action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
+               .protocol = RTE_SECURITY_PROTOCOL_IPSEC,
+               .ipsec = {
+                       .proto = RTE_SECURITY_IPSEC_SA_PROTO_ESP,
+                       .mode = RTE_SECURITY_IPSEC_SA_MODE_TUNNEL,
+                       .direction = RTE_SECURITY_IPSEC_SA_DIR_EGRESS,
+                       .options = { 0 }
+               },
+               .crypto_capabilities = dpaa2_sec_capabilities
+       },
+       { /* IPsec Lookaside Protocol offload ESP Tunnel Ingress */
+               .action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
+               .protocol = RTE_SECURITY_PROTOCOL_IPSEC,
+               .ipsec = {
+                       .proto = RTE_SECURITY_IPSEC_SA_PROTO_ESP,
+                       .mode = RTE_SECURITY_IPSEC_SA_MODE_TUNNEL,
+                       .direction = RTE_SECURITY_IPSEC_SA_DIR_INGRESS,
+                       .options = { 0 }
+               },
+               .crypto_capabilities = dpaa2_sec_capabilities
+       },
+       {
+               .action = RTE_SECURITY_ACTION_TYPE_NONE
+       }
+};
+
+/**
+ * Checksum
+ *
+ * @param buffer calculate chksum for buffer
+ * @param len    buffer length
+ *
+ * @return checksum value in host cpu order
+ */
+static inline uint16_t
+calc_chksum(void *buffer, int len)
+{
+       uint16_t *buf = (uint16_t *)buffer;
+       uint32_t sum = 0;
+       uint16_t result;
+
+       for (sum = 0; len > 1; len -= 2)
+               sum += *buf++;
+
+       if (len == 1)
+               sum += *(unsigned char *)buf;
+
+       sum = (sum >> 16) + (sum & 0xFFFF);
+       sum += (sum >> 16);
+       result = ~sum;
+
+       return  result;
+}
+
 #endif /* _RTE_DPAA2_SEC_PMD_PRIVATE_H_ */