crypto/qat: fix GEN4 AEAD job in raw data path
[dpdk.git] / drivers / crypto / qat / qat_sym.h
index 1a97488..e3ec7f0 100644 (file)
@@ -5,8 +5,8 @@
 #ifndef _QAT_SYM_H_
 #define _QAT_SYM_H_
 
-#include <rte_cryptodev_pmd.h>
-#ifdef RTE_LIBRTE_SECURITY
+#include <cryptodev_pmd.h>
+#ifdef RTE_LIB_SECURITY
 #include <rte_net_crc.h>
 #endif
 
@@ -29,6 +29,9 @@
  */
 #define QAT_SYM_SGL_MAX_NUMBER 16
 
+/* Maximum data length for single pass GMAC: 2^14-1 */
+#define QAT_AES_GMAC_SPC_MAX_SIZE 16383
+
 struct qat_sym_session;
 
 struct qat_sym_sgl {
@@ -41,6 +44,14 @@ struct qat_sym_op_cookie {
        struct qat_sym_sgl qat_sgl_dst;
        phys_addr_t qat_sgl_src_phys_addr;
        phys_addr_t qat_sgl_dst_phys_addr;
+       union {
+               /* Used for Single-Pass AES-GMAC only */
+               struct {
+                       struct icp_qat_hw_cipher_algo_blk cd_cipher
+                                       __rte_packed __rte_cache_aligned;
+                       phys_addr_t cd_phys_addr;
+               } spc_gmac;
+       } opt;
 };
 
 int
@@ -135,7 +146,7 @@ qat_bpicipher_postprocess(struct qat_sym_session *ctx,
        return sym_op->cipher.data.length - last_block_len;
 }
 
-#ifdef RTE_LIBRTE_SECURITY
+#ifdef RTE_LIB_SECURITY
 static inline void
 qat_crc_verify(struct qat_sym_session *ctx, struct rte_crypto_op *op)
 {
@@ -212,58 +223,76 @@ qat_sym_preprocess_requests(void **ops __rte_unused,
 #endif
 
 static inline void
-qat_sym_process_response(void **op, uint8_t *resp)
+qat_sym_process_response(void **op, uint8_t *resp, void *op_cookie)
 {
        struct icp_qat_fw_comn_resp *resp_msg =
                        (struct icp_qat_fw_comn_resp *)resp;
        struct rte_crypto_op *rx_op = (struct rte_crypto_op *)(uintptr_t)
                        (resp_msg->opaque_data);
        struct qat_sym_session *sess;
+       uint8_t is_docsis_sec;
 
 #if RTE_LOG_DP_LEVEL >= RTE_LOG_DEBUG
        QAT_DP_HEXDUMP_LOG(DEBUG, "qat_response:", (uint8_t *)resp_msg,
                        sizeof(struct icp_qat_fw_comn_resp));
 #endif
 
+#ifdef RTE_LIB_SECURITY
+       if (rx_op->sess_type == RTE_CRYPTO_OP_SECURITY_SESSION) {
+               /*
+                * Assuming at this point that if it's a security
+                * op, that this is for DOCSIS
+                */
+               sess = (struct qat_sym_session *)
+                               get_sec_session_private_data(
+                               rx_op->sym->sec_session);
+               is_docsis_sec = 1;
+       } else
+#endif
+       {
+               sess = (struct qat_sym_session *)
+                               get_sym_session_private_data(
+                               rx_op->sym->session,
+                               qat_sym_driver_id);
+               is_docsis_sec = 0;
+       }
+
        if (ICP_QAT_FW_COMN_STATUS_FLAG_OK !=
                        ICP_QAT_FW_COMN_RESP_CRYPTO_STAT_GET(
                        resp_msg->comn_hdr.comn_status)) {
 
                rx_op->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED;
        } else {
-#ifdef RTE_LIBRTE_SECURITY
-               uint8_t is_docsis_sec = 0;
-
-               if (rx_op->sess_type == RTE_CRYPTO_OP_SECURITY_SESSION) {
-                       /*
-                        * Assuming at this point that if it's a security
-                        * op, that this is for DOCSIS
-                        */
-                       sess = (struct qat_sym_session *)
-                                       get_sec_session_private_data(
-                                       rx_op->sym->sec_session);
-                       is_docsis_sec = 1;
-               } else
-#endif
-               {
-                       sess = (struct qat_sym_session *)
-                                       get_sym_session_private_data(
-                                       rx_op->sym->session,
-                                       qat_sym_driver_id);
-               }
-
                rx_op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
 
                if (sess->bpi_ctx) {
                        qat_bpicipher_postprocess(sess, rx_op);
-#ifdef RTE_LIBRTE_SECURITY
+#ifdef RTE_LIB_SECURITY
                        if (is_docsis_sec)
                                qat_crc_verify(sess, rx_op);
 #endif
                }
        }
+
+       if (sess->is_single_pass_gmac) {
+               struct qat_sym_op_cookie *cookie =
+                               (struct qat_sym_op_cookie *) op_cookie;
+               memset(cookie->opt.spc_gmac.cd_cipher.key, 0,
+                               sess->auth_key_length);
+       }
+
        *op = (void *)rx_op;
 }
+
+int
+qat_sym_configure_dp_ctx(struct rte_cryptodev *dev, uint16_t qp_id,
+       struct rte_crypto_raw_dp_ctx *raw_dp_ctx,
+       enum rte_crypto_op_sess_type sess_type,
+       union rte_cryptodev_session_ctx session_ctx, uint8_t is_update);
+
+int
+qat_sym_get_dp_ctx_size(struct rte_cryptodev *dev);
+
 #else
 
 static inline void
@@ -273,8 +302,10 @@ qat_sym_preprocess_requests(void **ops __rte_unused,
 }
 
 static inline void
-qat_sym_process_response(void **op __rte_unused, uint8_t *resp __rte_unused)
+qat_sym_process_response(void **op __rte_unused, uint8_t *resp __rte_unused,
+       void *op_cookie __rte_unused)
 {
 }
+
 #endif
 #endif /* _QAT_SYM_H_ */