cryptodev: rename ADD field
[dpdk.git] / drivers / crypto / qat / qat_crypto.c
index 7e04f21..ec481ae 100644 (file)
@@ -214,7 +214,7 @@ adf_modulo(uint32_t data, uint32_t shift);
 
 static inline int
 qat_write_hw_desc_entry(struct rte_crypto_op *op, uint8_t *out_msg,
-               struct qat_crypto_op_cookie *qat_op_cookie);
+               struct qat_crypto_op_cookie *qat_op_cookie, struct qat_qp *qp);
 
 void
 qat_crypto_sym_clear_session(struct rte_cryptodev *dev,
@@ -492,6 +492,8 @@ qat_crypto_set_session_parameters(struct rte_cryptodev *dev,
        session->cd_paddr = rte_mempool_virt2phy(NULL, session) +
                        offsetof(struct qat_session, cd);
 
+       session->min_qat_dev_gen = QAT_GEN1;
+
        /* Get requested QAT command id */
        qat_cmd_id = qat_get_cmd_id(xform);
        if (qat_cmd_id < 0 || qat_cmd_id >= ICP_QAT_FW_LA_CMD_DELIMITER) {
@@ -742,7 +744,7 @@ qat_crypto_sym_configure_session_aead(struct rte_crypto_sym_xform *xform,
                if (qat_alg_aead_session_create_content_desc_auth(session,
                                        aead_xform->key.data,
                                        aead_xform->key.length,
-                                       aead_xform->add_auth_data_length,
+                                       aead_xform->aad_length,
                                        aead_xform->digest_length,
                                        RTE_CRYPTO_AUTH_OP_GENERATE))
                        goto error_out;
@@ -755,7 +757,7 @@ qat_crypto_sym_configure_session_aead(struct rte_crypto_sym_xform *xform,
                if (qat_alg_aead_session_create_content_desc_auth(session,
                                        aead_xform->key.data,
                                        aead_xform->key.length,
-                                       aead_xform->add_auth_data_length,
+                                       aead_xform->aad_length,
                                        aead_xform->digest_length,
                                        RTE_CRYPTO_AUTH_OP_VERIFY))
                        goto error_out;
@@ -924,7 +926,7 @@ qat_pmd_enqueue_op_burst(void *qp, struct rte_crypto_op **ops,
 
        while (nb_ops_sent != nb_ops_possible) {
                ret = qat_write_hw_desc_entry(*cur_op, base_addr + tail,
-                               tmp_qp->op_cookies[tail / queue->msg_size]);
+                       tmp_qp->op_cookies[tail / queue->msg_size], tmp_qp);
                if (ret != 0) {
                        tmp_qp->stats.enqueue_err_count++;
                        /*
@@ -1081,7 +1083,7 @@ set_cipher_iv(uint16_t iv_length, uint16_t iv_offset,
 
 static inline int
 qat_write_hw_desc_entry(struct rte_crypto_op *op, uint8_t *out_msg,
-               struct qat_crypto_op_cookie *qat_op_cookie)
+               struct qat_crypto_op_cookie *qat_op_cookie, struct qat_qp *qp)
 {
        int ret = 0;
        struct qat_session *ctx;
@@ -1117,6 +1119,12 @@ qat_write_hw_desc_entry(struct rte_crypto_op *op, uint8_t *out_msg,
                return -EINVAL;
        }
 
+       if (unlikely(ctx->min_qat_dev_gen > qp->qat_dev_gen)) {
+               PMD_DRV_LOG(ERR, "Session alg not supported on this device gen");
+               op->status = RTE_CRYPTO_OP_STATUS_INVALID_SESSION;
+               return -EINVAL;
+       }
+
        qat_req = (struct icp_qat_fw_la_bulk_req *)out_msg;
        rte_mov128((uint8_t *)qat_req, (const uint8_t *)&(ctx->fw_req));
        qat_req->comn_mid.opaque_data = (uint64_t)(uintptr_t)op;
@@ -1195,18 +1203,7 @@ qat_write_hw_desc_entry(struct rte_crypto_op *op, uint8_t *out_msg,
                        auth_ofs = op->sym->auth.data.offset >> 3;
                        auth_len = op->sym->auth.data.length >> 3;
 
-                       if (ctx->qat_hash_alg ==
-                                       ICP_QAT_HW_AUTH_ALGO_KASUMI_F9) {
-                               if (do_cipher) {
-                                       auth_len = auth_len + auth_ofs + 1 -
-                                               ICP_QAT_HW_KASUMI_BLK_SZ;
-                                       auth_ofs = ICP_QAT_HW_KASUMI_BLK_SZ;
-                               } else {
-                                       auth_len = auth_len + auth_ofs + 1;
-                                       auth_ofs = 0;
-                               }
-                       } else
-                               auth_param->u1.aad_adr =
+                       auth_param->u1.aad_adr =
                                        rte_crypto_op_ctophys_offset(op,
                                                        ctx->auth_iv.offset);
 
@@ -1218,6 +1215,21 @@ qat_write_hw_desc_entry(struct rte_crypto_op *op, uint8_t *out_msg,
                        set_cipher_iv(ctx->auth_iv.length,
                                ctx->auth_iv.offset,
                                cipher_param, op, qat_req);
+                       auth_ofs = op->sym->auth.data.offset;
+                       auth_len = op->sym->auth.data.length;
+
+                       auth_param->u1.aad_adr = 0;
+                       auth_param->u2.aad_sz = 0;
+
+                       /*
+                        * If len(iv)==12B fw computes J0
+                        */
+                       if (ctx->auth_iv.length == 12) {
+                               ICP_QAT_FW_LA_GCM_IV_LEN_FLAG_SET(
+                                       qat_req->comn_hdr.serv_specif_flags,
+                                       ICP_QAT_FW_LA_GCM_IV_LEN_12_OCTETS);
+
+                       }
                } else {
                        auth_ofs = op->sym->auth.data.offset;
                        auth_len = op->sym->auth.data.length;
@@ -1230,6 +1242,21 @@ qat_write_hw_desc_entry(struct rte_crypto_op *op, uint8_t *out_msg,
        }
 
        if (do_aead) {
+               if (ctx->qat_hash_alg ==
+                               ICP_QAT_HW_AUTH_ALGO_GALOIS_128 ||
+                               ctx->qat_hash_alg ==
+                                       ICP_QAT_HW_AUTH_ALGO_GALOIS_64) {
+                       /*
+                        * If len(iv)==12B fw computes J0
+                        */
+                       if (ctx->cipher_iv.length == 12) {
+                               ICP_QAT_FW_LA_GCM_IV_LEN_FLAG_SET(
+                                       qat_req->comn_hdr.serv_specif_flags,
+                                       ICP_QAT_FW_LA_GCM_IV_LEN_12_OCTETS);
+                       }
+
+               }
+
                cipher_len = op->sym->aead.data.length;
                cipher_ofs = op->sym->aead.data.offset;
                auth_len = op->sym->aead.data.length;
@@ -1347,30 +1374,6 @@ qat_write_hw_desc_entry(struct rte_crypto_op *op, uint8_t *out_msg,
                qat_req->comn_mid.dest_data_addr = dst_buf_start;
        }
 
-       if (ctx->qat_hash_alg == ICP_QAT_HW_AUTH_ALGO_GALOIS_128 ||
-                       ctx->qat_hash_alg == ICP_QAT_HW_AUTH_ALGO_GALOIS_64) {
-               if (ctx->cipher_iv.length == 12 ||
-                               ctx->auth_iv.length == 12) {
-                       /*
-                        * For GCM a 12 byte IV is allowed,
-                        * but we need to inform the f/w
-                        */
-                       ICP_QAT_FW_LA_GCM_IV_LEN_FLAG_SET(
-                               qat_req->comn_hdr.serv_specif_flags,
-                               ICP_QAT_FW_LA_GCM_IV_LEN_12_OCTETS);
-               }
-               /* GMAC */
-               if (!do_aead) {
-                       qat_req->comn_mid.dst_length =
-                               qat_req->comn_mid.src_length =
-                                       rte_pktmbuf_data_len(op->sym->m_src);
-                       auth_param->u1.aad_adr = 0;
-                       auth_param->auth_len = op->sym->auth.data.length;
-                       auth_param->auth_off = op->sym->auth.data.offset;
-                       auth_param->u2.aad_sz = 0;
-               }
-       }
-
 #ifdef RTE_LIBRTE_PMD_QAT_DEBUG_TX
        rte_hexdump(stdout, "qat_req:", qat_req,
                        sizeof(struct icp_qat_fw_la_bulk_req));