net/nfp: align dynamic log names with standard
[dpdk.git] / drivers / crypto / dpaa_sec / dpaa_sec.h
index 93369e4..f45b36c 100644 (file)
@@ -8,7 +8,7 @@
 #define _DPAA_SEC_H_
 
 #define NUM_POOL_CHANNELS      4
-#define DPAA_SEC_BURST         32
+#define DPAA_SEC_BURST         7
 #define DPAA_SEC_ALG_UNSUPPORT (-1)
 #define TDES_CBC_IV_LEN                8
 #define AES_CBC_IV_LEN         16
@@ -91,7 +91,8 @@ typedef struct dpaa_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; /*!< Authentication Algorithm*/
+       enum rte_crypto_aead_algorithm aead_alg; /*!< AEAD Algorithm*/
+       enum rte_security_session_protocol proto_alg; /*!< Security Algorithm*/
        union {
                struct {
                        uint8_t *data;  /**< pointer to key data */
@@ -114,6 +115,9 @@ typedef struct dpaa_sec_session_entry {
        } iv;   /**< Initialisation vector parameters */
        uint16_t auth_only_len; /*!< Length of data for Auth only */
        uint32_t digest_length;
+       struct ipsec_encap_pdb encap_pdb;
+       struct ip ip4_hdr;
+       struct ipsec_decap_pdb decap_pdb;
        struct dpaa_sec_qp *qp;
        struct qman_fq *inq;
        struct sec_cdb cdb;     /**< cmd block associated with qp */
@@ -131,6 +135,7 @@ struct dpaa_sec_qp {
 
 #define RTE_DPAA_MAX_NB_SEC_QPS 1
 #define RTE_DPAA_MAX_RX_QUEUE RTE_DPAA_SEC_PMD_MAX_NB_SESSIONS
+#define DPAA_MAX_DEQUEUE_NUM_FRAMES 63
 
 /* internal sec queue interface */
 struct dpaa_sec_dev_private {
@@ -288,7 +293,7 @@ static const struct rte_cryptodev_capabilities dpaa_sec_capabilities[] = {
                .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
                {.sym = {
                        .xform_type = RTE_CRYPTO_SYM_XFORM_AEAD,
-                       {.auth = {
+                       {.aead = {
                                .algo = RTE_CRYPTO_AEAD_AES_GCM,
                                .block_size = 16,
                                .key_size = {
@@ -378,4 +383,60 @@ static const struct rte_cryptodev_capabilities dpaa_sec_capabilities[] = {
        RTE_CRYPTODEV_END_OF_CAPABILITIES_LIST()
 };
 
+static const struct rte_security_capability dpaa_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 = dpaa_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 = dpaa_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 /* _DPAA_SEC_H_ */